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.
(require 'vc)
(require 'tool-bar)
(require 'ewoc)
+(require 'seq)
;;; Code:
(eval-when-compile (require 'cl-lib))
'(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)...
;; 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)
(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.