From 04031093dd873153b8af734fae5122bf27dcdb19 Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 3 Nov 2017 22:47:59 +1300 Subject: Check for availability of Vim shellescape() It doesn't seem to be in very old Vims; worth testing for to avoid errors if I try to use the function. --- vim/ftplugin/html.vim | 10 ++++++---- vim/ftplugin/perl.vim | 17 +++++++++++------ 2 files changed, 17 insertions(+), 10 deletions(-) (limited to 'vim/ftplugin') diff --git a/vim/ftplugin/html.vim b/vim/ftplugin/html.vim index 7400326c..5505dbaa 100644 --- a/vim/ftplugin/html.vim +++ b/vim/ftplugin/html.vim @@ -1,8 +1,10 @@ " Run tidy -eq -utf8 on file for the current buffer -function s:HTMLTidy() - execute '!tidy -eq -utf8 ' . shellescape(expand('%')) -endfunction -nnoremap v :exe :call HTMLTidy() +if exists('*shellescape') + function s:HTMLTidy() + execute '!tidy -eq -utf8 ' . shellescape(expand('%')) + endfunction + nnoremap v :exe :call HTMLTidy() +endif " Make a bare URL into a link to itself function! s:UrlLink() diff --git a/vim/ftplugin/perl.vim b/vim/ftplugin/perl.vim index 53341183..c4923051 100644 --- a/vim/ftplugin/perl.vim +++ b/vim/ftplugin/perl.vim @@ -1,6 +1,11 @@ -" Run perl -c on file for the current buffer -nnoremap pc :exe "!perl -c " . shellescape(expand("%")) -" Run perlcritic on the file for the current buffer -nnoremap pl :exe "!perlcritic " . shellescape(expand("%")) -" Run the current buffer through perltidy -nnoremap pt :%!perltidy +" External commands for Perl files +if exists('*shellescape') + + " Run perl -c on file for the current buffer + nnoremap pc :exe "!perl -c " . shellescape(expand("%")) + " Run perlcritic on the file for the current buffer + nnoremap pl :exe "!perlcritic " . shellescape(expand("%")) + " Run the current buffer through perltidy + nnoremap pt :%!perltidy + +endif -- cgit v1.2.3