From 3d625f15f9869562ec4efd6ab492b3d5bfc5a37e Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 27 Jun 2025 12:39:29 +0100 Subject: [PATCH] New user option vc-dir-save-some-buffers-on-revert * lisp/vc/vc-dir.el (vc-dir-save-some-buffers-on-revert): New user option. (vc-dir-refresh): Use it. * etc/NEWS: Document it. (cherry picked from commit 772099bc9b8043d46154992e1f06d7b4aa9ceccd) --- lisp/vc/vc-dir.el | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index b8c7e8f6707..ae648deadee 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -166,6 +166,12 @@ That is, refreshing the VC-Dir buffer also hides `up-to-date' and :group 'vc :version "31.1") +(defcustom vc-dir-save-some-buffers-on-revert nil + "If non-nil, first offer to save relevant buffers when refreshing VC-Dir." + :type 'boolean + :group 'vc + :version "31.1") + (defun vc-dir-move-to-goal-column () ;; Used to keep the cursor on the file name column. (beginning-of-line) @@ -1367,6 +1373,8 @@ Throw an error if another update process is in progress." (error "Another update process is in progress, cannot run two at a time") (let ((def-dir default-directory) (backend vc-dir-backend)) + (when vc-dir-save-some-buffers-on-revert + (vc-buffer-sync-fileset `(,vc-dir-backend (,def-dir)) t)) (vc-set-mode-line-busy-indicator) ;; Call the `dir-status' backend function. ;; `dir-status' is supposed to be asynchronous. -- 2.39.5