Reputation: 4173
Sometimes I need to redefined the whole map of a mode. That means that I am not interested in the default bindings, it is undesired to accidentally use some default keybinding when no remapping was assigned.
For example, I define dired-mode-map
as
(evil-define-key 'normal dired-mode-map
....
How can I clear all the default keybindings before mapping my own?
Upvotes: 2
Views: 444
Reputation: 41548
This seems to work:
(setcdr dired-mode-map (cdr (make-keymap)))
(set-keymap-parent dired-mode-map special-mode-map)
That is, it creates a new empty keymap and replaces the contents of dired-mode-map
with that. It happens to work because a keymap is a list whose car is just the symbol keymap
, so the cdr is all that needs to be changed.
Upvotes: 1