aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas2020-01-19 15:58:06 +0100
committerStefan Kangas2020-01-19 15:59:33 +0100
commite5e31aab9b13701c0aefd93ad786d4b8feff2789 (patch)
treeb52e80e0792ce4d950c52f26cb77cbeb1641b82f
parent3d81d2326a210516496ea7b217f30cf48c897bf6 (diff)
downloademacs-e5e31aab9b13701c0aefd93ad786d4b8feff2789.tar.gz
emacs-e5e31aab9b13701c0aefd93ad786d4b8feff2789.zip
Improve error handling in dired-change-marks
* lisp/dired.el (dired-change-marks): Signal user-error if mark character is invalid. Catch more invalid characters. (Bug#29842)
-rw-r--r--lisp/dired.el28
1 files changed, 15 insertions, 13 deletions
diff --git a/lisp/dired.el b/lisp/dired.el
index 46b35ba192d..98e3be72278 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -3868,19 +3868,21 @@ OLD and NEW are both characters used to mark files."
3868 (new (progn (message "Change %c marks to (new mark): " old) 3868 (new (progn (message "Change %c marks to (new mark): " old)
3869 (read-char)))) 3869 (read-char))))
3870 (list old new))) 3870 (list old new)))
3871 (if (or (eq old ?\r) (eq new ?\r)) 3871 (dolist (c (list new old))
3872 (ding) 3872 (if (or (not (char-displayable-p c))
3873 (let ((string (format "\n%c" old)) 3873 (eq c ?\r))
3874 (inhibit-read-only t)) 3874 (user-error "Invalid mark character: `%c'" c)))
3875 (save-excursion 3875 (let ((string (format "\n%c" old))
3876 (goto-char (point-min)) 3876 (inhibit-read-only t))
3877 (while (search-forward string nil t) 3877 (save-excursion
3878 (if (if (= old ?\s) 3878 (goto-char (point-min))
3879 (save-match-data 3879 (while (search-forward string nil t)
3880 (dired-get-filename 'no-dir t)) 3880 (if (if (= old ?\s)
3881 t) 3881 (save-match-data
3882 (subst-char-in-region (match-beginning 0) 3882 (dired-get-filename 'no-dir t))
3883 (match-end 0) old new))))))) 3883 t)
3884 (subst-char-in-region (match-beginning 0)
3885 (match-end 0) old new))))))
3884 3886
3885(defun dired-unmark-all-marks () 3887(defun dired-unmark-all-marks ()
3886 "Remove all marks from all files in the Dired buffer." 3888 "Remove all marks from all files in the Dired buffer."