[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Regexp search: syntax class for comment starter (\s<) does not work
Re: Regexp search: syntax class for comment starter (\s<) does not work consistently in all modes
Tue, 1 Oct 2019 23:08:40 +0300
On Fri, Sep 27, 2019 at 05:32:43PM -0400, Stefan Monnier wrote:
> > Seems that regexp search for comment starter syntax class, \s<,
> > doesn't work out of the box in ...
> It doesn't do what you think: it looks for characters with the < syntax.
> These chars are recognized as starting a comment (tho it depends where
> they appear, e.g. within a string), but they're not the only kinds of
> chars that can start a comment.
I see. I was hoping it would automatically "expand" to a regexp
containing the possible comment start character sequences in the
particular mode the buffer is in, regardless of the context (inside a
string, or not - by the way, at least in lisp-mode, \s< finds ";"
inside a string as well).
I'm still pretty confused how bat-mode, for example, works as the
syntax table doesn't contain < syntax. It does define a comment-start
variable, however. I took a quick look at search.c and regex.c, but I
guess it takes a while of digging around the innards of emacs to get
some understanding. Sounds like an interesting challenge. But perhaps
> If you want to look for comments, you're probably better off using
> something like comment-search-forward (or comment-start-skip).
Right, I'll take a look at these next, it sounds they're good matches
for my current use case.
- Re: Regexp search: syntax class for comment starter (\s<) does not work consistently in all modes,
Janne Nykopp <=