On Thu, 28 Aug 2008 14:52:55 -0500, James Gray wrote:
> My copy of the command already has text.map(). We cannot do the
> reverse either, switch to text.lines.map() as 1.8 doesn't have lines().
OK, my embarrassment level is up pretty high. :-)
This is what works for me in 1.9:
when "line" # line by line comment
if text !~ /\A[\t ]+\z/ &&
text.lines.map { |l| !!(l =~ /\A\s*(#{com[:esc_start]}|$)/)
}.uniq == [true]
if $selected
out text.gsub(
/^(\s*)#{com[:esc_start]}(.*?)#{com[:esc_end]}(\s*)$/,
'\1\2\3' )
exit
else
r = text.sub(
/^(\s*)#{com[:esc_start]}(.*?)#{com[:esc_end]}(\s*)$/,
'\1\2\3' )
i = ENV["TM_LINE_INDEX"].to_i
i = i > text.index(/#{com[:esc_start]}/) ?
[[0, i - com[:start].length].max, r.length].min :
[i, r.length].min
r[i, 0] = "\0"
out r
exit
end
end
-Charles
_______________________________________________
textmate-dev mailing list
[email protected]
http://lists.macromates.com/listinfo/textmate-dev