[SVN] Passing variables to osascript, or other workaround?

Charilaos Skiadas cskiadas at uchicago.edu
Thu May 12 06:50:39 UTC 2005


On May 11, 2005, at 10:33 PM, Allan Odgaard wrote:
> And you're certainly right about the shell being slow, here's the 
> times on my 2.5 GHz G5:
>    sed    1.020s
>    perl   1.300s
>    ruby   2.191s
>    bash  11.008s

> Btw: if you want to experiment with this, just paste the loop into TM, 
> select it, and press ctrl-R, then it'll run it within TM and output 
> the result -- a bit easier than to play with this in a terminal window 
> :)

Just tried with the sed and bash methods. quite startling difference on 
my iBook G4:

	sed   2.093s
	bash 36.259s   !!!!!!!

> Bash rarely allow nested statements, what you can do is use commands 
> instead of built-in features:
> 	list=$(cut <<<$list -b-80|sed -e 's|\\|\\\\|g')

neat! I need to do some more reading it seems... I hadn't even heard of 
cut. :-)

> Btw: I switched from `...` to $(...) because the former requires 
> escaping of \, and I switched from s/.../.../ to s|...|...| in the sed 
> substitution for cosmetic reasons.

I see what you mean :-) I have to admit though, I'm so used to seeing 
the s/../../ syntax, that the alternative seems a bit weird. I'll grow 
out of it hopefully.
>> but that took me back to the previous error. Is there something else 
>> I might need to escape, maybe braces or something? (i.e. when I cut 
>> at the 80 characters, maybe I've left some braces unended?)
>
> I don't think so -- but if you did the cut after escaping escapes, you 
> could cut in the middle of such an escape pair, and thus have a bad 
> string again.

no, I was doing the cutting first, right after the sed command. In 
hindsight, that wasn't such a great idea, since it operated on the 
whole list as one line, and hence killed most of it. I'll try to see 
what happens in more detail when I get some time. For now, I've set it 
up to just show the labels. It might make sense at some point to make 
it look for a comment immediately after the label command, and add the 
whole comment if there is one. Or people should just choose their label 
names carefully so that they are meaningful. :-)

>> In terms of scope, this is to be used inside a \ref{} or an \eqref{} 
>> (can't remember if there are others). would the proper scope be 
>> text.latex, declaration.ref-or-label.latex or 
>> keyword.control.ref-or-label.latex ?
>
> declaration.ref-or-label is most appropriate IMHO. The 
> keyowrd.control.ref-or-label

Did you mean to drop the ".latex" here?

> would work, but only because the start bracket is currently part of 
> the keyword, so placing the caret just after { would still give a 
> scope of being in the keyword, but that could change.
>
> This of course assuming that the command is only useful inside a 
> \(eq)?ref, otherwise the scope should be text.latex. Limiting a scope 
> should mainly be done when it's an advantage, e.g. if you bind it to 
> 'escape' then it's required that you put it inside the 
> declaration.ref-or-label scope, so that escape doesn't lose its value 
> outside this scope. But if you put it on some unused (for latex) key, 
> then there's probably little reason to not provide the feature in the 
> entire text.latex scope.

Yeah, what I had in mind was using it only in the \(eq)?ref context, 
and maybe binding it to the same key as BibDesk completion. I feel, 
maybe it's just me, that esc should be doing instant completion, 
without popup lists and stuff. That's what I expect from it anyway.

Outside of \(eq)?ref, what would be helpful would be a command like the 
"goto symbol...", but would catch labels instead of sectioning 
commands. I guess I could probably easily write one that is basically 
like the Show labels, but opens them in a new window instead, with line 
numbers etc. In fact, I'll do that soon. I am guessing at this point it 
can't be done to look as cool as the "goto symbol..." one?
That thing is awesome.

Thanks for all the help, and the scripting lessons. They are especially 
appreciated. Is there a good place to learn such less basic scripting 
stuff? Whenever I try to google for something relevant, I get a bunch 
of trivial tutorials.
My main source of information right now is the opengroup's 
specification at
http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
but it is a bit poor on examples, and a bit too much like a 
specification...
Pretty good for a reference though.
I guess I just have to write enough scripts of my own until it sticks. 
:-)

Haris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 4562 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate-dev/attachments/20050512/6011eac0/attachment.bin>


More information about the textmate-dev mailing list