Subject: Re: bug#18133: Suppressing asynchronous command output

From: martin rudalics <[email-masked]>
Date: Sat, 24 Dec 2016 10:16:34 +0100

> Here is the implementation I currently use (from Juri Linkov, message #8,
 > second block of code):
 >
 > (advice-add 'comint-output-filter :after
 >              "Stop Async Shell Command output from appearing until there is
 > output."
 >              (lambda (process string)
 >                (when (and (string-match-p "\\*Async Shell Command\\*"
 >                                           (buffer-name (process-buffer
 > process))))
 >                  (display-buffer (process-buffer process)))))
 >
 > I think this does what you say: whenever some output arrives, the buffer
 > pops up. It does not involve changing the behaviour of display-buffer.
 >
 > All my patch does is move the advice into a function suitable for
 > comint-output-filter-functions.

To turn this into a minor mode I would do two things:

(1) Add an entry to ‘display-buffer-overriding-action’ so that the
     buffer is not displayed right away.

(2) Get rid of the advice, maybe by doing the display at the end of
     ‘comint-output-filter-functions’.

 > But I'm still confused by how you
 >> >want to add something to ‘display-buffer-alist’ and at the same time to
 >> >not change the behavior of ‘display-buffer’;-)
 > ​
 > I suggested adding an option to display-buffer-alist's defcustom
 > specification, something like:
 >
 >                  :options (((regexp "\\*Async Shell Command\\*") (function
 > display-buffer-no-window)))
 >
 > By default, this is not selected, so it does not change the default
 > behaviour.

Please don't do such things.  Within a couple of months we would be back
where we were before the introduction of ‘display-buffer-alist’.

 > I currently simply add an item to display-buffer-alist:
 >
 > (add-to-list 'display-buffer-alist '("\\*Async Shell Command\\*"
 >                                       display-buffer-no-window))

If you now try to customize ‘display-buffer-alist’, you'll be told that
this option has been "CHANGED outside Customize".  You can avoid that by
doing

(customize-save-variable
  'display-buffer-alist
  (add-to-list
   'display-buffer-alist '("\\*Async Shell Command\\*"
			  display-buffer-no-window)))

instead.

martin