From pierodancona@gmail.com Sun Sep 24 10:54:41 2006 From: "Piero D\\'Ancona" To: textmate@lists.macromates.com Subject: [TxMt] idea: a better label completion technique Date: Sun, 24 Sep 2006 10:54:21 +0000 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0218676985324347020==" --===============0218676985324347020== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Hi list I am using TextMate full time to write Latex and it's great, and improving. One thing I do not like is the CocoaDialog interface to insert \refs: too slow and clumsy. I (almost) can stand it for bibliography completion but \refs are too many, too similar to each other, and too frequently needed, so the dialog interrupts my workflow. So I started thinking and tinkering, but my coding skills are too poor (I also sent a msg to this list asking for help). Finally I think it is better to publish the idea and let the code wizards code it, if they like it. My feeling is that this could be the optimal way to insert references, even better than auctex's. The idea is very simple: parse the tex file, write all labels (plus some surrounding text) into an auxiliary .lbl file, convert this into html, and replace each \label{...} command with an "a href" to a tiny javascript command that tells TextMate to insert the label's name into the source file. Finally, output to HTML. (Improvement: just search the labels matching a few characters, as it is now). Do you see it? This produces an HTML window, with a list of all my labels, followed by the beginning lines of the equations (or section titles). More important, each label is clickable, and when I click on it, the reference gets inserted into the source file. I can keep the label window open, so no need to invoke the command over and over. When I add more equations, I just refresh the window as necessary. But I got stuck with some stupid coding problems. 1- Easy to grep the tex file for lines containing a \label command plus some context. E.g. the following command outputs line number, plus the \label line, plus two nonempty lines following it: sed -n -e "/\\label/{=;N;N;G;p;}" | sed '/^$/d' | sed 's/^\([0-9]+\)$/\n\1/' 2- Easy to save all this info into a file fileName.lbl and do some rudimentary html-ization (just add

's to separate the labels from each other- you can do much better I know, but this is fast) 3- Not so difficult to replace each "\label{...}" with the javascript link. But I got stuck when writing the osascript. Let me explain. Is is easy to create a link such that, when I click on it, TeXniscope is activated (e.g.): TeXniscope Nice! So I said, I'll just insert an osascript telling TextMate to insert the label reference: \labe{...} (of course, "....." must be replaced in both places with the \label's name, using some bash, and some string must be joined etc etc) This doesn't work. Why?? even the simple Finder does not work. This must be some escaping trickery. Could some pious wizard explain what's wrong? and even better, like the idea so much to code it? I do not think it should be hard (for you :). Regards, Piero --===============0218676985324347020==-- From pierodancona@gmail.com Sun Sep 24 11:04:48 2006 From: "Piero D\\\\\\'Ancona" To: textmate@lists.macromates.com Subject: [TxMt] Re: idea: a better label completion technique Date: Sun, 24 Sep 2006 11:04:23 +0000 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5510774710663624123==" --===============5510774710663624123== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit PS: sorry for the typo: read "/usr" instead of "/ust" > 'tell app \"Finder\" to activate'", null);">Finder > --===============5510774710663624123==-- From daniel@kaesmayr.net Sun Sep 24 11:35:41 2006 From: Daniel =?utf-8?q?K=C3=A4smayr?= To: textmate@lists.macromates.com Subject: Re: [TxMt] idea: a better label completion technique Date: Sun, 24 Sep 2006 13:35:35 +0200 Message-ID: <8F42EE12-7B6C-45C4-BC2B-422F8220BBBA@kaesmayr.net> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7894907688235066546==" --===============7894907688235066546== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sounds like a good idea, I also did not really like that part, especially since I have many refs (auto-included via the snippets), but don't really remember how they are called and this autocompletion isn't that helpful. This idea as well as its implementation as a html-list sounds great; just make sure it also works with larger documents and split latex projects that depend on one master file and many included or input files… just my 2c, Dan --===============7894907688235066546== Content-Type: application/pkcs7-signature Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" MIME-Version: 1.0 MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIMTjCCAuAw ggJJoAMCAQICECPJtujtzcJvZ3I1HnHpwyQwDQYJKoZIhvcNAQEEBQAwYjELMAkGA1UEBhMCWkEx JTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDA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nWmC3O2MAkGBSsOAwIaBQCgggFvMBgGCSqGSIb3DQEJAzEL BgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTA2MDkyNDExMzUzNVowIwYJKoZIhvcNAQkEMRYE FJUmlqm7N+vK03PeVOJZPchMTIVWMIGFBgkrBgEEAYI3EAQxeDB2MGIxCzAJBgNVBAYTAlpBMSUw IwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBMdGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVy c29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIQI8m26O3Nwm9ncjUecenDJDCBhwYLKoZIhvcNAQkQ AgsxeKB2MGIxCzAJBgNVBAYTAlpBMSUwIwYDVQQKExxUaGF3dGUgQ29uc3VsdGluZyAoUHR5KSBM dGQuMSwwKgYDVQQDEyNUaGF3dGUgUGVyc29uYWwgRnJlZW1haWwgSXNzdWluZyBDQQIQI8m26O3N wm9ncjUecenDJDANBgkqhkiG9w0BAQEFAASCAQB6GuEZsa2CFPlzbLgveGU7TaeUE45KIqwBj2lf SpmMqwBXlpOUwd9DVQZ+Y0AR15B+pFszhr/Xpg7VlAgqj2M1WS30bmNg3f/j4wR9tQ02eyLEi/ku MGYI158DW+nRnbfppHgimo6+fPK9SKADDo2mudQL41WFnn8/lsG5v49yHeJKd98quu3YL4ueCtWq 5RVdjn2QK0T5pUgfRPO7TXOIoK6QGIkc9KHT3AauXlTYDkjWyAkQ/tIyOBRho7eBSEWFxfI1IPcm gemmvamZIuPnOCMgdtJSAtU7ZNpCCuC8VJzrog7zz9m0ZrFt/U8bK+fMYtQBlm2R619tpw6/4WK1 AAAAAAAA --===============7894907688235066546==-- From throw-away-1@macromates.com Sun Sep 24 12:02:49 2006 From: Allan Odgaard To: textmate@lists.macromates.com Subject: Re: [TxMt] idea: a better label completion technique Date: Sun, 24 Sep 2006 14:02:41 +0200 Message-ID: <556D3920-2DF2-481D-8D07-FA611A0FF25A@macromates.com> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1065925108288610514==" --===============1065925108288610514== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit On 24/9/2006, at 12:54, Piero D''Ancona wrote: > [...] This must be some escaping trickery. Could some pious wizard > explain what's wrong? You need to escape the double quotes inside the attribute value (since the attribute value itself is surrounded in double quotes). Also, the command needs to be run asynchronously to not stall TM. Here’s a proof-of-concept, you will likely be disappointed by the time it takes to click the link, till text is actually inserted -- that’s time spent by osascript. --===============1065925108288610514== Content-Type: application/octet-stream Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="InsertIntoTM.tmCommand" MIME-Version: 1.0 PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPCFET0NUWVBFIHBsaXN0IFBV QkxJQyAiLS8vQXBwbGUgQ29tcHV0ZXIvL0RURCBQTElTVCAxLjAvL0VOIiAiaHR0cDovL3d3dy5h cHBsZS5jb20vRFREcy9Qcm9wZXJ0eUxpc3QtMS4wLmR0ZCI+CjxwbGlzdCB2ZXJzaW9uPSIxLjAi Pgo8ZGljdD4KCTxrZXk+YmVmb3JlUnVubmluZ0NvbW1hbmQ8L2tleT4KCTxzdHJpbmc+bm9wPC9z dHJpbmc+Cgk8a2V5PmJ1bmRsZVVVSUQ8L2tleT4KCTxzdHJpbmc+Mjc4REIzMkMtNjJFNS00NkQz LUE0MkQtMDZGMEUxQkZGRUMzPC9zdHJpbmc+Cgk8a2V5PmNvbW1hbmQ8L2tleT4KCTxzdHJpbmc+ Y2F0ICZsdDsmbHQ7J0hUTUwnCgogICAmbHQ7YSBocmVmPSJqYXZhc2NyaXB0OlRleHRNYXRlLnN5 c3RlbSgmYW1wO3F1b3Q7L3Vzci9iaW4vb3Nhc2NyaXB0ICZhbXA7Jmd0Oy9kZXYvbnVsbCAtZSAn dGVsbCBhcHAgXCZhbXA7cXVvdDtUZXh0TWF0ZVwmYW1wO3F1b3Q7IHRvIGluc2VydCBcJm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