Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show overridden/shadowed key bindings?

Tags:

emacs

In emacs, how can I show shadowed/overridden key bindings for the current buffer? They won't show up when running describe-bindings (C-h b).

In other words: how can I see if the modes active in a buffer have conflicting key bindings?

like image 243
Norswap Avatar asked Dec 20 '12 11:12

Norswap


1 Answers

Just call describe-mode: C-hm

The majority of mode docstrings will display their keymaps, and the method used to list them here also tells you if a binding is shadowed.

It doesn't tell you what it's shadowed by, but of course that's trivial to check with C-hc or C-hk.

e.g.:

key             binding
---             -------
[...]
C-M-q           indent-sexp
  (that binding is currently shadowed by another mode)

That text is generated by the function substitute-command-keys which processes the mode docstring when the documentation function is called.

e.g.:

(substitute-command-keys "\\{lisp-interaction-mode-map}")

The following functions can also be useful:

(key-binding KEY &optional ACCEPT-DEFAULT NO-REMAP POSITION) ;; dominant binding
(global-key-binding KEYS &optional ACCEPT-DEFAULT)
(local-key-binding KEYS &optional ACCEPT-DEFAULT)
(minor-mode-key-binding KEY &optional ACCEPT-DEFAULT) ;; discover keymap(s)
like image 92
phils Avatar answered Sep 28 '22 01:09

phils