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).
This commit is contained in:
Sean Whitton 2025-04-03 16:31:36 +08:00
parent 12b06992df
commit 4ace02755b

View 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))))