我的配置文件中有很多 evil-define-key
, 因为很多 mode 中, evil key bindings 都覆盖了这个 mode 本来的 key bindings. 但有时候 evil-define-key 不起作用. 比如:
(evil-define-key 'normal ivy-occur-grep-mode-map (kbd "RET") #'ivy-occur-press-and-switch)
(evil-define-key 'motion ivy-occur-grep-mode-map (kbd "RET") #'ivy-occur-press-and-switch)
按 RET 对应的仍然是 evil-motion-state-map
中的 evil-ret
.
ivy-occur-grep-mode-map 定义如下:
(defvar ivy-occur-grep-mode-map
(let ((map (copy-keymap ivy-occur-mode-map)))
(ivy-define-key map (kbd "C-x C-q") 'ivy-wgrep-change-to-wgrep-mode)
(ivy-define-key map "w" 'ivy-wgrep-change-to-wgrep-mode)
map)
"Keymap for Ivy Occur Grep mode.")