]> git.eshelyaron.com Git - emacs.git/commitdiff
VC: Fix displaying the async command buffer during async checkins
authorSean Whitton <spwhitton@spwhitton.name>
Fri, 11 Jul 2025 08:58:20 +0000 (09:58 +0100)
committerEshel Yaron <me@eshelyaron.com>
Thu, 24 Jul 2025 08:07:12 +0000 (10:07 +0200)
* 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

index b644d8916e1ebe2a3c112c820aaf3e2dac5751c5..a3b8a5af8ad8244b4433d559f430414ff9329861 100644 (file)
@@ -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 "\f\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 "\f\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