2

I use Evil, and I'm using the General package to set my custom keybindings. I'm using SPC as a leader key. The trouble is, I find that SPC is not interpreted as my leader key in some modes, namely dired, and also in the *Messages* buffer. I can't seem to figure out how to get it to work.

I've defined my leader key like this:

(general-define-key
 :states 'motion
 :prefix "SPC"
 ; Bindings under the leader key defined here...

Adding keymaps: 'dired-mode-map doesn't seem to work, which is odd, because C-h k SPC in dired mode shows SPC runs the command dired-next-line (found in dired-mode-map)...

Does anyone know how to define my SPC leader key such that it will be effective in all modes?

Thanks!

2

I think you need to set the keybindings in normal state :states 'normal

  • Unfortunately that's not working for me. From github.com/noctuid/evil-guide - Remember that binding a key in motion state is like binding a key in the normal, visual, and operator states all at once (unless that key is already bound in one of those states). I've been going through the guide at the above URL but I'm still at a loss, nothing seems to be working. – the-konapie Apr 5 '17 at 17:49
  • 2
    Did you try adding both :states 'normal and :keymaps 'dired-mode-map? There is a small distinction between using :states and binding in motion state. I believe a key bound in evil-motion-state-map would be inherited to normal and insert state keymaps if it is unbound in those. Please read the section Notes for Evil Users in github.com/noctuid/general.el/blob/master/README.org – Yash Yadavalli Apr 5 '17 at 18:49
  • 1
    Apparently I hadn't tried that particular combination. It works! Thanks so much, this was driving me nuts! If I could get my leader key to work in Messages (more importantly, in help mode - I discovered it doesn't work there, either) then that would be perfect... – the-konapie Apr 6 '17 at 0:18
  • Try adding message-buffer-mode-map to the list of keymaps. Ideally just having :states 'normal should enable the keybindings in all modes. I'd check why that's not working, one guess is SPC is being rebound somewhere else – Yash Yadavalli Apr 6 '17 at 13:42
  • Thanks for the suggestion. I did try this, but it doesn't work: (general-define-key :keymaps 'messages-buffer-mode-map :states 'normal ... C-h m does suggest that "SPC" is being shadowed. C-h k SPC suggest that it's being shadowed by a binding in evil-motion-state-map. But :states 'motion or :states '(normal motion) doesn't work, either. Interestingly, the situation was similar with help mode (in that evil-motion-state-map had a binding for SPC that was shadowing my binding), but in the case of help mode, adding motion to :states worked for me. – the-konapie Apr 6 '17 at 14:15
-1

This what worked for me

As per description. If one does not want keys to be overridden he/she should use :keymaps ‘override

(general-define-key
 :states ‘normal
 :keymaps ‘override
 :prefix “SPC”
 ...)
  • 1
    Can you elaborate? – DoMiNeLa10 Aug 8 at 15:02
  • Please consider explaining why this works (answers the question) - what it does etc. – Drew Aug 8 at 15:52
  • As per description. If one does not want keys to be overridden he/she should use :keymaps ‘override – akoppela Aug 12 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.