Subject: bug#18716: Patch for this bug

From: Reuben Thomas <[email-masked]>
Date: Tue, 8 Nov 2016 22:16:45 +0000

On 8 November 2016 at 20:04, Eli Zaretskii <[email-masked]> wrote:

> > From: Reuben Thomas <[email-masked]>
> > Date: Tue, 8 Nov 2016 17:51:26 +0000
> >
> > It makes dired-mark-unmarked-files act case-insensitively.
>
> You meant case-sensitively, I presume.
>

​That's right, sorry.​ Fixed.

I don't understand what happened to the comment about *.JPG files on
> case-sensitive filesystems,

I took it into account. My experience is that on a case-insensitive system
(e.g. a GNU system), one finds occasional files like this, typically copied
from other systems or extracted from archives. These are not a problem for
dired-omit-mode. For visiting such files, treating auto-mode-alist and
similar case-insensitively is no problem.

> and how does this patch do TRT on
> case-insensitive filesystems.
>

It doesn't, I've fixed it in the same way as the usage of auto-mode-alist,
by testing the system type.

> IOW, it sounds like the right solution cannot be so simple, because
> this will most probably cause user complaints of the opposite kind.
> No?​​

​See above. The only people I can see complaining are users of
case-insensitive file systems on case-sensitive systems. The correct fix
there is in any case to use the case-sensitivity of the file system, rather
than using the operating system as an indicator of that. (The same applies
to auto-mode-alist.)

Btw, if the problem is only with COPYING.LIB, maybe a better
> heuristics would be to remove .lib from completion-ignored-extensions,
> as it is no longer so widespread where Emacs users dwell?
>

​I don't think special cases are a good idea. There are other examples,
e.g. CVS is a pattern, which will also match "cvs", which I have in e.g.
wiki CVS repositories.

​I also added a couple of additional patches to tidy up obsolete
documentation, comments and code from dired-x.el.​

-- 
http://rrt.sc3d.org
From df718d0c292c761b808746c210519569a31be1a0 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Tue, 8 Nov 2016 17:42:24 +0000
Subject: [PATCH 1/3] Match files case-sensitively in dired-x

