diff options
Diffstat (limited to 'devdocs/elisp/syntax-properties.html')
| -rw-r--r-- | devdocs/elisp/syntax-properties.html | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/devdocs/elisp/syntax-properties.html b/devdocs/elisp/syntax-properties.html new file mode 100644 index 00000000..88f4dd58 --- /dev/null +++ b/devdocs/elisp/syntax-properties.html @@ -0,0 +1,18 @@ + <h3 class="section">Syntax Properties</h3> <p>When the syntax table is not flexible enough to specify the syntax of a language, you can override the syntax table for specific character occurrences in the buffer, by applying a <code>syntax-table</code> text property. See <a href="text-properties">Text Properties</a>, for how to apply text properties. </p> <p>The valid values of <code>syntax-table</code> text property are: </p> <dl compact> <dt><var>syntax-table</var></dt> <dd> +<p>If the property value is a syntax table, that table is used instead of the current buffer’s syntax table to determine the syntax for the underlying text character. </p> </dd> <dt><code>(<var>syntax-code</var> . <var>matching-char</var>)</code></dt> <dd> +<p>A cons cell of this format is a raw syntax descriptor (see <a href="syntax-table-internals">Syntax Table Internals</a>), which directly specifies a syntax class for the underlying text character. </p> </dd> <dt><code>nil</code></dt> <dd><p>If the property is <code>nil</code>, the character’s syntax is determined from the current syntax table in the usual way. </p></dd> </dl> <dl> <dt id="parse-sexp-lookup-properties">Variable: <strong>parse-sexp-lookup-properties</strong> +</dt> <dd><p>If this is non-<code>nil</code>, the syntax scanning functions, like <code>forward-sexp</code>, pay attention to <code>syntax-table</code> text properties. Otherwise they use only the current syntax table. </p></dd> +</dl> <dl> <dt id="syntax-propertize-function">Variable: <strong>syntax-propertize-function</strong> +</dt> <dd> +<p>This variable, if non-<code>nil</code>, should store a function for applying <code>syntax-table</code> properties to a specified stretch of text. It is intended to be used by major modes to install a function which applies <code>syntax-table</code> properties in some mode-appropriate way. </p> <p>The function is called by <code>syntax-ppss</code> (see <a href="position-parse">Position Parse</a>), and by Font Lock mode during syntactic fontification (see <a href="syntactic-font-lock">Syntactic Font Lock</a>). It is called with two arguments, <var>start</var> and <var>end</var>, which are the starting and ending positions of the text on which it should act. It is allowed to arbitrarily move point within the region delimited by <var>start</var> and <var>end</var>; such motions don’t need to use <code>save-excursion</code> (see <a href="excursions">Excursions</a>). It is also allowed to call <code>syntax-ppss</code> on any position before <var>end</var>, but if a Lisp program calls <code>syntax-ppss</code> on some position and later modifies the buffer at some earlier position, then it is that program’s responsibility to call <code>syntax-ppss-flush-cache</code> to flush the now obsolete info from the cache. </p> <p><strong>Caution:</strong> When this variable is non-<code>nil</code>, Emacs removes <code>syntax-table</code> text properties arbitrarily and relies on <code>syntax-propertize-function</code> to reapply them. Thus if this facility is used at all, the function must apply <strong>all</strong> <code>syntax-table</code> text properties used by the major mode. In particular, Modes derived from a CC Mode mode must not use this variable, since CC Mode uses other means to apply and remove these text properties. </p> +</dd> +</dl> <dl> <dt id="syntax-propertize-extend-region-functions">Variable: <strong>syntax-propertize-extend-region-functions</strong> +</dt> <dd> +<p>This abnormal hook is run by the syntax parsing code prior to calling <code>syntax-propertize-function</code>. Its role is to help locate safe starting and ending buffer positions for passing to <code>syntax-propertize-function</code>. For example, a major mode can add a function to this hook to identify multi-line syntactic constructs, and ensure that the boundaries do not fall in the middle of one. </p> <p>Each function in this hook should accept two arguments, <var>start</var> and <var>end</var>. It should return either a cons cell of two adjusted buffer positions, <code>(<var>new-start</var> . <var>new-end</var>)</code>, or <code>nil</code> if no adjustment is necessary. The hook functions are run in turn, repeatedly, until they all return <code>nil</code>. </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/Syntax-Properties.html" class="_attribution-link">https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-Properties.html</a> + </p> +</div> |
