I would like to understand when keymaps of minor modes get "applied" and how do they get applied exactly? In particular, is there a way to see a list of a active minor-mode maps? I know I can look the list of active minor-modes and check which of them has a keymap, but I am looking for a deeper understanding of the mechanism).

One reason I want to understand this is to figure out what happens when I have multiple minor modes mapping the same key sequence. Which one gets precedence and how can I influence this?

1 Answer 1

minor-mode-map-alist is a variable defined in `C source code'.

Alist of keymaps to use for minor modes.
Each element looks like (VARIABLE . KEYMAP); KEYMAP is used to read
key sequences and look up bindings if VARIABLE's value is non-nil.
If two active keymaps bind the same key, the keymap appearing earlier
in the list takes precedence.

https://stackoverflow.com/a/24688860/324105 might also help.

  • Thanks. Somehow I couldn't find that question here. I will mark my question as a duplicate. UPDATE: Wasn't able to since the question is not on Emacs StackExchange.
    – Tohiko
    Apr 24, 2020 at 10:06
  • " In addition, portions of text in the buffer can specify their own keymaps, which override all other keymaps." (emacs manual, 49.3.3). Not sure how this should be interpreted.
    – Muihlinn
    Apr 24, 2020 at 10:09
  • @Muihlinn There's a fairly substantial array of keymaps which are checked in priority order. This question was only about minor modes. masteringemacs.org/article/… is a good article on the more general subject.
    – phils
    Apr 24, 2020 at 10:13
  • A question here can't/shouldn't be closed because it is a duplicate of one on another Stack Exchange site. On the other hand, we shouldn't duplicate questions across sites - e.g., it wouldn't be a good idea to look for questions on S.O. to duplicate here with new questions. Bottom line: you can delete your question here, as it is a duplicate of an SO question. There's no requirement to do that, though.
    – Drew
    Apr 24, 2020 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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