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.
This commit is contained in:
Sean Whitton 2025-06-27 12:39:29 +01:00
parent d70f1e0cfe
commit 772099bc9b
2 changed files with 14 additions and 0 deletions

View file

@ -1876,6 +1876,12 @@ the VC Directory buffer also has the effect of the 'x' command.
That is, typing 'g' refreshes the buffer and also hides items in the
'up-to-date' and 'ignored' states.
---
*** New user option 'vc-dir-save-some-buffers-on-revert'.
If you customize this variable to non-nil, Emacs will offer to save
relevant buffers before generating the contents of a VC Directory buffer
(like the third-party package Magit does with its status buffer).
+++
*** New user option 'vc-async-checkin' to enable async checkin operations.
Currently only supported by the Git and Mercurial backends.

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