emacs-31 00c290be853: Avoid infinite loop in some Dired marking commands

Stephen Berman via Mailing list for Emacs changes <[email protected]>
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: emacs-31
commit 00c290be85313f0c75c742896833e65a07033108
Author: milkvetch <[email protected]>
Commit: Stephen Berman <[email protected]>

    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.
---
 lisp/dired-aux.el | 8 ++++++--
 lisp/dired-x.el   | 1 +
 lisp/dired.el     | 2 ++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/lisp/dired-aux.el b/lisp/dired-aux.el
index a870f610094..50287a67129 100644
--- a/lisp/dired-aux.el
+++ b/lisp/dired-aux.el
@@ -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))
diff --git a/lisp/dired-x.el b/lisp/dired-x.el
index ecd7c83e42a..128332bb0cf 100644
--- a/lisp/dired-x.el
+++ b/lisp/dired-x.el
@@ -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))
diff --git a/lisp/dired.el b/lisp/dired.el
index 26e698341d8..53ec6779061 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -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)))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.