* lisp/dired-x.el (dired-mark-unmarked-files): Match the regex
case-sensitively on case-sensitive systems (Bug#18716).
---
 lisp/dired-x.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lisp/dired-x.el b/lisp/dired-x.el
index 8313905..5adf781 100644
--- a/lisp/dired-x.el
+++ b/lisp/dired-x.el
@@ -594,7 +594,10 @@ dired-mark-unmarked-files
       ;; not already marked
       (looking-at-p " ")
       ;; uninteresting
-      (let ((fn (dired-get-filename localp t)))
+      (let ((fn (dired-get-filename localp t))
+            ;; Match patterns case-insensitively on case-insensitive
+            ;; systems
+            (case-fold-search (memq system-type '(windows-nt cygwin))))
         (and fn (string-match-p regexp fn))))
      msg)))
 
-- 
2.7.4

From b351ba71ddc352ebfee8f08882299bc9b41a6b78 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Tue, 8 Nov 2016 22:01:59 +0000
Subject: [PATCH 2/3] Remove pre-customize dired-x.el documentation

* lisp/dired-x.el (Commentary): Remove USAGE section explaining how to
use dired-x from .emacs.  It is now fully customizable.
* lisp/dired-x.el (dired-guess-shell-alist-user): Remove explanation of
how to set this custom variable in .emacs.  It should be customized.
---
 lisp/dired-x.el | 26 +-------------------------
 1 file changed, 1 insertion(+), 25 deletions(-)

diff --git a/lisp/dired-x.el b/lisp/dired-x.el
index 5adf781..30cfaf4 100644
--- a/lisp/dired-x.el
+++ b/lisp/dired-x.el
@@ -29,20 +29,6 @@
 ;; This is based on Sebastian Kremer's excellent dired-x.el (Dired Extra),
 ;; version 1.191, adapted for GNU Emacs.  See the `dired-x' info pages.
 
-;; USAGE: In your ~/.emacs,
-;;
-;; (add-hook 'dired-load-hook
-;;           (lambda ()
-;;                       (load "dired-x")
-;;                       ;; Set global variables here.  For example:
-;;                       ;; (setq dired-guess-shell-gnutar "gtar")
-;;                       ))
-;; (add-hook 'dired-mode-hook
-;;           (lambda ()
-;;                       ;; Set buffer-local variables here.  For example:
-;;                       ;; (dired-omit-mode 1)
-;;                       ))
-;;
 ;; At load time dired-x.el will install itself and bind some dired keys.
 ;; Some dired.el and dired-aux.el functions have extra features if
 ;; dired-x is loaded.
@@ -1082,17 +1068,7 @@ dired-guess-shell-alist-user
 with \\[previous-history-element] (M-p) .
 
 The variable `dired-guess-shell-case-fold-search' controls whether
-REGEXP is matched case-sensitively.
-
-You can set this variable in your ~/.emacs.  For example, to add rules for
-`.foo' and `.bar' files, write
-
- (setq dired-guess-shell-alist-user
-        '((\"\\\\.foo\\\\'\" \"FOO-COMMAND\")
-          (\"\\\\.bar\\\\'\"
-           (if condition
-              \"BAR-COMMAND-1\"
-            \"BAR-COMMAND-2\"))))"
+REGEXP is matched case-sensitively."
   :group 'dired-x
   :type '(alist :key-type regexp :value-type (repeat sexp)))
 
-- 
2.7.4

From c9ec6bc3187cb3a90ae748ec08cb0f3c000ba353 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <[email-masked]>
Date: Tue, 8 Nov 2016 22:04:52 +0000
Subject: [PATCH 3/3] Remove obsolete comments and commented code from
 dired-x.el

* lisp/dired-x.el (dired-mark-sexp): Remove a query from 1993 and its
1997 answer about whether dired-mark-sexp is used.
* lisp/dired-x.el (dired-buffers-for-dir-exact): Remove this function
commented out since before dired-x.el was added to RCS in 1994.
---
 lisp/dired-x.el | 26 --------------------------
 1 file changed, 26 deletions(-)

diff --git a/lisp/dired-x.el b/lisp/dired-x.el
index 30cfaf4..e5957b4 100644
--- a/lisp/dired-x.el
+++ b/lisp/dired-x.el
@@ -1376,29 +1376,6 @@ dired-buffer-more-recently-used-p
        (memq buffer1 (buffer-list))
        (not (memq buffer1 (memq buffer2 (buffer-list))))))
 
-;; Same thing as `dired-buffers-for-dir' of dired.el? - lrd 11/23/93
-;; (defun dired-buffers-for-dir-exact (dir)
-;; ;; Return a list of buffers that dired DIR (a directory or wildcard)
-;; ;; at top level, or as subdirectory.
-;; ;; Top level matches must match the wildcard part too, if any.
-;; ;; The list is in reverse order of buffer creation, most recent last.
-;; ;; As a side effect, killed dired buffers for DIR are removed from
-;; ;; dired-buffers.
-;;   (let ((alist dired-buffers) result elt)
-;;     (while alist
-;;       (setq elt (car alist)
-;;             alist (cdr alist))
-;;       (let ((buf (cdr elt)))
-;;         (if (buffer-name buf)
-;;             ;; Top level must match exactly against dired-directory in
-;;             ;; case one of them is a wildcard.
-;;             (if (or (equal dir (with-current-buffer buf dired-directory))
-;;                     (assoc dir (with-current-buffer buf dired-subdir-alist)))
-;;                 (setq result (cons buf result)))
-;;           ;; else buffer is killed - clean up:
-;;           (setq dired-buffers (delq elt dired-buffers)))))
-;;     result))
-
 
 ;; Needed if ls -lh is supported and also for GNU ls -ls.
 (defun dired-x--string-to-number (str)
@@ -1416,9 +1393,6 @@ dired-x--string-to-number
           (setq val (* 1024.0 val)))))
     val))
 
-;; Does anyone use this? - lrd 6/29/93.
-;; Apparently people do use it. - lrd 12/22/97.
-
 (defun dired-mark-sexp (predicate &optional unflag-p)
   "Mark files for which PREDICATE returns non-nil.
 With a prefix arg, unmark or unflag those files instead.
-- 
2.7.4