Problem with parent keymap
Albert Krewinkel
tarleb+evil at moltkeplatz.de
Mon Sep 8 21:56:48 CEST 2014
Hi,
I just encountered some unexpected behavior when defining key bindings
for maps which have parent maps: When I define a key for some state for
the parent map as well as the child map, the child map overrides the
bindings for the parent map.
Here is what I mean:
(defun alok-foo () (interactive) (message "foo"))
(defun alok-bar () (interactive) (message "bar"))
(defvar alok-mode-map (make-sparse-keymap))
(defvar alok-child-mode-map
(let ((map (make-sparse-keymap)))
(set-keymap-parent map alok-mode-map)
(define-key map (kbd "M-<return>") 'alok-bar)
map))
(define-derived-mode alok-mode prog-mode "ALOK"
"Major ALOK mode")
(define-derived-mode alok-child-mode alok-mode "calok"
"ALOK derived mode")
(evil-set-initial-state 'alok-mode 'motion)
(evil-set-initial-state 'alok-child-mode 'motion)
(evil-define-key 'motion alok-mode-map
(kbd "f") 'alok-foo)
(evil-define-key 'motion alok-child-mode-map
(kbd "f") 'alok-bar)
When I enter into alok-mode and press `f`, I would ecpect to see "foo"
in the message area, but instead I get "bar".
I tried to find the reason for this myself, but I got stuck quickly.
Is there a way to work around this?
Thanks in advance!
Albert
--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124
More information about the implementations-list
mailing list