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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 76313 <at> debbugs.gnu.org
Subject: Re: bug#76313: New function `replace-region`
Date: Tue, 18 Feb 2025 08:30:16 -0500
>  (replace-buffer-contents SOURCE &optional MAX-SECS MAX-COSTS CHEAP-AND-RECKLESS)

Hmm... I don't think people will be happy to replace their

    (insert foo)
    (delete-region from to)

with

    (save-restriction
      (narrow-to-region from to)
      (replace-buffer-contents foo nil nil 'cheap))

Without mentioning that it would be a backward-incompatible change because
currently `replace-buffer-contents` considers a string argument as the
name of a buffer.

> where, if CHEAP-AND-RECKLESS is non-nil, we call replace_region
> disregarding what will that do to markers and overlays?  If you want
> to support INHERIT, CHEAP-AND-RECKLESS could be also non-nil and non-t
> to indicate that.

FWIW, `minibuffer--replace` seems to want INHERIT at the same time as
"fancy".  Tho I must admit that I can't remember why I needed
INHERIT there.  Maybe because of insertion in a field?

> I can live with that; at least we stay with the
> same 2 APIs, of which one is implemented on top of the other.

`replace-region-contents` is a bad API (the REPLACE-FN part is a bad
idea, all the callers I could find would be better served if they could
pass a string instead): we should obsolete it.


        Stefan





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.