emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

async-shell-command


From: Marcin Borkowski
Subject: async-shell-command
Date: Sat, 16 Apr 2016 09:54:20 +0200
User-agent: mu4e 0.9.13; emacs 25.1.50.8

Hi Emacs devs,

I have a minor issue with the `async-shell-command'.  I'd like it not to
display the *Async Shell Command* buffer (and I modified
`display-buffer-alist' accordingly), but then again /sometimes/ I want
to see that buffer.  It is only natural to use the prefix argument for
that, so here's what I did:

--8<---------------cut here---------------start------------->8---
(defun async-shell-dispatch (orig-fun command &optional output-buffer 
error-buffer)
  "If OUTPUT-BUFFER is '(4) (i.e., C-u), temporarily turn off
blocking of displaying the output-buffer."
  (if (equal output-buffer '(4))
      (let ((display-buffer-alist
             (remove '("^*Async Shell Command*" . (display-buffer-no-window)) 
display-buffer-alist)))
        (funcall orig-fun command nil error-buffer))
    (funcall orig-fun command output-buffer error-buffer)))

(advice-add 'async-shell-command :around 'async-shell-dispatch)
--8<---------------cut here---------------end--------------->8---

(BTW, I described all that on my blog:
http://mbork.pl/2016-04-07_Hiding_those_annoying_Async_Shell_Command_buffers
http://mbork.pl/2016-04-12_Showing_some_of_those_Async_Shell_Command_buffers)

Of course, this is extremely hackish.  I thought that stock Emacs could
use the prefix argument to `async-shell-command' for something else than
"make this synchronous after all, and put the result at point", which
seems odd (and not documented, btw).  For instance, C-u M-& might /not/
show the *Async Shell Command* buffer, and when some option is set, this
hiding/showing behavior would be reversed (as in my solution).  OTOH,
maybe the current way of doing things is fine, and just needs mentioning
in the docstring?

Any ideas?  WDYT?

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



reply via email to

[Prev in Thread] Current Thread [Next in Thread]