GNU bug report logs - #18133
Suppressing asynchronous command output

Previous Next

Package: emacs;

Reported by: Reuben Thomas <rrt <at> sc3d.org>

Date: Mon, 28 Jul 2014 18:48:02 UTC

Severity: wishlist

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Reuben Thomas <rrt <at> sc3d.org>
To: Juri Linkov <juri <at> jurta.org>
Cc: 18133 <at> debbugs.gnu.org
Subject: bug#18133: Suppressing asynchronous command output
Date: Wed, 30 Jul 2014 10:16:25 +0100
[Message part 1 (text/plain, inline)]
On 30 July 2014 00:47, Juri Linkov <juri <at> jurta.org> wrote:

> > When using an asychronous command, e.g. & from dired-mode, it would be
> nice
> > if it didn't pop up the buffer until output was received. Often, no
> output
> > is received, for example, when using an asynchronous command to start an
> > external viewer (here, it makes sense to start it asynchronously, as the
> > user doesn't want Emacs to block until the viewer exits).
> >
> > This thread:
> > https://groups.google.com/forum/#!topic/gnu.emacs.help/xrs6ny67c_4
> > discusses the issue, and gives some workarounds and partial solutions;
> but
> > would there be any disadvantage to changing the behavior to pop up the
> > buffer when input arrives, and otherwise not do so?
>
> It's possible to display *Async Shell Command* only
> when the command finishes with empty input using:
>
>   (add-to-list 'display-buffer-alist '("\\*Async Shell Command\\*"
>                                        display-buffer-no-window (nil)))
>
>   (advice-add 'shell-command-sentinel :after
>               (lambda (process signal)
>                 (when (and (string-match-p "\\*Async Shell Command\\*"
>                                            (buffer-name (process-buffer
> process)))
>                            (memq (process-status process) '(exit signal))
>                            (not (zerop (buffer-size (process-buffer
> process)))))
>                   (display-buffer (process-buffer process)))))
>
> or when the first output is received:
>
>   (add-to-list 'display-buffer-alist '("\\*Async Shell Command\\*"
>                                        display-buffer-no-window (nil)))
>
>   (advice-add 'comint-output-filter :after
>               (lambda (process string)
>                 (when (and (string-match-p "\\*Async Shell Command\\*"
>                                            (buffer-name (process-buffer
> process))))
>                   (display-buffer (process-buffer process)))))
>

Thanks very much. The second form seems like the "right" one: when running
a command asynchronously, output should be immediately visible.

Is this suitable also to be used as the basis of a patch to Emacs?

-- 
http://rrt.sc3d.org
[Message part 2 (text/html, inline)]

This bug report was last modified 4 years and 301 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.