From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#22457: 24.5; [PATCH] `dired-mark-if' should not count non-changes Date: Sun, 24 Jan 2016 10:05:44 -0800 (PST) Message-ID: <2a6ff247-2b75-4f85-9a4c-889576ed7b34@default> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1453658784 8947 80.91.229.3 (24 Jan 2016 18:06:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 24 Jan 2016 18:06:24 +0000 (UTC) To: 22457@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jan 24 19:06:10 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aNP3C-0000Yx-EV for geb-bug-gnu-emacs@m.gmane.org; Sun, 24 Jan 2016 19:06:10 +0100 Original-Received: from localhost ([::1]:33017 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNP3B-0000Uq-EB for geb-bug-gnu-emacs@m.gmane.org; Sun, 24 Jan 2016 13:06:09 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53243) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNP38-0000Ua-2f for bug-gnu-emacs@gnu.org; Sun, 24 Jan 2016 13:06:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aNP34-0002wd-Rs for bug-gnu-emacs@gnu.org; Sun, 24 Jan 2016 13:06:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46889) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNP34-0002wX-O5 for bug-gnu-emacs@gnu.org; Sun, 24 Jan 2016 13:06:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aNP34-0005ha-7R for bug-gnu-emacs@gnu.org; Sun, 24 Jan 2016 13:06:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 24 Jan 2016 18:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 22457 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.145365875921908 (code B ref -1); Sun, 24 Jan 2016 18:06:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 24 Jan 2016 18:05:59 +0000 Original-Received: from localhost ([127.0.0.1]:35109 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aNP31-0005hH-8A for submit@debbugs.gnu.org; Sun, 24 Jan 2016 13:05:59 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:33990) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aNP2z-0005h5-GT for submit@debbugs.gnu.org; Sun, 24 Jan 2016 13:05:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aNP2t-0002sd-F7 for submit@debbugs.gnu.org; Sun, 24 Jan 2016 13:05:52 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:39709) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNP2t-0002sQ-BV for submit@debbugs.gnu.org; Sun, 24 Jan 2016 13:05:51 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNP2s-0000UN-DN for bug-gnu-emacs@gnu.org; Sun, 24 Jan 2016 13:05:51 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aNP2p-0002pR-68 for bug-gnu-emacs@gnu.org; Sun, 24 Jan 2016 13:05:50 -0500 Original-Received: from aserp1040.oracle.com ([141.146.126.69]:47255) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNP2o-0002ok-Ve for bug-gnu-emacs@gnu.org; Sun, 24 Jan 2016 13:05:47 -0500 Original-Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u0OI5jfG031955 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sun, 24 Jan 2016 18:05:46 GMT Original-Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.13.8/8.13.8) with ESMTP id u0OI5jdC026398 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Sun, 24 Jan 2016 18:05:45 GMT Original-Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id u0OI5jpu015187 for ; Sun, 24 Jan 2016 18:05:45 GMT X-Priority: 3 X-Mailer: Oracle Beehive Extensions for Outlook 2.0.1.9 (901082) [OL 12.0.6691.5000 (x86)] X-Source-IP: aserv0022.oracle.com [141.146.126.234] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:111927 Archived-At: `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) "U= nmarking") ((eq dired-del-marker dired-marker-char) "F= lagging") (t "M= arking")) ,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+ cou= nt)))) (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) "flag= ged" "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=3D/c/usr --host=3Di686-pc-mingw32'