From: Lars Ingebrigtsen Date: Sat, 13 Jul 2019 04:10:29 +0000 (+0200) Subject: Add a new command in vc-dir mode to delete files X-Git-Tag: emacs-27.0.90~1970 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a3509a71c0a11ce3cfa6eb96c6452bff68fc5bd9;p=emacs.git Add a new command in vc-dir mode to delete files * doc/emacs/maintaining.texi (VC Directory Commands): Document it. * lisp/vc/vc-dir.el (vc-dir-delete-files-no-vc): New command and keystroke (bug#31732). --- diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi index 4986c111030..42ea4d3254d 100644 --- a/doc/emacs/maintaining.texi +++ b/doc/emacs/maintaining.texi @@ -1349,7 +1349,14 @@ Prompt for the name of a branch and display the change history of that branch (@code{vc-print-branch-log}). @item B s -Switch to a branch (@code{vc-retrieve-tag}). @xref{Switching Branches}. +Switch to a branch (@code{vc-retrieve-tag}). @xref{Switching +Branches}. + +@item d +Delete the marked files, or the current file if no marks +(@code{vc-dir-delete-files-no-vc)}. The files will not be marked as +deleted in the version control system, so this function is mostly +useful for unregistered files. @end table @cindex stashes in version control diff --git a/etc/NEWS b/etc/NEWS index 902203f0c33..7ff2b42bdab 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -690,6 +690,11 @@ to Hg revert. print diffs and logs between the merge base (common ancestor) of two given revisions. +*** The new `d' command (`vc-dir-delete-files-no-vc') in `vc-dir-mode' +buffers will delete the marked files (or if no files are marked, the +file under point). This command does not notify the VC backend, and +is mostly useful for unregistered files. + ** Diff mode +++ *** Hunks are now automatically refined by font-lock. diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index be1084d4abe..79f395c4822 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -180,6 +180,9 @@ See `run-hooks'." (define-key map [open] '(menu-item "Open File" vc-dir-find-file :help "Find the file on the current line")) + (define-key map [delete] + '(menu-item "Delete" vc-dir-delete-files-no-vc + :help "Delete the marked files")) (define-key map [sepvcdet] '("--")) ;; FIXME: This needs a key binding. And maybe a better name ;; ("Insert" like PCL-CVS uses does not sound that great either)... @@ -264,6 +267,7 @@ See `run-hooks'." ;; bound by `special-mode'. ;; Marking. (define-key map "m" 'vc-dir-mark) + (define-key map "d" 'vc-dir-delete-files-no-vc) (define-key map "M" 'vc-dir-mark-all-files) (define-key map "u" 'vc-dir-unmark) (define-key map "U" 'vc-dir-unmark-all-files) @@ -762,8 +766,21 @@ that share the same state." (interactive "e") (vc-dir-at-event e (vc-dir-mark-unmark 'vc-dir-toggle-mark-file))) +(defun vc-dir-delete-files-no-vc () + "Delete the marked files, or the current file if no marks. +The files will not be marked as deleted in the version control +system; see `vc-dir-delete-file'." + (interactive) + (map-y-or-n-p "Delete %s? " + #'delete-file + (or (vc-dir-marked-files) + (list (vc-dir-current-file)))) + (revert-buffer)) + (defun vc-dir-delete-file () - "Delete the marked files, or the current file if no marks." + "Delete the marked files, or the current file if no marks. +The files will also be marked as deleted in the version control +system." (interactive) (mapc 'vc-delete-file (or (vc-dir-marked-files) (list (vc-dir-current-file)))))