From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.devel Subject: async-shell-command Date: Sat, 16 Apr 2016 09:54:20 +0200 Message-ID: <87a8kuugyb.fsf@mbork.pl> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1460793315 25728 80.91.229.3 (16 Apr 2016 07:55:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 16 Apr 2016 07:55:15 +0000 (UTC) To: emacs-devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Apr 16 09:55:06 2016 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1arL4L-0006Cr-K9 for ged-emacs-devel@m.gmane.org; Sat, 16 Apr 2016 09:55:05 +0200 Original-Received: from localhost ([::1]:50801 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1arL4K-00073T-Me for ged-emacs-devel@m.gmane.org; Sat, 16 Apr 2016 03:55:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55160) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1arL45-0006xk-7x for emacs-devel@gnu.org; Sat, 16 Apr 2016 03:54:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1arL42-0004PY-2I for emacs-devel@gnu.org; Sat, 16 Apr 2016 03:54:49 -0400 Original-Received: from mail.mojserwer.eu ([2a01:5e00:2:52::8]:42180) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1arL41-0004OQ-SS for emacs-devel@gnu.org; Sat, 16 Apr 2016 03:54:46 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by mail.mojserwer.eu (Postfix) with ESMTP id 691CDACA75F for ; Sat, 16 Apr 2016 09:54:29 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail.mojserwer.eu Original-Received: from mail.mojserwer.eu ([127.0.0.1]) by localhost (mail.mojserwer.eu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fE5nQvWWvwwt for ; Sat, 16 Apr 2016 09:54:26 +0200 (CEST) Original-Received: from localhost (98-171.echostar.pl [213.156.98.171]) by mail.mojserwer.eu (Postfix) with ESMTPSA id 52977ACA75E for ; Sat, 16 Apr 2016 09:54:26 +0200 (CEST) User-agent: mu4e 0.9.13; emacs 25.1.50.8 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2a01:5e00:2:52::8 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:202981 Archived-At: 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