From pierodancona@gmail.com Tue Sep 26 09:28:08 2006 From: Piero D'Ancona To: textmate@lists.macromates.com Subject: [TxMt] question: how to insert a "" from javascript? Date: Tue, 26 Sep 2006 09:27:37 +0000 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4809858720087640099==" --===============4809858720087640099== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Hi, one never really escapes the escape tunnel. I have a new problem with escapes. >From the command line I can ask TextMate to insert a backslash: osascript -s 'tell app "TextMate" to insert "\"' I want to do the same from a javascript contained in an a href link. But I can not find the correct way to escape things. Allan's suggestion works perfectly with ordinary text; the following html code: TEXTOFLINK
produces a link TEXTOFLINK and when I click on it, TEXTTOINSERT is inserted into TextMate. But if TEXTTOINSERT contains a backslash, it is ignored. A pity since I want to insert a tex command... What should I write instead of TEXTTOINSERT to get, say, "\eqref" to be inserted? Yes, I am escape-blind. Thanks for any help, Piero PS hm... no one seems to like my new idea for label completion. I'll keep it for personal use :) --===============4809858720087640099==-- From throw-away-1@macromates.com Tue Sep 26 13:31:46 2006 From: Allan Odgaard To: textmate@lists.macromates.com Subject: Re: [TxMt] question: how to insert a "" from javascript? Date: Tue, 26 Sep 2006 15:31:41 +0200 Message-ID: <42D450EE-D566-4C9A-A965-871B42A8EB0C@macromates.com> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3130383987391662625==" --===============3130383987391662625== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On 26/9/2006, at 11:27, Piero D'Ancona wrote: > [...] osascript -s 'tell app "TextMate" to insert "\"' > > I want to do the same from a javascript > contained in an a href link. But I can not find the > correct way to escape things [...] Use \\ for one backslash in JavaScript strings. --===============3130383987391662625==-- From pierodancona@gmail.com Tue Sep 26 14:49:25 2006 From: Piero D'Ancona To: textmate@lists.macromates.com Subject: [TxMt] Re: question: how to insert a Date: Tue, 26 Sep 2006 14:44:13 +0000 Message-ID: In-Reply-To: <42D450EE-D566-4C9A-A965-871B42A8EB0C@macromates.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7354272078868824090==" --===============7354272078868824090== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Allan Odgaard writes: > > On 26/9/2006, at 11:27, Piero D'Ancona wrote: > > > [...] osascript -s 'tell app "TextMate" to insert "\"' > > > > I want to do the same from a javascript > > contained in an a href link. But I can not find the > > correct way to escape things [...] > > Use \\ for one backslash in JavaScript strings. > > I am not that blind, I tried \eqref, \\eqref, \\\eqref, \\\\eqref... up to six (!) but the backslash is not inserted: only "eqref" or nothing at all, depending on the number of slashes. I'll try again since the word of the master is beyond doubt, but... Piero --===============7354272078868824090==-- From throw-away-1@macromates.com Tue Sep 26 15:29:54 2006 From: Allan Odgaard To: textmate@lists.macromates.com Subject: Re: [TxMt] Re: question: how to insert a Date: Tue, 26 Sep 2006 17:28:17 +0200 Message-ID: <195716FE-D850-45E5-A6B4-E3229D464A9B@macromates.com> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0415164887233179402==" --===============0415164887233179402== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On 26/9/2006, at 16:44, Piero D'Ancona wrote: >> Use \\ for one backslash in JavaScript strings. > I am not that blind, I tried \eqref, \\eqref, \\\eqref, > \\\\eqref... up to six (!) but the backslash is not > inserted: only "eqref" or nothing at all, depending > on the number of slashes. > I'll try again since the word of the master is beyond doubt, but... Yeah, you would actually need 4 or 8 here. 2 for the actual AppleScript string, but this is inside a JavaScript string, so both needs escaping (so total is now 4) -- depending on how you produce the JavaScript, you may need to again escape each, making it now 8. This would be the case if you use e.g. echo with a double-quoted string. In single-quoted strings or here-docs you would not need to escape \. --===============0415164887233179402==-- From pierodancona@gmail.com Tue Sep 26 15:42:26 2006 From: Piero D'Ancona To: textmate@lists.macromates.com Subject: [TxMt] Re: question: how to insert a "\" - NOT WORKING Date: Tue, 26 Sep 2006 15:34:01 +0000 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6537992363208441607==" --===============6537992363208441607== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit > Allan Odgaard ...> writes: > > > > > On 26/9/2006, at 11:27, Piero D'Ancona wrote: > > > > > [...] osascript -s 'tell app "TextMate" to insert "\"' > > > > > > I want to do the same from a javascript > > > contained in an a href link. But I can not find the > > > correct way to escape things [...] > > > > Use \\ for one backslash in JavaScript strings. > > I confirm what I said: it does not work. Try the following html: try A link is produced but if you click on it nothing happens. (if you put \eqref instead of \\eqref, the text "eqref" is inserted). Sorry! something here really escapes me, as usual Piero --===============6537992363208441607==-- From pierodancona@gmail.com Tue Sep 26 15:48:40 2006 From: Piero D'Ancona To: textmate@lists.macromates.com Subject: [TxMt] Re: question: how to insert a Date: Tue, 26 Sep 2006 15:38:32 +0000 Message-ID: In-Reply-To: <195716FE-D850-45E5-A6B4-E3229D464A9B@macromates.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3015560154687720993==" --===============3015560154687720993== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Lovely! eight escapes does the trick. My faith went only so far as six \\\\\\, forgive me, master Piero --===============3015560154687720993==-- From andy@hexten.net Tue Sep 26 15:50:27 2006 From: Andy Armstrong To: textmate@lists.macromates.com Subject: Re: [TxMt] Re: question: how to insert a Date: Tue, 26 Sep 2006 16:50:22 +0100 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5016039282723361620==" --===============5016039282723361620== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On 26 Sep 2006, at 16:38, Piero D'Ancona wrote: > Lovely! eight escapes does the trick. > My faith went only so far as six \\\\\\, > forgive me, master It's always going to be 2^(number of times the slash is escaped) - so six would never be right :) -- Andy Armstrong, hexten.net --===============5016039282723361620==-- From pierodancona@gmail.com Tue Sep 26 16:25:49 2006 From: "Piero D\\'Ancona" To: textmate@lists.macromates.com Subject: [TxMt] Re: question: how to insert a Date: Tue, 26 Sep 2006 16:16:50 +0000 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0015055341303738382==" --===============0015055341303738382== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Andy Armstrong writes: > > It's always going to be 2^(number of times the slash is escaped) - so > six would never be right :) > Well, at least it is not an odd number :))) --===============0015055341303738382==--