1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-26 10:49:33 +00:00

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.
This commit is contained in:
Reuben Thomas 2016-11-08 17:42:24 +00:00
parent b6a8025eed
commit 50b9ddfc13
3 changed files with 50 additions and 5 deletions

View File

@ -369,6 +369,18 @@ and @code{dired-texinfo-unclean-extensions}.
If non-@code{nil}, a list of extensions (strings) to omit from Dired listings.
Its format is the same as that of @code{completion-ignored-extensions}.
@vindex dired-omit-case-fold
@item dired-omit-case-fold
Default: @code{filesystem}
By default, when @code{dired-omit-case-fold} is set to @code{filesystem},
@code{dired-omit-mode} will match filenames and extensions
case-sensitively on Dired buffers visiting case-sensitive filesystems,
and case-insensitively on case-insensitive filesystems. Set it to
@code{nil} to be always case-sensitive, and to @code{t} to be always
case-insensitive.
@vindex dired-omit-localp
@item dired-omit-localp

View File

@ -82,6 +82,12 @@ given file is on a case-insensitive filesystem.
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

View File

@ -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)))