aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Whitton2025-06-09 12:13:06 +0100
committerSean Whitton2025-06-09 12:13:06 +0100
commitd660ed0b4cdd59c4ba1b61a2e6384dc485ef0dea (patch)
treebaabe8a30cc3d748b4d71fac42775f6e77c13fc5
parent00a30a752ecdf927f532ccf504d52392ef9d98da (diff)
downloademacs-d660ed0b4cdd59c4ba1b61a2e6384dc485ef0dea.tar.gz
emacs-d660ed0b4cdd59c4ba1b61a2e6384dc485ef0dea.zip
Prompt just once when deleting multiple files with C-x v v
* lisp/vc/vc.el (vc-delete-file): Accept lists of files in addition to single files. (vc-next-action): Call vc-delete-file once for all the files.
-rw-r--r--lisp/vc/vc.el85
1 files changed, 47 insertions, 38 deletions
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index b60055cdaeb..356eb2d7370 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -1501,7 +1501,7 @@ from which to check out the file(s)."
1501 (t 1501 (t
1502 (vc-register vc-fileset)))) 1502 (vc-register vc-fileset))))
1503 ((eq state 'missing) 1503 ((eq state 'missing)
1504 (mapc #'vc-delete-file files)) 1504 (vc-delete-file files))
1505 ;; Files are up-to-date, or need a merge and user specified a revision 1505 ;; Files are up-to-date, or need a merge and user specified a revision
1506 ((or (eq state 'up-to-date) (and verbose (eq state 'needs-update))) 1506 ((or (eq state 'up-to-date) (and verbose (eq state 'needs-update)))
1507 (cond 1507 (cond
@@ -3658,48 +3658,57 @@ backend to NEW-BACKEND, and unregister FILE from the current backend.
3658 (vc-checkin file new-backend comment (stringp comment))))) 3658 (vc-checkin file new-backend comment (stringp comment)))))
3659 3659
3660;;;###autoload 3660;;;###autoload
3661(defun vc-delete-file (file) 3661(defun vc-delete-file (file-or-files)
3662 "Delete file and mark it as such in the version control system. 3662 "Delete file and mark it as such in the version control system.
3663If called interactively, read FILE, defaulting to the current 3663If called interactively, read FILE-OR-FILES, defaulting to the current
3664buffer's file name if it's under version control." 3664buffer's file name if it's under version control.
3665When called from Lisp, FILE-OR-FILES can be a file name or a list of
3666file names."
3665 (interactive (list (read-file-name "VC delete file: " nil 3667 (interactive (list (read-file-name "VC delete file: " nil
3666 (when (vc-backend buffer-file-name) 3668 (when (vc-backend buffer-file-name)
3667 buffer-file-name) 3669 buffer-file-name)
3668 t))) 3670 t)))
3669 (setq file (expand-file-name file)) 3671 (setq file-or-files (mapcar #'expand-file-name (ensure-list file-or-files)))
3670 (let ((buf (get-file-buffer file)) 3672 (dolist (file file-or-files)
3671 (backend (vc-backend file))) 3673 (let ((buf (get-file-buffer file))
3672 (unless backend 3674 (backend (vc-backend file)))
3673 (error "File %s is not under version control" 3675 (unless backend
3674 (file-name-nondirectory file))) 3676 (error "File %s is not under version control"
3675 (unless (vc-find-backend-function backend 'delete-file) 3677 (file-name-nondirectory file)))
3676 (error "Deleting files under %s is not supported in VC" backend)) 3678 (unless (vc-find-backend-function backend 'delete-file)
3677 (when (and buf (buffer-modified-p buf)) 3679 (error "Deleting files under %s is not supported in VC" backend))
3678 (error "Please save or undo your changes before deleting %s" file)) 3680 (when (and buf (buffer-modified-p buf))
3679 (let ((state (vc-state file))) 3681 (error "Please save or undo your changes before deleting %s" file))
3680 (when (eq state 'edited) 3682 (let ((state (vc-state file)))
3681 (error "Please commit or undo your changes before deleting %s" file)) 3683 (when (eq state 'edited)
3682 (when (eq state 'conflict) 3684 (error "Please commit or undo your changes before deleting %s" file))
3683 (error "Please resolve the conflicts before deleting %s" file))) 3685 (when (eq state 'conflict)
3684 (unless (y-or-n-p (format "Really want to delete %s? " 3686 (error "Please resolve the conflicts before deleting %s" file)))))
3685 (file-name-nondirectory file))) 3687 (unless (y-or-n-p (if (cdr file-or-files)
3686 (error "Abort!")) 3688 (format "Really want to delete these %d files? "
3687 (unless (or (file-directory-p file) (null make-backup-files) 3689 (length file-or-files))
3688 (not (file-exists-p file))) 3690 (format "Really want to delete %s? "
3689 (with-current-buffer (or buf (find-file-noselect file)) 3691 (file-name-nondirectory (car file-or-files)))))
3690 (let ((backup-inhibited nil)) 3692 (error "Abort!"))
3691 (backup-buffer)))) 3693 (dolist (file file-or-files)
3692 ;; Bind `default-directory' so that the command that the backend 3694 (let ((buf (get-file-buffer file))
3693 ;; runs to remove the file is invoked in the correct context. 3695 (backend (vc-backend file)))
3694 (let ((default-directory (file-name-directory file))) 3696 (unless (or (file-directory-p file) (null make-backup-files)
3695 (vc-call-backend backend 'delete-file file)) 3697 (not (file-exists-p file)))
3696 ;; If the backend hasn't deleted the file itself, let's do it for him. 3698 (with-current-buffer (or buf (find-file-noselect file))
3697 (when (file-exists-p file) (delete-file file)) 3699 (let ((backup-inhibited nil))
3698 ;; Forget what VC knew about the file. 3700 (backup-buffer))))
3699 (vc-file-clearprops file) 3701 ;; Bind `default-directory' so that the command that the backend
3700 ;; Make sure the buffer is deleted and the *vc-dir* buffers are 3702 ;; runs to remove the file is invoked in the correct context.
3701 ;; updated after this. 3703 (let ((default-directory (file-name-directory file)))
3702 (vc-resynch-buffer file nil t))) 3704 (vc-call-backend backend 'delete-file file))
3705 ;; If the backend hasn't deleted the file itself, let's do it for him.
3706 (when (file-exists-p file) (delete-file file))
3707 ;; Forget what VC knew about the file.
3708 (vc-file-clearprops file)
3709 ;; Make sure the buffer is deleted and the *vc-dir* buffers are
3710 ;; updated after this.
3711 (vc-resynch-buffer file nil t))))
3703 3712
3704;;;###autoload 3713;;;###autoload
3705(defun vc-rename-file (old new) 3714(defun vc-rename-file (old new)