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 #162 received at 76313 <at> debbugs.gnu.org (full text, mbox):

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

>> 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.
>
> And the same cannot be done by calling replace-region-contents with
> MAX-SECS of zero?  If not, why not?

It certainly can.  I just think the difference in intended use-case and
behavior justify separate functions.

A replace-region function can be used in many places and is easy to
document.  The complexities of replace-region-contents which leak into
its signature and docstring are justified only in very few situations.

If replace-region-contents should do both jobs, quick and careful
replacements, it's hard to document.  Either you start with the quick
variant and have to say that MAX-SECS should be 0 (why? and why that
strange name?), or you start with the careful variant and append that a
MAX-SECS of 0 makes everything you've read until now meaningless.  And
that the frequently useful quick variant requires one explicit argument
more than the seldomly needed careful variant is a bit odd, too.

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.