Emacs: print key binding for a command or list all key bindings

孤者浪人 提交于 2019-11-28 13:23:28

问题


In Emacs (GNU 23.2, *nix), how can I:

  1. list the key sequences bound to a particular command? For example, how can we list all the key sequences that execute save-buffers-kill-emacs, with the output of key sequences bound to it? Assuming we can do this, listing the key sequences bound to goto-line should print the output: M-g g on a default install.
  2. list all key-bindings? Does C-h b do this? Would it print my own bindings?

I am aware that executing the command directly can print a key sequence it can be activated with, but it doesn't always do so, and a few things happen, including:
(1) the output doesn't remain for long, (2) the command is executed.

I want a command that lists for me (preferably all) the bindings attached to a given command, without executing the command, or something like that.


回答1:


  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.




回答2:


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.



来源:https://stackoverflow.com/questions/2845934/emacs-print-key-binding-for-a-command-or-list-all-key-bindings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!