[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 50b9ddf 2/4: Allow files to be matched case-sensiti
From: |
Reuben Thomas |
Subject: |
[Emacs-diffs] master 50b9ddf 2/4: Allow files to be matched case-sensitively in dired-x |
Date: |
Fri, 2 Dec 2016 16:09:36 +0000 (UTC) |
branch: master
commit 50b9ddfc132ead94a932e55ac39211b483109592
Author: Reuben Thomas <address@hidden>
Commit: Reuben Thomas <address@hidden>
Allow files to be matched case-sensitively in dired-x
* lisp/dired-x.el (dired-mark-unmarked-files): Add an argument which
controls case folding for matching the regex (Bug#18716).
(dired-omit-case-fold): New variable. Defaults to `t' on case-sensitive
systems, `nil' otherwise.
(dired-mark-omitted, dired-omit-expunge): Use dired-omit-case-fold.
* doc/misc/dired-x.texi, etc/NEWS: Document dired-omit-case-fold.
---
doc/misc/dired-x.texi | 12 ++++++++++++
etc/NEWS | 6 ++++++
lisp/dired-x.el | 37 ++++++++++++++++++++++++++++++++-----
3 files changed, 50 insertions(+), 5 deletions(-)
diff --git a/doc/misc/dired-x.texi b/doc/misc/dired-x.texi
index db01896..7ac5bc6 100644
--- a/doc/misc/dired-x.texi
+++ b/doc/misc/dired-x.texi
@@ -369,6 +369,18 @@ and @code{dired-texinfo-unclean-extensions}.
If address@hidden, a list of extensions (strings) to omit from Dired listings.
Its format is the same as that of @code{completion-ignored-extensions}.
address@hidden dired-omit-case-fold
address@hidden dired-omit-case-fold
+
+Default: @code{filesystem}
+
+By default, when @code{dired-omit-case-fold} is set to @code{filesystem},
address@hidden will match filenames and extensions
+case-sensitively on Dired buffers visiting case-sensitive filesystems,
+and case-insensitively on case-insensitive filesystems. Set it to
address@hidden to be always case-sensitive, and to @code{t} to be always
+case-insensitive.
+
@vindex dired-omit-localp
@item dired-omit-localp
diff --git a/etc/NEWS b/etc/NEWS
index cbce027..0d2162c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -83,6 +83,12 @@ of curved quotes for 'electric-quote-mode', allowing user to
choose
the types of quotes to be used.
+++
+** The new user variable 'dired-omit-case-fold' allows the user to
+customize the case-sensitivity of dired-omit-mode. It defaults to
+the same sensitivity as that of the filesystem for the corresponding
+dired buffer.
+
++++
** Emacs now uses double buffering to reduce flicker when editing and
resizing graphical Emacs frames on the X Window System. This support
requires the DOUBLE-BUFFER extension, which major X servers have
diff --git a/lisp/dired-x.el b/lisp/dired-x.el
index 8313905..5a0d883 100644
--- a/lisp/dired-x.el
+++ b/lisp/dired-x.el
@@ -133,6 +133,26 @@ If nil, there is no maximum size."
:type '(choice (const :tag "no maximum" nil) integer)
:group 'dired-x)
+(defcustom dired-omit-case-fold 'filesystem
+ "Determine whether `dired-omit-mode' will use case-folding to
+match the regexp of files to omit. When nil, always be
+case-sensitive; when t, always be case-insensitive; the default
+value, 'filesystem, causes case folding to be used on
+case-insensitive filesystems only."
+ :type '(choice (const :tag "Always case-sensitive" nil)
+ (const :tag "Always case-insensitive" t)
+ (const :tag "According to filesystem" filesystem))
+ :group 'dired-x
+ :version "26.1")
+
+(defun dired-omit-case-fold-p (dir)
+ "Return t if, according to `dired-omit-case-fold',
+ `dired-omit-mode' should use case folding to interpret its
+ regexp in directory DIR, or nil otherwise."
+ (if (eq dired-omit-case-fold 'filesystem)
+ (file-name-case-sensitive-p dir)
+ dired-omit-case-fold))
+
;; For backward compatibility
(define-obsolete-variable-alias 'dired-omit-files-p 'dired-omit-mode "22.1")
(define-minor-mode dired-omit-mode
@@ -507,7 +527,8 @@ Should never be used as marker by the user or other
packages.")
"Mark files matching `dired-omit-files' and `dired-omit-extensions'."
(interactive)
(let ((dired-omit-mode nil)) (revert-buffer)) ;; Show omitted files
- (dired-mark-unmarked-files (dired-omit-regexp) nil nil dired-omit-localp))
+ (dired-mark-unmarked-files (dired-omit-regexp) nil nil dired-omit-localp
+ (dired-omit-case-fold-p dired-directory)))
(defcustom dired-omit-extensions
(append completion-ignored-extensions
@@ -551,7 +572,8 @@ This functions works by temporarily binding
`dired-marker-char' to
(or (string= omit-re "")
(let ((dired-marker-char dired-omit-marker-char))
(when dired-omit-verbose (message "Omitting..."))
- (if (dired-mark-unmarked-files omit-re nil nil dired-omit-localp)
+ (if (dired-mark-unmarked-files omit-re nil nil dired-omit-localp
+ (dired-omit-case-fold-p
dired-directory))
(progn
(setq count (dired-do-kill-lines
nil
@@ -577,12 +599,14 @@ This functions works by temporarily binding
`dired-marker-char' to
"")))
;; Returns t if any work was done, nil otherwise.
-(defun dired-mark-unmarked-files (regexp msg &optional unflag-p localp)
+(defun dired-mark-unmarked-files (regexp msg &optional unflag-p localp
case-fold-p)
"Mark unmarked files matching REGEXP, displaying MSG.
REGEXP is matched against the entire file name. When called
interactively, prompt for REGEXP.
With prefix argument, unflag all those files.
-Optional fourth argument LOCALP is as in `dired-get-filename'."
+Optional fourth argument LOCALP is as in `dired-get-filename'.
+Optional fifth argument CASE-FOLD-P specifies the value of
+`case-fold-search' used for matching REGEXP."
(interactive
(list (read-regexp
"Mark unmarked files matching regexp (default all): "
@@ -594,7 +618,10 @@ Optional fourth argument LOCALP is as in
`dired-get-filename'."
;; 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 case-fold-p))
(and fn (string-match-p regexp fn))))
msg)))