diff options
| author | Sean Whitton | 2023-12-29 17:41:35 +0000 |
|---|---|---|
| committer | Sean Whitton | 2023-12-29 17:42:02 +0000 |
| commit | d7ff14fcba6f0830eeadb98981bb626cf7314c53 (patch) | |
| tree | c3896adae79cc11cd9478f738a8b82573456b46f | |
| parent | b0bead793f880a9434c38caeaa744f7d7a0e519b (diff) | |
| download | emacs-d7ff14fcba6f0830eeadb98981bb626cf7314c53.tar.gz emacs-d7ff14fcba6f0830eeadb98981bb626cf7314c53.zip | |
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).
| -rw-r--r-- | lisp/pcomplete.el | 14 |
1 files 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'." | |||
| 902 | (and dir-ignore (string-match dir-ignore file)) | 902 | (and dir-ignore (string-match dir-ignore file)) |
| 903 | (and file-ignore (string-match file-ignore file)))))))) | 903 | (and file-ignore (string-match file-ignore file)))))))) |
| 904 | (reg-pred (if regexp (lambda (file) (string-match regexp file)))) | 904 | (reg-pred (if regexp (lambda (file) (string-match regexp file)))) |
| 905 | (pred (cond | 905 | ;; `completion-file-name-table' calls `file-exists-p' when |
| 906 | ((null (or ign-pred reg-pred)) predicate) | 906 | ;; the predicate is nil. |
| 907 | ((null (or ign-pred predicate)) reg-pred) | 907 | ;; So likewise, defer to PREDICATE if it's there, else take |
| 908 | ((null (or reg-pred predicate)) ign-pred) | 908 | ;; ourselves to be responsible for calling `file-exists-p'. |
| 909 | (t (lambda (f) | 909 | (pred (if (or ign-pred reg-pred) |
| 910 | (lambda (f) | ||
| 910 | (and (or (null reg-pred) (funcall reg-pred f)) | 911 | (and (or (null reg-pred) (funcall reg-pred f)) |
| 911 | (or (null ign-pred) (funcall ign-pred f)) | 912 | (or (null ign-pred) (funcall ign-pred f)) |
| 912 | (or (null predicate) (funcall predicate f)))))))) | 913 | (funcall (or predicate #'file-exists-p) f))) |
| 914 | predicate))) | ||
| 913 | (lambda (s p a) | 915 | (lambda (s p a) |
| 914 | (if (and (eq a 'metadata) pcomplete-compare-entry-function) | 916 | (if (and (eq a 'metadata) pcomplete-compare-entry-function) |
| 915 | `(metadata (cycle-sort-function | 917 | `(metadata (cycle-sort-function |