I'm having a problem where it appears Emacs is not looking at keybindings set in my evil-motion-state-map
.
Below is my entire init.el
. I start with an empty .emacs.d
directory and only install evil
.
;; The following line is a workaround for Emacs 26.2.
(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")
(package-initialize)
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")))
(setq package-selected-packages
'(evil))
;;; theme config
(set-face-attribute 'default nil :height 160)
(defun lookup-spc-tab ()
"For debugging."
(interactive)
(message "SPC TAB binding for motion and normal states: %s %s"
(lookup-key evil-motion-state-map (kbd "SPC TAB"))
(lookup-key evil-normal-state-map (kbd "SPC TAB"))))
;;; evil config
(evil-mode 1)
(lookup-spc-tab)
(evil-define-key 'motion 'global
(kbd "SPC") (make-sparse-keymap)
(kbd "SPC TAB") #'switch-to-buffer)
(evil-define-key 'motion Info-mode-map
(kbd "SPC") (make-sparse-keymap)
(kbd "SPC SPC") #'Info-scroll-up)
(lookup-spc-tab)
When I start Emacs the following is printed in the *Messages*
, which leads me to believe that SPC TAB
was set in evil-motion-state-map
. The following messages come from my debugging function lookup-spc-tab
and appear in the *Messages*
.
SPC TAB binding for motion and normal states: 1 1
SPC TAB binding for motion and normal states: switch-to-buffer 1
Now for my question:
In every mode I've tried (Fundamental, Emacs-Lisp, Message), in both motion and normal state, SPC SPC
is undefined and SPC TAB
is switch-to-buffer
; this is all to be expected.
The exception is Info mode. When I use Info mode, in both motion and normal state, SPC SPC
is Info-scroll-up
(expected), but SPC TAB
is undefined. What is is about Info mode that overrides SPC TAB
? SPC TAB
works in every other mode!
However, if I do:
...
(evil-define-key 'normal 'global
(kbd "SPC") (make-sparse-keymap)
(kbd "SPC TAB") #'switch-to-buffer)
(evil-define-key 'normal Info-mode-map
(kbd "SPC") (make-sparse-keymap)
(kbd "SPC SPC") #'Info-scroll-up)
...
That is, if I change my config to modify normal states instead of motion states, then everything works (in normal state) in every mode, even Info mode. Specifically, SPC TAB
is defined in every mode, including Info mode, and SPC SPC
is defined only in Info mode. All as expected.
So, again, my question is, what is it about evil-motion-state-map
that gets overridden in Info mode only? And why does only motion state get overridden but not normal state?