From 29bdba37f2ac3a912d15d2b65169cfb312707da2 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Fri, 23 Jan 2026 14:11:27 +0000 Subject: [PATCH] New bindings for vc-revert * lisp/vc/vc-dir.el (vc-dir-mode-map): Bind vc-revert to '@'. * lisp/vc/vc-hooks.el (vc-prefix-map): Additionally bind vc-revert to 'C-x v @'. * doc/emacs/maintaining.texi (VC Undo, VC Directory Commands): * etc/NEWS: Document the change. --- doc/emacs/maintaining.texi | 32 +++++++++++++++++++------------- etc/NEWS | 9 ++++++++- lisp/vc/vc-dir.el | 1 + lisp/vc/vc-hooks.el | 3 ++- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi index 0c6e5c820e7..f1090d4b43f 100644 --- a/doc/emacs/maintaining.texi +++ b/doc/emacs/maintaining.texi @@ -1360,6 +1360,7 @@ also prompt for a specific VCS shell command to run for this purpose. @table @kbd @item C-x v u +@item C-x v @@ Revert the work file(s) in the current VC fileset to the last revision (@code{vc-revert}). @@ -1374,24 +1375,25 @@ Delete an unpushed commit from the revision history. @end table @kindex C-x v u +@kindex C-x v @@ @findex vc-revert @vindex vc-revert-show-diff - If you want to discard all the changes you have made to the current -VC fileset, type @kbd{C-x v u} (@code{vc-revert}). This will ask you -for confirmation before discarding the changes. If you agree, the -fileset is reverted. + If you want to discard all the changes you have made to the current VC +fileset, type @kbd{C-x v u} or @kbd{C-x v @@} (@code{vc-revert}). This +will ask you for confirmation before discarding the changes. If you +agree, the fileset is reverted. If @code{vc-revert-show-diff} is non-@code{nil}, this command will -show you a diff between the work file(s) and the revision from which -you started editing. Afterwards, the diff buffer will either be -killed (if this variable is @code{kill}), or the buffer will be buried -(any other non-@code{nil} value). If you don't want @kbd{C-x v u} to -show a diff, set this variable to @code{nil} (you can still view the -diff directly with @kbd{C-x v =}; @pxref{Old Revisions}). +show you a diff between the work file(s) and the revision from which you +started editing. Afterwards, the diff buffer will either be killed (if +this variable is @code{kill}), or the buffer will be buried (any other +non-@code{nil} value). If you don't want @code{vc-revert} to show you +diffs, set this variable to @code{nil} (you can still view the diff +directly with @kbd{C-x v =}; @pxref{Old Revisions}). - On locking-based version control systems, @kbd{C-x v u} leaves files -unlocked; you must lock again to resume editing. You can also use -@kbd{C-x v u} to unlock a file if you lock it and then decide not to + On locking-based version control systems, @code{vc-revert} leaves +files unlocked; you must lock again to resume editing. You can also use +@code{vc-revert} to unlock a file if you lock it and then decide not to change it. @findex vc-revert-or-delete-revision @@ -1641,6 +1643,10 @@ ignore (@code{vc-dir-ignore}). For instance, if the VC is Git, it will append this file to the @file{.gitignore} file. If given a prefix, do this with all the marked files. +@item @@ +Discard all the changes you have made to the current fileset +(@code{vc-revert}). + @item q Quit the VC Directory buffer, and bury it (@code{quit-window}). diff --git a/etc/NEWS b/etc/NEWS index 2cb1978738e..594c0d45322 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2599,8 +2599,15 @@ cloning, or prompts for that, too. When the argument is non-nil, the function switches to a buffer visiting the directory into which the repository was cloned. ++++ +*** 'vc-revert' is now bound to '@' in VC-Dir. + ++++ +*** 'vc-revert' is now additionally bound to 'C-x v @'. +This is in addition to 'C-x v u'. + --- -*** 'C-x v u' ('vc-revert') now works on directories listed in VC Directory. +*** 'vc-revert' now works on directories listed in VC Directory. Reverting a directory means reverting changes to all files inside it. +++ diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index 1c6b6a4cba4..303cfd93ba2 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -396,6 +396,7 @@ That is, refreshing the VC-Dir buffer also hides `up-to-date' and (define-key map (kbd "M-s a C-s") #'vc-dir-isearch) (define-key map (kbd "M-s a M-C-s") #'vc-dir-isearch-regexp) (define-key map "G" #'vc-dir-ignore) + (define-key map "@" #'vc-revert) (let ((branch-map (make-sparse-keymap))) (define-key map "b" branch-map) diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el index 2e342c19919..e867654409c 100644 --- a/lisp/vc/vc-hooks.el +++ b/lisp/vc/vc-hooks.el @@ -1023,7 +1023,8 @@ In the latter case, VC mode is deactivated for this buffer." "m" #'vc-merge "r" #'vc-retrieve-tag "s" #'vc-create-tag - "u" #'vc-revert + "u" #'vc-revert ; The traditional binding. + "@" #'vc-revert ; Following VC-Dir's binding. "v" #'vc-next-action "+" #'vc-update "P" #'vc-push