emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Improve `replace-regexp-in-string' ergonomics?


From: Stefan Monnier
Subject: Re: Improve `replace-regexp-in-string' ergonomics?
Date: Tue, 12 Oct 2021 11:48:55 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> (new-and-spiffy-regexp-replace string
>                                "\\(foo\\)" "bar\\1"
>                                "\\(bar\\)" "foo\\1"
>                                ...)
>
> should work just fine, no matter how many of them you have -- you just
> have to transpose the groups down to where they were again before doing
> the replacement.

That's right (and `syntax-propertize-rules` does indeed do that, tho
for the above example it would probably be better to do it differently).

> It will break down if the user has a lot of actual backrefs in the
> matching regexps, but that's quite rare in practice.

Indeed, tho IIRC the problem can occur even with just a single backref.


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]