30

I want to define some key bindings for my new found usage of helm, amazing mode btw, and I want to do it without overwriting the usage of other keys. I realize that the number of different key combinations is infinite, but is there some way to see all undefined key bindings for say 1 level deep?

For example, I want to know what key bindings are available after hitting C-c, and then get a buffer with a listing of C-c some_keys.

Assuming this feature doesn't currently exist?

23

Check out the free-keys package, which gives you a function of the same name that shows you all your currently unused key-bindings.

bind-key is also a helpful tool which gives you a cleaner syntax for defining your own bindings, i.e.:

(bind-key "C-h C-k" 'free-keys)

bind-key also comes with a handy defun called describe-personal-keybindings to see all the key-bindings you've set as well as if and what bindings you've overridden.

6

Here are few ideas. They don't answer your question directly but they can help you figure out which key bindings are available for use.

Get a list of all key bindings starting with a prefix

The guide-key package can be used to show, in alphabetical order, all the key bindings that begin with the entered prefix.

The below screen capture shows guide-key showing me all my key-bindings beginning with C-x r. As the available bindings are listed alphabetically, it's easy to figure out which bindings are available.

The screen capture also shows what other key prefixes I use guide-key for.

My key bindings that begin with C-x r

Get a list of what bindings you overrode

The describe-personal-keybindings function that comes with the use-package package shows what key bindings you overrode as shown in below screen capture. You can review the results of this function to check if you overrode a binding unintentionally. The cool thing is that this function shows the bindings for all minor modes too.

Sample of what the output of describe-personal-keybindings looks like

5

You can hit C-c C-h to know all bindings that start with C-c. This works for any key sequence that is "incomplete": hit that key sequence and then C-h to see all the keybindings that start with that sequence. You can then pick something not in the list.

To know whether a particular keybinding is defined (to avoid overwriting it), you can use C-h c or M-x describe-key-briefly (or C-h k or M-x describe-key) to see what it is defined to, in the current mode.

1

Icicles key completion - S-TAB - shows you all key sequences currently available for use (i.e., bound, not free), including after you hit a prefix key.

For example, C-x r S-TAB shows key sequences with the prefix C-x r.

Keys that are not listed are unbound (free).

You can sort the displayed key sequences in different ways, using C-,.

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.