From ef641633b58846f6f3e7a3d8e1893469d0f83834 Mon Sep 17 00:00:00 2001 From: gmarik Date: Fri, 26 Nov 2010 16:28:52 -0600 Subject: [PATCH] Cleanup --- autoload/vundle/scripts.vim | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/autoload/vundle/scripts.vim b/autoload/vundle/scripts.vim index 4d28710..4a3710a 100644 --- a/autoload/vundle/scripts.vim +++ b/autoload/vundle/scripts.vim @@ -1,5 +1,5 @@ func! vundle#scripts#search(bang,search_str) - let matches = filter(eval(vundle#scripts#read(a:bang)), 'v:val =~ "'.escape(a:search_str,'"').'"') + let matches = filter(s:load_scripts(a:bang), 'v:val =~ "'.escape(a:search_str,'"').'"') let results = map(matches, ' printf("Bundle \"%s\"", v:val) ') call s:display(results, a:search_str) endf @@ -16,16 +16,16 @@ func! s:display(results,search_str) redraw endf -func! vundle#scripts#fetch(to) +func! s:fetch_scripts(to) let temp = tempname() exec '!curl http://vim-scripts.org/api/scripts.json > '.temp exec '!mkdir -p $(dirname '.a:to.') && mv -f '.temp.' '.a:to endf -func! vundle#scripts#read(bang) - let scripts_file = expand('$HOME/.vim-vundle/vim-scripts.org.json') - if '!' == a:bang || !filereadable(scripts_file) - call vundle#scripts#fetch(scripts_file) +func! s:load_scripts(bang) + let f = expand('$HOME/.vim-vundle/vim-scripts.org.json') + if '!' == a:bang || !filereadable(f) + call s:fetch_scripts(f) endif - return readfile(scripts_file, 'b')[0] + return eval(readfile(f, 'b')[0]) endf