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
This commit is contained in:
parent
cad5f50a64
commit
088295df77
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user