Whoops - that was a bit messed up. Here's the ACTUAL finished source (which escapes any '$'s other than the $0 it inserts.
#!/usr/bin/env ruby
$t = STDIN.read
if $t =~ /\A(.*);\Z/ $c = ENV['TM_LINE_INDEX'].to_i print $t.insert($c, ';$0').gsub(/$([^0])/, '$\1') else print $t.gsub('$', '$')+';$0' end
On 2/13/07, Kevin Cox kevintcox@gmail.com wrote:
Wow. Thanks so much!
If anybody's interested, here's the finished source:
#!/usr/bin/env ruby
$t = STDIN.read
if $t =~ /\A(.*);\Z/ $c = ENV['TM_LINE_INDEX'].to_i print $t.insert($c, ';$0') else print $t+';$0' end
On 2/13/07, Charilaos Skiadas skiadas@hanover.edu wrote:
On Feb 13, 2007, at 2:16 PM, Kevin Cox wrote:
Hello all,
input: selected text or line output: replace selected text activation: key equivalent ';' scope: "source"
#!/usr/bin/env ruby
$t = STDIN.read
if $t =~ /\A(.*);\Z/ $c = ENV['TM_LINE_INDEX'].to_i print $t.insert($c, ';') else print $t+';' end
Any idea how to move the cursor? Snippets handle cursor motion, but I'm not sure I can get the semicolon to go to the right spot. Ideas? Tricks?
Set your output to Insert as snippet. This will actually replace whatever the input is, but will interpret the output as a snippet. Then you do the processing of the line, and you snippet-escape the result, and add $0 at the location where you want the caret to end up. The library escape.rb will be of help to you, it contains an "e_sn" command that escapes the text for use in a snippet.
Best, Kevin
Haris
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate