unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Janne Nykopp <newcup@peruna.fi>
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, 1 Oct 2019 23:08:40 +0300	[thread overview]
Message-ID: <20191001200840.6p3fi2wsmnbxacnl@peruna.fi> (raw)
In-Reply-To: <jwv36gh5sxb.fsf-monnier+emacs@gnu.org>

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
later, as:

> 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.

Thank you!

Best regards,
Janne Nykopp 



  reply	other threads:[~2019-10-01 20:08 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 [this message]
2019-10-02  1:44     ` Stefan Monnier

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=20191001200840.6p3fi2wsmnbxacnl@peruna.fi \
    --to=newcup@peruna.fi \
    --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).