bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Joseph Turner
Subject: bug#66224: [PATCH] Add optional PREDICATE argument to read-directory-name
Date: Thu, 28 Sep 2023 21:19:24 -0700

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Joseph Turner via "Bug reports for GNU Emacs, the Swiss army knife of
> text editors" <bug-gnu-emacs@gnu.org> 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

Thank you!! See attached patch.

Joseph

Attachment: 0001-Add-optional-PREDICATE-argument-to-read-directory-na.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]