Subject: bug#66224: [PATCH] Add optional PREDICATE argument to read-directory-name

From: Michael Heerdegen <[email-masked]>
Date: Fri, 29 Sep 2023 05:54:31 +0200

Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <[email-masked]> writes:

> -		  'file-directory-p))
> +                  (lambda (filename)
> +                    (if predicate
> +                        (and (file-directory-p filename)
> +                             (funcall predicate filename))
> +                      (file-directory-p filename)))))

Yip.  Nitpick: The code will be faster if you move the test out of the
predicate (so that it will not be performed repeatedly):

#+begin_src emacs-lisp
(if predicate
    (lambda (filename)
      (and (file-directory-p filename)
           (funcall predicate filename)))
  #'file-directory-p)
#+end_src

Michael.