Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Commit

Permalink
add SyntasticMake() to wrap up the :lmake procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Grenfell committed Jul 15, 2009
1 parent 0d73093 commit 0e98aa3
Showing 1 changed file with 41 additions and 16 deletions.
57 changes: 41 additions & 16 deletions plugin/syntastic.vim
Expand Up @@ -140,23 +140,7 @@ function! s:CacheErrors()

for ft in split(&ft, '\.')
if exists("*SyntaxCheckers_". ft ."_GetLocList") && filereadable(expand("%"))
let oldloclist = getloclist(0)
let old_makeprg = &makeprg
let old_shellpipe = &shellpipe
let old_errorformat = &errorformat

if !s:running_windows
"this is a hack to stop the screen needing to be ':redraw'n when
"when :lmake is run. Otherwise the screen flickers annoyingly
let &shellpipe='&>'
endif

let b:syntastic_loclist = extend(b:syntastic_loclist, SyntaxCheckers_{ft}_GetLocList())

call setloclist(0, oldloclist)
let &makeprg = old_makeprg
let &errorformat = old_errorformat
let &shellpipe=old_shellpipe
endif
endfor
endfunction
Expand Down Expand Up @@ -245,4 +229,45 @@ function! SyntasticStatuslineFlag()
endif
endfunction

"A wrapper for the :lmake command. Sets up the make environment according to
"the options given, runs make, resets the environment, returns the location
"list
"
"a:options can contain the following keys:
" 'makeprg'
" 'errorformat'
"
"The corresponding options are set for the duration of the function call. They
"are set with :let, so dont escape spaces.
function! SyntasticMake(options)
let oldloclist = getloclist(0)
let old_makeprg = &makeprg
let old_shellpipe = &shellpipe
let old_errorformat = &errorformat

if !s:running_windows
"this is a hack to stop the screen needing to be ':redraw'n when
"when :lmake is run. Otherwise the screen flickers annoyingly
let &shellpipe='&>'
endif

if has_key(a:options, 'makeprg')
let &makeprg = a:options['makeprg']
endif

if has_key(a:options, 'errorformat')
let &errorformat = a:options['errorformat']
endif

silent lmake!
let errors = getloclist(0)

call setloclist(0, oldloclist)
let &makeprg = old_makeprg
let &errorformat = old_errorformat
let &shellpipe=old_shellpipe

return errors
endfunction

" vim: set et sts=4 sw=4:

0 comments on commit 0e98aa3

Please sign in to comment.