From 0765f97dd386f46279dd47be745f73940a53e425 Mon Sep 17 00:00:00 2001 From: Martin Grenfell Date: Tue, 23 Oct 2012 22:37:11 +0100 Subject: [PATCH] refactor out some duplication of /dev/null logic --- autoload/syntastic/util.vim | 18 ++++++++++++++++++ syntax_checkers/less.vim | 6 +----- syntax_checkers/rst.vim | 6 +----- syntax_checkers/typescript.vim | 6 +----- 4 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 autoload/syntastic/util.vim diff --git a/autoload/syntastic/util.vim b/autoload/syntastic/util.vim new file mode 100644 index 00000000..854cd63d --- /dev/null +++ b/autoload/syntastic/util.vim @@ -0,0 +1,18 @@ +if exists("g:loaded_syntastic_util_autoload") + finish +endif +let g:loaded_syntastic_util_autoload = 1 + +let s:save_cpo = &cpo +set cpo&vim + +function! syntastic#util#DevNull() + if has('win32') + return 'NUL' + endif + return '/dev/null' +endfunction + +let &cpo = s:save_cpo +unlet s:save_cpo +" vim: set et sts=4 sw=4: diff --git a/syntax_checkers/less.vim b/syntax_checkers/less.vim index 58857a69..c90fd330 100644 --- a/syntax_checkers/less.vim +++ b/syntax_checkers/less.vim @@ -42,12 +42,8 @@ else end function! SyntaxCheckers_less_GetLocList() - let devnull = '/dev/null' - if has('win32') - let devnull = 'NUL' - endif let makeprg = s:check_file . ' ' . g:syntastic_less_options . ' ' . - \ shellescape(expand('%')) . ' ' . devnull + \ shellescape(expand('%')) . ' ' . syntastic#util#DevNull() let errorformat = '%m in %f:%l:%c' return SyntasticMake({ 'makeprg': makeprg, diff --git a/syntax_checkers/rst.vim b/syntax_checkers/rst.vim index cd3a716b..2a89aec4 100644 --- a/syntax_checkers/rst.vim +++ b/syntax_checkers/rst.vim @@ -24,12 +24,8 @@ if !executable("rst2pseudoxml.py") endif function! SyntaxCheckers_rst_GetLocList() - let devnull = '/dev/null' - if has('win32') - let devnull = 'NUL' - endif let makeprg = 'rst2pseudoxml.py --report=2 --exit-status=1 ' . - \ shellescape(expand('%')) . ' ' . devnull + \ shellescape(expand('%')) . ' ' . syntastic#util#DevNull() let errorformat = '%f:%l:\ (%tNFO/1)\ %m, \%f:%l:\ (%tARNING/2)\ %m, diff --git a/syntax_checkers/typescript.vim b/syntax_checkers/typescript.vim index a539d1ee..2a903a9a 100644 --- a/syntax_checkers/typescript.vim +++ b/syntax_checkers/typescript.vim @@ -14,11 +14,7 @@ if !executable("tsc") endif function! SyntaxCheckers_typescript_GetLocList() - let devnull = '/dev/null' - if has('win32') - let devnull = 'NUL' - endif - let makeprg = 'tsc ' . shellescape(expand("%")) . ' --out ' . devnull + let makeprg = 'tsc ' . shellescape(expand("%")) . ' --out ' . syntastic#util#DevNull() let errorformat = '%f (%l\,%c): %m' return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) endfunction