From 9543d6387e644ff393664939e997f6cfd694d98b Mon Sep 17 00:00:00 2001 From: Lucas Hoffmann Date: Tue, 3 Mar 2015 10:50:28 +0100 Subject: [PATCH] Refactor global variables into script local variables. These variables only occur in one file each. By making them script local variables this is "documented" in the code. At the same time the global namespace is polluted less. Changed: g:bundle_names -> s:bundle_names g:vundle_last_status -> s:last_status g:vundle_log_file -> s:log_file g:vundle_view -> s:view --- autoload/vundle/config.vim | 8 ++++---- autoload/vundle/installer.vim | 6 +++--- autoload/vundle/scripts.vim | 14 +++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/autoload/vundle/config.vim b/autoload/vundle/config.vim index 5ecb30b..a17eeb1 100644 --- a/autoload/vundle/config.vim +++ b/autoload/vundle/config.vim @@ -43,7 +43,7 @@ func! vundle#config#init() if !exists('g:bundles') | let g:bundles = [] | endif call s:rtp_rm_a() let g:bundles = [] - let g:bundle_names = {} + let s:bundle_names = {} endf @@ -91,14 +91,14 @@ endf " return -- 0 if the bundle's name has been seen before, 1 otherwise " --------------------------------------------------------------------------- funct! s:check_bundle_name(bundle) - if has_key(g:bundle_names, a:bundle.name) + if has_key(s:bundle_names, a:bundle.name) echoerr 'Vundle error: Name collision for Plugin ' . a:bundle.name_spec . - \ '. Plugin ' . g:bundle_names[a:bundle.name] . + \ '. Plugin ' . s:bundle_names[a:bundle.name] . \ ' previously used the name "' . a:bundle.name . '"' . \ '. Skipping Plugin ' . a:bundle.name_spec . '.' return 0 endif - let g:bundle_names[a:bundle.name] = a:bundle.name_spec + let s:bundle_names[a:bundle.name] = a:bundle.name_spec return 1 endf diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index 05f3a16..ee635c9 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -55,11 +55,11 @@ func! s:process(bang, cmd) exec ':norm '.a:cmd - if 'error' == g:vundle_last_status + if 'error' == s:last_status let msg = 'With errors; press l to view log' endif - if 'updated' == g:vundle_last_status && empty(msg) + if 'updated' == s:last_status && empty(msg) let msg = 'Plugins updated; press u to view changelog' endif @@ -118,7 +118,7 @@ func! vundle#installer#run(func_name, name, ...) abort throw 'whoops, unknown status:'.status endif - let g:vundle_last_status = status + let s:last_status = status return status endf diff --git a/autoload/vundle/scripts.vim b/autoload/vundle/scripts.vim index a08f6dc..b5635bb 100644 --- a/autoload/vundle/scripts.vim +++ b/autoload/vundle/scripts.vim @@ -54,12 +54,12 @@ endf " View the logfile after an update or installation. " --------------------------------------------------------------------------- func! s:view_log() - if !exists('g:vundle_log_file') - let g:vundle_log_file = tempname() + if !exists('s:log_file') + let s:log_file = tempname() endif - call writefile(g:vundle_log, g:vundle_log_file) - execute 'silent pedit ' . g:vundle_log_file + call writefile(g:vundle_log, s:log_file) + execute 'silent pedit ' . s:log_file wincmd P | wincmd H endf @@ -139,15 +139,15 @@ endf " strings) " --------------------------------------------------------------------------- func! vundle#scripts#view(title, headers, results) - if exists('g:vundle_view') && bufloaded(g:vundle_view) - exec g:vundle_view.'bd!' + if exists('s:view') && bufloaded(s:view) + exec s:view.'bd!' endif exec 'silent pedit [Vundle] '.a:title wincmd P | wincmd H - let g:vundle_view = bufnr('%') + let s:view = bufnr('%') " " make buffer modifiable " to append without errors