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/indenting-macros.html | |
new repository
Diffstat (limited to 'devdocs/elisp/indenting-macros.html')
| -rw-r--r-- | devdocs/elisp/indenting-macros.html | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/devdocs/elisp/indenting-macros.html b/devdocs/elisp/indenting-macros.html new file mode 100644 index 00000000..1b20e0cc --- /dev/null +++ b/devdocs/elisp/indenting-macros.html @@ -0,0 +1,12 @@ + <h3 class="section">Indenting Macros</h3> <p>Within a macro definition, you can use the <code>declare</code> form (see <a href="defining-macros">Defining Macros</a>) to specify how <tt class="key">TAB</tt> should indent calls to the macro. An indentation specification is written like this: </p> <div class="example"> <pre class="example">(declare (indent <var>indent-spec</var>)) +</pre> +</div> <p> This results in the <code>lisp-indent-function</code> property being set on the macro name. </p> <p>Here are the possibilities for <var>indent-spec</var>: </p> <dl compact> <dt><code>nil</code></dt> <dd><p>This is the same as no property—use the standard indentation pattern. </p></dd> <dt><code>defun</code></dt> <dd><p>Handle this function like a ‘<samp>def</samp>’ construct: treat the second line as the start of a <em>body</em>. </p></dd> <dt>an integer, <var>number</var> +</dt> <dd><p>The first <var>number</var> arguments of the function are <em>distinguished</em> arguments; the rest are considered the body of the expression. A line in the expression is indented according to whether the first argument on it is distinguished or not. If the argument is part of the body, the line is indented <code>lisp-body-indent</code> more columns than the open-parenthesis starting the containing expression. If the argument is distinguished and is either the first or second argument, it is indented <em>twice</em> that many extra columns. If the argument is distinguished and not the first or second argument, the line uses the standard pattern. </p></dd> <dt>a symbol, <var>symbol</var> +</dt> <dd> +<p><var>symbol</var> should be a function name; that function is called to calculate the indentation of a line within this expression. The function receives two arguments: </p> <dl compact> <dt><var>pos</var></dt> <dd><p>The position at which the line being indented begins. </p></dd> <dt><var>state</var></dt> <dd><p>The value returned by <code>parse-partial-sexp</code> (a Lisp primitive for indentation and nesting computation) when it parses up to the beginning of this line. </p></dd> </dl> <p>It should return either a number, which is the number of columns of indentation for that line, or a list whose car is such a number. The difference between returning a number and returning a list is that a number says that all following lines at the same nesting level should be indented just like this one; a list says that following lines might call for different indentations. This makes a difference when the indentation is being computed by <kbd>C-M-q</kbd>; if the value is a number, <kbd>C-M-q</kbd> need not recalculate indentation for the following lines until the end of the list. </p> +</dd> </dl><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/Indenting-Macros.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Indenting-Macros.html</a> + </p> +</div> |
