unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#30213: 26.0.91; shell buffer not displayed when not erased and async-shell-command-display-buffer is used
@ 2018-01-22 20:10 Alex Branham
  2018-01-23  0:23 ` Basil L. Contovounesios
  2018-02-03 21:31 ` Juri Linkov
  0 siblings, 2 replies; 9+ messages in thread
From: Alex Branham @ 2018-01-22 20:10 UTC (permalink / raw)
  To: 30213


With async-shell-command-display-buffer set to t and
shell-command-dont-erase-buffer set to 'beg-last-output, async shell
buffers do not get displayed after the second async call, presumably
because the buffer doesn't get erased so there isn't a first line
written.


In GNU Emacs 26.0.91 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.26)
 of 2018-01-22 built on mars
Repository revision: 1fc98ed073a2d26ad941748ecb13aa6f47dd7b01
Windowing system distributor 'The X.Org Foundation', version 11.0.11906000
Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --mandir=/usr/share/man --with-mailutils
 --with-gameuser=:games --with-sound=alsa --with-modules --without-gconf
 --without-gsettings --without-gpm --without-m17n-flt
 --without-imagemagick --with-xml2 'CFLAGS=-march=x86-64 -mtune=generic
 -O2 -pipe -fstack-protector-strong -fno-plt'
 CPPFLAGS=-D_FORTIFY_SOURCE=2
 'LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now
 -fuse-ld=gold''

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND DBUS NOTIFY ACL GNUTLS LIBXML2 FREETYPE
LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 MODULES THREADS LIBSYSTEMD
LCMS2

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#30213: 26.0.91; shell buffer not displayed when not erased and async-shell-command-display-buffer is used
  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-02-03 21:31 ` Juri Linkov
  1 sibling, 1 reply; 9+ messages in thread
From: Basil L. Contovounesios @ 2018-01-23  0:23 UTC (permalink / raw)
  To: Alex Branham; +Cc: 30213

Alex Branham <alex.branham@gmail.com> writes:

> With async-shell-command-display-buffer set to t and
> shell-command-dont-erase-buffer set to 'beg-last-output, async shell
> buffers do not get displayed after the second async call, presumably
> because the buffer doesn't get erased so there isn't a first line
> written.

Just to clarify: are you setting shell-command-dont-erase-buffer to
beg-last-output or beg-last-out?  The former isn't a valid value for
this user option.

Either way, I cannot reproduce what I think you are doing in a build of
today's master branch, but I think it would help if you listed the
precise steps leading to the output buffer failing to display.

Thanks,

-- 
Basil





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#30213: 26.0.91; shell buffer not displayed when not erased and async-shell-command-display-buffer is used
  2018-01-23  0:23 ` Basil L. Contovounesios
@ 2018-01-23 14:53   ` Alex Branham
  2018-01-23 14:57     ` Alex Branham
  0 siblings, 1 reply; 9+ messages in thread
From: Alex Branham @ 2018-01-23 14:53 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: 30213

Rebuilding Emacs from the latest commit on the emacs-26 branch seems to have solved the issue, whatever it was.

Thanks!

On Mon 22 Jan 2018 at 18:23, Basil L. Contovounesios <contovob@tcd.ie> wrote:

