emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC]: replace-region-contents


From: Stefan Monnier
Subject: Re: [RFC]: replace-region-contents
Date: Sun, 03 Feb 2019 12:05:57 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>> PS: I wish replace-buffer-contents interpreted a string as the text to
>> use as replacement rather than as a buffer name
> You'd need to insert the string into a buffer anyway, before you could
> run the code, so might as well do that in Lisp.

I was only talking about the API, not the implementation.  If I had to
implement the feature, I'd likely rename replace-buffer-contents to
internal--replace-buffer-contents and do the string->buffer conversion
in an Elisp wrapper, simply as a convenience to the user.

`replace-buffer-contents` is basically a fancy replacement for
delete-region + insert and `insert` accepts a string as argument, so
it's very natural to also accept a string as argument.

> (I find text processing based on strings a bad idea in Emacs, btw.

Agreed.

In the case of replace-buffer-contents, I think we could have an equally
efficient code that accepts a string instead of a buffer.  But it'd
definitely be inconvenient to write code that works both ways.

> Buffers are much more convenient and efficient.)

I find strings standing for buffers to be ugly and a source of bugs
(because buffer names can change), so even if we don't accept strings as
I suggested above, I'd prefer that we signal an error when we receive
a string rather than silently looking for a buffer that has the
same name.


        Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]