Next: Text Quoting Style, Previous: Accessing Documentation, Up: Documentation
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]
\{
mapvar}
describe-bindings
.
\<
mapvar>
`
text-quoting-style
.
See Text Quoting Style.
'
text-quoting-style
.
\=
Please note: Each ‘\’ must be doubled when written in a string in Emacs Lisp.
The value of this variable is a symbol that specifies the style Emacs should use for single quotes in the wording of help and messages. If the variable's value is
curve
, the style is ‘like this’ with curved single quotes. If the value isstraight
, the style is 'like this' with straight apostrophes. If the value isgrave
, quotes are not translated and the style is `like this' with grave accent and apostrophe, the standard style before Emacs version 25. The default valuenil
acts likecurve
if curved single quotes seem to be displayable, and likegrave
otherwise.This option is useful on platforms that have problems with curved quotes. You can customize it freely according to your personal preference.
This function scans string for the above special sequences and replaces them by what they stand for, returning the result as a string. This permits display of documentation that refers accurately to the user's own customized key bindings.
If a command has multiple bindings, this function normally uses the first one it finds. You can specify one particular key binding by assigning an
:advertised-binding
symbol property to the command, like this:(put 'undo :advertised-binding [?\C-/])The
:advertised-binding
property also affects the binding shown in menu items (see Menu Bar). The property is ignored if it specifies a key binding that the command does not actually have.
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 C-j 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 \ `\\<minibuffer-local-must-match-map>\\[abort-recursive-edit]'.") ⇒ "To abort a recursive edit from the minibuffer, type ‘C-g’."
There are other special conventions for the text in documentation strings—for instance, you can refer to functions, variables, and sections of this manual. See Documentation Tips, for details.