unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Marcin Borkowski <mbork@mbork.pl>
To: emacs-devel <emacs-devel@gnu.org>
Subject: async-shell-command
Date: Sat, 16 Apr 2016 09:54:20 +0200	[thread overview]
Message-ID: <87a8kuugyb.fsf@mbork.pl> (raw)

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	other threads:[~2016-04-16  7:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-16  7:54 Marcin Borkowski [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a8kuugyb.fsf@mbork.pl \
    --to=mbork@mbork.pl \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).