I want a perl snippet that does this:
open($1, "$2") or die "Can't open file: $!\n"; while(<$3>) { $4 }
I enter this into the snippet editor. What happens is: 1. The "entry point" is always $2. (in other words, type 'openTAB', get the snippet, but the insertion point is at $2) 2. hitting TAB after entering some text moves the insertion to $1, but any attempts to hit tab to move to the while ($3) fail; it just inserts a literal TAB. 3. escaping the $! with something like $! has no effect; it always inserts '!n'. I even tried \n and variations thereof with $! to no effect.
I'm not sure if this is a side effect of the Perl syntax rules/bundle (using the stock one, I long since abandoned mine in favor of the other, superior one :) or another weirdness.
As a side note, I want $1 and $3 to be the same thing; is it enough to just call 'em both $1?
On Jan 28, 2005, at 17:23, Gregg Thomason wrote:
I want a perl snippet that does this: [...]
- The "entry point" is always $2. (in other words, type 'openTAB',
get the snippet, but the insertion point is at $2)
That's strange -- and I can't reproduce. What version of TM are you using? And you're sure the problem isn't with your tab-key (making two tabs)? ;)
- escaping the $! with something like $! has no effect; it always
inserts '!n'. I even tried \n and variations thereof with $! to no effect.
It should be ā$!\nā.
I'm not sure if this is a side effect of the Perl syntax rules/bundle [...]
Shouldn't be.
As a side note, I want $1 and $3 to be the same thing; is it enough to just call 'em both $1?
Yes, I changed your snippet to this:
open($1, "$2") or die "Can't open file: $!\n"; while(<$1>) { $3 }
Here's how it looks when I use it: http://macromates.com/movies/perl_snippet.mov
On Friday, January 28, 2005, at 11:38AM, Allan Odgaard allan@macromates.com wrote:
That's strange -- and I can't reproduce. What version of TM are you using? And you're sure the problem isn't with your tab-key (making two tabs)? ;)
1.1b3 (v1.1b3)
It's reading a bundle bad somewhere. Just for kicks I changed the quoted 'die' text to something nonsensical and restarted TM, opened a new document, set to Perl syntax, and tried again. No dice: it printed the old (sensical) string!
I guess I'm at "nuke all prefs and start over". I'll follow up if that doesn't cure anything.
Here's how it looks when I use it: http://macromates.com/movies/perl_snippet.mov
Totally gotta get a copy of Snapz...
On Jan 28, 2005, at 17:59, Gregg Thomason wrote:
It's reading a bundle bad somewhere. Just for kicks I changed the quoted 'die' text to something nonsensical and restarted TM, opened a new document, set to Perl syntax, and tried again. No dice: it printed the old (sensical) string!
Oh... that's _very_ strange indeed. If it does find two snippets with same trigger, it will give you a menu.
Try to change the tab trigger.