summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mendler <mail@daniel-mendler.de>2024-01-19 07:29:28 +0100
committerDaniel Mendler <mail@daniel-mendler.de>2024-01-19 07:29:28 +0100
commit21e44fee862c96cd169ab715f0fb1e041c83afa0 (patch)
tree6edd7eae7547e3766cd49a5dcbe4fc4113b48c4b
parent249f6702e99343aac045697178e319784aacd2f0 (diff)
cape-capf-super: Add comments
-rw-r--r--cape.el12
1 files changed, 9 insertions, 3 deletions
diff --git a/cape.el b/cape.el
index 19fd78f..c824073 100644
--- a/cape.el
+++ b/cape.el
@@ -902,12 +902,18 @@ The functions `cape-wrap-super' and `cape-capf-super' are experimental."
(sort (or (completion-metadata-get md 'display-sort-function)
#'identity))
(cands (funcall sort (all-completions str table pr))))
+ ;; Handle duplicates with a hash table.
(cl-loop
for cand in-ref cands
- for other = (gethash cand ht t) do
+ for dup = (gethash cand ht t) do
(cond
- ((eq other t) (puthash cand plist ht))
- ((not (equal other plist))
+ ((eq dup t)
+ ;; Candidate does not yet exist.
+ (puthash cand plist ht))
+ ((not (equal dup plist))
+ ;; Duplicate candidate. Candidate plist is
+ ;; different, therefore disambiguate the
+ ;; candidates.
(setf cand (propertize cand 'cape-capf-super
(cons cand plist))))))
(push cands candidates)))