Skip to content

Commit 0b1c06e

Browse files
committed
Bug fix and improvement for xolox#misc#option#get()
1 parent e228b0e commit 0b1c06e

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

option.vim

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
" Vim auto-load script
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: June 26, 2011
3+
" Last Change: June 27, 2011
44
" URL: http://peterodding.com/code/vim/misc/
55

6-
function! xolox#misc#option#get(name, default)
7-
if exists('g:' . a:name)
8-
return eval('g:' . a:name)
9-
elseif exists('b:' . a:name)
6+
function! xolox#misc#option#get(name, ...)
7+
if exists('b:' . a:name)
8+
" Buffer local variable.
109
return eval('b:' . a:name)
11-
else
12-
return a:default
10+
elseif exists('g:' . a:name)
11+
" Global variable.
12+
return eval('g:' . a:name)
13+
elseif exists('a:1')
14+
" Default value.
15+
return a:1
1316
endif
1417
endfunction
1518

0 commit comments

Comments
 (0)