From: Lars Ingebrigtsen Date: Sun, 14 Jul 2019 12:25:44 +0000 (+0200) Subject: Rename vc-dir-delete-files-no-vc to vc-dir-clean-files X-Git-Tag: emacs-27.0.90~1919 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d3256dc78a464117c4fef98b572611370482763a;p=emacs.git Rename vc-dir-delete-files-no-vc to vc-dir-clean-files * doc/emacs/maintaining.texi (VC Directory Commands): Adjust command name. * lisp/vc/vc-dir.el (vc-dir-clean-files): Rename from vc-dir-delete-files-no-vc, and work on unregistered files only (bug#31732). (vc-dir-menu-map): Adjust command name. --- diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi index 42ea4d3254d..c3895bffb5e 100644 --- a/doc/emacs/maintaining.texi +++ b/doc/emacs/maintaining.texi @@ -1354,7 +1354,7 @@ 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 +(@code{vc-dir-clean-delete)}. The files will not be marked as deleted in the version control system, so this function is mostly useful for unregistered files. @end table diff --git a/etc/NEWS b/etc/NEWS index a36785a82b3..190509ff130 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -694,7 +694,7 @@ 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' +*** The new `d' command (`vc-dir-clean-files') 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 --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index 79f395c4822..436a0a67223 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -41,6 +41,7 @@ (require 'vc) (require 'tool-bar) (require 'ewoc) +(require 'seq) ;;; Code: (eval-when-compile (require 'cl-lib)) @@ -181,8 +182,8 @@ See `run-hooks'." '(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")) + '(menu-item "Delete" vc-dir-clean-files + :help "Delete the unregistered 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)... @@ -267,7 +268,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 "d" 'vc-dir-clean-files) (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) @@ -766,16 +767,24 @@ 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 () +(defun vc-dir-clean-files () "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) + (let* ((files (or (vc-dir-marked-files) (list (vc-dir-current-file)))) - (revert-buffer)) + (tracked + (seq-filter (lambda (file) + (not (eq (vc-call-backend vc-dir-backend 'state file) + 'unregistered))) + files))) + (when tracked + (user-error "Trying to clean tracked file%s: %s" + (if (= (length tracked) 1) "" "s") + (mapconcat #'file-name-nondirectory tracked ", "))) + (map-y-or-n-p "Delete %s? " #'delete-file files) + (revert-buffer))) (defun vc-dir-delete-file () "Delete the marked files, or the current file if no marks.