[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-26 699081f: Fix deferred display of async shell-comm
From: |
Juri Linkov |
Subject: |
[Emacs-diffs] emacs-26 699081f: Fix deferred display of async shell-command buffers |
Date: |
Sat, 3 Feb 2018 16:22:59 -0500 (EST) |
branch: emacs-26
commit 699081f0516b057ce9319383b244a8e1e8e88516
Author: Basil L. Contovounesios <address@hidden>
Commit: Juri Linkov <address@hidden>
Fix deferred display of async shell-command buffers
* lisp/simple.el (shell-command): Display async shell buffer on
process output for every, not just first, command invocation. Check
buffer liveness, not name, before displaying. (bug#30213, bug#30280)
---
lisp/simple.el | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/lisp/simple.el b/lisp/simple.el
index 3ac6b86..e2deceb 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -3547,14 +3547,20 @@ the use of a shell (with its need to quote arguments)."
;; carriage motion (see comint-inhibit-carriage-motion).
(set-process-filter proc 'comint-output-filter)
(if async-shell-command-display-buffer
+ ;; Display buffer immediately.
(display-buffer buffer '(nil (allow-no-window . t)))
- (add-function :before (process-filter proc)
- (lambda (process _string)
- (let ((buf (process-buffer process)))
- (when (and (zerop (buffer-size buf))
- (string= (buffer-name buf)
- bname))
- (display-buffer buf))))))))
+ ;; Defer displaying buffer until first process output.
+ ;; Use disposable named advice so that the buffer is
+ ;; displayed at most once per process lifetime.
+ (let ((nonce (make-symbol "nonce")))
+ (add-function :before (process-filter proc)
+ (lambda (proc _string)
+ (let ((buf (process-buffer proc)))
+ (when (buffer-live-p buf)
+ (remove-function (process-filter
proc)
+ nonce)
+ (display-buffer buf))))
+ `((name . ,nonce)))))))
;; Otherwise, command is executed synchronously.
(shell-command-on-region (point) (point) command
output-buffer nil error-buffer)))))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-26 699081f: Fix deferred display of async shell-command buffers,
Juri Linkov <=