[TxMt] Reformat comment command

Allan Odgaard throw-away-1 at macromates.com
Wed Aug 23 17:41:20 UTC 2006


On 23/8/2006, at 19:24, Alan Schussman wrote:

> As I set up Reformat Comment commands for the languages I use most  
> frequently (LaTeX and R), it occurred  to me that maybe there's a  
> way to make a single call to rubywrap more generic, so that we  
> don't need a command per bundle. This is the result:

I was going to say that this belongs in the Source bundle.

> scope = ENV["TM_SCOPE"]
> case scope
>   when /comment\.(block|line)\.number-sign\./

Probably better to grab the comment character from the start of the  
input. Otherwise there is a more full mapping in the “Continue Line  
Comment” snippet in the Source bundle.

> text =`echo -n "#{e_as(STDIN.read).gsub(/[$`]/, '\\\\\0')}" | ruby  
> "#{ENV["TM_SUPPORT_PATH"]}/bin/rubywrap.rb" #{flags}`

This seems redundant and wrong. e_as is for escaping text to use in  
AppleScript strings.

The line can be:

     text = `ruby "#{ENV["TM_SUPPORT_PATH"]}/bin/rubywrap.rb" #{flags}`

> I also added a gsub to the command because it was eating latex math  
> and R symbols ($). There's probably a better solution to that.

Likely because of the Insert as Snippet -- but the e_sn should take  
care of that.

I am however not sure inserting as snippet is ideal -- I reckon this  
was to preserve the indent, but maybe better to Replace Text and have  
the command indent properly.






More information about the textmate mailing list