Subject: Re: bug#76313: New function `replace-region`

From: Stefan Monnier <[email-masked]>
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