[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/cape e93aff6719 1/2: Fix cape-super-cache invalidation
From: |
ELPA Syncer |
Subject: |
[elpa] externals/cape e93aff6719 1/2: Fix cape-super-cache invalidation (Fix #29) |
Date: |
Sat, 26 Feb 2022 22:57:17 -0500 (EST) |
branch: externals/cape
commit e93aff671929177263068edfe5894e192840c3fe
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
Fix cape-super-cache invalidation (Fix #29)
---
README.org | 1 +
cape.el | 41 +++++++++++++++++++++--------------------
2 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/README.org b/README.org
index c5b8a28006..6c50dd12c9 100644
--- a/README.org
+++ b/README.org
@@ -170,6 +170,7 @@ then be used as a Capf via ~cape-company-to-capf~.
Cape supports merging multiple Capfs using the function ~cape-super-capf~. This
feature is experimental and should only be used in special scenarios.
+*Don't use cape-super-capf if you are not 100% sure that you need it!*
Note that ~cape-super-capf~ is not needed if you want to use multiple Capfs
which
are tried one by one, e.g., it is perfectly possible to use ~cape-file~
together
diff --git a/cape.el b/cape.el
index 6a205a3e3f..00cc37303c 100644
--- a/cape.el
+++ b/cape.el
@@ -821,7 +821,7 @@ If INTERACTIVE is nil the function acts like a capf."
(when-let (results (delq nil (mapcar #'funcall capfs)))
(pcase-let* ((`((,beg ,end . ,_)) results)
(cache-candidates nil)
- (cache-str nil)
+ (cache-filter nil)
(cache-ht (make-hash-table :test #'equal))
(extra-fun
(lambda (prop)
@@ -851,25 +851,26 @@ If INTERACTIVE is nil the function acts like a capf."
(display-sort-function . identity)
(cycle-sort-function . identity)))
('t
- (unless (equal str cache-str)
- (let ((ht (make-hash-table :test #'equal))
- (candidates nil))
- (cl-loop for (table . plist) in tables do
- (let* ((pr (plist-get plist :predicate))
- (md (completion-metadata "" table pr))
- (sort (or (completion-metadata-get md
'display-sort-function)
- #'identity))
- (cands (funcall sort (all-completions
str table pr))))
- (cl-loop for cell on cands
- for cand = (car cell) do
- (if (and (eq (gethash cand ht t) t)
- (or (not pred) (funcall
pred cand)))
- (puthash cand plist ht)
- (setcar cell nil)))
- (setq candidates (nconc candidates cands))))
- (setq cache-str str
- cache-candidates (delq nil candidates)
- cache-ht ht)))
+ (let ((filter (list str (copy-sequence
completion-regexp-list) completion-ignore-case)))
+ (unless (equal filter cache-filter)
+ (let ((ht (make-hash-table :test #'equal))
+ (candidates nil))
+ (cl-loop for (table . plist) in tables do
+ (let* ((pr (plist-get plist :predicate))
+ (md (completion-metadata "" table pr))
+ (sort (or (completion-metadata-get md
'display-sort-function)
+ #'identity))
+ (cands (funcall sort (all-completions
str table pr))))
+ (cl-loop for cell on cands
+ for cand = (car cell) do
+ (if (and (eq (gethash cand ht t)
t)
+ (or (not pred) (funcall
pred cand)))
+ (puthash cand plist ht)
+ (setcar cell nil)))
+ (setq candidates (nconc candidates
cands))))
+ (setq cache-filter (list str (copy-sequence
completion-regexp-list) completion-ignore-case)
+ cache-candidates (delq nil candidates)
+ cache-ht ht))))
(copy-sequence cache-candidates))
(_
(completion--some