Avoid infinite loop in some Dired marking commands

These commands use dired-get-filename inside a dired-mark-if form;
when the bottom subdirectory is hidden, dired-get-filename makes
it so the dired-mark-if loop never reaches the end of the buffer.
This is fixed by skipping hidden subdirectories (bug#80964).

* lisp/dired.el (dired-mark-files-regexp)
(dired-mark-files-containing-regexp):
* lisp/dired-x.el (dired-mark-unmarked-files):
* lisp/dired-aux.el (dired-compare-directories): Skip hidden subdirectories.
This commit is contained in:
milkvetch 2026-06-21 20:19:19 +02:00 committed by Stephen Berman
parent e78a0fc9f4
commit 00c290be85
3 changed files with 9 additions and 2 deletions

View file

@ -361,12 +361,16 @@ only in the active region if `dired-mark-region' is non-nil."
dir1 nil
(lambda ()
(dired-mark-if
(member (dired-get-filename nil t) file-list1) nil)))
(and (not (dired--hidden-p))
(member (dired-get-filename nil t) file-list1))
nil)))
(dired-fun-in-all-buffers
dir2 nil
(lambda ()
(dired-mark-if
(member (dired-get-filename nil t) file-list2) nil)))
(and (not (dired--hidden-p))
(member (dired-get-filename nil t) file-list2))
nil)))
(message "Marked in dir1: %s, in dir2: %s"
(format-message (ngettext "%d file" "%d files" (length file-list1))
(length file-list1))

View file

@ -552,6 +552,7 @@ files in the active region if `dired-mark-region' is non-nil."
(let ((dired-marker-char (if unflag-p ?\s dired-marker-char)))
(dired-mark-if
(and
(not (dired--hidden-p))
(if unflag-p
;; Already marked.
(not (= (following-char) ?\s))

View file

@ -4766,6 +4766,7 @@ object files--just `.o' will mark more than you might think."
(dired-mark-if
(and (not (looking-at-p dired-re-dot))
(not (eolp)) ; empty line
(not (dired--hidden-p))
(let ((fn (dired-get-filename t t)))
(and fn (string-match-p regexp fn))))
"matching file")))
@ -4817,6 +4818,7 @@ since it was last visited."
(dired-mark-if
(and (not (looking-at-p dired-re-dot))
(not (eolp)) ; empty line
(not (dired--hidden-p))
(let ((fn (dired-get-filename nil t)))
(when (and fn (file-readable-p fn)
(not (file-directory-p fn)))