[Vim-latex-cvs] vimfiles/ftplugin/latex-suite compiler.vim,1.12,1.13
Brought to you by:
srinathava,
tmaas
From: <sri...@us...> - 2002-11-20 11:10:02
|
Update of /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite In directory sc8-pr-cvs1:/tmp/cvs-serv20883 Modified Files: compiler.vim Log Message: Implemented Carl's idea of having the log file also being shown when RunLaTeX() is run. This is what happens presently: When you press \ll, then the quickfix window with one error on each line opens up. Beneath the quickfix window, the log file is opened in a "preview" window. The display within the preview window is adjusted to match with the error currently being examined by the user. When the user moves around within the quickfix window, this display is automatically adjusted to keep in sync. When the user presses <enter> in the quickfix window, then he is taken to the correct line and column number of the .tex file. The column number is computed either from the length of the broken line after l.\d\+ in the log file or if we have a undefined citation, then search for the missing citation word... New functions added: PositionPreviewWindow() : positions the display of the log file UpdatePreviewWindow() : positions the display of the log file and then returns to the quickfix window. GotoErrorLocation() : goes to the correct line and column number of the .tex file being edited. TODO: 1. multiple errors on the same line dont work. the preview window gets stuck on the first error. 2. test more robustly. 3. Ask people about various formats of LaTeX warnings, so we can guess column numbers in other situations too. As of now, only undefined citations and errors are caught well. For all other kinds, we goto the first column of the correct line number. Index: compiler.vim =================================================================== RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/latex-suite/compiler.vim,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** compiler.vim 14 Nov 2002 17:30:45 -0000 1.12 --- compiler.vim 20 Nov 2002 11:09:58 -0000 1.13 *************** *** 2,8 **** " File: compiler.vim " Author: Srinath Avadhanula - " Version: 1.0 " Created: Tue Apr 23 05:00 PM 2002 PST ! " Last Change: Thu Nov 14 09:00 AM 2002 PST " " Description: functions for compiling/viewing/searching latex documents --- 2,7 ---- " File: compiler.vim " Author: Srinath Avadhanula " Created: Tue Apr 23 05:00 PM 2002 PST ! " Last Change: Wed Nov 20 03:00 AM 2002 PST " " Description: functions for compiling/viewing/searching latex documents *************** *** 90,93 **** --- 89,95 ---- exec 'cd '.expand("%:p:h") + " close any preview windows left open. + pclose! + " if a makefile exists, just use the make utility if glob('makefile') != '' || glob('Makefile') != '' *************** *** 112,118 **** let winnum = winnr() cwindow ! " just open the cwindow, do not remain there... ! execute winnum "wincmd w" exec 'cd '.curd --- 114,136 ---- let winnum = winnr() + + " close the quickfix window before trying to open it again, otherwise + " whether or not we end up in the quickfix window after the :cwindow + " command is not fixed. + cclose cwindow ! " if we moved to a different window, then it means we had some errors. ! if winnum != winnr() ! call UpdatePreviewWindow(mainfname) ! exe 'nnoremap <buffer> <silent> j j:call UpdatePreviewWindow("'.mainfname.'")<CR>' ! exe 'nnoremap <buffer> <silent> k k:call UpdatePreviewWindow("'.mainfname.'")<CR>' ! exe 'nnoremap <buffer> <silent> <up> <up>:call UpdatePreviewWindow("'.mainfname.'")<CR>' ! exe 'nnoremap <buffer> <silent> <down> <down>:call UpdatePreviewWindow("'.mainfname.'")<CR>' ! exe 'nnoremap <buffer> <silent> <enter> :call GotoErrorLocation("'.mainfname.'", '.winnum.')<CR>' ! ! " resize the window to just fit in with the number of lines. ! exec ( line('$') < 4 ? line('$') : 4 ).' wincmd _' ! call GotoErrorLocation(mainfname, winnum) ! endif exec 'cd '.curd *************** *** 217,220 **** --- 235,310 ---- " }}} + " PositionPreviewWindow: positions the preview window correctly. {{{ + " Description: + function! PositionPreviewWindow(filename) + if getline('.') !~ '|\d\+ \(error\|warning\)|' + if !search('|\d\+ \(error\|warning\)|') + pclose! + return + endif + endif + let linenum = matchstr(getline('.'), '|\zs\d\+\ze \(error\|warning\)|') + if getline('.') =~ '|\d\+ warning|' + let searchpat = escape(matchstr(getline('.'), '|\d\+ warning|\s*\zs.*'), '\ ') + else + let searchpat = 'l.'.linenum + endif + exec 'bot pedit +/'.searchpat.'/ '.a:filename.'.log' + " TODO: This is not robust enough. Check that a wincmd j actually takes + " us to the preview window. Moreover, the resizing should be done only the + " first time around. + wincmd j + endfunction " }}} + " UpdatePreviewWindow: updates the view of the log file {{{ + " Description: + " This function should be called when focus is in a quickfix window. + " It opens the log file in a preview window and makes it display that + " part of the log file which corresponds to the error which the user is + " currently on in the quickfix window. Control returns to the quickfix + " window when the function returns. + " + function! UpdatePreviewWindow(filename) + call PositionPreviewWindow(a:filename) + 6 wincmd _ + wincmd k + endfunction " }}} + " GotoErrorLocation: goes to the correct location of error in the tex file {{{ + " Description: + " This function should be called when focus is in a quickfix window. This + " function will first open the preview window of the log file (if it is not + " already open), position the display of the preview to coincide with the + " current error under the cursor and then take the user to the file in + " which this error has occured. + " + " 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, winnum) + + let linenum = matchstr(getline('.'), '|\zs\d\+\ze \(warning\|error\)|') + call PositionPreviewWindow(a:filename) + + if getline('.') =~ 'l.\d\+' + + let brokenline = matchstr(getline('.'), 'l.'.linenum.' \zs.*\ze') + let column = strlen(brokenline) + let normcmd = column.'|' + + elseif getline('.') =~ 'LaTeX Warning: Citation `.*' + + let ref = matchstr(getline('.'), "LaTeX Warning: Citation `\\zs[^']\\+\\ze'") + let normcmd = '0/'.ref."\<CR>" + + else + + let normcmd = '0' + + endif + + exec a:winnum.' wincmd w' + exec 'silent! '.linenum.' | normal! '.normcmd + + endfunction " }}} " vim:fdm=marker:ts=4:sw=4 |