[Vim-latex-cvs] vimfiles/ftplugin/latex-suite main.vim,1.54,1.55
Brought to you by:
srinathava,
tmaas
From: <sri...@us...> - 2003-12-14 09:38:52
|
Update of /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite In directory sc8-pr-cvs1:/tmp/cvs-serv3973 Modified Files: main.vim Log Message: A serious attempt at fixing the file names with spaces problems across various platforms. Change: Tex_GetMainFileName now applies the file name modifier to the filename after removing the trailing .latexmain part if it exists. Bug: Tex_FindInRtp would return a non-empty string even if a filename is not found in the &rtp. New: A trivial function Tex_CD() which just escapes spaces in the directory name before cd'ing to it. Use this function henceforth whenever you want to cd to another directory instead of the exec 'cd '.dirname routine. TODO: Maybe make this robust to detect previous attempts at escaping spaces and if so, /not/ escape it again. Index: main.vim =================================================================== RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/main.vim,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** main.vim 30 Nov 2003 09:48:08 -0000 1.54 --- main.vim 14 Dec 2003 07:13:44 -0000 1.55 *************** *** 409,423 **** endif endfunction " }}} ! " Tex_GetMainFileName: gets the name (without extension) of the main file being compiled. {{{ ! " Description: returns '' if .latexmain doesnt exist. ! " i.e if main.tex.latexmain exists, then returns: ! " d:/path/to/main ! " if a:1 is supplied, then it is used to modify the *.latexmain ! " file instead of using ':p:r:r'. function! Tex_GetMainFileName(...) if a:0 > 0 let modifier = a:1 else ! let modifier = ':p:r:r' endif --- 409,432 ---- endif endfunction " }}} ! " Tex_GetMainFileName: gets the name of the main file being compiled. {{{ ! " Description: returns the full path name of the main file. ! " This function checks for the existence of a .latexmain file ! " which might point to the location of a "main" latex file. ! " If .latexmain exists, then return the full path name of the ! " file being pointed to by it. ! " ! " Otherwise, return the full path name of the current buffer. ! " ! " You can supply an optional "modifier" argument to the ! " function, which will optionally modify the file name before ! " returning. ! " NOTE: From version 1.6 onwards, this function always trims ! " away the .latexmain part of the file name before applying the ! " modifier argument. function! Tex_GetMainFileName(...) if a:0 > 0 let modifier = a:1 else ! let modifier = ':p' endif *************** *** 433,438 **** let dirmodifier = '%:p:h' let dirLast = expand(dirmodifier) ! " escape spaces whenever we use cd (diego Caraffini) ! exe 'cd '.escape(dirLast, ' ') " move up the directory tree until we find a .latexmain file. --- 442,446 ---- let dirmodifier = '%:p:h' let dirLast = expand(dirmodifier) ! call Tex_CD(dirLast) " move up the directory tree until we find a .latexmain file. *************** *** 446,460 **** endif let dirLast = expand(dirmodifier) ! exec 'cd '.escape(dirLast, ' ') endwhile let lheadfile = glob('*.latexmain') if lheadfile != '' ! let lheadfile = fnamemodify(lheadfile, modifier) endif ! exe 'cd '.escape(curd, ' ') ! return escape(lheadfile, ' ') endfunction --- 454,478 ---- endif let dirLast = expand(dirmodifier) ! call Tex_CD(dirLast) endwhile let lheadfile = glob('*.latexmain') if lheadfile != '' ! " Remove the trailing .latexmain part of the filename... We never want ! " that. ! let lheadfile = fnamemodify(substitute(lheadfile, '\.latexmain$', '', ''), modifier) ! else ! " If we cannot find any main file, just modify the filename of the ! " current buffer. ! let lheadfile = expand('%'.modifier) endif ! call Tex_CD(curd) ! " NOTE: The caller of this function needs to escape spaces in the ! " file name as appropriate. The reason its not done here is that ! " escaping spaces is not safe if this file is to be used as part of ! " an external command on certain platforms. ! return lheadfile endfunction *************** *** 525,531 **** let retVal = escape(a:string, "\\") " The next escape is because when the shellxquote is ", then the grep ! " commad is usually called as bash -c "grep pattern filename" which means ! " that we need to escape backslashes (because they get halved) and also ! " double quotes. if &shellxquote == '"' let retVal = escape(retVal, "\"\\") --- 543,550 ---- let retVal = escape(a:string, "\\") " The next escape is because when the shellxquote is ", then the grep ! " commad is usually called as ! " bash -c "grep pattern filename" ! " which means that we need to escape backslashes (because they get halved) ! " and also double quotes. if &shellxquote == '"' let retVal = escape(retVal, "\"\\") *************** *** 557,561 **** let s:debugString_ = (exists('s:debugString_') ? s:debugString_ : '') ! \ . a:str."\n" endfunction " }}} " Tex_PrintDebug: prings s:debugString {{{ --- 576,582 ---- let s:debugString_ = (exists('s:debugString_') ? s:debugString_ : '') ! \ . pattern.' : '.a:str."\n" ! ! " exec '!echo '.pattern.' : '.a:str.' >> /tmp/ls.log' endfunction " }}} " Tex_PrintDebug: prings s:debugString {{{ *************** *** 608,612 **** let filelist = globpath(&rtp, 'ftplugin/latex-suite/'.a:directory.'/'.pattern)."\n" call Tex_Debug("filelist = ".filelist, "main") ! if filelist == '' return '' endif --- 629,634 ---- let filelist = globpath(&rtp, 'ftplugin/latex-suite/'.a:directory.'/'.pattern)."\n" call Tex_Debug("filelist = ".filelist, "main") ! ! if filelist == "\n" return '' endif *************** *** 677,680 **** --- 699,707 ---- endif endfunction " }}} + " Tex_CD: cds to given directory escaping spaces if necessary {{{ + " " Description: + function! Tex_CD(dirname) + exec 'cd '.escape(a:dirname, ' ') + endfunction " }}} " source texproject.vim before other files *************** *** 704,707 **** --- 731,735 ---- endif + " ============================================================================== " Finally set up the folding, options, mappings and quit. *************** *** 717,721 **** exe 'setlocal dict+='.s:path.'/dictionaries/dictionary' ! call Tex_Debug('SetTeXOptions: sourcing maps') " smart functions if g:Tex_SmartKeyQuote --- 745,749 ---- exe 'setlocal dict+='.s:path.'/dictionaries/dictionary' ! call Tex_Debug('SetTeXOptions: sourcing maps', 'main') " smart functions if g:Tex_SmartKeyQuote *************** *** 738,742 **** augroup LatexSuite au LatexSuite User LatexSuiteFileType ! \ call Tex_Debug('main.vim: Catching LatexSuiteFileType event') | \ call <SID>SetTeXOptions() augroup END --- 766,770 ---- augroup LatexSuite au LatexSuite User LatexSuiteFileType ! \ call Tex_Debug('main.vim: Catching LatexSuiteFileType event', 'main') | \ call <SID>SetTeXOptions() augroup END *************** *** 889,892 **** --- 917,921 ---- " }}} + let &cpo = s:save_cpo *************** *** 897,900 **** --- 926,930 ---- exec 'pyfile '.expand('<sfile>:p:h').'/pytools.py' + " vim:fdm=marker:ff=unix:noet:ts=4:sw=4:nowrap |