]> git.eshelyaron.com Git - emacs.git/commitdiff
New user option vc-dir-save-some-buffers-on-revert
authorSean Whitton <spwhitton@spwhitton.name>
Fri, 27 Jun 2025 11:39:29 +0000 (12:39 +0100)
committerEshel Yaron <me@eshelyaron.com>
Wed, 23 Jul 2025 19:23:48 +0000 (21:23 +0200)
* 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

index b8c7e8f67075cc538312c08c841401603b0a8aa2..ae648deadee2f21cd99f152c01e4859f2c76492b 100644 (file)
@@ -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.