|
From: | Stefan Monnier |
Subject: | Re: Removing no-back-reference restriction from syntax-propertize-rules |
Date: | Sun, 17 May 2020 19:57:24 -0400 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> -(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
[Prev in Thread] | Current Thread | [Next in Thread] |