Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show Emacs keybindings which start with a particular key

I've read this, but my question is different. I'd like to know how to view key-bindings in Emacs which start with a particular key. I'd like to bind f2, but would like to know what it's currently bound to. Pressing C-h m prompts for the key sequence. Entering f2 here results in Emacs waiting for me to complete the chain, as f2 alone does nothing. How can I view all key-bindings which start with f2?

like image 873
SabreWolfy Avatar asked Apr 26 '12 09:04

SabreWolfy


1 Answers

F2F1 or F2C-h

In general, typing F1 or C-h after any prefix-binding will list all the bindings using that prefix:

describe-prefix-bindings is an interactive compiled Lisp function in help.el.

Describe the bindings of the prefix used to reach this command. The prefix described consists of all but the last event of the key sequence that ran this command.

F1 is the more reliable of the two (but only very slightly so), as detailed by the following documentation excerpts.

M-: (info "(emacs) Misc Help") RET:

You can get a list of subcommands for a particular prefix key by typing C-h (describe-prefix-bindings) after the prefix key. (There are a few prefix keys for which this does not work--those that provide their own bindings for C-h. One of these is <ESC>, because <ESC> C-h is actually C-M-h, which marks a defun.)

M-: (info "(emacs) Keys") RET:

Typing the help character (C-h or <F1>) after a prefix key displays a list of the commands starting with that prefix. The sole exception to this rule is <ESC>: <ESC> C-h is equivalent to C-M-h, which does something else entirely. You can, however, use <F1> to display a list of commands starting with <ESC>.

M-: (info "(emacs) Help") RET:

C-h or <F1> means "help" in various other contexts as well. For instance, you can type them after a prefix key to view a list of the keys that can follow the prefix key. (A few prefix keys don't support C-h in this way, because they define other meanings for it, but they all support <F1> for help.)

M-: (info "(elisp) Key Binding Conventions") RET:

Don't bind C-h following any prefix character (including C-c).
If you don't bind C-h, it is automatically available as a help character for listing the subcommands of the prefix character.

like image 68
phils Avatar answered Sep 21 '22 20:09

phils