[Vim-latex-cvs] vimfiles/ftplugin/latex-suite envmacros.vim,1.24,1.25
Brought to you by:
srinathava,
tmaas
From: <sri...@us...> - 2003-01-15 02:52:51
|
Update of /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite In directory sc8-pr-cvs1:/tmp/cvs-serv23938 Modified Files: envmacros.vim Log Message: - instead of custom functions for creating prompt strings of environments/commands/templates/packages etc, use a function Tex_CreatePrompt() everywhere. See main.vim for usage details. It turns out the bug Mikolaj reported with the prompt not changing was becuause of a buggy SetUpCommandPrompt() function. TODO: There are many globally visible functions not starting with the Tex_ prefix. Will have to fix that soon. - Code cleanup: bugs where introduced in previous versions when Tex_ChangeEnvironments() was called with an argument. Will have to ask Mikolaj to be a bit more careful in adding new features... - More cleanup: Also changed some script local variables to function local variables... Should ask Mikolaj not to use script local variables unecessarily. They make the code very unreadable. I always keep wondering why this variable needs to be visible outside this function... - Code cleanup: g:Tex_PromptedEnvironmentsDefault and g:Tex_PromptedCommandsDefault moved from here to packages.vim, which is a more natural place for them. Index: envmacros.vim =================================================================== RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/envmacros.vim,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** envmacros.vim 14 Jan 2003 23:56:52 -0000 1.24 --- envmacros.vim 15 Jan 2003 02:52:47 -0000 1.25 *************** *** 501,525 **** " Contributions / suggestions from Carl Mueller (auctex.vim) " ============================================================================== - " SetUpEnvironmentsPrompt: sets up a prompt string using g:Tex_PromptedEnvironments {{{ - " Description: - " - let g:Tex_PromptedEnvironmentsDefault = g:Tex_PromptedEnvironments - function! SetUpEnvironmentsPrompt() - let num_common = GetListCount(g:Tex_PromptedEnvironments) - - let i = 1 - let s:common_env_prompt = "\n" - - while i < num_common - - let env1 = Tex_Strntok(g:Tex_PromptedEnvironments, ',', i) - let env2 = Tex_Strntok(g:Tex_PromptedEnvironments, ',', i + 1) - - let s:common_env_prompt = s:common_env_prompt.'('.i.') '.env1."\t".( strlen(env1) < 4 ? "\t" : '' ).'('.(i+1).') '.env2."\n" - - let i = i + 2 - endwhile - let s:common_env_prompt = s:common_env_prompt.'Enter number or name of environment: ' - endfunction " }}} " PromptForEnvironment: prompts for an environment {{{ " Description: --- 501,504 ---- *************** *** 527,531 **** if !exists('s:common_env_prompt') ! call SetUpEnvironmentsPrompt() endif --- 506,513 ---- if !exists('s:common_env_prompt') ! let s:common_env_prompt = ! \ "\n" . ! \ Tex_CreatePrompt(g:Tex_PromptedEnvironments, 2, ',') . ! \ "Enter number or name of environment: " endif *************** *** 612,618 **** inoremap <silent> <Plug>Tex_FastEnvironmentInsert <C-r>=Tex_FastEnvironmentInsert("no")<cr> nnoremap <silent> <Plug>Tex_FastEnvironmentInsert i<C-r>=Tex_FastEnvironmentInsert("no")<cr> - inoremap <silent> <Plug>Tex_FastEnvironmentChange <C-O>:call Tex_ChangeEnvironments("no")<CR> - nnoremap <silent> <Plug>Tex_FastEnvironmentChange :call Tex_ChangeEnvironments("no")<CR> vnoremap <silent> <Plug>Tex_FastEnvironmentInsert <C-\><C-N>:call Tex_FastEnvironmentInsert("yes")<CR> " Tex_FastEnvironmentInsert: maps <F5> to prompt for env and insert it " {{{ --- 594,600 ---- inoremap <silent> <Plug>Tex_FastEnvironmentInsert <C-r>=Tex_FastEnvironmentInsert("no")<cr> nnoremap <silent> <Plug>Tex_FastEnvironmentInsert i<C-r>=Tex_FastEnvironmentInsert("no")<cr> vnoremap <silent> <Plug>Tex_FastEnvironmentInsert <C-\><C-N>:call Tex_FastEnvironmentInsert("yes")<CR> + inoremap <silent> <Plug>Tex_FastEnvironmentChange <C-O>:call Tex_ChangeEnvironments()<CR> + nnoremap <silent> <Plug>Tex_FastEnvironmentChange :call Tex_ChangeEnvironments()<CR> " Tex_FastEnvironmentInsert: maps <F5> to prompt for env and insert it " {{{ *************** *** 713,732 **** exe 'echomsg "You are within a '.env_name.' environment."' ! let s:change_env = PromptForEnvironment('Do you want to change it to (number or name)? ') ! if s:change_env == 'eqnarray' call <SID>Change('eqnarray', 1, '', 1) ! elseif s:change_env == 'eqnarray*' call <SID>Change('eqnarray*', 0, '\\nonumber', 0) ! elseif s:change_env == 'align' call <SID>Change('align', 1, '', 1) ! elseif s:change_env == 'align*' call <SID>Change('align*', 0, '\\nonumber', 0) ! elseif s:change_env == 'equation*' call <SID>Change('equation*', 0, '&\|\\lefteqn{\|\\nonumber\|\\\\', 0) ! elseif s:change_env == '' return 0 else ! call <SID>Change(s:change_env, 0, '', '') return 0 endif --- 695,714 ---- exe 'echomsg "You are within a '.env_name.' environment."' ! let change_env = PromptForEnvironment('What do you want to change it to? ') ! if change_env == 'eqnarray' call <SID>Change('eqnarray', 1, '', 1) ! elseif change_env == 'eqnarray*' call <SID>Change('eqnarray*', 0, '\\nonumber', 0) ! elseif change_env == 'align' call <SID>Change('align', 1, '', 1) ! elseif change_env == 'align*' call <SID>Change('align*', 0, '\\nonumber', 0) ! elseif change_env == 'equation*' call <SID>Change('equation*', 0, '&\|\\lefteqn{\|\\nonumber\|\\\\', 0) ! elseif change_env == '' return 0 else ! call <SID>Change(change_env, 0, '', '') return 0 endif *************** *** 818,822 **** if g:Tex_HotKeyMappings != '' ! " SetUpHotKeys: maps <F1> through <F4> to insert environments {{{ " Description: function! <SID>SetUpHotKeys() --- 800,804 ---- if g:Tex_HotKeyMappings != '' ! " SetUpHotKeys: maps <F1> through <F4> to insert environments " Description: function! <SID>SetUpHotKeys() *************** *** 832,836 **** endwhile ! endfunction " }}} endif --- 814,818 ---- endwhile ! endfunction endif *************** *** 866,903 **** " Implementation of Fast Environment commands for LaTeX commands " ============================================================================== - " SetUpCommandPrompt: sets up a prompt string using g:Tex_PromptedCommands {{{ - " Description: - " - - " This variable is default string for promting useful with updating new - " commands - let g:Tex_PromptedCommandsDefault = g:Tex_PromptedCommands - - function! SetUpCommandPrompt() - let num_common = GetListCount(g:Tex_PromptedCommands) - - let i = 1 - let s:common_com_prompt = "\n" - - while i < num_common - - let com1 = Tex_Strntok(g:Tex_PromptedCommands, ',', i) - let com2 = Tex_Strntok(g:Tex_PromptedCommands, ',', i + 1) - - let s:common_com_prompt = s:common_com_prompt.'('.i.') '.com1."\t".( strlen(com1) < 4 ? "\t" : '' ).'('.(i+1).') '.com2."\n" - - let i = i + 2 - endwhile - let s:common_com_prompt = s:common_com_prompt.'Enter number or name of command: ' - endfunction " }}} " PromptForCommand: prompts for a command {{{ " Description: function! PromptForCommand(ask) ! if !exists('s:common_com_prompt') ! call SetUpCommandPrompt() ! endif ! let inp = input(a:ask.s:common_com_prompt) if inp =~ '^[0-9]\+$' let com = Tex_Strntok(g:Tex_PromptedCommands, ',', inp) --- 848,860 ---- " Implementation of Fast Environment commands for LaTeX commands " ============================================================================== " PromptForCommand: prompts for a command {{{ " Description: function! PromptForCommand(ask) ! let common_com_prompt = ! \ Tex_CreatePrompt(g:Tex_PromptedCommands, 2, ',') . "\n" . ! \ "Enter number or command name :" ! let inp = input(a:ask."\n".common_com_prompt) if inp =~ '^[0-9]\+$' let com = Tex_Strntok(g:Tex_PromptedCommands, ',', inp) *************** *** 913,917 **** function! Tex_DoCommand(...) if a:0 < 1 ! let com = PromptForCommand('Choose which command to insert: ') if com != '' return Tex_PutCommand(com) --- 870,874 ---- function! Tex_DoCommand(...) if a:0 < 1 ! let com = PromptForCommand('Choose a command to insert: ') if com != '' return Tex_PutCommand(com) *************** *** 969,973 **** vnoremap <silent> <Plug>Tex_FastCommandInsert <C-\><C-N>:call Tex_FastCommandInsert('yes')<CR> ! " Tex_FastEnvironmentInsert: maps <F7> to prompt for command and insert it " {{{ " Description: " Here we are not solving if we are in preamble, behaviour is always the --- 926,930 ---- vnoremap <silent> <Plug>Tex_FastCommandInsert <C-\><C-N>:call Tex_FastCommandInsert('yes')<CR> ! " Tex_FastCommandInsert: maps <F7> to prompt for command and insert it " {{{ " Description: " Here we are not solving if we are in preamble, behaviour is always the *************** *** 985,989 **** " }}} ! " Tex_ChangeEnvironments: calls ChangeCommand() to change the environment {{{ " Description: " Finds out which environment the cursor is positioned in and changes --- 942,946 ---- " }}} ! " Tex_ChangeCommand: calls ChangeCommand() to change the environment {{{ " Description: " Finds out which environment the cursor is positioned in and changes *************** *** 994,998 **** function! Tex_ChangeCommand(isvisual) ! let s:pos_com = line('.').' | normal! '.virtcol('.').'|' let com_line = searchpair('\\\k\{-}{', '', '}', 'b') --- 951,955 ---- function! Tex_ChangeCommand(isvisual) ! let pos_com = line('.').' | normal! '.virtcol('.').'|' let com_line = searchpair('\\\k\{-}{', '', '}', 'b') *************** *** 1005,1018 **** if !exists('com_name') echomsg "You are not inside command" return 0 endif exe 'echomsg "You are within a '.com_name.' command."' ! let s:change_com = PromptForCommand('Do you want to change it to (number or name)? ') ! if s:change_com == '' return 0 else ! call <SID>ChangeCommand(s:change_com) return 0 endif --- 962,978 ---- if !exists('com_name') echomsg "You are not inside command" + exe pos_com return 0 endif exe 'echomsg "You are within a '.com_name.' command."' ! let change_com = PromptForCommand('Do you want to change it to (number or name)? ') ! if change_com == '' ! exe pos_com return 0 else ! call <SID>ChangeCommand(change_com) ! exe pos_com return 0 endif *************** *** 1020,1023 **** --- 980,984 ---- endfunction + " }}} " ChangeCommand: Changes current command according to prompt menu {{{ " Description: *************** *** 1026,1030 **** exe 'normal ct{'.a:newcom."\<Esc>" - exe s:pos_com endfunction --- 987,990 ---- *************** *** 1057,1061 **** " }}} - " }}} " this statement has to be at the end. let s:doneOnce = 1 --- 1017,1020 ---- |