diff options
| -rw-r--r-- | README.org | 1 | ||||
| -rw-r--r-- | cape.el | 41 |
2 files changed, 22 insertions, 20 deletions
@@ -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 @@ -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 |
