From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: Eli Zaretskii <eliz@gnu.org>
Cc: alex.branham@gmail.com, 30213@debbugs.gnu.org,
Reuben Thomas <rrt@sc3d.org>
Subject: bug#30213: 26.0.91; shell buffer not displayed when not erased and async-shell-command-display-buffer is used
Date: Tue, 23 Jan 2018 22:44:06 +0000 [thread overview]
Message-ID: <87zi54jivd.fsf@tcd.ie> (raw)
In-Reply-To: <83a7x4nzjq.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 23 Jan 2018 21:30:17 +0200")
[-- Attachment #1: Type: text/plain, Size: 1681 bytes --]
Eli Zaretskii <eliz@gnu.org> writes:
>> From: "Basil L. Contovounesios" <contovob@tcd.ie>
>> Date: Tue, 23 Jan 2018 18:53:13 +0000
>> Cc: 30213@debbugs.gnu.org
>>
>> * lisp/simple.el (shell-command): Display async command buffer on
>> process output for every invocation, not just the first. (bug#30213)
>> ---
>> lisp/simple.el | 4 +---
>> 1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/lisp/simple.el b/lisp/simple.el
>> index 3ac6b86381..20e22bf98f 100644
>> --- a/lisp/simple.el
>> +++ b/lisp/simple.el
>> @@ -3551,9 +3551,7 @@ shell-command
>> (add-function :before (process-filter proc)
>> (lambda (process _string)
>> (let ((buf (process-buffer process)))
>> - (when (and (zerop (buffer-size buf))
>> - (string= (buffer-name buf)
>> - bname))
>> + (when (string= (buffer-name buf) bname)
>> (display-buffer buf))))))))
>> ;; Otherwise, command is executed synchronously.
>> (shell-command-on-region (point) (point) command
>
> Looks like you are removing the feature we just introduced in Emacs
> 26, see commit 85512e7: it shows the shell buffer only if there is
> some output there. Or am I missing something?
This feature is implemented by the surrounding add-function advice on
the process filter, which I am not removing. Here is my patch in the
surrounding context of the async-shell-command-display-buffer switch:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: diff.diff --]
[-- Type: text/x-diff, Size: 1021 bytes --]
diff --git a/lisp/simple.el b/lisp/simple.el
index 3ac6b86381..20e22bf98f 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -3549,13 +3549,11 @@ shell-command
(if async-shell-command-display-buffer
(display-buffer buffer '(nil (allow-no-window . t)))
(add-function :before (process-filter proc)
(lambda (process _string)
(let ((buf (process-buffer process)))
- (when (and (zerop (buffer-size buf))
- (string= (buffer-name buf)
- bname))
+ (when (string= (buffer-name buf) bname)
(display-buffer buf))))))))
;; Otherwise, command is executed synchronously.
(shell-command-on-region (point) (point) command
output-buffer nil error-buffer)))))))
[-- Attachment #3: Type: text/plain, Size: 1107 bytes --]
When async-shell-command-display-buffer is non-nil, the output buffer is
displayed immediately. Otherwise, the buffer is displayed by the
(advised) process filter, which should only be invoked for
output-producing shell commands[1]. For example, the Unix null command
M-& : RET does not invoke the process filter.
Without my patch, the process filter advice only displays the output
buffer if it is already empty, i.e. if no previous shell-command
invocation has written output to the process buffer. This guard seems
to contradict the purpose of a non-nil shell-command-dont-erase-buffer
setting.
So, my patch continues to allow the immediate display of the output
buffer, irrespective of command output, when
async-shell-command-display-buffer is non-nil, as well as the deferred
and repeated display of the output buffer, irrespective of
shell-command-dont-erase-buffer and subject to command output, when
async-shell-command-display-buffer is nil.
[1] This assumption is based on observation, not expertise in process
filters; I cannot guarantee the absence of obscure edge cases.
--
Basil
next prev parent reply other threads:[~2018-01-23 22:44 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-22 20:10 bug#30213: 26.0.91; shell buffer not displayed when not erased and async-shell-command-display-buffer is used Alex Branham
2018-01-23 0:23 ` Basil L. Contovounesios
2018-01-23 14:53 ` Alex Branham
2018-01-23 14:57 ` Alex Branham
2018-01-23 18:53 ` Basil L. Contovounesios
2018-01-23 19:07 ` Alex Branham
2018-01-23 19:30 ` Eli Zaretskii
2018-01-23 22:44 ` Basil L. Contovounesios [this message]
2018-02-03 21:31 ` Juri Linkov
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zi54jivd.fsf@tcd.ie \
--to=contovob@tcd.ie \
--cc=30213@debbugs.gnu.org \
--cc=alex.branham@gmail.com \
--cc=eliz@gnu.org \
--cc=rrt@sc3d.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.