Update of /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite
In directory sc8-pr-cvs1:/tmp/cvs-serv22512
Modified Files:
compiler.vim wizardfuncs.vim
Log Message:
Bug: compiling parts of a document did not open up the preview of the .log
file.
Cause: mainfname was not defined in part compilation
A lot of restructuring in compiler.vim and wizardfuncs.vim. See the
accompanying e-mail to vim-latex-devel. Will also note this in Changelog.
Index: compiler.vim
===================================================================
RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/compiler.vim,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** compiler.vim 5 Jun 2003 18:16:28 -0000 1.37
--- compiler.vim 8 Jun 2003 22:14:55 -0000 1.38
***************
*** 96,99 ****
--- 96,101 ----
" RunLaTeX() is called.
function! RunLaTeX()
+
+ call Tex_Debug('getting to RunLaTeX, b:fragmentFile = '.exists('b:fragmentFile'))
if &ft != 'tex'
echo "calling RunLaTeX from a non-tex file"
***************
*** 108,155 ****
" Logic to choose how to compile:
! " if g:partcomp is set
! " do partial compilation
! " else if there is a makefile and no .latexmain
! " do make
! " else
! " call the latex compiler on
! " the current file if there is not .latexmain
! " .latexmain if there is one
! "
! " if partial compilation is wanted
! if exists("g:partcomp")
! " Change directory to location of temporary file. In this way output
! " files will be in temporary directory (no garbage in real current
! " directory). System will take care about space.
! let curdir = getcwd()
! let pcomdir = fnamemodify(g:tfile, ":p:h")
! exe 'lcd '.pcomdir
! exec 'make '.g:tfile
! exe 'lcd '.curdir
! redraw!
! else
! let mainfname = Tex_GetMainFileName()
! " if a makefile and no *.latexmain exists, just use the make utility
! " this also sets mainfname for the rest of the function
! if (glob('makefile') != '' || glob('Makefile') != '')
! let mainfname = expand("%:t:r")
! let _makeprg = &l:makeprg
! let &l:makeprg = 'make $*'
! if exists('s:target')
! exec 'make '.s:target
! else
! exec 'make'
! endif
! let &l:makeprg = _makeprg
! else
! " otherwise, if a *.latexmain file is found, then use that file to
! " construct a main file.
! if mainfname == ''
! let mainfname = expand("%:t")
! endif
! exec 'make '.mainfname
! endif
! redraw!
! endif
let winnum = winnr()
--- 110,143 ----
" Logic to choose how to compile:
! " if b:fragmentFile exists, then this is a fragment
! " therefore, just compile this file
! " else
! " if makefile or Makefile exists, then use that
! " elseif *.latexmain exists
! " use that
! " else use current file
! "
! " if mainfname exists, then it means it was supplied to RunLaTeX().
! let mainfname = Tex_GetMainFileName()
! if exists('b:fragmentFile') || mainfname == ''
! let mainfname = expand('%:t')
! endif
!
! " if a makefile exists, then use that irrespective of whether *.latexmain
! " exists or not. mainfname is still extracted from *.latexmain (if
! " possible) log file name depends on the main file which will be compiled.
! if glob('makefile') != '' || glob('Makefile') != ''
! let _makeprg = &l:makeprg
! let &l:makeprg = 'make $*'
! if exists('s:target')
! exec 'make '.s:target
! else
! exec 'make'
! endif
! let &l:makeprg = _makeprg
! else
! exec 'make '.mainfname
! endif
! redraw!
let winnum = winnr()
***************
*** 160,167 ****
cclose
cwindow
! " remove extension from mainfname
! let mfnlog = fnamemodify(mainfname, ":r")
" if we moved to a different window, then it means we had some errors.
! if winnum != winnr() && glob(mfnlog.'.log') != ''
call UpdatePreviewWindow(mfnlog)
exe 'nnoremap <buffer> <silent> j j:call UpdatePreviewWindow("'.mfnlog.'")<CR>'
--- 148,156 ----
cclose
cwindow
! " create log file name from mainfname
! let mfnlog = fnamemodify(mainfname, ":t:r").'.log'
! call Tex_Debug('mfnlog = '.mfnlog, 'comp')
" if we moved to a different window, then it means we had some errors.
! if winnum != winnr()
call UpdatePreviewWindow(mfnlog)
exe 'nnoremap <buffer> <silent> j j:call UpdatePreviewWindow("'.mfnlog.'")<CR>'
***************
*** 189,193 ****
" in g:tfile variable. If g:tfile doesnt exist, no problem. Function is called
" as silent.
! function! ViewLaTeX(size)
if &ft != 'tex'
echo "calling ViewLaTeX from a non-tex file"
--- 178,182 ----
" in g:tfile variable. If g:tfile doesnt exist, no problem. Function is called
" as silent.
! function! ViewLaTeX()
if &ft != 'tex'
echo "calling ViewLaTeX from a non-tex file"
***************
*** 199,203 ****
exec 'cd '.expand("%:p:h")
! if Tex_GetMainFileName() != ''
let mainfname = Tex_GetMainFileName()
else
--- 188,195 ----
exec 'cd '.expand("%:p:h")
! " If b:fragmentFile is set, it means this file was compiled as a fragment
! " using Tex_PartCompile, which means that we want to ignore any
! " *.latexmain or makefile's.
! if Tex_GetMainFileName() != '' && !exists('b:fragmentFile')
let mainfname = Tex_GetMainFileName()
else
***************
*** 209,226 ****
" editor from the command line. that would have really helped ensure
" that this particular vim and yap are connected.
! if a:size == "all"
! exec '!start' s:viewer mainfname . '.' . s:target
! else
! exec '!start' s:viewer g:tfile . '.' . s:target
! endif
elseif has('macunix')
if strlen(s:viewer)
let s:viewer = '-a ' . s:viewer
endif
! if a:size == "all"
! execute '!open' s:viewer mainfname . '.' . s:target
! else
! execute '!open' s:viewer g:tfile . '.' . s:target
! endif
else
" taken from Dimitri Antoniou's tip on vim.sf.net (tip #225).
--- 201,210 ----
" editor from the command line. that would have really helped ensure
" that this particular vim and yap are connected.
! exec '!start' s:viewer mainfname . '.' . s:target
elseif has('macunix')
if strlen(s:viewer)
let s:viewer = '-a ' . s:viewer
endif
! execute '!open' s:viewer mainfname . '.' . s:target
else
" taken from Dimitri Antoniou's tip on vim.sf.net (tip #225).
***************
*** 240,256 ****
exec '!kdvi --unique '.mainfname.'.dvi &'
else
! if a:size == "all"
! exec '!'.s:viewer.' '.mainfname.'.dvi &'
! else
! exec '!'.s:viewer.' '.g:tfile.'.dvi &'
! endif
endif
redraw!
else
! if a:size == "all"
! exec '!'.s:viewer.' '.mainfname.'.'.s:target.' &'
! else
! exec '!'.s:viewer.' '.g:tfile.'.'.s:target.' &'
! endif
redraw!
endif
--- 224,232 ----
exec '!kdvi --unique '.mainfname.'.dvi &'
else
! exec '!'.s:viewer.' '.mainfname.'.dvi &'
endif
redraw!
else
! exec '!'.s:viewer.' '.mainfname.'.'.s:target.' &'
redraw!
endif
***************
*** 318,321 ****
--- 294,336 ----
" }}}
+ " Tex_PartCompile: compiles selected fragment {{{
+ " Description: creates a temporary file from the selected fragment of text
+ " prepending the preamble and \end{document} and then asks RunLaTeX() to
+ " compile it.
+ function! Tex_PartCompile() range
+
+ call Tex_Debug('getting to Tex_PartCompile', 'comp')
+ " Save position
+ let pos = line('.').' | normal! '.virtcol('.').'|'
+
+ " Create temporary file and save its name into global variable to use in
+ " compiler.vim
+ let tmpfile = tempname().'.tex'
+
+ " If mainfile exists open it in tiny window and extract preamble there,
+ " otherwise do it from current file
+ let mainfile = Tex_GetMainFileName(":p:r")
+ if mainfile != ''
+ exe 'bot 1 split '.mainfile
+ exe '1,/\s*\\begin{document}/w '.tmpfile
+ wincmd q
+ else
+ exe '1,/\s*\\begin{document}/w '.tmpfile
+ endif
+
+ exe a:firstline.','.a:lastline."w! >> ".tmpfile
+
+ " edit the temporary file
+ exec 'drop '.tmpfile
+
+ " append the \end{document} line.
+ $ put ='\end{document}'
+ w
+
+ " set this as a fragment file.
+ let b:fragmentFile = 1
+
+ silent! call RunLaTeX()
+ endfunction " }}}
" ==============================================================================
***************
*** 396,402 ****
" land us on the error in a.tex.
if errfile != ''
! exec 'bot pedit +/(\(\f\|\[\|\]\)*'.errfile.'/ '.a:filename.'.log'
else
! exec 'bot pedit +0 '.a:filename.'.log'
endif
" Goto the preview window
--- 411,417 ----
" land us on the error in a.tex.
if errfile != ''
! exec 'bot pedit +/(\(\f\|\[\|\]\)*'.errfile.'/ '.a:filename
else
! exec 'bot pedit +0 '.a:filename
endif
" Goto the preview window
***************
*** 438,444 ****
"
" The position is both the correct line number and the column number.
- "
- " TODO: When there are multiple errors on the same line, this only takes you
- " to the very first error every time.
function! GotoErrorLocation(filename)
--- 453,456 ----
***************
*** 447,450 ****
--- 459,468 ----
" without applying any logic.
exec "normal! \<enter>"
+ " If the log file is not found, then going to the correct line number is
+ " all we can do.
+ if glob(a:filename) == ''
+ return
+ endif
+
let winnum = winnr()
" then come back to the quickfix window
***************
*** 499,520 ****
if has("gui")
nnoremap <buffer> <Leader>ll :silent! call RunLaTeX()<cr>
! vnoremap <buffer> <Leader>lc :call Tex_PartCompilation("f","l","v")<cr>
! nnoremap <buffer> <Leader>lv :silent! call ViewLaTeX("all")<cr>
! nnoremap <buffer> <Leader>lp :silent! call ViewLaTeX("part")<cr>
nnoremap <buffer> <Leader>ls :silent! call ForwardSearchLaTeX()<cr>
else
nnoremap <buffer> <Leader>ll :call RunLaTeX()<cr>
! vnoremap <buffer> <Leader>lc :call Tex_PartCompilation("f","l","v")<cr>
! nnoremap <buffer> <Leader>lv :call ViewLaTeX("all")<cr>
! nnoremap <buffer> <Leader>lp :call ViewLaTeX("part")<cr>
nnoremap <buffer> <Leader>ls :call ForwardSearchLaTeX()<cr>
end
end
endfunction
" }}}
augroup LatexSuite
! au LatexSuite User LatexSuiteFileType call <SID>SetCompilerMaps()
augroup END
" vim:fdm=marker:ff=unix:noet:ts=4:sw=4
--- 517,546 ----
if has("gui")
nnoremap <buffer> <Leader>ll :silent! call RunLaTeX()<cr>
! vnoremap <buffer> <Leader>ll :call Tex_PartCompile()<cr>
! nnoremap <buffer> <Leader>lv :silent! call ViewLaTeX()<cr>
nnoremap <buffer> <Leader>ls :silent! call ForwardSearchLaTeX()<cr>
else
nnoremap <buffer> <Leader>ll :call RunLaTeX()<cr>
! vnoremap <buffer> <Leader>ll :call Tex_PartCompile()<cr>
! nnoremap <buffer> <Leader>lv :call ViewLaTeX()<cr>
nnoremap <buffer> <Leader>ls :call ForwardSearchLaTeX()<cr>
end
end
+ vnoremap <buffer> <silent> <Plug>Tex_PartCompile :call Tex_PartCompile()<CR>
+ if !hasmapto('<Plug>Tex_PartCompilation',"v")
+ vmap <buffer> <silent> <F10> <Plug>Tex_PartCompile
+ endif
+ endif
+
endfunction
" }}}
augroup LatexSuite
! au LatexSuite User LatexSuiteFileType
! \ call Tex_Debug('compiler.vim: Catching LatexSuiteFileType event') |
! \ call <SID>SetCompilerMaps()
augroup END
+
+ command! -nargs=0 -range=% TPartCompile :<line1>, <line2> silent! call Tex_PartCompile()
" vim:fdm=marker:ff=unix:noet:ts=4:sw=4
Index: wizardfuncs.vim
===================================================================
RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/wizardfuncs.vim,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** wizardfuncs.vim 31 May 2003 17:51:15 -0000 1.16
--- wizardfuncs.vim 8 Jun 2003 22:14:55 -0000 1.17
***************
*** 235,298 ****
" ==============================================================================
- " Partial compilation and viewing output
- " ==============================================================================
- "
- noremap <buffer> <silent> <Plug>Tex_PartCompilation :call Tex_PartCompilation("f","l","v")<CR>
-
- if !hasmapto('<Plug>Tex_PartCompilation',"v")
- vmap <buffer> <silent> <F10> <Plug>Tex_PartCompilation
- endif
-
- command! -nargs=0 -range TPartComp silent! call Tex_PartCompilation(<line1>,<line2>, "c")
- command! -nargs=0 TPartView silent! call ViewLaTeX("part")
-
- " Tex_PartCompilation: compilation of selected fragment {{{
- function! Tex_PartCompilation(fline,lline,mode) range
-
- " Set partial compilation flag
- let g:partcomp = 1
- " Save position
- let pos = line('.').' | normal! '.virtcol('.').'|'
-
- " Create temporary file and save its name into global variable to use in
- " compiler.vim
- let tmpfile = tempname()
- let g:tfile = tmpfile
- let tmpfile = tmpfile.'.tex'
-
- "Create temporary file
- " If mainfile exists open it in tiny window and extract preamble there,
- " otherwise do it from current file
- let mainfile = Tex_GetMainFileName(":p:r")
- if mainfile != ''
- exe 'bot 1 split '.mainfile
- exe '1,/\s*\\begin{document}/w '.tmpfile
- wincmd q
- else
- exe '1,/\s*\\begin{document}/w '.tmpfile
- endif
- " Write range to file, check how it works with marks, range and //,//
- if a:mode == 'v'
- exe a:firstline.','.a:lastline."w! >> ".tmpfile
- else
- exe a:fline.','.a:lline."w! >> ".tmpfile
- endif
- " Add \end{document} to temporary file. Is it really the only way?
- let _clipboard = @c
- let @c = '\end{document}'
- exe 'redir >> '.tmpfile
- echo @c
- redir END
- let @c = _clipboard
-
- silent! call RunLaTeX()
-
- " Unlet partial compilation flag for not interfering with normal
- " compilation. Maybe argument for RunLaTeX() is better?
- unlet g:partcomp
-
- endfunction " }}}
-
- " ==============================================================================
" Tables of shortcuts
" ==============================================================================
--- 235,238 ----
|