bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#39067: shell-command-dont-erase-buffer strange behaviour


From: Eli Zaretskii
Subject: bug#39067: shell-command-dont-erase-buffer strange behaviour
Date: Sat, 11 Jan 2020 11:25:18 +0200

> From: Madhu <address@hidden>
> Date: Fri, 10 Jan 2020 05:34:18 +0000
> 
> C-h v shell-command-dont-erase-buffer
> C-h f shell-command
> 
> Cut to the chase with the test case:
> 
> (let ((shell-command-dont-erase-buffer 'beg-last-out))
>   (with-current-buffer (get-buffer-create "OUT")
>     (erase-buffer)
>     (shell-command "/bin/echo FOO" t)
>     (shell-command "/bin/echo FOO" t)))
> 
> The result (as expected) is a buffer named OUT with 2 lines FOO.
> The same result is expected with the following code:
> 
> (let ((shell-command-dont-erase-buffer 'beg-last-out))
>   (with-current-buffer (get-buffer-create "OUT")
>     (erase-buffer)
>     (shell-command "/bin/echo FOO" "OUT")
>     (shell-command "/bin/echo FOO" "OUT")))
> 
> However in this case (and in some other cases) shell-command erases the
> "OUT" buffer despite a non-NIL binding of
> shell-command-dont-erase-buffer
> 
> (at least since emacs 25.2)

AFAICT, there's a small mess here.  shell-command sometimes calls
shell-command-on-region, and sometimes calls
call-process-shell-command.  The shell-command-dont-erase-buffer
option is only tested in shell-command-on-region, and it only prevents
erasing the buffer if OUTPUT-BUFFER is _different_ from the current
buffer.  Which explains why the second recipe does still erase the
buffer: remove the with-current-buffer part, and it will work as you
expected.  When shell-command calls call-process-shell-command, which
happens in the first case, the buffer is _never_ erased, regardless of
the value of shell-command-dont-erase-buffer.

IOW, this feature is not working as advertised in several important
use case, and never did AFAICT.  Its implementation is incomplete.

Tino, could you please look into this, and fix this stuff so that this
variable affects all invocations of shell-command?

Thanks.





reply via email to

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