GNU bug report logs - #22457
24.5; [PATCH] `dired-mark-if' should not count non-changes

Previous Next

Package: emacs;

Reported by: Drew Adams <drew.adams <at> oracle.com>

Date: Sun, 24 Jan 2016 18:06:02 UTC

Severity: minor

Tags: fixed

Found in version 24.5

Fixed in version 27.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Drew Adams <drew.adams <at> oracle.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.5; [PATCH] `dired-mark-if' should not count non-changes
Date: Sun, 24 Jan 2016 10:05:44 -0800 (PST)
`dired-mark-if' marks, unmarks, or flags Dired lines that satisfy its
PREDICATE argument.

But it should do nothing if a given line is already so marked, unmarked,
or flagged.  More importantly, it should not count that line as having
been marked, unmarked, or flagged.  The message that echoes the count of
changes should not take such non-changes into account.

(Also, trivially, the message should not end in a period (.).)

Yes, this is a change in behavior (the message) observed by users.  But
it is TRT, IMO.

Here is a fixed version of the macro.  The diff is trivial.

(defmacro dired-mark-if (predicate msg)
  "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'.
Return value is the number of files marked, or nil if none were marked."
  `(let ((inhibit-read-only  t)
         count)
    (save-excursion
      (setq count  0)
      (when ,msg (message "%s %ss%s..."
                          (cond ((eq dired-marker-char ?\040)            "Unmarking")
                                ((eq dired-del-marker dired-marker-char) "Flagging")
                                (t                                       "Marking"))
                          ,msg
                          (if (eq dired-del-marker dired-marker-char) " for deletion" "")))
      (goto-char (point-min))
      (while (not (eobp))
        (when ,predicate
          (unless (looking-at (char-to-string dired-marker-char))
            (delete-char 1) (insert dired-marker-char) (setq count  (1+ count))))
        (forward-line 1))
      (when ,msg (message "%s %s%s %s%s" count ,msg
                          (dired-plural-s count)
                          (if (eq dired-marker-char ?\040) "un" "")
                          (if (eq dired-marker-char dired-del-marker) "flagged" "marked"))))
    (and (> count 0)  count)))


In GNU Emacs 24.5.1 (i686-pc-mingw32)
 of 2015-04-11 on LEG570
Windowing system distributor `Microsoft Corp.', version 6.1.7601
Configured using:
 `configure --prefix=/c/usr --host=i686-pc-mingw32'




This bug report was last modified 6 years and 3 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.