help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to get forward-comment work for major mode that can't use syntax


From: Stefan Monnier
Subject: Re: How to get forward-comment work for major mode that can't use syntax for all comments?
Date: Tue, 15 Apr 2025 18:03:18 -0400
User-agent: Gnus/5.13 (Gnus v5.13)

> Reading about `syntax-propertize-function` still leaves me wondering
> how I should handle this.

`grep` is your friend: look for other packages using
`syntax-propertize-function` to find examples.  The simplest ones
probably use `syntax-propertize-rules` to define the function.

> If there was no other use of the '#' character in Seed7 I could handle
> the syntax by the following 2 calls to `modify-syntax-table':
>
>     (modify-syntax-entry ?# ". 12c" st)
>     (modify-syntax-entry ?\n "> c" st)
>
> Should I use these lines in addition of a function that can be identified
> as a `syntax-propertize-function', and the goal of that function would
> be to identify the places where '#' is not identifying a comment

Yes.

> From section 36.4 about syntax-propertize-function:
>   Caution: When this variable is non-nil, Emacs removes syntax-table
>   text properties arbitrarily and relies on syntax-propertize-function to
> reapply them.
>   Thus if this facility is used at all, the function must apply all
> syntax-table text
>   properties used by the major mode.

This talks about *text properties*.  They're used only to override
locally the buffer-local syntax-table.

> I must admit I sometimes think the documentation would be more useful with
> context and examples...

Emacs comes with megabytes of ELisp code.  That seems like a rather
generous amount of examples.  Also, if the doc was perfect, we'd never
get to talk to our users.  🙂


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]