Hi all, I'm using the NEO keyboard layout, and i want to integrate it somehow with Evil. One case is to change the state bindings of the key 'r', because 'r' is assigned to 'k' on qwert(z|y). Currently i'm doing this by editing the global evil state maps directly: (define-key evil-normal-state-map "r" nil) (define-key evil-motion-state-map "r" 'evil-previous-line) Without setting 'r' to nil in normal state, i would call the evil-replace function every time, when i try to move one line up. I don't know whether this is the clean way of removing key bindings from a map. I've copied this solution from somewhere. Now this approach feels pretty dirty, because i think it's not intended by the developers to change the evil state maps this way. My second idea was to create a NEO minor mode with a sparse keymap and use evil-define-key, as described in the documentation. However, "unsetting" the 'r' keybinding in the normal state didn't work: (evil-define-key 'normal neo-mode-map "r" nil) ;; or 'undefine instead of nil (evil-define-key 'motion neo-mode-map "r" 'evil-previous-line) Pressing 'r' in normal state just doesn't do anything, but doing so in a motion only state buffer (like *Help*) worked. I've tried to understand how the auxiliary keymaps for evil work. It seems the keybinding of 'r' to nil or 'undefine is stored in the auxiliary map and takes precedence over the keybind for the motion state. Last i found the evil-make-intercept-map and evil-make-overriding-map functions, but i don't think they are solutions to my problem. I think the neo-minor-mode solution would be the best way, but i don't know how to completely remove a keybinding from an evil state during such a mode. I would be thankful for any advice. BTW: Please CC me
On 2013-03-09, Tempora Tempa <[email protected]> wrote:
Hi all,
I'm using the NEO keyboard layout, and i want to integrate it somehow with Evil. One case is to change the state bindings of the key 'r', because 'r' is assigned to 'k' on qwert(z|y). Currently i'm doing this by editing the global evil state maps directly:
(define-key evil-normal-state-map "r" nil) (define-key evil-motion-state-map "r" 'evil-previous-line)
This is in fact the right way to do. Motion state bindings are, well, motions that are available in normal, visual, operator and motion state. That's why they are placed in their own map. Normal state bindings are only available in normal state.
[...] I think the neo-minor-mode solution would be the best way, but i don't know how to completely remove a keybinding from an evil state during such a mode.
I would not do this. I think the best way is to directly manipulate the keymaps and not using a minor mode. You may write a function that does this. Since neo is really different from qwertz, you may even consider to start with fresh empty keymaps and install completely customized bindings, i.e. start with (setq emacs-normal-state-map (make-sparse-keymap)) and then add you keybindings (almost all standard bindings are in `evil-maps.el`, I would probably just copy this file and then create may own map. Best regards, Frank btw: I do not use neo now, but I did a few year ago and not being able to configure the bindings in viper was one of the motivations to start vim-mode ;)
participants (2)
-
Frank Fischer -
Tempora Tempa