unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: emacs-devel <emacs-devel@gnu.org>
Subject: Re: [elpa] externals/xr e77aa97: Postfix ops are literal after ^ but not after \(?:^\)
Date: Tue, 19 Feb 2019 22:05:52 +0100	[thread overview]
Message-ID: <4F49EFF3-C19A-4998-8686-DC528539D3B4@acm.org> (raw)
In-Reply-To: <jwvy36bfrw2.fsf-monnier+emacsdiffs@gnu.org>

19 feb. 2019 kl. 21.29 skrev Stefan Monnier <monnier@IRO.UMontreal.CA>:
> 
>>    Postfix ops are literal after ^ but not after \(?:^\)
> 
> BTW, some of those details of the syntax of regexps are really
> undesirable.  Would it be possible for xr to flag them somehow to try
> and discourage their use?
> 
> Of course, even better would be to flag such uses not only in xr but
> more generally.  I'm thinking for example of a regexp that starts with
> a postfix operator or that backslash-escapes a non-special character.

The xr machinery could probably be reused for that sort of linting, yes, but whether it's a good place depends on how we want to use it. It could be used in static linting of regexps in elisp string literals, but with false positives and negatives. Putting it in regex-emacs.c would allow for exact detection but only of those actually used during execution.

By the way, the reason for fixing this rather minor bug in xr, apart from general perfectionism, was a bug in rx: bol and eol are unconditionally translated to ^ and $ no matter where they occur. For example:

(rx "a" bol "b" eol "c")
=>
"a^b$c"  (which means literally "a^b$c")

(rx (zero-or-more bol))
=>
"^*"     (which means literally "^*")

rx should bracket the ^$ stuff and generate something like "a\\(?:^\\)b\\(?:$\\)c" and "\\(?:^\\)*".





  reply	other threads:[~2019-02-19 21:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190219201441.31417.54763@vcs0.savannah.gnu.org>
     [not found] ` <20190219201444.721BF20477@vcs0.savannah.gnu.org>
2019-02-19 20:29   ` [elpa] externals/xr e77aa97: Postfix ops are literal after ^ but not after \(?:^\) Stefan Monnier
2019-02-19 21:05     ` Mattias Engdegård [this message]
2019-02-20 12:06     ` Mattias Engdegård
2019-02-21  1:35       ` Stefan Monnier
2019-02-21  9:27         ` Mattias Engdegård

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=4F49EFF3-C19A-4998-8686-DC528539D3B4@acm.org \
    --to=mattiase@acm.org \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@IRO.UMontreal.CA \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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