Emacsist RSS --- If never, make it ever: C-h C-h

Showing some of those Async Shell Command buffers

7433

这里 查看更多 Emacs 相关推荐文章最新 Emacs 圈的动态. 欢迎关注微信公众账号: Emacsist

Last time, I showed how to make those pesky *Async Shell Command* buffers disappear (or more precisely, how not to make them appear in the first place). I briefly mentioned that sometimes it might be useful to actually see them. Well, here’s the way.

(add-to-list 'display-buffer-alist '("^*Async Shell Command*" . (display-buffer-no-window)))

(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)

This is clearly a quick-and-dirty hack, but at least Emacs makes it possible. Here’s a short explanation: I wrap the async-shell-command in an advice, and call it from within it, but with one twist: ifthe prefix argument is C-u, I temporarily remove the very same thing I added to display-buffer-alistearlier. (Of course, it works because display-buffer-alist is a special variable, not a lexically scoped one.) Needless to say that this “solution” is extremely brittle and definitely a textbook example of bad practices – don’t try this at home, kids! – so if you have a better idea, make sure to leave it in the comments!

In the meantime, I’m now going to raise this subject on the emacs-devel mailing list, since I’d like stock Emacs to be able to do something like this without such terrible hacks.

原文出处: Marcin Borkowski
原文地址: http://mbork.pl/2016-04-12_Showing_some_of_those_Async_Shell_Command_buffers
原文时间: 2016-04-13 03:22
本文地址: http://emacsist.com/10851
整理时间: 2016-04-22 04:19

本文由 Hick 整理,转载请保留以上信息;
COPYLEFTThe articles on this site come from Internet, thanks to all the original authors.
      If anything about COPYRIGHT, or LEFT, please contact Emacsist at gmail dot com .