From: Bob Hiestand Date: Tue, 27 Sep 2011 14:37:05 +0000 (-0500) Subject: Added execution context stack. X-Git-Tag: v1.99.44~4 X-Git-Url: https://repo.or.cz/w/vcscommand.git/commitdiff_plain/b094465fa7cd916209a82cc25062ac869021d8e4 Added execution context stack. --- diff --git a/plugin/vcscommand.vim b/plugin/vcscommand.vim index 6e2a1cd..fa1022d 100644 --- a/plugin/vcscommand.vim +++ b/plugin/vcscommand.vim @@ -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}