From 9dff25b7c8f2d39cf413342ea44aa48dcc2348b4 Mon Sep 17 00:00:00 2001 From: Srinath Avadhanula Date: Wed, 16 Jul 2003 16:44:41 +0000 Subject: [PATCH] =?UTF-8?q?Bug:=20If=20g:Tex=5FSmartQuoteOpen/Close=20cont?= =?UTF-8?q?ain=20the=20'~'=20character=20(french=20quotes=20=20=20=20=20?= =?UTF-8?q?=20are=20"=EF=BF=BD~"=20and=20"~=EF=BF=BD",=20then=20we=20get?= =?UTF-8?q?=20an=20error=20in=20quotations=20(Mathieu=20=20=20=20=20=20Cla?= =?UTF-8?q?baut).=20Fix:=20escape=20~=20in=20the=20search()=20function=20(?= =?UTF-8?q?Mathieu=20Clabaut).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change: make Tex_GetMainFile() recursively search upwards for a *.latexmain file. --- ftplugin/latex-suite/main.vim | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/ftplugin/latex-suite/main.vim b/ftplugin/latex-suite/main.vim index e54a150..834c394 100755 --- a/ftplugin/latex-suite/main.vim +++ b/ftplugin/latex-suite/main.vim @@ -227,7 +227,7 @@ if g:Tex_SmartKeyQuote let q = open while 1 " Look for preceding quote (open or close), ignoring " math mode and '\"' . - call search(open . boundary . close . '\|^$\|"', "bw") + call search(escape(open . boundary . close . '\|^$\|"', "~"), "bw") if synIDattr(synID(line("."), col("."), 1), "name") !~ "^texMath" \ && (col(".") == 1 || getline(".")[col(".")-2] != '\') break @@ -400,18 +400,34 @@ function! Tex_GetMainFileName(...) else let modifier = ':p:r:r' endif + let curd = getcwd() - exe 'cd '.expand('%:p:h') + + 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. + " TODO: Should we be doing this recursion by default, or should there be a + " setting? + while glob('*.latexmain') == '' + let dirmodifier = dirmodifier.':h' + " break from the loop if we cannot go up any further. + if expand(dirmodifier) == dirLast + break + endif + let dirLast = expand(dirmodifier) + exec 'cd '.escape(dirLast, ' ') + endwhile + let lheadfile = glob('*.latexmain') - " dirty hack to check in dir one level up. TODO: while with ":h" mod. - if lheadfile == '' - cd .. - let lheadfile = glob('*.latexmain') - endif if lheadfile != '' let lheadfile = fnamemodify(lheadfile, modifier) endif - exe 'cd '.curd + + exe 'cd '.escape(curd, ' ') + return lheadfile endfunction