Subject: bug#27465: 24.5; `dired-mark-unmarked-files' with non-nil UNFLAG-P

From: Drew Adams <[email-masked]>
Date: Fri, 23 Jun 2017 15:44:21 -0700 (PDT)

AFAICT this could never have worked.

1. Prior to Emacs 24, the interactive spec was just "P", which could of
   course not work interactively.  In Emacs 24 it was changed to read
   the REGEXP and use the prefix arg for UNFLAG-P.  That "P" was an
   indication that the command never worked interactively and was
   probably ill-conceived for that.  And that "P" remained from Emacs
   20 (if not before) through 23.

2. There are no occurrences in the Elisp sources that use non-nil
   UNFLAG-P.

3. Non-nil UNFLAG-P does nothing, AFAICT.  It _cannot_ do anything.
   Certainly it cannot unflag, which means change a deletion flag (`D')
   to a space char.  Why?  Because the replacement is applied only to
   lines that already have a space char (not a `D').

   Its effect in that case is indeed to post a space char.  But it does
   so only for lines that already have a space char!

   This is the call:

   (dired-mark-if
     (and
      (looking-at-p " ") ; <=== Mark (with a SPC) only if already there!
      (let ((fn (dired-get-filename localp t)))
        (and fn (string-match-p regexp fn))))
     msg)

What to do?  I suggest NOT trying to have any "unflag" behavior here.
If it were fixed, so that it actually replaced `D' with ` ' when there
is a prefix arg, I think that behavior would be confusing.  IOW, better
not to fix the implementation to fix an awful design.  Mark-if-unmarked
should not mean unflag sometimes.

But if you really want to fix this so that it does what the doc says,
that's OK by me.  Something should be done about it, anyway.

(BTW, the comment "uninteresting" is backward wrt the comment "not
already marked".  The files that are checked are those that are not
already marked and are interesting, i.e, match.)

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'