[SVN] r2362 (Latex)

Brad Miller bonelake at mac.com
Fri Dec 2 22:51:47 UTC 2005


Haris,

Indeed this modification works fine for me without having
TM_LATEX_COMMANDS or TM_LATEX_SHORTCUTS defined.

Thanks,

Brad


On Dec 2, 2005, at 9:09 AM, Charilaos Skiadas wrote:

> Actually the following should be fixing it. Can someone test it and  
> tell me, without any extra variables set?
>
> #!/usr/bin/env ruby
> #
> # This script will expand the current word either to
> # \word{} (if it's matched by the commands pattern),
> # to one of the shortcuts in the shortcut dictionary,
> # otherwise to \begin{word} … \end{word} with the caret
> # inbetween.
> #
> # With no selection, it will insert \begin{environment}
> # … \end{environment} and allow you to overwrite the
> # environment name.
>
> if(ENV.has_key?('TM_LATEX_COMMANDS'))
>     testing = ENV['TM_LATEX_COMMANDS'].to_s
>     commands = /^cite|footcite|footnote|label|ref|text(it|bf|tt|sf| 
> sc)|#{testing}$/
> else
>     commands = /^cite|footcite|footnote|label|ref|text(it|bf|tt|sf| 
> sc)$/
> end
> customShortcuts = Hash.new
> ENV['TM_LATEX_SHORTCUTS'].to_s.split(',').each { |x|
>   temp = x.split('=>')
>   customShortcuts["#{temp[0]}"]="#{temp[1]}"
> }
> shortcuts = { "it" => "textit", "bf" => "textbf", "tt" => "texttt",
> "sf" => "textsf", "sc" => "textsc",    "em" => "emph", "fc" =>  
> "footcite", "fn" => "footnote",  "eqn" => "equation", "item" =>  
> "itemize", "enum" => "enumerate" }.update(customShortcuts)
>
> name = STDIN.read
> if(!shortcuts[name].nil?)
>   name = shortcuts[name]
> end
> if(name == '')
>   print("\\begin{${1:environment}}\n\t$2\n\\end{$1}")
> elsif(commands.match(name))
>   print("\\#{name}{$1}")
> else
>   lab = ENV['TM_LATEX_INSERT_LABEL'].to_i
>   if(lab == 1)
>     labPrefix = name.slice(0,3)
>     print("\\begin{#{name}}\n\\label{#{labPrefix}:$1}\n\t$2\n\\end{# 
> {name}}")
>   else
>     print("\\begin{#{name}}\n\t$1\n\\end{#{name}}")
>   end
> end
>
> _______________________________________________
> textmate-dev mailing list
> textmate-dev at lists.macromates.com
> http://lists.macromates.com/mailman/listinfo/textmate-dev




More information about the textmate-dev mailing list