[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/corfu e4a6bc1: corfu--recompute-candidates: Extract cor
From: |
ELPA Syncer |
Subject: |
[elpa] externals/corfu e4a6bc1: corfu--recompute-candidates: Extract corfu--filter-files |
Date: |
Wed, 14 Jul 2021 17:57:09 -0400 (EDT) |
branch: externals/corfu
commit e4a6bc1b53ba1e2369e93d021cb2e4932a17b9cd
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
corfu--recompute-candidates: Extract corfu--filter-files
Show hidden files only when all other files have been filtered out.
This is the behavior of the `completion-pcm--filename-try-filter`.
---
corfu.el | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/corfu.el b/corfu.el
index 31b5df5..3a5c693 100644
--- a/corfu.el
+++ b/corfu.el
@@ -34,8 +34,9 @@
;;; Code:
(require 'seq)
-(require 'cl-lib)
-(eval-when-compile (require 'subr-x))
+(eval-when-compile
+ (require 'cl-lib)
+ (require 'subr-x))
(defgroup corfu nil
"Completion Overlay Region FUnction."
@@ -431,6 +432,13 @@ filter string with spaces is allowed."
(nconc (seq-filter (lambda (x) (string-prefix-p word x)) candidates)
(seq-remove (lambda (x) (string-prefix-p word x)) candidates))))
+(defun corfu--filter-files (files)
+ "Filter FILES by `completion-ignored-extensions'."
+ (let ((re (concat "\\(?:\\(?:\\`\\|/\\)\\.\\.?/\\|"
+ (regexp-opt completion-ignored-extensions)
+ "\\)\\'")))
+ (or (seq-remove (lambda (x) (string-match-p re x)) files) files)))
+
(defun corfu--recompute-candidates (str metadata pt table pred)
"Recompute candidates from STR, METADATA, PT, TABLE and PRED."
(pcase-let* ((before (substring str 0 pt))
@@ -452,10 +460,7 @@ filter string with spaces is allowed."
;; 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 (corfu--filter-files all)))
(setq all (if-let (sort (corfu--metadata-get metadata
'display-sort-function))
(funcall sort all)
(sort all #'corfu--sort-predicate)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/corfu e4a6bc1: corfu--recompute-candidates: Extract corfu--filter-files,
ELPA Syncer <=