diff options
Diffstat (limited to 'devdocs/elisp/splicing-into-lists.html')
| -rw-r--r-- | devdocs/elisp/splicing-into-lists.html | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/devdocs/elisp/splicing-into-lists.html b/devdocs/elisp/splicing-into-lists.html new file mode 100644 index 00000000..6df95ac5 --- /dev/null +++ b/devdocs/elisp/splicing-into-lists.html @@ -0,0 +1,12 @@ + <h4 class="subsection">Splicing into Lists</h4> <p>The <code>:inline</code> feature lets you splice a variable number of elements into the middle of a <code>list</code> or <code>vector</code> customization type. You use it by adding <code>:inline t</code> to a type specification which is contained in a <code>list</code> or <code>vector</code> specification. </p> <p>Normally, each entry in a <code>list</code> or <code>vector</code> type specification describes a single element type. But when an entry contains <code>:inline t</code>, the value it matches is merged directly into the containing sequence. For example, if the entry matches a list with three elements, those become three elements of the overall sequence. This is analogous to ‘<samp>,@</samp>’ in a backquote construct (see <a href="backquote">Backquote</a>). </p> <p>For example, to specify a list whose first element must be <code>baz</code> and whose remaining arguments should be zero or more of <code>foo</code> and <code>bar</code>, use this customization type: </p> <div class="example"> <pre class="example">(list (const baz) (set :inline t (const foo) (const bar))) +</pre> +</div> <p>This matches values such as <code>(baz)</code>, <code>(baz foo)</code>, <code>(baz bar)</code> and <code>(baz foo bar)</code>. </p> <p>When the element-type is a <code>choice</code>, you use <code>:inline</code> not in the <code>choice</code> itself, but in (some of) the alternatives of the <code>choice</code>. For example, to match a list which must start with a file name, followed either by the symbol <code>t</code> or two strings, use this customization type: </p> <div class="example"> <pre class="example">(list file + (choice (const t) + (list :inline t string string))) +</pre> +</div> <p>If the user chooses the first alternative in the choice, then the overall list has two elements and the second element is <code>t</code>. If the user chooses the second alternative, then the overall list has three elements and the second and third must be strings. </p> <p>The widgets can specify predicates to say whether an inline value matches the widget with the <code>:match-inline</code> element. </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/Splicing-into-Lists.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Splicing-into-Lists.html</a> + </p> +</div> |
