diff options
| author | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2024-04-07 13:41:34 -0500 |
| commit | 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 (patch) | |
| tree | f1190704f78f04a2b0b4c977d20fe96a828377f1 /devdocs/elisp/defining-commands.html | |
new repository
Diffstat (limited to 'devdocs/elisp/defining-commands.html')
| -rw-r--r-- | devdocs/elisp/defining-commands.html | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/devdocs/elisp/defining-commands.html b/devdocs/elisp/defining-commands.html new file mode 100644 index 00000000..773e8f59 --- /dev/null +++ b/devdocs/elisp/defining-commands.html @@ -0,0 +1,31 @@ + <h3 class="section">Defining Commands</h3> <p>The special form <code>interactive</code> turns a Lisp function into a command. The <code>interactive</code> form must be located at top-level in the function body, usually as the first form in the body; this applies to both lambda expressions (see <a href="lambda-expressions">Lambda Expressions</a>) and <code>defun</code> forms (see <a href="defining-functions">Defining Functions</a>). This form does nothing during the actual execution of the function; its presence serves as a flag, telling the Emacs command loop that the function can be called interactively. The argument of the <code>interactive</code> form specifies how the arguments for an interactive call should be read. </p> <p>Alternatively, an <code>interactive</code> form may be specified in a function symbol’s <code>interactive-form</code> property. A non-<code>nil</code> value for this property takes precedence over any <code>interactive</code> form in the function body itself. This feature is seldom used. </p> <p>Sometimes, a function is only intended to be called interactively, never directly from Lisp. In that case, give the function a non-<code>nil</code> <code>interactive-only</code> property, either directly or via <code>declare</code> (see <a href="declare-form">Declare Form</a>). This causes the byte compiler to warn if the command is called from Lisp. The output of <code>describe-function</code> will include similar information. The value of the property can be: a string, which the byte-compiler will use directly in its warning (it should end with a period, and not start with a capital, e.g., <code>"use (system-name) instead."</code>); <code>t</code>; any other symbol, which should be an alternative function to use in Lisp code. </p> <p>Generic functions (see <a href="generic-functions">Generic Functions</a>) cannot be turned into commands by adding the <code>interactive</code> form to them. </p> <table class="menu" border="0" cellspacing="0"> <tr> +<td align="left" valign="top">• <a href="using-interactive" accesskey="1">Using Interactive</a> +</td> +<td> </td> +<td align="left" valign="top">General rules for <code>interactive</code>. </td> +</tr> <tr> +<td align="left" valign="top">• <a href="interactive-codes" accesskey="2">Interactive Codes</a> +</td> +<td> </td> +<td align="left" valign="top">The standard letter-codes for reading arguments in various ways. </td> +</tr> <tr> +<td align="left" valign="top">• <a href="interactive-examples" accesskey="3">Interactive Examples</a> +</td> +<td> </td> +<td align="left" valign="top">Examples of how to read interactive arguments. </td> +</tr> <tr> +<td align="left" valign="top">• <a href="command-modes" accesskey="4">Command Modes</a> +</td> +<td> </td> +<td align="left" valign="top">Specifying that commands are for a specific mode. </td> +</tr> <tr> +<td align="left" valign="top">• <a href="generic-commands" accesskey="5">Generic Commands</a> +</td> +<td> </td> +<td align="left" valign="top">Select among command alternatives. </td> +</tr> </table><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/Defining-Commands.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Defining-Commands.html</a> + </p> +</div> |
