1
2
3
4
5
6
|
<h3 class="section">Documentation Basics</h3> <p>A documentation string is written using the Lisp syntax for strings, with double-quote characters surrounding the text. It is, in fact, an actual Lisp string. When the string appears in the proper place in a function or variable definition, it serves as the function’s or variable’s documentation. </p> <p>In a function definition (a <code>lambda</code> or <code>defun</code> form), the documentation string is specified after the argument list, and is normally stored directly in the function object. See <a href="function-documentation">Function Documentation</a>. You can also put function documentation in the <code>function-documentation</code> property of a function name (see <a href="accessing-documentation">Accessing Documentation</a>). </p> <p>In a variable definition (a <code>defvar</code> form), the documentation string is specified after the initial value. See <a href="defining-variables">Defining Variables</a>. The string is stored in the variable’s <code>variable-documentation</code> property. </p> <p>Sometimes, Emacs does not keep documentation strings in memory. There are two such circumstances. Firstly, to save memory, the documentation for preloaded functions and variables (including primitives) is kept in a file named <samp>DOC</samp>, in the directory specified by <code>doc-directory</code> (see <a href="accessing-documentation">Accessing Documentation</a>). Secondly, when a function or variable is loaded from a byte-compiled file, Emacs avoids loading its documentation string (see <a href="docs-and-compilation">Docs and Compilation</a>). In both cases, Emacs looks up the documentation string from the file only when needed, such as when the user calls <kbd>C-h f</kbd> (<code>describe-function</code>) for a function. </p> <p>Documentation strings can contain special <em>key substitution sequences</em>, referring to key bindings which are looked up only when the user views the documentation. This allows the help commands to display the correct keys even if a user rearranges the default key bindings. See <a href="keys-in-documentation">Keys in Documentation</a>. </p> <p>In the documentation string of an autoloaded command (see <a href="autoload">Autoload</a>), these key-substitution sequences have an additional special effect: they cause <kbd>C-h f</kbd> on the command to trigger autoloading. (This is needed for correctly setting up the hyperlinks in the <samp>*Help*</samp> buffer.) </p><div class="_attribution">
<p class="_attribution-p">
Copyright © 1990-1996, 1998-2022 Free Software Foundation, Inc. <br>Licensed under the GNU GPL license.<br>
<a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Documentation-Basics.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Documentation-Basics.html</a>
</p>
</div>
|