Previous: , Up: User-interface conventions   [Contents][Index]

3.1.4 Key bindings

In general we try to make our key bindings fit with the overall Emacs style. We also have the following somewhat unusual convention of our own: when entering a three-key sequence, the final key can be pressed either with control or unmodified. For example, the slime-describe-symbol command is bound to C-c C-d d, but it also works to type C-c C-d C-d. We’re simply binding both key sequences because some people like to hold control for all three keys and others don’t, and with the two-key prefix we’re not afraid of running out of keys.

There is one exception to this rule, just to trip you up. We never bind C-h anywhere in a key sequence, so C-c C-d C-h doesn’t do the same thing as C-c C-d h. This is because Emacs has a built-in default so that typing a prefix followed by C-h will display all bindings starting with that prefix, so C-c C-d C-h will actually list the bindings for all documentation commands. This feature is just a bit too useful to clobber!

“Are you deliberately spiting Emacs’s brilliant online help facilities? The gods will be angry!”

This is a brilliant piece of advice. The Emacs online help facilities are your most immediate, up-to-date and complete resource for keybinding information. They are your friends:

C-h k <key>

describe-key “What does this key do?”
Describes current function bound to <key> for focus buffer.

C-h b

describe-bindings “Exactly what bindings are available?”
Lists the current key-bindings for the focus buffer.

C-h m

describe-mode “Tell me all about this mode”
Shows all the available major mode keys, then the minor mode keys, for the modes of the focus buffer.

C-h l

view-lossage “Woah, what key chord did I just do?”
Shows you the literal sequence of keys you’ve pressed in order.

Note: In this documentation the designation C-h is a canonical key which might actually mean Ctrl-h, or F1, or whatever you have help-command bound to in your .emacs. Here is a common situation:

(global-set-key [f1]   'help-command)
(global-set-key "\C-h" 'delete-backward-char)

In this situation everywhere you see C-h in the documentation you would substitute F1.

You can assign or change default key bindings globally using the global-set-key function in your ~/.emacs file like this:

(global-set-key "\C-c s" 'slime-selector)

which binds C-c s to the function slime-selector.

Alternatively, if you want to assign or change a key binding in just a particular slime mode, you can use the define-key function in your ~/.emacs file like this:

(define-key slime-repl-mode-map (kbd "C-c ;")

which binds C-c ; to the function slime-insert-balanced-comments in the REPL buffer.

Previous: , Up: User-interface conventions   [Contents][Index]