> Alex Branham <alex.branham@gmail.com> writes:
>
>> With async-shell-command-display-buffer set to t and
>> shell-command-dont-erase-buffer set to 'beg-last-output, async shell
>> buffers do not get displayed after the second async call, presumably
>> because the buffer doesn't get erased so there isn't a first line
>> written.
>
> Just to clarify: are you setting shell-command-dont-erase-buffer to
> beg-last-output or beg-last-out?  The former isn't a valid value for
> this user option.
>
> Either way, I cannot reproduce what I think you are doing in a build of
> today's master branch, but I think it would help if you listed the
> precise steps leading to the output buffer failing to display.
>
> Thanks,






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#30213: 26.0.91; shell buffer not displayed when not erased and async-shell-command-display-buffer is used
  2018-01-23 14:53   ` Alex Branham
@ 2018-01-23 14:57     ` Alex Branham
  2018-01-23 18:53       ` Basil L. Contovounesios
  0 siblings, 1 reply; 9+ messages in thread
From: Alex Branham @ 2018-01-23 14:57 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: 30213

I'm sorry, haven't had my morning coffee yet. I can reproduce this, but there was an error in my initial email. From emacs -Q

(setq shell-command-dont-erase-buffer 'beg-last-out
      async-shell-command-display-buffer nil)

then do an async shell command, delete the window that shows the output, then call another async shell command. The window is never re-shown.

Alex

On Tue 23 Jan 2018 at 08:53, Alex Branham <alex.branham@gmail.com> wrote:

> Rebuilding Emacs from the latest commit on the emacs-26 branch seems to have solved the issue, whatever it was.
>
> Thanks!
>
> On Mon 22 Jan 2018 at 18:23, Basil L. Contovounesios <contovob@tcd.ie> wrote:
>
>> Alex Branham <alex.branham@gmail.com> writes:
>>
>>> With async-shell-command-display-buffer set to t and
>>> shell-command-dont-erase-buffer set to 'beg-last-output, async shell
>>> buffers do not get displayed after the second async call, presumably
>>> because the buffer doesn't get erased so there isn't a first line
>>> written.
>>
>> Just to clarify: are you setting shell-command-dont-erase-buffer to
>> beg-last-output or beg-last-out?  The former isn't a valid value for
>> this user option.
>>
>> Either way, I cannot reproduce what I think you are doing in a build of
>> today's master branch, but I think it would help if you listed the
>> precise steps leading to the output buffer failing to display.
>>
>> Thanks,






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#30213: 26.0.91; shell buffer not displayed when not erased and async-shell-command-display-buffer is used
  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
  0 siblings, 2 replies; 9+ messages in thread
From: Basil L. Contovounesios @ 2018-01-23 18:53 UTC (permalink / raw)
  To: Alex Branham; +Cc: 30213

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: 0001-Fix-deferred-display-of-async-shell-command-buffer.patch --]
[-- Type: text/x-diff, Size: 1291 bytes --]

From c236ef15477a7d76ee0420794f149bbcafdc8798 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Tue, 23 Jan 2018 18:18:04 +0000
Subject: [PATCH] Fix deferred display of async shell-command buffer

* 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
-- 
2.15.1


[-- Attachment #2: Type: text/plain, Size: 562 bytes --]


Alex Branham <alex.branham@gmail.com> writes:

> I'm sorry, haven't had my morning coffee yet. I can reproduce this, but there
> was an error in my initial email. From emacs -Q
>
> (setq shell-command-dont-erase-buffer 'beg-last-out
>       async-shell-command-display-buffer nil)
>
> then do an async shell command, delete the window that shows the output, then
> call another async shell command. The window is never re-shown.

Thanks, I'm able to reproduce this on both emacs-26 and master branches
and believe the attached patch fixes the issue.

-- 
Basil

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#30213: 26.0.91; shell buffer not displayed when not erased and async-shell-command-display-buffer is used
  2018-01-23 18:53       ` Basil L. Contovounesios
@ 2018-01-23 19:07         ` Alex Branham
  2018-01-23 19:30         ` Eli Zaretskii
  1 sibling, 0 replies; 9+ messages in thread
From: Alex Branham @ 2018-01-23 19:07 UTC (permalink / raw)
  To: Basil L. Contovounesios; +Cc: 30213

This seems to fix it for me, thanks!


On Tue 23 Jan 2018 at 12:53, Basil L. Contovounesios <contovob@tcd.ie> wrote:

> From c236ef15477a7d76ee0420794f149bbcafdc8798 Mon Sep 17 00:00:00 2001
> From: "Basil L. Contovounesios" <contovob@tcd.ie>
> Date: Tue, 23 Jan 2018 18:18:04 +0000
> Subject: [PATCH] Fix deferred display of async shell-command buffer
>
> * 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
> -- 
> 2.15.1
>
>
> Alex Branham <alex.branham@gmail.com> writes:
>
>> I'm sorry, haven't had my morning coffee yet. I can reproduce this, but there
>> was an error in my initial email. From emacs -Q
>>
>> (setq shell-command-dont-erase-buffer 'beg-last-out
>>       async-shell-command-display-buffer nil)
>>
>> then do an async shell command, delete the window that shows the output, then
>> call another async shell command. The window is never re-shown.
>
> Thanks, I'm able to reproduce this on both emacs-26 and master branches
> and believe the attached patch fixes the issue.






^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#30213: 26.0.91; shell buffer not displayed when not erased and async-shell-command-display-buffer is used
  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
  1 sibling, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2018-01-23 19:30 UTC (permalink / raw)
  To: Basil L. Contovounesios, Reuben Thomas; +Cc: alex.branham, 30213

> 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?





^ permalink raw reply	[flat|nested] 9+ messages in thread

* bug#30213: 26.0.91; shell buffer not displayed when not erased and async-shell-command-display-buffer is used
  2018-01-23 19:30         ` Eli Zaretskii
@ 2018-01-23 22:44           ` Basil L. Contovounesios
  0 siblings, 0 replies; 9+ messages in thread
From: Basil L. Contovounesios @ 2018-01-23 22:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: alex.branham, 30213, Reuben Thomas

[-- 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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* bug#30213: 26.0.91; shell buffer not displayed when not erased and async-shell-command-display-buffer is used
  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-02-03 21:31 ` Juri Linkov
  1 sibling, 0 replies; 9+ messages in thread
From: Juri Linkov @ 2018-02-03 21:31 UTC (permalink / raw)
  To: Alex Branham; +Cc: 30213-done

> With async-shell-command-display-buffer set to t and
> shell-command-dont-erase-buffer set to 'beg-last-output, async shell
> buffers do not get displayed after the second async call, presumably
> because the buffer doesn't get erased so there isn't a first line
> written.

Thanks for the report.  The fix implemented by Basil in bug#30280
is pushed now to the emacs-26 branch.





^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-02-03 21:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2018-02-03 21:31 ` Juri Linkov

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).