From 4dd7ceb5f8f986f40f64f4c1918f76de6f2f84a7 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 11 Jul 2025 09:58:20 +0100 Subject: [PATCH] VC: Fix displaying the async command buffer during async checkins * lisp/vc/vc-dispatcher.el (vc--display-async-command-buffer): New function, factored out of vc-do-async-command. (vc-do-async-command): Use it. (vc-finish-logentry): Bind vc--inhibit-async-window when running the log operation, then call vc--display-async-command-buffer again ourselves after performing other window changes. (cherry picked from commit 10024cc06557493e50c913cf5cba3c01a3588410) --- lisp/vc/vc-dispatcher.el | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el index b644d8916e1..a3b8a5af8ad 100644 --- a/lisp/vc/vc-dispatcher.el +++ b/lisp/vc/vc-dispatcher.el @@ -485,6 +485,16 @@ case, and the process object in the asynchronous case." (defvar vc--inhibit-async-window nil) +(defun vc--display-async-command-buffer (buffer) + (unless vc--inhibit-async-window + (when-let* ((window (display-buffer buffer)) + (start (with-current-buffer buffer + (save-excursion + (goto-char (point-max)) + (and (re-search-backward " \n" nil t) + (match-end 0)))))) + (set-window-start window start)))) + (defun vc-do-async-command (buffer root command &rest args) "Run COMMAND asynchronously with ARGS, displaying the result. Send the output to BUFFER, which should be a buffer or the name @@ -494,7 +504,7 @@ The process object is returned. Display the buffer in some window, but don't select it." (let ((dir default-directory) (inhibit-read-only t) - new-window-start proc) + proc) (setq buffer (get-buffer-create buffer)) (if (get-buffer-process buffer) (error "Another VC action on %s is running" root)) @@ -510,7 +520,6 @@ Display the buffer in some window, but don't select it." (goto-char (point-max)) (unless (eq (point) (point-min)) (insert " \n")) - (setq new-window-start (point)) (insert "Running '" cmd) (dolist (flag flags) (let ((lines (string-lines flag))) @@ -529,9 +538,7 @@ Display the buffer in some window, but don't select it." (insert "'...\n") args)))) (setq proc (apply #'vc-do-command t 'async command nil args)))) - (unless vc--inhibit-async-window - (when-let ((window (display-buffer buffer))) - (set-window-start window new-window-start))) + (vc--display-async-command-buffer buffer) proc)) (defvar compilation-error-regexp-alist) @@ -874,7 +881,9 @@ the buffer contents as a comment." ;; OK, do it to it (let ((log-operation-ret (with-current-buffer parent - (funcall log-operation log-fileset log-entry)))) + (let ((vc--inhibit-async-window t)) + (funcall log-operation log-fileset log-entry))))) + (pop-to-buffer parent) (setq vc-log-operation nil) @@ -885,6 +894,10 @@ the buffer contents as a comment." (t (quit-windows-on logbuf nil 0))) + (when (eq (car-safe log-operation-ret) 'async) + (vc--display-async-command-buffer (process-buffer + (cadr log-operation-ret)))) + ;; Now make sure we see the expanded headers. ;; If the `vc-log-operation' started an async operation then we ;; need to delay running the hooks. It tells us whether it did -- 2.39.5