Merge pull request #106 from salviati6/issue105

Fix for issue #105
This commit is contained in:
Karl Yngve Lervåg 2015-01-30 10:03:28 +01:00
commit d9f58a8b20
3 changed files with 26 additions and 14 deletions

View File

@ -110,7 +110,7 @@ function! latex#latexmk#clean(full) " {{{1
" Run latexmk clean process " Run latexmk clean process
" "
if has('win32') if has('win32')
let cmd = 'cd /D ' . shellescape(data.root) . ' & ' let cmd = 'cd /D "' . data.root . '" & '
else else
let cmd = 'cd ' . shellescape(data.root) . '; ' let cmd = 'cd ' . shellescape(data.root) . '; '
endif endif
@ -120,7 +120,7 @@ function! latex#latexmk#clean(full) " {{{1
else else
let cmd .= ' -c ' let cmd .= ' -c '
endif endif
let cmd .= shellescape(data.base) let cmd .= latex#util#fnameescape(data.base)
let g:latex#data[b:latex.id].cmds.clean = cmd let g:latex#data[b:latex.id].cmds.clean = cmd
let exe = { let exe = {
\ 'cmd' : cmd, \ 'cmd' : cmd,
@ -331,7 +331,7 @@ function! s:latexmk_build_cmd(data) " {{{1
let tmp = tempname() let tmp = tempname()
if has('win32') if has('win32')
let cmd = 'cd /D ' . shellescape(a:data.root) let cmd = 'cd /D "' . a:data.root . '"'
let cmd .= ' && set max_print_line=2000 & latexmk' let cmd .= ' && set max_print_line=2000 & latexmk'
else else
let cmd = 'cd ' . shellescape(a:data.root) let cmd = 'cd ' . shellescape(a:data.root)
@ -363,7 +363,7 @@ function! s:latexmk_build_cmd(data) " {{{1
let s:first_callback = 1 let s:first_callback = 1
endif endif
let cmd .= ' ' . shellescape(a:data.base) let cmd .= ' ' . latex#util#fnameescape(a:data.base)
if g:latex_latexmk_continuous || g:latex_latexmk_background if g:latex_latexmk_continuous || g:latex_latexmk_background
if has('win32') if has('win32')

View File

@ -85,7 +85,7 @@ let s:convert_back_list = map([
function! latex#util#error_deprecated(variable) " {{{1 function! latex#util#error_deprecated(variable) " {{{1
if exists(a:variable) if exists(a:variable)
echoerr "Deprecation error: " . a:variable echoerr "Deprecation error: " . a:variable
echoerr "Please red docs for more info!" echoerr "Please read docs for more info!"
echoerr ":h vim-latex-changelog" echoerr ":h vim-latex-changelog"
endif endif
endfunction endfunction
@ -170,7 +170,19 @@ function! latex#util#execute(exe) " {{{1
redraw! redraw!
endif endif
endfunction endfunction
" }}}1
function! latex#util#fnameescape(path) " {{{1
"
" In a Windows environment, a path used in "cmd" only needs to be
" enclosed by double quotes. shellscape() on Windows with
" "shellslash" set will produce a path enclosed by single quotes,
" which "cmd" does not recognize and reports an error.
" Any path that goes into latex#util#execute() should be
" processed through this function.
"
return has('win32') ? '"' . a:path . '"' : shellescape(a:path)
endfunction
function! latex#util#get_env(...) " {{{1 function! latex#util#get_env(...) " {{{1
" latex#util#get_env([with_pos]) " latex#util#get_env([with_pos])
" Returns: " Returns:

View File

@ -77,7 +77,7 @@ function! latex#view#general() " {{{1
return return
endif endif
let exe.cmd .= ' ' . g:latex_view_general_options let exe.cmd .= ' ' . g:latex_view_general_options
let exe.cmd .= ' ' . shellescape(outfile) let exe.cmd .= ' ' . latex#util#fnameescape(outfile)
call latex#util#execute(exe) call latex#util#execute(exe)
let g:latex#data[b:latex.id].cmds.view = exe.cmd let g:latex#data[b:latex.id].cmds.view = exe.cmd
@ -185,9 +185,9 @@ function! latex#view#sumatrapdf() "{{{1
let exe = {} let exe = {}
let exe.cmd = 'SumatraPDF ' . g:latex_view_sumatrapdf_options let exe.cmd = 'SumatraPDF ' . g:latex_view_sumatrapdf_options
let exe.cmd .= ' -forward-search ' . shellescape(expand('%:p')) let exe.cmd .= ' -forward-search ' . latex#util#fnameescape(expand('%:p'))
let exe.cmd .= ' ' . line('.') let exe.cmd .= ' ' . line('.')
let exe.cmd .= ' ' . shellescape(outfile) let exe.cmd .= ' ' . latex#util#fnameescape(outfile)
call latex#util#execute(exe) call latex#util#execute(exe)
let g:latex#data[b:latex.id].cmds.view = exe.cmd let g:latex#data[b:latex.id].cmds.view = exe.cmd
@ -203,8 +203,8 @@ function! latex#view#okular() "{{{1
let exe = {} let exe = {}
let exe.cmd = 'okular ' . g:latex_view_okular_options let exe.cmd = 'okular ' . g:latex_view_okular_options
let exe.cmd .= ' --unique ' . shellescape(outfile) let exe.cmd .= ' --unique ' . latex#util#fnameescape(outfile)
let exe.cmd .= '\#src:' . line('.') . shellescape(expand('%:p')) let exe.cmd .= '\#src:' . line('.') . latex#util#fnameescape(expand('%:p'))
call latex#util#execute(exe) call latex#util#execute(exe)
let g:latex#data[b:latex.id].cmds.view = exe.cmd let g:latex#data[b:latex.id].cmds.view = exe.cmd
@ -270,8 +270,8 @@ function! s:mupdf_forward_search() "{{{1
let l:cmd = "synctex view -i " let l:cmd = "synctex view -i "
\ . (line(".") + 1) . ":" \ . (line(".") + 1) . ":"
\ . (col(".") + 1) . ":" \ . (col(".") + 1) . ":"
\ . shellescape(expand("%:p")) \ . latex#util#fnameescape(expand("%:p"))
\ . " -o " . shellescape(outfile) \ . " -o " . latex#util#fnameescape(outfile)
\ . " | grep -m1 'Page:' | sed 's/Page://' | tr -d '\n'" \ . " | grep -m1 'Page:' | sed 's/Page://' | tr -d '\n'"
let l:page = system(l:cmd) let l:page = system(l:cmd)
let g:latex#data[b:latex.id].cmds.view_mupdf_synctex = l:cmd let g:latex#data[b:latex.id].cmds.view_mupdf_synctex = l:cmd
@ -298,7 +298,7 @@ function! s:mupdf_start() "{{{1
" Start MuPDF " Start MuPDF
let exe = {} let exe = {}
let exe.cmd = 'mupdf ' . g:latex_view_mupdf_options let exe.cmd = 'mupdf ' . g:latex_view_mupdf_options
let exe.cmd .= ' ' . shellescape(outfile) let exe.cmd .= ' ' . latex#util#fnameescape(outfile)
call latex#util#execute(exe) call latex#util#execute(exe)
let g:latex#data[b:latex.id].cmds.view = exe.cmd let g:latex#data[b:latex.id].cmds.view = exe.cmd