From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: Removing no-back-reference restriction from syntax-propertize-rules
Date: Sun, 17 May 2020 19:57:24 -0400 [thread overview]
Message-ID: <jwvmu666ru4.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87wo5cff39.fsf@gnu.org> (Tassilo Horn's message of "Sat, 16 May 2020 10:39:54 +0200")
> -(defun syntax-propertize--shift-groups (re n)
> - (replace-regexp-in-string
> - "\\\\(\\?\\([0-9]+\\):"
> - (lambda (s)
> - (replace-match
> - (number-to-string (+ n (string-to-number (match-string 1 s))))
> - t t s 1))
> - re t t))
> +(defun syntax-propertize--shift-groups-and-backrefs (re n)
> + (let ((incr (lambda (s)
> + (replace-match
> + (number-to-string
> + (+ n (string-to-number (match-string 1 s))))
> + t t s 1))))
> + (replace-regexp-in-string
> + "[^\\]\\\\\\([0-9]+\\)" incr
> + (replace-regexp-in-string "\\\\(\\?\\([0-9]+\\):" incr re t t)
> + t t)))
I think it's OK, but I think the risk of false positives for `\N` is
sufficiently high (compared to that for `\(?N:`) that I think we need to
be more careful and use `subregexp-context-p`.
Stefan
next prev parent reply other threads:[~2020-05-17 23:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-16 8:39 Removing no-back-reference restriction from syntax-propertize-rules Tassilo Horn
2020-05-16 13:17 ` Stefan Monnier
2020-05-16 13:56 ` Tassilo Horn
2020-05-17 2:41 ` Stefan Monnier
2020-05-17 23:57 ` Stefan Monnier [this message]
2020-05-18 18:20 ` Tassilo Horn
2020-05-18 19:30 ` Stefan Monnier
2020-05-18 21:30 ` Tassilo Horn
2020-05-19 2:58 ` Stefan Monnier
2020-05-19 13:28 ` Tassilo Horn
2020-05-19 15:06 ` Stefan Monnier
2020-05-19 18:54 ` Tassilo Horn
2020-05-19 18:55 ` 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=jwvmu666ru4.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=emacs-devel@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.
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).