[TxMt] [LaTeX Bundle] New command for numprint

Alain Matthes alain.matthes at mac.com
Sun Nov 15 10:22:15 UTC 2009


Hi

I'm not an expert with Ruby so I need to know if the next command is safe

I want to select a "number" and to get $\numprint{number}$ if number is not empty
 and number is not  inside a math environment 
   or
 \numprint{number} if number is inside a math environment.

then
    if number is empty, I want to get  \numprint{...}  or $\numprint{...}$

I made this and I would like to know if this code is correct

#!/usr/bin/ruby
    #  Created by Alain Matthes on 2009-11-15 (www.altermundus.com).

require ENV["TM_SUPPORT_PATH"] + "/lib/exit_codes.rb"

if ENV['TM_SELECTED_TEXT'].nil?
	input = ENV['']
else
	input = ENV['TM_SELECTED_TEXT']
end

if ENV['TM_SCOPE'].match(/math.((.*)|(la))tex/)
	$math_del = ""
else
	$math_del = "\\$"
end

TextMate.exit_insert_snippet("#{$math_del}\\numprint{#{input}$0}#{$math_del}")


Is it possible to use a shortcut to go out of the first environment {...} and then to go out
 of the math environment because the caret is inside {number} ?

Best regards

Alain Matthes





More information about the textmate mailing list