Subject: Re: bug#5618: 23.1.91; shell-command-on-region unexpectedly erases buffer

From: Lars Ingebrigtsen <[email-masked]>
Date: Thu, 27 Jan 2022 19:31:08 +0100

[email-masked] writes:

> - Start with some buffer with text in it. *scratch* will do fine.
> - Put point somewhere in text
> - evaluate (shell-command-on-region (point) (point) "/bin/date" (current-buffer) nil)
>
> (The actual values of START and END are irrelevant, though).
>
> The whole content of the buffer gets replaced by output of
> command. According to the doc, I'd expect the ouput to be inserted
> before point.

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

The behaviour has now been documented as such:

----
Optional fourth arg OUTPUT-BUFFER specifies where to put the
command's output.  If the value is a buffer or buffer name,
erase that buffer and insert the output there; a non-nil value of
`shell-command-dont-erase-buffer' prevent to erase the buffer.
If the value is nil, use the buffer specified by `shell-command-buffer-name'.
Any other non-nil value means to insert the output in the
current buffer after START.
----

And we've grown an extra user option (that's...  pretty confusing in
itself, I think).  So while the semantics here are far less than ideal,
I don't think there's anything further to do here, and I'm closing this
bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no