Subject: bug#18326: 24.4.50; allow-no-window for async-shell-command in temp buffer

From: Joe Corneli <[email-masked]>
Date: Tue, 26 Aug 2014 23:59:29 +0100

Hi Stefan:

I tried this:

(setq display-buffer-alist
      '(("\\*Async Shell Command\\*" . (display-buffer-no-window . nil))))

(defun sudo-shell-command (command)
  (interactive "MShell command (root): ")
    (with-temp-buffer
      (cd "/sudo::/")
      (async-shell-command command)))

(sudo-shell-command "touch /dev/null")

The buffer still pops up.

The docs say:

(async-shell-command COMMAND &optional OUTPUT-BUFFER ERROR-BUFFER)
[...]
To run COMMAND without displaying the output
in a window you can configure `display-buffer-alist' to use the action
`display-buffer-no-window' for the buffer `*Async Shell Command*'.

OK, would be be able to tell me how I do that?  It seems that I've now
tried two seemingly sensible ways to do this configuration, and the
docs led me to the previous configuration, and not clearly to anything
else.

display-buffer-alist is a variable defined in `window.el'.
[...]
This is a list of elements (CONDITION . ACTION), where:

 CONDITION is either a regexp matching buffer names, or a
  function that takes two arguments - a buffer name and the
  ACTION argument of `display-buffer' - and returns a boolean.

 ACTION is a cons cell (FUNCTION . ALIST), where FUNCTION is a
  function or a list of functions.  Each such function should
  accept two arguments: a buffer to display and an alist of the
  same form as ALIST.  See `display-buffer' for details.

(display-buffer-no-window BUFFER ALIST)
[...]
Display BUFFER in no window.
If ALIST has a non-nil `allow-no-window' entry, then don't display
a window at all.