From: Sean Whitton Date: Thu, 3 Apr 2025 08:31:36 +0000 (+0800) Subject: vc-setup-buffer: Fix leaving wrong default-directory X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=db3641308d000019681fba4edd9eb96f57571eaa;p=emacs.git vc-setup-buffer: Fix leaving wrong default-directory * 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) --- diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el index 3f7c58cb2d4..1a9ca2de5c9 100644 --- a/lisp/vc/vc-dispatcher.el +++ b/lisp/vc/vc-dispatcher.el @@ -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))))