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)
This commit is contained in:
parent
d2d5e54824
commit
699081f051
1 changed files with 13 additions and 7 deletions
|
@ -3547,14 +3547,20 @@ the use of a shell (with its need to quote arguments)."
|
||||||
;; carriage motion (see comint-inhibit-carriage-motion).
|
;; carriage motion (see comint-inhibit-carriage-motion).
|
||||||
(set-process-filter proc 'comint-output-filter)
|
(set-process-filter proc 'comint-output-filter)
|
||||||
(if async-shell-command-display-buffer
|
(if async-shell-command-display-buffer
|
||||||
|
;; Display buffer immediately.
|
||||||
(display-buffer buffer '(nil (allow-no-window . t)))
|
(display-buffer buffer '(nil (allow-no-window . t)))
|
||||||
(add-function :before (process-filter proc)
|
;; Defer displaying buffer until first process output.
|
||||||
(lambda (process _string)
|
;; Use disposable named advice so that the buffer is
|
||||||
(let ((buf (process-buffer process)))
|
;; displayed at most once per process lifetime.
|
||||||
(when (and (zerop (buffer-size buf))
|
(let ((nonce (make-symbol "nonce")))
|
||||||
(string= (buffer-name buf)
|
(add-function :before (process-filter proc)
|
||||||
bname))
|
(lambda (proc _string)
|
||||||
(display-buffer buf))))))))
|
(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.
|
;; Otherwise, command is executed synchronously.
|
||||||
(shell-command-on-region (point) (point) command
|
(shell-command-on-region (point) (point) command
|
||||||
output-buffer nil error-buffer)))))))
|
output-buffer nil error-buffer)))))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue