unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Madhu <madhu@cs.unm.edu>, Tino Calancha <tino.calancha@gmail.com>
Cc: 39067@debbugs.gnu.org
Subject: bug#39067: shell-command-dont-erase-buffer strange behaviour
Date: Sat, 11 Jan 2020 11:25:18 +0200	[thread overview]
Message-ID: <834kx28hvl.fsf@gnu.org> (raw)
In-Reply-To: <xfezhevkh7p.fsf@cs.unm.edu> (message from Madhu on Fri, 10 Jan 2020 05:34:18 +0000)

> From: Madhu <madhu@cs.unm.edu>
> 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	other threads:[~2020-01-11  9:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-10  5:34 bug#39067: shell-command-dont-erase-buffer strange behaviour Madhu
2020-01-11  9:25 ` Eli Zaretskii [this message]
2020-01-11  9:57   ` Michael Albinus
2020-01-13 20:22   ` Tino Calancha
2020-01-14  8:49     ` Michael Albinus
2020-01-19 10:19       ` Tino Calancha
2020-01-19 18:05         ` Glenn Morris
2020-01-19 20:55           ` Tino Calancha
2020-01-20  3:25             ` Eli Zaretskii
2020-01-20 13:20               ` Tino Calancha
2020-02-01 13:36       ` Michael Albinus
2020-01-20 10:04 ` Mattias Engdegård
2020-01-20 13:21   ` Tino Calancha
2020-01-20 13:30     ` Mattias Engdegård

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=834kx28hvl.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=39067@debbugs.gnu.org \
    --cc=madhu@cs.unm.edu \
    --cc=tino.calancha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).