[Vim-latex-devel] Adding Custom Macros for packages
Brought to you by:
srinathava,
tmaas
From: Aditya M. <adi...@al...> - 2004-02-20 09:56:57
|
Hi, I like the envmacro feature of vim-latex a lot and would like to use it for other package that I frequently use. I started with defining envmacros in the envmarco.vim file but then Mikolaj Machowski suggested that these mappings should go in the package directory. The scheme that I have come up with is to define the mappings within the g:Tex_package_packagename string in the package/packagename file. I started with the amsmath package as it is the most widely used. So, what I wanted to do was EAL expands to \begin{align} <++> \end{align}<++> and similarly EGA expands to gahter environment. So, I changed packages/amsmath as follows -23 \.'env:align' +23 \.'env:aling#EAL' -25 \.'env:gather' +25 \.'env:gather#EGA' Next I modified the function Tex_ProcessPackageCommand in packages.vim has follows function! Tex_ProcessPackageCommand(command) if a:command =~ ':' let commandType = matchstr(a:command, '^\w\+\ze:') let commandName = matchstr(a:command, '^\w\+:\zs[^:#]\+\ze:\?') let extra = strpart(a:command, strlen(commandType.':'.commandName)) let extrapart = matchstr(extra,'^:\zs\w\+\ze#') let mapping = matchstr(extra,'#\zs.\+\ze') else let commandType = '' let commandName = a:command let extrapart = '' let mapping = '' endif let command = s:CommandSpec_{commandType} let command = substitute(command, '<+replace+>', commandName, 'g') let command = substitute(command, '<+extra+>', extrapart, 'g') if mapping != '' if g:Tex_EnvironmentMaps call IMAP (mapping,'\begin{'.commandName."}\<CR>".extrapart."<++>\<CR>\\end{".commandName."}<++>", 'tex') endif endif return IMAP_PutTextWithMovement(command) endfunction This does not work properly. If I open a tex file having \usepackage{amsmath} and type EAL nothing happens. But if I use the menu to go to TeX-Suite -> Packages -> amsmath command -> Environment and choose 'align#EAL' (I have to sort out the menu entry) it will output the align environment. Now EAL will expand as desired. What this means is that Tex_ProcessPackageCommand() is being called only when I choose the menu item and not otherwise. So this method is doomed. Can anyone suggest what would be a better method to assign environment macros to packages Sincerely Aditya -- Aditya Mahajan, EECS Systems, University of Michigan http://www.eecs.umich.edu/~adityam || Ph: 7342624008 |