I frequently launch external programs from emacs using M-!, such as Firefox or Evince, etc. Whenever I do, a buffer pops up full of results for the process, which clobbers whatever else I've got going on in terms of windows arrangement.

Is there a way to bury such buffers by default, so that I don't have to see them unless I decide to go looking for them?


4 Answers 4


Since mention that the command is running asynchronously I am assuming you mean the command async-shell-command bound to M-&. You can follow the advice in documentation of async-shell-command (you can read it by doing C-hfasync-shell-commandRET) customize display-buffer-alist as follows

(add-to-list 'display-buffer-alist (cons "\\*Async Shell Command\\*.*" (cons #'display-buffer-no-window nil)))

Now the buffer used by the command to display output will never be shown.

  • This works beautifully, thank you. Additionally, I didn't know about M-& either. I was using M-! and then manually adding the & to the command I passed to the shell. Commented Dec 19, 2014 at 18:12

Emacs has a general-purpose facility to prevent any unintentional (or indeed intentional) window configuration changes from causing problems.

Add (winner-mode 1) to your init file. Then when something messes up your windows, use C-c<left> (winner-undo) to restore them. You can use it repeatedly to undo multiple window configuration changes. C-c<right> (winner-redo) returns you to the most recent configuration.

  • Yes, I am a very enthusiastic user of Winner Mode! Commented Dec 19, 2014 at 18:12

Here's my configuration. It should work great if you're on Linux.

(require 'dired-aux)

(defvar dired-filelist-cmd
  '(("vlc" "-L")))

(defun dired-start-process (cmd &optional file-list)
   (let ((files (dired-get-marked-files t current-prefix-arg)))
      (dired-read-shell-command "& on %s: " current-prefix-arg files)
   cmd nil shell-file-name
   (format "nohup 1>/dev/null 2>/dev/null %s \"%s\""
           (if (> (length file-list) 1)
               (format "%s %s" cmd
                       (cadr (assoc cmd dired-filelist-cmd)))
           (mapconcat #'expand-file-name file-list "\" \""))))

(define-key dired-mode-map "r" 'dired-start-process)

Not only will it hide those pesky buffers when you e.g. open a pdf file from dired, Evince will persist even if you close Emacs. There's also a small customization for queuing up marked video files for a vlc playlist.


You can suppress that window for a single command instead of globally using let

(let ((display-buffer-alist
       (cons (cons "\\*Async Shell Command\\*.*"
                   (cons #'display-buffer-no-window nil))
             display-buffer-alist))) ;; suppress async shell command window
  (async-shell-command command))
  • I suggest (cons NEWTHING display-buffer-alist) instead of (list NEWTHING) so as not to completely inhibit the original alist.
    – phils
    Commented Feb 6, 2017 at 3:45
  • Good suggestion, implemented it.
    – killdash9
    Commented Feb 6, 2017 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.