1

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?

  • 1
    Please, give more information. Which minor mode do you want to modify? Which keymap do you want to use? Do you want to set the keymap of an existing minor mode to the keymap of another one or do you define your own minor-mode? When you define your own minor mode you can pass the keymap to define-minor-mode. Otherwise you can also use copy-keymap. – Tobias Sep 21 '17 at 13:12
  • What @Tobias said. The question is not very clear. You have set-keymap-parent and copy-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
  • Made the question more clear I want to achieve – AdrieanKhisbe Sep 21 '17 at 14:33
1

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))
  • That solution looks rather hacky. I am still wondering whether you actually should define a new minor-mode with (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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.