emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master e5e31aa: Improve error handling in dired-change-marks


From: Stefan Kangas
Subject: master e5e31aa: Improve error handling in dired-change-marks
Date: Sun, 19 Jan 2020 10:01:08 -0500 (EST)

branch: master
commit e5e31aab9b13701c0aefd93ad786d4b8feff2789
Author: Stefan Kangas <address@hidden>
Commit: Stefan Kangas <address@hidden>

    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)
---
 lisp/dired.el | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/lisp/dired.el b/lisp/dired.el
index 46b35ba..98e3be7 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -3868,19 +3868,21 @@ OLD and NEW are both characters used to mark files."
          (new (progn (message  "Change %c marks to (new mark): " old)
                      (read-char))))
      (list old new)))
-  (if (or (eq old ?\r) (eq new ?\r))
-      (ding)
-    (let ((string (format "\n%c" old))
-         (inhibit-read-only t))
-      (save-excursion
-       (goto-char (point-min))
-       (while (search-forward string nil t)
-         (if (if (= old ?\s)
-                 (save-match-data
-                   (dired-get-filename 'no-dir t))
-               t)
-             (subst-char-in-region (match-beginning 0)
-                                   (match-end 0) old new)))))))
+  (dolist (c (list new old))
+    (if (or (not (char-displayable-p c))
+            (eq c ?\r))
+        (user-error "Invalid mark character: `%c'" c)))
+  (let ((string (format "\n%c" old))
+        (inhibit-read-only t))
+    (save-excursion
+      (goto-char (point-min))
+      (while (search-forward string nil t)
+        (if (if (= old ?\s)
+                (save-match-data
+                  (dired-get-filename 'no-dir t))
+              t)
+            (subst-char-in-region (match-beginning 0)
+                                  (match-end 0) old new))))))
 
 (defun dired-unmark-all-marks ()
   "Remove all marks from all files in the Dired buffer."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]