From 0b1c06ef1d296590b23bbe4da46faeef6541a8ba Mon Sep 17 00:00:00 2001 From: Peter Odding Date: Mon, 27 Jun 2011 02:45:14 +0200 Subject: Bug fix and improvement for xolox#misc#option#get() --- option.vim | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/option.vim b/option.vim index 8c6d63d..8727ea1 100644 --- a/option.vim +++ b/option.vim @@ -1,15 +1,18 @@ " Vim auto-load script " Author: Peter Odding -" Last Change: June 26, 2011 +" Last Change: June 27, 2011 " URL: http://peterodding.com/code/vim/misc/ -function! xolox#misc#option#get(name, default) - if exists('g:' . a:name) - return eval('g:' . a:name) - elseif exists('b:' . a:name) +function! xolox#misc#option#get(name, ...) + if exists('b:' . a:name) + " Buffer local variable. return eval('b:' . a:name) - else - return a:default + elseif exists('g:' . a:name) + " Global variable. + return eval('g:' . a:name) + elseif exists('a:1') + " Default value. + return a:1 endif endfunction -- cgit v1.2.3