Emacs: 为命令打印密钥绑定或列出所有密钥绑定

在 Emacs (GNU 23.2,* nix)中,我如何:

  1. 列出绑定到特定命令的键序列?例如,我们如何列出所有执行 save-buffers-kill-emacs的键序列,并将键序列的输出绑定到它?假设我们可以这样做,列出绑定到 goto-line的键序列应该在默认安装中打印输出: M-g g
  2. 列出所有的键绑定? C-h b会这样做吗? 它会打印我自己的绑定吗?

我知道直接执行命令可以打印一个可以激活它的密钥序列,但它并不总是这样做,而且会发生一些事情,包括:
(1)输出时间不长; (2)命令执行。

我想要一个 指挥官为我(最好是所有)列出绑定到一个给定的命令,而不执行命令,或类似的东西。

47388 次浏览
  1. C-h f (or M-x describe-function) will show you the bindings for a command.

  2. You are correct, C-h b (or M-x describe-bindings) will show you all bindings. C-h m (M-x describe-mode) is also handy to list bindings by mode.

You might also try C-h k (M-x describe-key) to show what command is bound to a key. For instance, on my machine save-buffers-kill-emacs isn't bound to anything, but C-h k C-x C-c tells me that C-x C-c is bound to save-buffers-kill-terminal. It will list all bindings for the command at the same time.

How about just

M-x where-is <COMMAND>

You get the same information as you'd get with C-h f.

Also bound to C-h w, <f1> w and <help> w.