Added execution context stack.
authorBob Hiestand <bob.hiestand@gmail.com>
Tue, 27 Sep 2011 14:37:05 +0000 (27 09:37 -0500)
committerBob Hiestand <bob.hiestand@gmail.com>
Thu, 29 Sep 2011 18:22:45 +0000 (29 13:22 -0500)
plugin/vcscommand.vim

index 6e2a1cd..fa1022d 100644 (file)
@@ -360,6 +360,9 @@ let s:plugins = {}
 " temporary values of overridden configuration variables
 let s:optionOverrides = {}
 
+" Stack of dictionaries representing nested options
+let s:executionContext = []
+
 " state flag used to vary behavior of certain automated actions
 let s:isEditFileRunning = 0
 
@@ -403,6 +406,20 @@ function! s:VCSCommandUtility.addMenuItem(shortcut, command)
        endif
 endfunction
 
+" Function: s:VCSCommandUtility.pushContext(context) {{{2
+" Adds a dictionary containing current options to the stack.
+
+function! s:VCSCommandUtility.pushContext(context)
+       call insert(s:executionContext, a:context)
+endfunction
+
+" Function: s:VCSCommandUtility.popContext() {{{2
+" Removes a dictionary containing current options from the stack.
+
+function! s:VCSCommandUtility.popContext()
+       call remove(s:executionContext, 0)
+endfunction
+
 " Function: s:ClearMenu() {{{2
 " Removes all VCSCommand menu items
 function! s:ClearMenu()
@@ -1277,9 +1294,15 @@ endfunction
 " searched in the window, buffer, then global spaces.
 
 function! VCSCommandGetOption(name, default)
+       for context in s:executionContext
+               if has_key(context, a:name)
+                       return context[a:name]
+               endif
+       endfor
        if has_key(s:optionOverrides, a:name) && len(s:optionOverrides[a:name]) > 0
                return s:optionOverrides[a:name][-1]
-       elseif exists('w:' . a:name)
+       endif
+       if exists('w:' . a:name)
                return w:{a:name}
        elseif exists('b:' . a:name)
                return b:{a:name}