32

I am trying out a new major mode, how can I take advantage of Emacs' documentation system to get a listing of key bindings available in that specific buffer?

38

C-h b will list all the bindings available in a buffer. This is a mnemonic for help (C-h) bindings (b).

You can also get a list of keybindings via C-h m, which is help for the major and minor modes for the buffer. The formatting of this is a little clearer, but includes additional information about the modes beyond just listing the keybindings.

  • Thanks, I wanted to know this earlier today and blanked on how to do so. C-h m is the one I remember using a long time ago, but forgot. – nixeagle Oct 6 '14 at 19:43
22

I use the command helm-decsbinds, which is available via melpa. I mapped it to C-h b because it is basically a drop-in replacement for describe-bindings. The benefit is that it is easier to navigate and search than the output of describe-bindings because you can easily search for keywords and the helm buffer will narrow to show all of the matches, and which mode they come from

helm-descbinds in action

For any selection in the list, you can choose to either perform the action, or to jump to the documentation for the command.

10

Although not the canonical emacs way of doing things, I quite like using discover-my-major for that purpose because it just feels more effective.

It is available on melpa and is powered by the makey library, which is responsible for those nice menus magit is known for.

I'd suggest you check out the github link for a screenshot demonstrating the functionality.

Install it (I'd suggest from melpa using package.el) and add

(require 'discover-my-major)
(global-set-key (kbd "C-h C-m") 'discover-my-major)

to your config.

4

Although not exactly what you are looking for you might want to try out guide-key. If you enter a prefix sequence without completing it guide-key will pop up a buffer showing you the available completions and what functions they execute. I find this very useful when I need to learn new bindings in Emacs.

enter image description here

  • 3
    Note that the github page for guide-key says "This package is not maintained actively. which-key is a better altenative." – Mark Apr 26 at 13:32
2

Icicles key completion gives you all of the info you get from C-h b (describe-bindings), C-h w (where-is), and C-h c (describe-key-briefly), rolled into one. Just hit S-TAB anytime at top level.

  • Every key sequence that you can possibly type in the current context (with the exception of keys such as q that just insert characters) is displayed in buffer *Completions*. This tells you which keys are available now.

  • The command that each key sequence is bound to is also shown in *Completions*, next to the key name (e.g. b = bookmark-jump). This gives you a rough idea what the key (e.g. b) does.

  • Each key sequence that is bound locally, that is, each key that has a special meaning for the current buffer mode, is highlighted in *Completions* with a pale yellow background. This tells you which bindings are those offered by the current mode.

  • Click C-M-mouse-2 on a key name (with its command name). A *Help* buffer opens with a complete description of the command bound to the key. This tells you what the key sequence does in detail.

    • Click another key (command) to get help on it, and so on… You can do this all day, browsing through the available key bindings to learn what they do. This is a great way, in particular, to learn about the keys defined by a given mode.
    • Click any link in the *Help* buffer to find out about stuff related to a given command and its key sequence. Navigate throughout the help system – you can do this all day too. Then pick another key to interrogate…
  • If you want to then use a key (command), then just click mouse-2 on its name in *Completions* (or complete the key + command name and hit RET). Or cancel, using C-g, and hit the key as you would normally.

You can start with S-TAB, to see all currently available keys. Or you can start by hitting a prefix key (e.g. C-x) and then hit S-TAB to see all keys that have that prefix (i.e., all keys available after you have hit that prefix key). (The "command" associated with a prefix key is indicated by ....)

You can even complete menu-bar menus this way, by accessing the pseudo-function prefix key menu-bar.

See also this description

2

You may want to look at C-h m that lists all key bindings of major mode and minor modes. Read more about other Help commands here. Emacs help system is rich.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.