diff --git a/etc/NEWS b/etc/NEWS index eb85baae341..32f08d63c68 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -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. diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index 278bafba022..dfd95b17397 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.