]> git.eshelyaron.com Git - emacs.git/commitdiff
vc-setup-buffer: Fix leaving wrong default-directory
authorSean Whitton <spwhitton@spwhitton.name>
Thu, 3 Apr 2025 08:31:36 +0000 (16:31 +0800)
committerEshel Yaron <me@eshelyaron.com>
Thu, 3 Apr 2025 16:51:59 +0000 (18:51 +0200)
* lisp/vc/vc-dispatcher.el (vc-setup-buffer): Use run-with-timer
to ensure the buffer-local value gets set (bug#77306).

(cherry picked from commit 4ace02755bc5cd5add8d88be5abf2de60a92e635)

lisp/vc/vc-dispatcher.el

index 3f7c58cb2d4a83c0205fb55ad0afebe8b7e8fd24..1a9ca2de5c9a96e89e5f98692c8fb38c87f3adfc 100644 (file)
@@ -195,7 +195,19 @@ Another is that undo information is not kept."
       (setq-local vc-parent-buffer camefrom)
       (setq-local vc-parent-buffer-name
                   (concat " from " (buffer-name camefrom))))
+
+    ;; We want to set the buffer-local value of `default-directory' to
+    ;; olddir.  This `setq' alone ought to be sufficient.  But if there
+    ;; is a let-binding of `default-directory' in effect, such as the
+    ;; one established by `vc-print-root-log', then all we are able to
+    ;; do is change the let-binding, and not affect the underlying
+    ;; buffer-local cell.  Work around this using `run-with-timer'.
+    ;; See bug#53626 and bug#77306.
     (setq default-directory olddir)
+    (run-with-timer 0 nil (lambda ()
+                            (with-current-buffer buf
+                              (setq default-directory olddir))))
+
     (let ((buffer-undo-list t)
           (inhibit-read-only t))
       (erase-buffer))))