1

Below is the entirety of my Evil key bindings in init.el:

(evil-define-key 'normal 'global (kbd "SPC") (make-sparse-keymap))
(evil-define-key 'normal 'global (kbd "SPC TAB") #'ivy-switch-buffer)
(evil-define-key 'normal 'Info-mode-map (kbd "SPC") (make-sparse-keymap))
(evil-define-key 'normal 'Info-mode-map (kbd "SPC SPC") #'Info-scroll-up)

The end result of this is as follows:

  • In Emacs-Lisp mode, SPC TAB is bound to ivy-switch-buffer; this is expected.
  • In Emacs-Lisp mode, SPC SPC is bound to Info-scroll-up; this is unexpected.
  • In Info mode, SPC TAB is undefined; this is unexpected.
  • In Info mode, SPC SPC is bound to Info-scroll-up; this is expected.

It seems to me (in one sentence) that the global config is not global and the local config is global. This is the opposite of what I would expect.

The Info-scroll-up binding is defined on Info-mode-map and has effect even when Info mode is not active. Why?

The ivy-switch-buffer binding is defined globally, but does not work when I am in Info mode. Not only does it not work, but it is undefined. It's not that SPC TAB has been replaced by another command, SPC TAB is undefined (and SPC is a prefix key). Why?

I can't form any mental model of why Evil / Emacs is behaving this way. Why is it behaving this way?

2
  • Please look at the Emacs manual on keybindings, and then the evil manual on how to do keybindings in evil globally and in specific modes.
    – Dan
    Nov 15, 2019 at 21:54
  • 1
    @Dan I have read all 11 pages of the Evil manual twice.
    – Buttons840
    Nov 15, 2019 at 22:08

1 Answer 1

1

This works as expected:

(evil-define-key 'normal 'global (kbd "SPC") (make-sparse-keymap))
(evil-define-key 'normal 'global (kbd "SPC TAB") #'ivy-switch-buffer)
(evil-define-key 'normal Info-mode-map (kbd "SPC") (make-sparse-keymap))
(evil-define-key 'normal Info-mode-map (kbd "SPC SPC") #'Info-scroll-up)

Notice that Info-mode-map is not quoted like it was in the original question.

The evil-define-key docs mention you can pass 'global' or 'local as the second argument. I'm not sure what it does if you give it some other quoted value like I was doing, but now that I'm calling evil-define-key correctly it works the way I would expect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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