Reputation: 2091
I installed a new major mode (sunrise commander), and I want to reset all its predefined key bindings. Although I can use
(add-hook 'sr-mode-hook
'(lambda ()
(define-key sr-mode-map "KEY" nil)
...
))
this mode have so many bindings, it's a tag tedious to my taste.
Is there a way to completely reset the key bindings of this major mode in a one-liner or few-liners?
EDIT #1: I tried using these methods as described below:
(eval-after-load "sunrise"
'(setq sr-mode-map (make-sparse-keymap)))
OR
(add-hook 'sr-mode-hook
(lambda ()
(setq sr-mode-map (make-sparse-keymap))))
Sadly, neither of them seems to work.
Do I actually need to define a new, empty keymap? E.g. using
(defvar sunrise-keys-mode-map (make-keymap) "sunrise-keys-mode keymap.")
(define-minor-mode sunrise-keys-mode
"A minor mode so that my key settings override sunrise major mode keymap."
t " my-keys" 'sunrise-keys-mode-map)
(sunrise-keys-mode 1)
(eval-after-load "sunrise" ;; Fix this line to include the correct library name
'(setq sr-mode-map (sunrise-keys-mode)))
EDIT #2: After a bit of tinkering in the sunrise commander code, I noticed that the sr-mode-map is based on the dired mode map. I disabled both, and it worked perfectly.
(eval-after-load "sunrise-commander"
'(setq sr-mode-map (make-sparse-keymap)
dired-mode-map (make-sparse-keymap)))
For future reference - the above is the only code needed. make-sparse-keymap is a function that returns an empty keymap (unless provided with an argument, apparently).
Upvotes: 1
Views: 747
Reputation: 20248
You cound bind sr-mode-map
to a newly-created, empty keymap:
(setq sr-mode-map (make-sparse-keymap))
You might need to delay this until after sunrise commander is loaded:
(eval-after-load "sc" ;; Fix this line to include the correct library name
'(setq sr-mode-map (make-sparse-keymap)))
Upvotes: 2