I know, that I can unbind keys using unbind-key
. In this case I have to know the key I want to unbind. But I don't know the key. I just want to unbind all keys of some-mode-map
. I don't want override them, I just want to unbind them and then to define my own keys in the some-mode-map
. I know that I could iterate some-mode-map
and apply unbind-key
, but may be there is a more straightforward solution? And I don't know how to iterate a keymap
.
Update
Tried (as was suggested by phils in comments) this way and it didn't work:
(use-package neotree
:config
(setq neotree-mode-map (make-sparse-keymap))
(define-key neotree-mode-map (kbd "RET") 'neotree-enter)
)
(use-package evil
:init
(setq evil-overriding-maps '((neotree-mode-map)))
)
neotree-mode-map
remains not cleaned. And depending on package configuration order, evil
bindings gets overridden. It doesn't unless I redefine neotree-mode-map
. I know I could obtain desired result with evil-define-key
, but I want to keep package specific settings in its own configuration file. If I employ evil-define-key
, neotree
key binding definitions will be in setup-evil.el
and not in setup-neotree.el
Update 2
Answer works, as does (setq neotree-mode-map (make-sparse-keymap))
.
But it appears that neotree-mode-map
has parent map, and that's why some key bindings "come back" after "cleaning".
Another thing I figured out is, that evil
put into overriding maps some extra information.
(keymap
...
(override-state . all)
...
)
And that's why I should clear map before evil
configuration.
neotree-mode-map
"remains uncleaned"? Or is it that you have correctly redefined that variable but existing code still points, not to the variable, but to its former value (a keymap, i.e., a list)? What doesC-h v neotree-mode-map
tell you about this? (Or useC-h M-k
(describe-keymap
) from libraryhelp-fns+.el
, for a human-readable listing of the keymap bindings.) – Misrepresentneotree-mode-map
value is:Value: (keymap (override-state . all) (13 . neotree-enter) keymap (103 . revert-buffer) (60 . beginning-of-buffer) (62 . end-of-buffer) (104 . describe-mode) (63 . describe-mode) (127 . scroll-down-command) (33554464 . scroll-down-command) ... (45 . negative-argument) (remap keymap (self-insert-command . undefined)))
– Execratory