summaryrefslogtreecommitdiff
path: root/cape.el
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2026-04-19 20:42:31 +0200
committerDaniel Mendler <mail@daniel-mendler.de>2026-04-19 20:47:03 +0200
commit2e15e1909754752f66096dde1b8d639d6eb25f35 (patch)
treec6d7982aa348d27d2085de164bc65c7b0e15c674 /cape.el
parent1e09a4905e22fb6b01bfbbbc3d373fe897f570fc (diff)
Revert "cape-capf-super: Disambiguate duplicates based on :exit-function"HEADmain
This reverts commit 30372e41e8f8e92557ee9fd965d64b8fee8dc357. The deduplication won't work for duplicate candidates coming from the same Capf. Sometimes Capfs produce duplicates which only differ in their properties.
Diffstat (limited to 'cape.el')
-rw-r--r--cape.el36
1 files changed, 15 insertions, 21 deletions
diff --git a/cape.el b/cape.el
index 715c051..1b936ca 100644
--- a/cape.el
+++ b/cape.el
@@ -985,28 +985,22 @@ turn."
;; candidates if we've already determined that
;; main candidates are available.
(cands (when (or main (or exclusive cand-ht candidates))
- (funcall sort (all-completions str table pr))))
- (cands (cons nil cands))
- (ptr cands))
+ (funcall sort (all-completions str table pr)))))
;; Handle duplicates with a hash table.
- (while (cdr ptr)
- (let* ((cand (cadr ptr))
- (dup (gethash cand ht t)))
- (cond
- ((eq dup t)
- ;; Candidate is unique so far.
- (puthash cand cand-plist ht)
- (pop ptr))
- ((not (equal (plist-get dup :exit-function)
- (plist-get cand-plist :exit-function)))
- ;; Disambiguate duplicate candidates with
- ;; different exit functions.
- (setf (cadr ptr) (propertize cand 'cape-capf-super
- (cons cand cand-plist)))
- (pop ptr))
- (t ;; Delete duplicate candidate.
- (setcdr ptr (cddr ptr))))))
- (when (cdr cands) (push (cdr cands) candidates))))
+ (cl-loop
+ for cand in-ref cands
+ for dup = (gethash cand ht t) do
+ (cond
+ ((eq dup t)
+ ;; Candidate does not yet exist.
+ (puthash cand cand-plist ht))
+ ((not (equal dup cand-plist))
+ ;; Duplicate candidate. Candidate plist is
+ ;; different, therefore disambiguate the
+ ;; candidates.
+ (setf cand (propertize cand 'cape-capf-super
+ (cons cand cand-plist))))))
+ (when cands (push cands candidates))))
(when (or cand-ht candidates)
(setq candidates (apply #'nconc (nreverse candidates))
cand-ht ht)