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

From: Eli Zaretskii <[email-masked]>
Date: Tue, 18 Feb 2025 17:36:21 +0200

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

Then how about reimplementing replace-region-contents in C, and making
a similar change (an additional optional arg) to it instead?

> `replace-region-contents` is a bad API

Why is it bad?