From: Reuben Thomas <rrt@sc3d.org>
To: Juri Linkov <juri@linkov.net>
Cc: 18133@debbugs.gnu.org
Subject: bug#18133: Suppressing asynchronous command output
Date: Tue, 27 Dec 2016 01:09:23 +0000 [thread overview]
Message-ID: <CAOnWdojmRaOQrEkVdvxuapD+5XuWtJEP+2Fir-EQaG6a4Rz7UQ@mail.gmail.com> (raw)
In-Reply-To: <87fula1dbk.fsf@mail.linkov.net>
[-- Attachment #1.1: Type: text/plain, Size: 572 bytes --]
On 26 December 2016 at 23:27, Juri Linkov <juri@linkov.net> wrote:
[message cut]
Thanks, Juri, for helping again with this bug.
I attach an updated version of my patch, which uses an :options setting for
display-buffer-alist so that the current behaviour remains the default, and
runs a preoutput-filter-function which calls display-buffer only when
output is added to an empty buffer.
I believe this addresses the performance and behaviour issues, without the
need for another user option.
It is also rather shorter than the previous patch.
--
http://rrt.sc3d.org
[-- Attachment #1.2: Type: text/html, Size: 1556 bytes --]
[-- Attachment #2: 0001-Delay-showing-Async-Shell-Command-buffer-until-outpu.patch --]
[-- Type: text/x-patch, Size: 3970 bytes --]
From 935d50d93d37d2d4649673a5d52ec4efe4abce7b Mon Sep 17 00:00:00 2001
From: Reuben Thomas <rrt@sc3d.org>
Date: Mon, 19 Dec 2016 15:38:36 +0000
Subject: [PATCH] Delay showing Async Shell Command buffer until output
(Bug#18133)
* lisp/comint.el (comint-input-filter): Add process argument.
(comint-output-filter-functions): Add `comint-make-buffer-visible' to
the list, document the second argument (the process).
(comint-send-input): Call input and output filter functions with
process argument.
(comint-output-filter): Call output filter functions with process
argument.
(comint-make-buffer-visible): New hook function, to make Async Shell
Command buffer visible.
(comint-postoutput-scroll-to-bottom):
(comint-watch-for-password-prompt): Add dummy process argument.
* lisp/window.el (display-buffer-alist): Add a default entry to hide
Async Shell Command output window.
* lisp/ansi-color.el (ansi-color-process-output): Add a dummy process
argument.
---
lisp/comint.el | 22 ++++++++++++++++------
lisp/window.el | 5 ++++-
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/lisp/comint.el b/lisp/comint.el
index b9c65b0..6fa2fc9 100644
--- a/lisp/comint.el
+++ b/lisp/comint.el
@@ -1913,12 +1913,12 @@ comint-send-input
;; but that scrolled the buffer in undesirable ways.
(run-hook-with-args 'comint-output-filter-functions "")))))
-(defvar comint-preoutput-filter-functions nil
+(defvar comint-preoutput-filter-functions '(comint-make-newly-written-buffer-visible)
"List of functions to call before inserting Comint output into the buffer.
-Each function gets one argument, a string containing the text received
-from the subprocess. It should return the string to insert, perhaps
-the same string that was received, or perhaps a modified or transformed
-string.
+Each function gets two argument, a string containing the text received
+from the subprocess, and the process. It should return the string to
+insert, perhaps the same string that was received, or perhaps a modified or
+transformed string.
The functions on the list are called sequentially, and each one is
given the string returned by the previous one. The string returned by
@@ -2023,7 +2023,7 @@ comint-output-filter
(let ((functions
(default-value 'comint-preoutput-filter-functions)))
(while (and functions string)
- (setq string (funcall (car functions) string))
+ (setq string (funcall (car functions) string process))
(setq functions (cdr functions))))
(setq string (funcall (car functions) string)))
(setq functions (cdr functions))))
@@ -2111,6 +2111,16 @@ comint-output-filter
(add-text-properties prompt-start (point) '(rear-nonsticky t)))
(goto-char saved-point)))))))
+(defun comint-make-newly-written-buffer-visible (string process)
+ "Make the output buffer visible when output is added to an empty buffer.
+Useful in `comint-preoutput-filter-functions'."
+ (let ((buffer (process-buffer process)))
+ (when (and (= 0 (buffer-size buffer))
+ (string-match-p "\\*Async Shell Command\\*"
+ (buffer-name buffer)))
+ (display-buffer (process-buffer process))))
+ string)
+
(defun comint-preinput-scroll-to-bottom ()
"Go to the end of buffer in all windows showing it.
Movement occurs if point in the selected window is not after the process mark,
diff --git a/lisp/window.el b/lisp/window.el
index fdb67ed..a49f4a3 100644
--- a/lisp/window.el
+++ b/lisp/window.el
@@ -6797,7 +6797,10 @@ display-buffer-alist
(choice :tag "Condition"
regexp
(function :tag "Matcher function"))
- :value-type ,display-buffer--action-custom-type)
+ :value-type ,display-buffer--action-custom-type
+ :options (("\\*Async Shell Command\\*"
+ (cons
+ (const display-buffer-no-window) (const nil)))))
:risky t
:version "24.1"
:group 'windows)
--
2.7.4
next prev parent reply other threads:[~2016-12-27 1:09 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-28 18:47 bug#18133: Suppressing asynchronous command output Reuben Thomas
2014-07-29 23:47 ` Juri Linkov
2014-07-30 9:16 ` Reuben Thomas
2014-07-30 9:48 ` Reuben Thomas
2014-07-30 16:35 ` Juri Linkov
2016-12-19 15:48 ` Reuben Thomas
2016-12-21 17:55 ` Eli Zaretskii
2016-12-21 22:44 ` Reuben Thomas
2016-12-22 16:28 ` Eli Zaretskii
2016-12-22 17:53 ` martin rudalics
2016-12-22 18:32 ` Eli Zaretskii
2016-12-22 19:42 ` Reuben Thomas
2016-12-22 20:15 ` martin rudalics
2016-12-22 20:26 ` Reuben Thomas
2016-12-23 18:59 ` martin rudalics
2016-12-23 19:10 ` Reuben Thomas
2016-12-23 19:55 ` martin rudalics
2016-12-23 21:07 ` Reuben Thomas
2016-12-24 9:16 ` martin rudalics
2016-12-24 11:11 ` Reuben Thomas
2016-12-24 12:06 ` Eli Zaretskii
2016-12-24 13:54 ` martin rudalics
2016-12-24 14:45 ` Reuben Thomas
2016-12-24 16:32 ` martin rudalics
2016-12-24 16:03 ` Eli Zaretskii
2016-12-24 16:33 ` martin rudalics
2016-12-24 16:56 ` Eli Zaretskii
2016-12-24 18:14 ` martin rudalics
2016-12-25 2:23 ` Reuben Thomas
2016-12-26 23:43 ` Reuben Thomas
2016-12-27 7:29 ` martin rudalics
2016-12-26 23:27 ` Juri Linkov
2016-12-27 1:09 ` Reuben Thomas [this message]
2016-12-27 1:20 ` Reuben Thomas
2016-12-27 6:23 ` Eli Zaretskii
2016-12-27 9:01 ` Reuben Thomas
2016-12-27 9:28 ` Eli Zaretskii
2016-12-27 22:21 ` Reuben Thomas
2016-12-28 16:01 ` Eli Zaretskii
2016-12-28 20:58 ` Reuben Thomas
2016-12-29 15:50 ` Eli Zaretskii
2016-12-29 23:08 ` Juri Linkov
2016-12-30 18:28 ` Reuben Thomas
2016-12-30 20:50 ` Eli Zaretskii
2016-12-30 22:33 ` Reuben Thomas
2016-12-30 22:56 ` Juri Linkov
2016-12-31 0:19 ` Reuben Thomas
2016-12-31 8:41 ` Eli Zaretskii
2017-06-28 21:45 ` Reuben Thomas
2017-06-28 21:53 ` Reuben Thomas
2017-06-28 22:05 ` Reuben Thomas
2017-08-07 12:31 ` Reuben Thomas
2017-08-07 16:25 ` Eli Zaretskii
2020-09-18 13:40 ` Lars Ingebrigtsen
2020-09-18 13:51 ` Reuben Thomas via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-09-18 14:04 ` Lars Ingebrigtsen
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=CAOnWdojmRaOQrEkVdvxuapD+5XuWtJEP+2Fir-EQaG6a4Rz7UQ@mail.gmail.com \
--to=rrt@sc3d.org \
--cc=18133@debbugs.gnu.org \
--cc=juri@linkov.net \
/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).