Subject: bug#49554: 28.0.50; [PATCH] dired-number-of-marked-files doesn't work correctly when there are no marked files

From: Daniel Martín <[email-masked]>
Date: Tue, 13 Jul 2021 22:30:00 +0200

Steps to reproduce the problem:

emacs -Q
Open a directory with files in Dired.
* N

Actual results:

The echo area shows "0 files marked (total size XX)".

After reading the source code, I think it should only show "No marked
files", but there's a syntax mistake in an if expression.  I've attached
a patch to correct the problem.  Thanks.

>From f31d307582c4a1350dc0572b651ee3faeb2d66c6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <[email-masked]>
Date: Tue, 13 Jul 2021 22:09:43 +0200
Subject: [PATCH] Fix dired-number-of-marked-files when there are no marked
 files

* lisp/dired.el (dired-number-of-marked-files): Fix if expression so
that the else part is evaluated correctly.
---
 lisp/dired.el | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lisp/dired.el b/lisp/dired.el
index fb353a92e4..7f24f752f7 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -3836,13 +3836,13 @@ dired-number-of-marked-files
                         when (stringp file)
                         sum (file-attribute-size (file-attributes file)))))
     (if (zerop nmarked)
-        (message "No marked files"))
-    (message "%d marked file%s (%s total size)"
-             nmarked
-             (if (= nmarked 1)
-                 ""
-               "s")
-             (funcall byte-count-to-string-function size))))
+        (message "No marked files")
+      (message "%d marked file%s (%s total size)"
+               nmarked
+               (if (= nmarked 1)
+                   ""
+                 "s")
+               (funcall byte-count-to-string-function size)))))
 
 (defun dired-mark-files-containing-regexp (regexp &optional marker-char)
   "Mark all files with contents containing REGEXP for use in later commands.
-- 
2.31.0