[TxMt] LaTeX Bundle

Alain Matthes alain.matthes at mac.com
Mon Nov 30 16:36:44 UTC 2009


Le 18 nov. 2009 à 01:00, Alex Ross a écrit :

> 
> 
> I simplified it a little bit, and added the features you wanted:
> 
>> #!/usr/bin/ruby
>>   #  Created by Alain Matthes on 2009-11-15 (www.altermundus.com).
>>   #  Some simplification by Alex Ross (http://lasersox.net)
>> 
>> snippet = "\\numprint{${1:#{$stdin.read || "..."}}}$2"
>> snippet = "\\$#{snippet}\\$$0" unless ENV['TM_SCOPE'].match(/math/)
>> 
>> puts snippet
> 
> Set Input: Selected Text or Nothing
> Output: Insert as Snippet


Hi Alex

Your code is interesting and it's very concise. Is it possible
 to have some details about the syntax?

I try to adapt this code. I would like to change 
"LaTeX Symbol Based on Current Word / Selection"

because the symbols are only used in math mode
so I try

#!/usr/bin/env ruby
require "#{ENV['TM_SUPPORT_PATH']}/lib/exit_codes"
require "#{ENV['TM_BUNDLE_SUPPORT']}/lib/config_helper.rb"
@plist = Config.load
shortcutHash = @plist['symbols']
currentWord = STDIN.read

if (shortcutHash.has_key?(currentWord)) then
currentWord = shortcutHash[currentWord]
currentWord = "\$#{currentWord}$" unless ENV['TM_SCOPE'].match(/math/)
print currentWord else
  TextMate.exit_discard
 end

but the caret is outside the math environment and I don't know
 how to keep it inside

Best regards

Alain Matthes






More information about the textmate mailing list