unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Mattias Engdegård" <mattiase@acm.org>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Shigeru Fukaya <shigeru.fukaya@gmail.com>,
	44861@debbugs.gnu.org, Stefan Kangas <stefankangas@gmail.com>,
	Dmitry Gutov <dgutov@yandex.ru>
Subject: bug#44861: 27.1; [PATCH] signal in `replace-regexp-in-string'
Date: Thu, 26 Nov 2020 15:54:56 +0100	[thread overview]
Message-ID: <5722D619-98C0-421B-84B5-F30B858FBDF8@acm.org> (raw)
In-Reply-To: <87zh34p64t.fsf@gnus.org>

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	other threads:[~2020-11-26 14:54 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-25  4:02 bug#44861: 27.1; [PATCH] signal in `replace-regexp-in-string' Shigeru Fukaya
2020-11-25 10:58 ` Mattias Engdegård
2020-11-25 14:58   ` Mattias Engdegård
2020-11-25 21:39     ` Stefan Kangas
2020-11-26 12:57       ` Mattias Engdegård
2020-11-26 13:12         ` Lars Ingebrigtsen
2020-11-26 13:39           ` Mattias Engdegård
2020-11-26 14:03             ` Lars Ingebrigtsen
2020-11-26 14:54               ` Mattias Engdegård [this message]
2020-11-29 13:28               ` Basil L. Contovounesios
2020-11-26 13:43           ` Stefan Kangas
2020-11-26 14:03             ` Lars Ingebrigtsen
2020-11-26 14:41             ` Eli Zaretskii

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=5722D619-98C0-421B-84B5-F30B858FBDF8@acm.org \
    --to=mattiase@acm.org \
    --cc=44861@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=larsi@gnus.org \
    --cc=shigeru.fukaya@gmail.com \
    --cc=stefankangas@gmail.com \
    /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).