4

I have two modes that bind a key. How can I choose which one should get to do its thing?

I'm asking generally but currently the situation is that when I'm in a certain mode, I want to use its bindings (which are currently shadowed by another mode).

I even tried to add a hook that local-set-keys at the end of my init file but that doesn't work, it gets shadowed too.

MasterMastic
  • 141
  • 3
  • Most simply, minor mode keymaps take precedence over the local (major mode, usually) keymap, which takes precedence over the global keymap. Minor mode keymap precedence is based on the order of minor-mode-map-alist at any given time (you can use after-load-functions to programatically massage this as new libraries are loaded). However there are more (and more complex) levels of keymap than this. You should update your question with precise details of what you are doing. Include the relevant elisp. – phils Jan 13 '17 at 14:01
  • 1
    See the Elisp manual, node Active Keymaps. – Drew Jan 13 '17 at 15:11
  • minor-mode keymaps always take precedence over the major mode and your local-keymap (which is usually a modified copy of the major-mode map). However, the problem you've run into is that multiple minor-modes can conflict with each other, and there's no built-in way to force one to have priority over another. See https://emacs.stackexchange.com/questions/13447/how-to-set-a-rule-for-the-order-of-minor-mode-map-alist for a workaround – Tyler Dec 06 '18 at 17:27
  • "mode" is too vague to be able to answer. Minor mode? Major mode? Just tell us which modes you're thinking of. – Stefan Dec 06 '18 at 20:02

0 Answers0