mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-18 11:50:38 -08:00
(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.
This commit is contained in:
parent
2ffe7ef250
commit
b602ba2fac
1 changed files with 22 additions and 16 deletions
|
|
@ -1770,26 +1770,32 @@ OLD and NEW are both characters used to mark files."
|
||||||
(match-end 0) old new))))))
|
(match-end 0) old new))))))
|
||||||
|
|
||||||
(defun dired-unmark-all-files (mark &optional arg)
|
(defun dired-unmark-all-files (mark &optional arg)
|
||||||
"Remove a specific mark or any mark from every file.
|
"Remove a specific mark (or any mark) from every file.
|
||||||
|
After this command, type the mark character to remove,
|
||||||
|
or type RET to remove all marks.
|
||||||
With prefix arg, query for each marked file.
|
With prefix arg, query for each marked file.
|
||||||
Type \\[help-command] at that time for help."
|
Type \\[help-command] at that time for help."
|
||||||
(interactive "sRemove marks (RET means all): \nP")
|
(interactive "cRemove marks (RET means all): \nP")
|
||||||
(let ((count 0)
|
|
||||||
(re (if (zerop (length mark)) dired-re-mark
|
|
||||||
(concat "^" (regexp-quote mark)))))
|
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(let (buffer-read-only case-fold-search query
|
(let* ((count 0)
|
||||||
|
buffer-read-only case-fold-search query
|
||||||
|
(string (format "\n%c" mark))
|
||||||
(help-form "\
|
(help-form "\
|
||||||
Type SPC or `y' to unmark one file, DEL or `n' to skip to next,
|
Type SPC or `y' to unmark one file, DEL or `n' to skip to next,
|
||||||
`!' to unmark all remaining files with no more questions."))
|
`!' to unmark all remaining files with no more questions."))
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(while (re-search-forward re nil t)
|
(while (if (eq mark ?\r)
|
||||||
|
(re-search-forward dired-re-mark nil t)
|
||||||
|
(search-forward string nil t))
|
||||||
(if (or (not arg)
|
(if (or (not arg)
|
||||||
(dired-query 'query "Unmark file `%s'? "
|
(dired-query 'query "Unmark file `%s'? "
|
||||||
(dired-get-filename t)))
|
(dired-get-filename t)))
|
||||||
(progn (delete-char -1) (insert " ") (setq count (1+ count))))
|
(progn (subst-char-in-region (1- (point)) (point)
|
||||||
(forward-line 1))))
|
(preceding-char) ?\ )
|
||||||
(message "%s" (format "Marks removed: %d %s" count mark))))
|
(setq count (1+ count)))))
|
||||||
|
(message (if (= count 1) "1 mark removed"
|
||||||
|
"%d marks removed")
|
||||||
|
count))))
|
||||||
|
|
||||||
;; Logging failures operating on files, and showing the results.
|
;; Logging failures operating on files, and showing the results.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue