Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Bug fix and improvement for xolox#misc#option#get()

  • Loading branch information...
commit 0b1c06ef1d296590b23bbe4da46faeef6541a8ba 1 parent e228b0e
Peter Odding authored June 27, 2011

Showing 1 changed file with 10 additions and 7 deletions. Show diff stats Hide diff stats

  1. 17  option.vim
17  option.vim
... ...
@@ -1,15 +1,18 @@
1 1
 " Vim auto-load script
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: June 26, 2011
  3
+" Last Change: June 27, 2011
4 4
 " URL: http://peterodding.com/code/vim/misc/
5 5
 
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.
10 9
     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
13 16
   endif
14 17
 endfunction
15 18
 

0 notes on commit 0b1c06e

Please sign in to comment.
Something went wrong with that request. Please try again.