bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#44861: 27.1; [PATCH] signal in `replace-regexp-in-string'


From: Mattias Engdegård
Subject: bug#44861: 27.1; [PATCH] signal in `replace-regexp-in-string'
Date: Thu, 26 Nov 2020 15:54:56 +0100

26 nov. 2020 kl. 15.03 skrev Lars Ingebrigtsen <larsi@gnus.org>:

> I started looking at that, and there's a huge pile of calls like
> 
> (replace-regexp-in-string ":" ";" string)
> 
> that can be rewritten to use string-replace.  But!  Every single case
> requires careful analysis, exactly because replace-regexp-in-string sets
> the match data.

No it doesn't; the entire body is wrapped in save-match-data.
It does set the match data locally for use in the replacement function, if any, 
but then string-replace cannot be used anyway.

There are other things that may need investigating for a switch to 
string-replace: whether case-folding is relevant, and whether a nil-or-absent 
argument to FIXEDCASE is intended, an oversight, or irrelevant.

In my experience, most code does not take case-folding into account at all or 
tacitly assume it does not apply. (Having a global variable controlling it is a 
terrible interface, by the way.) Similarly, most calls that omit FIXEDCASE do 
it without any thought that the replacement would be anything but literal. 
Thus, the risk isn't very big for either but these are still issues requiring 
some consideration.






reply via email to

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