unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: help-gnu-emacs@gnu.org
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	[thread overview]
Message-ID: <jwvy2y4x70y.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: 20191001200840.6p3fi2wsmnbxacnl@peruna.fi

> 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	other threads:[~2019-10-02  1:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-27 20:22 Regexp search: syntax class for comment starter (\s<) does not work consistently in all modes Janne Nykopp
2019-09-27 21:32 ` Stefan Monnier
2019-10-01 20:08   ` Janne Nykopp
2019-10-02  1:44     ` Stefan Monnier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvy2y4x70y.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).