emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] master 90c25b2: Make dired commands report how many files


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master 90c25b2: Make dired commands report how many files they mark
Date: Tue, 25 Jun 2019 11:45:05 -0400 (EDT)

branch: master
commit 90c25b245259e99013dfb9292bea054a0ab4ffb6
Author: Drew Adams <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Make dired commands report how many files they mark
    
    * lisp/dired.el (dired-mark-if): Report the number of files marked
    when called, not the total number of marked files (bug#22457).
---
 etc/NEWS      |  3 +++
 lisp/dired.el | 14 +++++++-------
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index efe2501..3b229ae 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -611,6 +611,9 @@ remapped to these, respectively.
 *** New command and keystroke `dired-number-of-marked-files' bound to
 `* N'.
 
+*** The marking commands now report how many files were marked by the
+command itself, not how many files are marked in total.
+
 ** Find-Dired
 
 *** New customizable variable 'find-dired-refine-function'.
diff --git a/lisp/dired.el b/lisp/dired.el
index ce82093..5618b25 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -538,7 +538,7 @@ Subexpression 2 must end right before the \\n.")
 ;;; Macros must be defined before they are used, for the byte compiler.
 
 (defmacro dired-mark-if (predicate msg)
-  "Mark all files for which PREDICATE evals to non-nil.
+  "Mark files for PREDICATE, according to `dired-marker-char'.
 PREDICATE is evaluated on each line, with point at beginning of line.
 MSG is a noun phrase for the type of files being marked.
 It should end with a noun that can be pluralized by adding `s'.
@@ -558,13 +558,13 @@ Return value is the number of files marked, or nil if 
none were marked."
                   "")))
       (goto-char (point-min))
       (while (not (eobp))
-        (if ,predicate
-            (progn
-              (delete-char 1)
-              (insert dired-marker-char)
-              (setq count (1+ count))))
+        (when ,predicate
+          (unless (looking-at-p (char-to-string dired-marker-char))
+            (delete-char 1)
+            (insert dired-marker-char)
+            (setq count (1+ count))))
         (forward-line 1))
-      (if ,msg (message "%s %s%s %s%s."
+      (when ,msg (message "%s %s%s %s%s"
                         count
                         ,msg
                         (dired-plural-s count)



reply via email to

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