diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2025-04-06 11:51:29 +0200 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2025-04-06 14:11:47 +0200 |
| commit | 101002411e6266b719fc252ce02f1418782d552f (patch) | |
| tree | a387a5655fceaa44e6f3a87cc7b566c04ba08350 | |
| parent | 70dba3ff51039079739e9a500962335a92f7cd81 (diff) | |
Update changelog
| -rw-r--r-- | CHANGELOG.org | 5 | ||||
| -rw-r--r-- | extensions/corfu-history.el | 8 |
2 files changed, 7 insertions, 6 deletions
diff --git a/CHANGELOG.org b/CHANGELOG.org index a88528b..89c4efe 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -4,8 +4,9 @@ * Development -- ~corfu-history-duplicate~: Prioritize duplicate history elements when sorting by - history via ~corfu-history-mode~. +- =corfu-history-duplicate= and =corfu-history-decay=: New customization options to + adjust the rank of duplicate history elements, such that they appear earlier + in the completion list. * Version 2.0 (2025-03-28) diff --git a/extensions/corfu-history.el b/extensions/corfu-history.el index 5ff6039..4280cbe 100644 --- a/extensions/corfu-history.el +++ b/extensions/corfu-history.el @@ -77,13 +77,13 @@ See also `corfu-history-duplicate'." (unless corfu-history--hash (let ((ht (make-hash-table :test #'equal :size (length corfu-history)))) (cl-loop for elem in corfu-history for idx from 0 - for w = (if-let ((w (gethash elem ht))) - ;; Reduce duplicate weight with exponential decay. - (- w (round (* corfu-history-duplicate + for r = (if-let ((r (gethash elem ht))) + ;; Reduce duplicate rank with exponential decay. + (- r (round (* corfu-history-duplicate (exp (* -1.0 corfu-history-decay idx))))) ;; Never outrank the most recent element. (if (= idx 0) (/ most-negative-fixnum 2) idx)) - do (puthash elem w ht)) + do (puthash elem r ht)) (setq corfu-history--hash ht))) (cl-loop for ht = corfu-history--hash for max = most-positive-fixnum for cand on cands do |
