Fix recent change in diff-no-select

* lisp/vc/diff.el (diff-no-select): Keep initial default directory
in *Diff* buffer.
This commit is contained in:
Michael Albinus 2025-02-28 18:03:54 +01:00
parent 5247da2e3c
commit 0af5c57499

View file

@ -187,7 +187,8 @@ returns the buffer used."
(prin1-to-string new)))) (prin1-to-string new))))
(list (or old-alt old) (list (or old-alt old)
(or new-alt new))))) (or new-alt new)))))
" "))) " "))
(thisdir default-directory))
(with-current-buffer buf (with-current-buffer buf
(setq buffer-read-only t) (setq buffer-read-only t)
(buffer-disable-undo (current-buffer)) (buffer-disable-undo (current-buffer))
@ -198,14 +199,15 @@ returns the buffer used."
(setq-local revert-buffer-function (setq-local revert-buffer-function
(lambda (_ignore-auto _noconfirm) (lambda (_ignore-auto _noconfirm)
(diff-no-select old new switches no-async (current-buffer)))) (diff-no-select old new switches no-async (current-buffer))))
(setq default-directory temporary-file-directory) (setq default-directory thisdir)
(setq diff-default-directory default-directory) (setq diff-default-directory default-directory)
(let ((inhibit-read-only t)) (let ((inhibit-read-only t))
(insert command "\n")) (insert command "\n"))
(with-file-modes #o600 (with-file-modes #o600
(if (and (not no-async) (fboundp 'make-process)) (if (and (not no-async) (fboundp 'make-process))
(let ((proc (start-process "Diff" buf shell-file-name (let* ((default-directory temporary-file-directory)
shell-command-switch command))) (proc (start-process "Diff" buf shell-file-name
shell-command-switch command)))
(set-process-filter proc #'diff-process-filter) (set-process-filter proc #'diff-process-filter)
(set-process-sentinel (set-process-sentinel
proc (lambda (proc _msg) proc (lambda (proc _msg)
@ -213,7 +215,8 @@ returns the buffer used."
(diff-sentinel (process-exit-status proc) (diff-sentinel (process-exit-status proc)
old-alt new-alt))))) old-alt new-alt)))))
;; Async processes aren't available. ;; Async processes aren't available.
(let ((inhibit-read-only t)) (let* ((default-directory temporary-file-directory)
(inhibit-read-only t))
(diff-sentinel (diff-sentinel
(call-process shell-file-name nil buf nil (call-process shell-file-name nil buf nil
shell-command-switch command) shell-command-switch command)