all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: 22457@debbugs.gnu.org
Subject: bug#22457: 24.5; [PATCH] `dired-mark-if' should not count non-changes
Date: Sun, 24 Jan 2016 10:05:44 -0800 (PST)	[thread overview]
Message-ID: <2a6ff247-2b75-4f85-9a4c-889576ed7b34@default> (raw)

`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'





             reply	other threads:[~2016-01-24 18:05 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-24 18:05 Drew Adams [this message]
2019-06-25 14:42 ` bug#22457: 24.5; [PATCH] `dired-mark-if' should not count non-changes Lars Ingebrigtsen
2019-06-25 15:33   ` Drew Adams
2019-06-25 15:44     ` Lars Ingebrigtsen
2019-06-25 22:47       ` Michael Heerdegen
2019-06-25 22:53         ` Lars Ingebrigtsen
2019-06-25 23:02           ` Michael Heerdegen
2019-06-25 23:12             ` Lars Ingebrigtsen
2019-06-25 23:26             ` Drew Adams
2019-06-25 23:30               ` Michael Heerdegen
2019-06-26  0:00                 ` Drew Adams
2019-06-26  8:50               ` Andreas Schwab
2019-06-26 13:32                 ` Drew Adams
2019-06-25 23:17         ` Drew Adams
2019-06-25 23:28           ` Michael Heerdegen
2019-06-25 15:46     ` Lars Ingebrigtsen
2019-06-25 16:06       ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a6ff247-2b75-4f85-9a4c-889576ed7b34@default \
    --to=drew.adams@oracle.com \
    --cc=22457@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.