aboutsummaryrefslogtreecommitdiff
path: root/evil-core.el
diff options
context:
space:
mode:
authorjustbur <justin@burkett.cc>2016-04-11 09:18:10 -0400
committerjustbur <justin@burkett.cc>2016-04-11 09:18:10 -0400
commit4f2849cc9989be96f0c51eb73b489fc99d7ebbb7 (patch)
tree2e1238fdc3193a4683a24a0ee5fcc5c2b05c58bf /evil-core.el
parentb4c105f8e08287e78a91c0b18e729e2f5ca44123 (diff)
evil-core.el: Add ignore-parent option to get-auxiliary-keymap
Without this if there is an auxiliary keymap in the parent map it gets used automatically, which may not be what you want. This option allows you to create a keymap in the passed map if it doesn't exist (even if it exists in the parent).
Diffstat (limited to 'evil-core.el')
-rw-r--r--evil-core.el15
1 files changed, 13 insertions, 2 deletions
diff --git a/evil-core.el b/evil-core.el
index 28648a0..9dbdd24 100644
--- a/evil-core.el
+++ b/evil-core.el
@@ -829,14 +829,25 @@ If AUX is nil, create a new auxiliary keymap."
aux)
(put 'evil-set-auxiliary-keymap 'lisp-indent-function 'defun)
-(defun evil-get-auxiliary-keymap (map state &optional create)
+(defun evil-get-auxiliary-keymap (map state &optional create ignore-parent)
"Get the auxiliary keymap for MAP in STATE.
If CREATE is non-nil, create an auxiliary keymap
-if MAP does not have one."
+if MAP does not have one. If CREATE and
+IGNORE-PARENT are non-nil then a new auxiliary
+keymap is created even if the parent of MAP has
+one already."
(when state
(let* ((key (vconcat (list (intern (format "%s-state" state)))))
+ (parent-aux (when (and ignore-parent
+ (keymap-parent map)
+ state)
+ (lookup-key (keymap-parent map) key)))
(aux (if state (lookup-key map key) map)))
(cond
+ ((and ignore-parent
+ (equal parent-aux aux)
+ create)
+ (evil-set-auxiliary-keymap map state))
((evil-auxiliary-keymap-p aux)
aux)
(create