summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2021-05-17 11:31:01 +0200
committerDaniel Mendler <mail@daniel-mendler.de>2021-05-17 11:31:01 +0200
commit02a2cbbaa52f1663705a39e5710bc39e1c76c700 (patch)
treeaf8a591173d2f977ad72e95152fcaf065ff015c0
parent7e5710c28293046c58f56e7486fb4ba8cd6354b8 (diff)
Do not overwrite the file predicate
See https://github.com/minad/vertico/commit/f281aac2e875d8333e29206ec25aaeea8f3d6800
-rw-r--r--corfu.el28
1 files changed, 11 insertions, 17 deletions
diff --git a/corfu.el b/corfu.el
index c59be1f..a9fc330 100644
--- a/corfu.el
+++ b/corfu.el
@@ -34,9 +34,8 @@
;;; Code:
(require 'seq)
-(eval-when-compile
- (require 'subr-x)
- (require 'cl-lib))
+(require 'cl-lib)
+(eval-when-compile (require 'subr-x))
(defgroup corfu nil
"Completion Overlay Region FUnction."
@@ -359,15 +358,6 @@ Set to nil in order to disable confirmation."
(and (= (length x) (length y))
(string< x y))))
-(defun corfu--file-predicate (pred)
- "Filter predicate for files given original predicate PRED."
- (let ((ignore (concat "\\(?:\\`\\|/\\)\\.?\\./\\'"
- (and completion-ignored-extensions
- (concat "\\|" (regexp-opt completion-ignored-extensions) "\\'")))))
- (if pred
- (lambda (x) (and (not (string-match-p ignore x)) (funcall pred x)))
- (lambda (x) (not (string-match-p ignore x))))))
-
(defun corfu--move-prefix-candidates-to-front (field candidates)
"Move CANDIDATES which match prefix of FIELD to the beginning."
(let ((word (replace-regexp-in-string " .*" "" field)))
@@ -389,13 +379,17 @@ Set to nil in order to disable confirmation."
(t (cons 0 (length after))))))
(field (substring str (car bounds) (+ pt (cdr bounds))))
(completing-file (eq (corfu--metadata-get metadata 'category) 'file))
- (all-hl (corfu--all-completions str table
- (if completing-file
- (corfu--file-predicate pred)
- pred)
- pt metadata))
+ (all-hl (corfu--all-completions str table pred pt metadata))
(all (car all-hl))
(base (or (when-let (z (last all)) (prog1 (cdr z) (setcdr z nil))) 0)))
+ ;; Filter the ignored file extensions. We cannot use modified predicate for this filtering,
+ ;; since this breaks the special casing in the `completion-file-name-table' for `file-exists-p'
+ ;; and `file-directory-p'.
+ (when completing-file
+ (let ((ignore (concat "\\(?:\\`\\|/\\)\\.?\\./\\'"
+ (and completion-ignored-extensions
+ (concat "\\|" (regexp-opt completion-ignored-extensions) "\\'")))))
+ (setq all (cl-delete-if (lambda (x) (string-match-p ignore x)) all))))
(setq all (if-let (sort (corfu--metadata-get metadata 'display-sort-function))
(funcall sort all)
(sort all #'corfu--sort-predicate)))