all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* async-shell-command
@ 2016-04-16  7:54 Marcin Borkowski
  2016-04-16 20:44 ` async-shell-command John Wiegley
  0 siblings, 1 reply; 6+ messages in thread
From: Marcin Borkowski @ 2016-04-16  7:54 UTC (permalink / raw)
  To: emacs-devel

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



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-04-19 20:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-16  7:54 async-shell-command Marcin Borkowski
2016-04-16 20:44 ` async-shell-command John Wiegley
2016-04-18 19:56   ` async-shell-command Marcin Borkowski
2016-04-18 20:09     ` async-shell-command Drew Adams
2016-04-19  0:47     ` async-shell-command John Wiegley
2016-04-19 20:30       ` async-shell-command Marcin Borkowski

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.