Tuesday, October 26, 2010

[PATCH] Protect read of g:Perl_PerlTags with exists()

There's an unprotected check of one of the configuration variables. It's only
triggered when you set ft=perl from .vimrc because the plugin hasn't been
loaded yet.

You shouldn't do that. Let the ftplugin system detect your files as Perl
files, or if they have non-standard extensions (something other than .pl/.perl)
set up an autocmd, e.g.:

au BufNewFile,BufRead *.not-perl setf perl

Patch below. BCC:'ed Dr. Fritz Mehner (maintainer)

Pushed to http://github.com/benizi/perl-support.vim

================================================== commit message

Most tests of global variables in conditionals have the form:

if exists("g:variable") && g:variable == 'somevalue'

This one didn't, and caused errors when unitialized.
---
ftplugin/perl.vim | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ftplugin/perl.vim b/ftplugin/perl.vim
index e34accc..82f949d 100644
--- a/ftplugin/perl.vim
+++ b/ftplugin/perl.vim
@@ -411,7 +411,7 @@ endif
" Generate (possibly exuberant) Ctags style tags for Perl sourcecode.
" Controlled by g:Perl_PerlTags, enabled by default.
" ----------------------------------------------------------------------------
-if has('perl') && g:Perl_PerlTags == 'enabled'
+if has('perl') && ( exists("g:Perl_PerlTags") && g:Perl_PerlTags == 'enabled' )
let g:Perl_PerlTagsTempfile = tempname()
if getfsize( expand('%') ) > 0
call Perl_do_tags( expand('%'), g:Perl_PerlTagsTempfile )
--
1.7.3.1

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments:

Post a Comment