diff options
| author | Sean Whitton | 2025-12-18 21:46:49 +0000 |
|---|---|---|
| committer | Sean Whitton | 2025-12-18 21:46:49 +0000 |
| commit | f9172be29a699300d6d4fc054e6bb81e93823df3 (patch) | |
| tree | ee609068cc6bb9ccccdf027719885fa3eba4f75f | |
| parent | 1cd6428bce546094bb99305d003b3361df52aaec (diff) | |
| download | emacs-f9172be29a699300d6d4fc054e6bb81e93823df3.tar.gz emacs-f9172be29a699300d6d4fc054e6bb81e93823df3.zip | |
Make VC-Dir's 'd' able to delete unregistered files
* lisp/vc/vc.el (vc-delete-file): Simplify.
* lisp/vc/vc-dir.el (vc-dir-delete-file): Handle deleting
unregistered files, too.
(vc-dir-menu-map, vc-dir-mode-map): Replace bindings for
vc-dir-clean-files with ones for vc-dir-delete-file.
* doc/emacs/maintaining.texi (VC Directory Commands):
* etc/NEWS: Document the bindings change.
| -rw-r--r-- | doc/emacs/maintaining.texi | 5 | ||||
| -rw-r--r-- | etc/NEWS | 7 | ||||
| -rw-r--r-- | lisp/vc/vc-dir.el | 9 | ||||
| -rw-r--r-- | lisp/vc/vc.el | 18 |
4 files changed, 22 insertions, 17 deletions
diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi index cc5e813f018..29e05ba17e5 100644 --- a/doc/emacs/maintaining.texi +++ b/doc/emacs/maintaining.texi | |||
| @@ -1707,9 +1707,8 @@ Branches}. | |||
| 1707 | 1707 | ||
| 1708 | @item d | 1708 | @item d |
| 1709 | Delete the marked files, or the current file if no marks | 1709 | Delete the marked files, or the current file if no marks |
| 1710 | (@code{vc-dir-clean-delete)}. The files will not be marked as | 1710 | (@code{vc-dir-delete-file)}. If the files are registered, they will be |
| 1711 | deleted in the version control system, so this function is mostly | 1711 | marked as deleted in the version control system. |
| 1712 | useful for unregistered files. | ||
| 1713 | @end table | 1712 | @end table |
| 1714 | 1713 | ||
| 1715 | @cindex stashes in version control | 1714 | @cindex stashes in version control |
| @@ -2501,6 +2501,13 @@ Previously, Emacs would simply refuse to make any changes. | |||
| 2501 | You can customize 'vc-dir-allow-mass-mark-changes' to restore the old | 2501 | You can customize 'vc-dir-allow-mass-mark-changes' to restore the old |
| 2502 | behavior or dispense with the prompting. | 2502 | behavior or dispense with the prompting. |
| 2503 | 2503 | ||
| 2504 | +++ | ||
| 2505 | *** VC Directory's 'd' command can now delete unregistered files too. | ||
| 2506 | Previously, this command could only delete registered files. | ||
| 2507 | To restore the old, more limited behavior, you can do | ||
| 2508 | |||
| 2509 | (keymap-set vc-dir-mode-map "d" #'vc-dir-clean-files) | ||
| 2510 | |||
| 2504 | --- | 2511 | --- |
| 2505 | *** New VC Directory bindings 'z d' and 'D' to delete Git stashes. | 2512 | *** New VC Directory bindings 'z d' and 'D' to delete Git stashes. |
| 2506 | These correspond to the existing 'z p' to pop a stash and 'P' to pop the | 2513 | These correspond to the existing 'z p' to pop a stash and 'P' to pop the |
diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index 59aa24460d3..11083878025 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el | |||
| @@ -279,8 +279,8 @@ That is, refreshing the VC-Dir buffer also hides `up-to-date' and | |||
| 279 | '(menu-item "Open File" vc-dir-find-file | 279 | '(menu-item "Open File" vc-dir-find-file |
| 280 | :help "Find the file on the current line")) | 280 | :help "Find the file on the current line")) |
| 281 | (define-key map [delete] | 281 | (define-key map [delete] |
| 282 | '(menu-item "Delete" vc-dir-clean-files | 282 | '(menu-item "Delete" vc-dir-delete-files |
| 283 | :help "Delete the unregistered marked files")) | 283 | :help "Delete marked files")) |
| 284 | (define-key map [sepvcdet] '("--")) | 284 | (define-key map [sepvcdet] '("--")) |
| 285 | ;; FIXME: This needs a key binding. And maybe a better name | 285 | ;; FIXME: This needs a key binding. And maybe a better name |
| 286 | ;; ("Insert" like PCL-CVS uses does not sound that great either)... | 286 | ;; ("Insert" like PCL-CVS uses does not sound that great either)... |
| @@ -362,7 +362,7 @@ That is, refreshing the VC-Dir buffer also hides `up-to-date' and | |||
| 362 | ;; bound by `special-mode'. | 362 | ;; bound by `special-mode'. |
| 363 | ;; Marking. | 363 | ;; Marking. |
| 364 | (define-key map "m" #'vc-dir-mark) | 364 | (define-key map "m" #'vc-dir-mark) |
| 365 | (define-key map "d" #'vc-dir-clean-files) | 365 | (define-key map "d" #'vc-dir-delete-file) |
| 366 | (define-key map "M" #'vc-dir-mark-all-files) | 366 | (define-key map "M" #'vc-dir-mark-all-files) |
| 367 | (define-key map "u" #'vc-dir-unmark) | 367 | (define-key map "u" #'vc-dir-unmark) |
| 368 | (define-key map "U" #'vc-dir-unmark-all-files) | 368 | (define-key map "U" #'vc-dir-unmark-all-files) |
| @@ -1028,8 +1028,7 @@ tracked by a VCS." | |||
| 1028 | The files will also be marked as deleted in the version control | 1028 | The files will also be marked as deleted in the version control |
| 1029 | system." | 1029 | system." |
| 1030 | (interactive) | 1030 | (interactive) |
| 1031 | (mapc #'vc-delete-file (or (vc-dir-marked-files) | 1031 | (vc-delete-file (or (vc-dir-marked-files) (vc-dir-current-file)))) |
| 1032 | (list (vc-dir-current-file))))) | ||
| 1033 | 1032 | ||
| 1034 | (defun vc-dir-find-file () | 1033 | (defun vc-dir-find-file () |
| 1035 | "Find the file on the current line." | 1034 | "Find the file on the current line." |
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 63215015297..4887df63141 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el | |||
| @@ -4492,10 +4492,8 @@ file names." | |||
| 4492 | (dolist (file file-or-files) | 4492 | (dolist (file file-or-files) |
| 4493 | (let ((buf (get-file-buffer file)) | 4493 | (let ((buf (get-file-buffer file)) |
| 4494 | (backend (vc-backend file))) | 4494 | (backend (vc-backend file))) |
| 4495 | (unless backend | 4495 | (unless (or (not backend) |
| 4496 | (error "File %s is not under version control" | 4496 | (vc-find-backend-function backend 'delete-file)) |
| 4497 | (file-name-nondirectory file))) | ||
| 4498 | (unless (vc-find-backend-function backend 'delete-file) | ||
| 4499 | (error "Deleting files under %s is not supported in VC" backend)) | 4497 | (error "Deleting files under %s is not supported in VC" backend)) |
| 4500 | (when (and buf (buffer-modified-p buf)) | 4498 | (when (and buf (buffer-modified-p buf)) |
| 4501 | (error "Please save or undo your changes before deleting %s" file)) | 4499 | (error "Please save or undo your changes before deleting %s" file)) |
| @@ -4518,11 +4516,13 @@ file names." | |||
| 4518 | (with-current-buffer (or buf (find-file-noselect file)) | 4516 | (with-current-buffer (or buf (find-file-noselect file)) |
| 4519 | (let ((backup-inhibited nil)) | 4517 | (let ((backup-inhibited nil)) |
| 4520 | (backup-buffer)))) | 4518 | (backup-buffer)))) |
| 4521 | ;; Bind `default-directory' so that the command that the backend | 4519 | (when backend |
| 4522 | ;; runs to remove the file is invoked in the correct context. | 4520 | ;; Bind `default-directory' so that the command that the backend |
| 4523 | (let ((default-directory (file-name-directory file))) | 4521 | ;; runs to remove the file is invoked in the correct context. |
| 4524 | (vc-call-backend backend 'delete-file file)) | 4522 | (let ((default-directory (file-name-directory file))) |
| 4525 | ;; If the backend hasn't deleted the file itself, let's do it for him. | 4523 | (vc-call-backend backend 'delete-file file))) |
| 4524 | ;; For the case of unregistered files, or if the backend didn't | ||
| 4525 | ;; actually delete the file. | ||
| 4526 | (when (file-exists-p file) (delete-file file)) | 4526 | (when (file-exists-p file) (delete-file file)) |
| 4527 | ;; Forget what VC knew about the file. | 4527 | ;; Forget what VC knew about the file. |
| 4528 | (vc-file-clearprops file) | 4528 | (vc-file-clearprops file) |