I would like to change the mode-map of a minor mode with mode map.
I mean replacing the original mode-map that was specified in the define-minor-mode
call with another one. Keeping the two mode-map unmodified.
How could I do that?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityI would like to change the mode-map of a minor mode with mode map.
I mean replacing the original mode-map that was specified in the define-minor-mode
call with another one. Keeping the two mode-map unmodified.
How could I do that?
After digging a bit I found the minor-mode-map-alist
variable in the doc. It is holding a mapping between the minor modes symbol, and their associated mode-map.
Hence to replace the mode-map of 'my-minor-mode
I went for:
(setcdr (assoc 'my-minor-mode minor-mode-map-alist) my-minor-mode-map))
(define-minor-mode new-minor-mode "some doc" nil nil my-minor-mode-map (other-minor-mode (if new-minor-mode 1 -1)))
and use that new minor mode instead of the other one.
– Tobias
Sep 21 '17 at 18:20
define-minor-mode
. Otherwise you can also usecopy-keymap
. – Tobias Sep 21 '17 at 13:12set-keymap-parent
andcopy-keymap
as two possibilities for grabbing stuff from another keymap. What you do depends on what you really want/need, which is not yet clear from your question. – Drew Sep 21 '17 at 13:53