GNU bug report logs - #76313
New function `replace-region`

Previous Next

Package: emacs;

Reported by: Stefan Monnier <monnier <at> iro.umontreal.ca>

Date: Sat, 15 Feb 2025 22:19:02 UTC

Severity: normal

Tags: patch

Full log


Message #156 received at 76313 <at> debbugs.gnu.org (full text, mbox):

From: Tassilo Horn <tsdh <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: phst <at> google.com, 76313 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 stefankangas <at> gmail.com
Subject: Re: bug#76313: New function `replace-region`
Date: Mon, 31 Mar 2025 08:21:56 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

> But I've changed my mind: I don't think we should unify
> `replace-region-contents` and my proposed `replace-region`.
>
> [...]
>
> While that was partly true, some of the problems were a lot more
> delicate: while `replace-region` is "easy" to use to do what I would
> describe as "edits", `replace-region-contents` is a good bit more
> delicate because its effect on point is less predictable.

I think that's a very good point.  Stefan's `replace-region` can be use
to replace text with some arbitrary other text with predictable
positioning of point.  `replace-region-contents` has always had the
assumption that the replacing text is very similar to the text it
replaces, e.g., a differently formatted version it.  Only in this
context it's sensible and intended that point doesn't move "out of the
middle" because only here we can assume the thing point is on is also
there in the replacing text.  (And, yes, the name
`replace-region-contents` doesn't transport that intention well.)

Bye,
Tassilo




This bug report was last modified 75 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.