[Vim-latex-cvs] vimfiles/ftplugin/latex-suite templates.vim,1.7,1.8
Brought to you by:
srinathava,
tmaas
From: <sri...@us...> - 2002-12-23 01:59:21
|
Update of /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite In directory sc8-pr-cvs1:/tmp/cvs-serv24780 Modified Files: templates.vim Log Message: Problem: The original mechanism did not account for the placeholder settings being changed. Changed the templates such that the first line contains a tab delimited list of placeholder specifications used in the file as well as the special characters for computing and executing things within the templates. ReadTemplate() reads in these specs from the first line and ProcessTemplates() uses them to process the template file. This allows for the template maker to not have to bother with the users placeholder settings. Index: templates.vim =================================================================== RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/templates.vim,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** templates.vim 22 Dec 2002 03:00:49 -0000 1.7 --- templates.vim 23 Dec 2002 01:59:18 -0000 1.8 *************** *** 5,9 **** " Version: 1.0 " Created: Tue Apr 23 05:00 PM 2002 PST ! " Last Change: Thu Dec 19 03:00 AM 2002 PST " " Description: functions for handling templates in latex-suite/templates --- 5,9 ---- " Version: 1.0 " Created: Tue Apr 23 05:00 PM 2002 PST ! " Last Change: Sun Dec 22 05:00 PM 2002 PST " " Description: functions for handling templates in latex-suite/templates *************** *** 30,34 **** \":call <SID>ReadTemplate('".fnameshort."')<CR>". \":call <SID>ProcessTemplate()<CR>:0<CR>". ! \"i<C-r>=IMAP_Jumpfunc()<CR>" let i = i + 1 endwhile --- 30,34 ---- \":call <SID>ReadTemplate('".fnameshort."')<CR>". \":call <SID>ProcessTemplate()<CR>:0<CR>". ! \"i<C-r>=IMAP_Jumpfunc('', 1)<CR>" let i = i + 1 endwhile *************** *** 42,46 **** " ReadTemplate: reads in the template file from the template directory. {{{ function! <SID>ReadTemplate(...) - if a:0 > 0 let filename = a:1.'.*' --- 42,45 ---- *************** *** 54,57 **** --- 53,70 ---- let fname = glob(s:path."/templates/".filename) exe "0read ".fname + " The first line of the file contains the specifications of what the + " placeholder characters and the other special characters are. + let pattern = '\v(\S+)\t(\S+)\t(\S+)\t(\S+)' + + let s:phsTemp = substitute(getline(1), pattern, '\1', '') + let s:pheTemp = substitute(getline(1), pattern, '\2', '') + let s:exeTemp = substitute(getline(1), pattern, '\3', '') + let s:comTemp = substitute(getline(1), pattern, '\4', '') + + call Tex_Debug('phs = '.s:phsTemp.', phe = '.s:pheTemp.', exe = '.s:exeTemp.', com = '.s:comTemp) + + " delete the first line into ze blackhole. + 0 d _ + call Tex_pack_all() endfunction *************** *** 63,83 **** " http://vim.sourceforge.net/scripts/script.php?script_id=222 function! <SID>ProcessTemplate() ! silent! %s/^¿\(\_.[^¿]*\)¿$/\=<SID>Compute(submatch(1))/ge ! silent! %s/¡\([^¡]*\)¡/\=<SID>Exec(submatch(1))/ge ! silent! g/¿¿/d ! call Tex_CleanSearchHistory() ! call Tex_CleanSearchHistory() ! call Tex_CleanSearchHistory() endfunction function! <SID>Exec(what) ! exec 'return '.a:what endfunction " Back-Door to trojans !!! function! <SID>Compute(what) ! exe a:what ! return "¿¿" endfunction --- 76,107 ---- " http://vim.sourceforge.net/scripts/script.php?script_id=222 function! <SID>ProcessTemplate() ! if exists('s:phsTemp') && s:phsTemp != '' ! exec 'silent! %s/^'.s:comTemp.'\(\_.\{-}\)'.s:comTemp.'$/\=<SID>Compute(submatch(1))/ge' ! exec 'silent! %s/'.s:exeTemp.'\(.\{-}\)'.s:exeTemp.'/\=<SID>Exec(submatch(1))/ge' ! exec 'silent! g/'.s:comTemp.s:comTemp.'/d' ! ! let phsUser = IMAP_GetPlaceHolderStart() ! let pheUser = IMAP_GetPlaceHolderEnd() ! ! exec 'silent! %s/'.s:phsTemp.'\(.\{-}\)'.s:pheTemp.'/'.phsUser.'\1'.pheUser.'/ge' ! ! " A function only puts one item into the search history... ! call Tex_CleanSearchHistory() ! endif endfunction function! <SID>Exec(what) ! exec 'return '.a:what endfunction " Back-Door to trojans !!! function! <SID>Compute(what) ! exe a:what ! if exists('s:comTemp') ! return s:comTemp.s:comTemp ! else ! return '' ! endif endfunction *************** *** 85,92 **** com! -nargs=? TTemplate :call <SID>ReadTemplate(<f-args>) ! \| :call <SID>ProcessTemplate() ! \| :0 ! \| :exec "normal! i\<C-r>=IMAP_Jumpfunc()\<CR>" ! \| :startinsert " vim:fdm=marker:ts=4:sw=4:noet --- 109,116 ---- com! -nargs=? TTemplate :call <SID>ReadTemplate(<f-args>) ! \| :call <SID>ProcessTemplate() ! \| :0 ! \| :exec "normal! i\<C-r>=IMAP_Jumpfunc('', 1)\<CR>" ! \| :startinsert " vim:fdm=marker:ts=4:sw=4:noet |