diff options
| author | Richard M. Stallman | 1993-06-06 21:13:16 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1993-06-06 21:13:16 +0000 |
| commit | b602ba2face6a3ca956f680fac95f8a8a4d74e4c (patch) | |
| tree | f34ab6bcba2897ce8ff750ebd7f7339e13a3593a | |
| parent | 2ffe7ef25038b822b54b87a36b4741133297afe0 (diff) | |
| download | emacs-b602ba2face6a3ca956f680fac95f8a8a4d74e4c.tar.gz emacs-b602ba2face6a3ca956f680fac95f8a8a4d74e4c.zip | |
(dired-unmark-all-files): Read arg as just a character.
Use non-regexp search to find a specific mark.
Use subst-char-in-region to make the change.
Improve the message at the end.
| -rw-r--r-- | lisp/dired.el | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/lisp/dired.el b/lisp/dired.el index 9d0fd907eea..4cdc1dab066 100644 --- a/lisp/dired.el +++ b/lisp/dired.el | |||
| @@ -1770,26 +1770,32 @@ OLD and NEW are both characters used to mark files." | |||
| 1770 | (match-end 0) old new)))))) | 1770 | (match-end 0) old new)))))) |
| 1771 | 1771 | ||
| 1772 | (defun dired-unmark-all-files (mark &optional arg) | 1772 | (defun dired-unmark-all-files (mark &optional arg) |
| 1773 | "Remove a specific mark or any mark from every file. | 1773 | "Remove a specific mark (or any mark) from every file. |
| 1774 | After this command, type the mark character to remove, | ||
| 1775 | or type RET to remove all marks. | ||
| 1774 | With prefix arg, query for each marked file. | 1776 | With prefix arg, query for each marked file. |
| 1775 | Type \\[help-command] at that time for help." | 1777 | Type \\[help-command] at that time for help." |
| 1776 | (interactive "sRemove marks (RET means all): \nP") | 1778 | (interactive "cRemove marks (RET means all): \nP") |
| 1777 | (let ((count 0) | 1779 | (save-excursion |
| 1778 | (re (if (zerop (length mark)) dired-re-mark | 1780 | (let* ((count 0) |
| 1779 | (concat "^" (regexp-quote mark))))) | 1781 | buffer-read-only case-fold-search query |
| 1780 | (save-excursion | 1782 | (string (format "\n%c" mark)) |
| 1781 | (let (buffer-read-only case-fold-search query | 1783 | (help-form "\ |
| 1782 | (help-form "\ | ||
| 1783 | Type SPC or `y' to unmark one file, DEL or `n' to skip to next, | 1784 | Type SPC or `y' to unmark one file, DEL or `n' to skip to next, |
| 1784 | `!' to unmark all remaining files with no more questions.")) | 1785 | `!' to unmark all remaining files with no more questions.")) |
| 1785 | (goto-char (point-min)) | 1786 | (goto-char (point-min)) |
| 1786 | (while (re-search-forward re nil t) | 1787 | (while (if (eq mark ?\r) |
| 1787 | (if (or (not arg) | 1788 | (re-search-forward dired-re-mark nil t) |
| 1788 | (dired-query 'query "Unmark file `%s'? " | 1789 | (search-forward string nil t)) |
| 1789 | (dired-get-filename t))) | 1790 | (if (or (not arg) |
| 1790 | (progn (delete-char -1) (insert " ") (setq count (1+ count)))) | 1791 | (dired-query 'query "Unmark file `%s'? " |
| 1791 | (forward-line 1)))) | 1792 | (dired-get-filename t))) |
| 1792 | (message "%s" (format "Marks removed: %d %s" count mark)))) | 1793 | (progn (subst-char-in-region (1- (point)) (point) |
| 1794 | (preceding-char) ?\ ) | ||
| 1795 | (setq count (1+ count))))) | ||
| 1796 | (message (if (= count 1) "1 mark removed" | ||
| 1797 | "%d marks removed") | ||
| 1798 | count)))) | ||
| 1793 | 1799 | ||
| 1794 | ;; Logging failures operating on files, and showing the results. | 1800 | ;; Logging failures operating on files, and showing the results. |
| 1795 | 1801 | ||