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

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

Re: Regexp search: syntax class for comment starter (\s<) does not work


From: Stefan Monnier
Subject: Re: Regexp search: syntax class for comment starter (\s<) does not work consistently in all modes
Date: Tue, 01 Oct 2019 21:44:14 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> by the way, at least in lisp-mode, \s< finds ";"
> inside a string as well).

Indeed, as I said, \s< only denotes those characters which the syntax
tables says "can" start a comment.  Whether they do depends on where
they are.

> I'm still pretty confused how bat-mode, for example, works as the
> syntax table doesn't contain < syntax.

There is no single char which starts a comment in bat-mode, since the
comment delimiter is composed of 3 characters ("rem") and only in some
places (e.g. "remember" doesn't count as a comment, even though it
starts with "rem").

Syntax-tables can handle 2-char comment delimiters (which covers
languages like C), and for more complex cases such as bat-mode's you
have to use `syntax-propertize-function` as does
`bat--syntax-propertize` to apply a `<` syntax to those `r` characters
which are part of the magic "rem" sequence.

You might like to read the syntax-tables chapter in the Elisp manual.


        Stefan




reply via email to

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