GNU Emacs Lisp Reference Manual
When documentation strings refer to key sequences, they should use the current, actual key bindings. They can do so using certain special text sequences described below. Accessing documentation strings in the usual way substitutes current key binding information for these special sequences. This works by calling substitute-command-keys. You can also call that function yourself.
Here is a list of the special sequences and what they mean:
\[command]M-x command' if command has no key bindings.\{mapvar}describe-bindings.\<mapvar>\[command]' sequences in this documentation string.Please note: Each `\' must be doubled when written in a string in Emacs Lisp.
Here are examples of the special sequences:
(substitute-command-keys
"To abort recursive edit, type: \\[abort-recursive-edit]")
=> "To abort recursive edit, type: C-]"
(substitute-command-keys
"The keys that are defined for the minibuffer here are:
\\{minibuffer-local-must-match-map}")
=> "The keys that are defined for the minibuffer here are:
? minibuffer-completion-help
SPC minibuffer-complete-word
TAB minibuffer-complete
LFD minibuffer-complete-and-exit
RET minibuffer-complete-and-exit
C-g abort-recursive-edit
"
(substitute-command-keys
"To abort a recursive edit from the minibuffer, type\
\\\\[abort-recursive-edit].")
=> "To abort a recursive edit from the minibuffer, type C-g."