Problem with parent keymap

Frank Fischer frank-fischer at shadow-soft.de
Sun Sep 14 10:47:07 CEST 2014


Am 08.09.2014 um 21:56 schrieb Albert Krewinkel:
> 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.

The reason is that the auxiliary keymaps defined by `evil-define-key`
are implemented using special key bindings in the keymaps. And these
maps are accessed using `lookup-key`. Therefore, if a parent keymap has
an auxiliary keymap, then searching for the auxiliary keymap in a child
keymaps (using something like `(lookup-key child-map
auxiliary-keymap-special-key)`) yields the binding in the parent keymap.

That said, it is certainly possible to fix the issue, but this needs a
careful handling of parent keymaps in the appropriate places.

You could try the following work around:

Define at least one auxiliary binding in the child keymap *before*
defining one in the parent keymap. This ensures that the child keymap
has its own auxiliary binding. (In other words: just swap the last two
lines in your example).

Frank





More information about the implementations-list mailing list