extract common code

This commit is contained in:
gmarik 2011-08-05 23:45:55 -05:00
parent b9226caacb
commit 57474f97a7
2 changed files with 9 additions and 31 deletions

View File

@ -4,7 +4,7 @@ func! vundle#installer#new(bang, ...) abort
\ map(copy(a:000), 'vundle#config#init_bundle(v:val, {})')
let names = map(copy(bundles), 'v:val.name_spec')
call s:display(['" Installing'], names)
call vundle#scripts#view('Installer',['" Installing'], names)
exec ":1"
redraw!
@ -23,24 +23,6 @@ func! vundle#installer#new(bang, ...) abort
echo 'Done! Helptags: '.len(helptags).' bundles processed'
endf
func! s:display(headers, results)
if exists('g:vundle_view')
exec g:vundle_view.'bd!'
endif
let results = map(a:results, ' printf("Bundle ' ."'%s'".'", v:val) ')
silent pedit [Vundle] installer
wincmd P | wincmd H
let g:vundle_view = bufnr('%')
call append(0, a:headers + results)
setl ft=vundle
call vundle#scripts#setup_view()
endf
func! s:sign(status)
if (!has('signs'))
return

View File

@ -1,18 +1,14 @@
func! vundle#scripts#all(bang, ...)
let b:match = ''
let info = ['"Keymap: i - Install bundle; c - Cleanup; r - Refine list; R - Reload list']
if a:1== '' " whether refine search string given
let matches = s:load_scripts(a:bang)
call s:display(info, matches)
else
let matches = s:load_scripts(a:bang)
if !empty(a:1)
let matches = filter(s:load_scripts(a:bang), 'v:val =~? "'.escape(a:1,'"').'"')
call s:display(info + ['"Search results for: '.a:1], matches)
if &hls
" TODO: search doesn't get highlighted for me
let @/=a:1
endif
let info += ['"Search results for: '.a:1]
" TODO: highlight matches
let b:match = a:1
endif
call vundle#scripts#view('search',info, reverse(matches))
redraw!
echo len(matches).' bundles found'
endf
@ -56,13 +52,13 @@ func! s:view_log()
wincmd P | wincmd H
endf
func! s:display(headers, results)
func! vundle#scripts#view(title, headers, results)
if exists('g:vundle_view')
exec g:vundle_view.'bd!'
endif
let results = reverse(map(a:results, ' printf("Bundle ' ."'%s'".'", v:val) '))
silent pedit [Vundle] search
let results = map(a:results, ' printf("Bundle ' ."'%s'".'", v:val) ')
exec 'silent pedit [Vundle] '.a:title
wincmd P | wincmd H