Emacs: Fix Minor Mode Key Priority

By Xah Lee. Date: .

2017-01-27 this page is work in progress

This page shows you how to change minor modes's key priority, when they conflict.

minor-mode-map-alist

Minor mode's keys priority depends on the variable minor-mode-map-alist .

minor-mode-map-alist is a association list. 〔►see Elisp: Association List

Each element of minor-mode-map-alist is a cons pair, of the form

(cons 'minor_mode_x_var minor_mode_x_keymap)

The minor_mode_x_var is a variable of the same name of the command to toggle the minor mode, and has value of t or nil. (all minor modes have this variable)

The minor_mode_x_keymap is a keymap for that minor mode. (keymap is basically a list, used for keybinding. (info "(elisp) Format of Keymaps") )

Each minor_mode_x_var may have value true or false. When true, it means the corresponding keymap is active.

Emacs goes thru the active one in minor-mode-map-alist, the front ones has priority.

Note: emacs has other mechanisms about priority of keys.

(info "(elisp) Controlling Active Maps")

Show Minor Mode Key Priority

You can use this command to show minor mode key priority.

(defun xah-display-minor-mode-key-priority  ()
  "Print out minor mode's key priority.
URL `http://ergoemacs.org/emacs/minor_mode_key_priority.html'
Version 2017-01-27"
  (interactive)
  (mapc
   (lambda (x) (prin1 (car x)) (terpri))
   minor-mode-map-alist))

Emacs: What's Minor Mode?

Emacs Keybinding How-To Topic

  1. Emacs: How to Define Keys
  2. Emacs: Change Major Mode Keys
  3. Emacs: Change Minor Mode Keys
  4. Emacs: Fix Minor Mode Key Priority
  5. Emacs: Define Key Sequence
  6. Emacs: How to Bind Super Hyper Keys
  7. Emacs: How to Define Menu Key
  8. Emacs: Remapping Keys Using key-translation-map
  9. Emacs: Bind Number Pad Keys
  10. Emacs: How to Set Mouse Buttons
Liket it? Put $5 at patreon. Or Buy Xah Emacs Tutorial. Thanks.