emacs-diffs
[Top][All Lists]
Advanced

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

master d7ff14fcba6: pcomplete--entries: In predicate, check file exists


From: Sean Whitton
Subject: master d7ff14fcba6: pcomplete--entries: In predicate, check file exists
Date: Fri, 29 Dec 2023 12:42:05 -0500 (EST)

branch: master
commit d7ff14fcba6f0830eeadb98981bb626cf7314c53
Author: Sean Whitton <spwhitton@spwhitton.name>
Commit: Sean Whitton <spwhitton@spwhitton.name>

    pcomplete--entries: In predicate, check file exists
    
    * lisp/pcomplete.el (pcomplete--entries): In the predicate passed to
    completion-table-with-predicate, when PREDICATE is nil, take ourselves
    to be responsible for calling file-exists-p (bug#67661).
---
 lisp/pcomplete.el | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lisp/pcomplete.el b/lisp/pcomplete.el
index 3dde001328d..109968399aa 100644
--- a/lisp/pcomplete.el
+++ b/lisp/pcomplete.el
@@ -902,14 +902,16 @@ this is `comint-dynamic-complete-functions'."
                      (and dir-ignore (string-match dir-ignore file))
                    (and file-ignore (string-match file-ignore file))))))))
          (reg-pred (if regexp (lambda (file) (string-match regexp file))))
-         (pred (cond
-                ((null (or ign-pred reg-pred))  predicate)
-                ((null (or ign-pred predicate)) reg-pred)
-                ((null (or reg-pred predicate)) ign-pred)
-                (t (lambda (f)
+         ;; `completion-file-name-table' calls `file-exists-p' when
+         ;; the predicate is nil.
+         ;; So likewise, defer to PREDICATE if it's there, else take
+         ;; ourselves to be responsible for calling `file-exists-p'.
+         (pred (if (or ign-pred reg-pred)
+                   (lambda (f)
                      (and (or (null reg-pred)  (funcall reg-pred f))
                           (or (null ign-pred)  (funcall ign-pred f))
-                          (or (null predicate) (funcall predicate f))))))))
+                          (funcall (or predicate #'file-exists-p) f)))
+                 predicate)))
     (lambda (s p a)
       (if (and (eq a 'metadata) pcomplete-compare-entry-function)
           `(metadata (cycle-sort-function



reply via email to

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