branch: externals/vertico commit 2cfffa1a425c9012242f4727174f3fe970debb65 Author: Daniel Mendler <m...@daniel-mendler.de> Commit: Daniel Mendler <m...@daniel-mendler.de>
Update changelog --- CHANGELOG.org | 6 +++--- extensions/vertico-sort.el | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.org b/CHANGELOG.org index 6df5c29e6f..c0e06d9240 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -6,9 +6,9 @@ - =vertico-flat-format=: Customizable =:spacer= string. - =vertico-sort=: Extracted sort functions to separate extension. -- =vertico-sort-history-duplicate=: New customization option to adjust weight of - duplicate history elements, such that they appear earlier in the completion - list. +- =vertico-sort-history-duplicate= and =vertico-sort-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-11) diff --git a/extensions/vertico-sort.el b/extensions/vertico-sort.el index b48c5b1fdd..2fd32ffd9e 100644 --- a/extensions/vertico-sort.el +++ b/extensions/vertico-sort.el @@ -78,13 +78,13 @@ See also `vertico-sort-history-duplicate'." ;; Drop base string from history elements & special file handling. (when (or (> base-len 0) file-sep) (setq elem (substring elem base-len (and file-sep (1+ file-sep))))) - (let ((w (if-let ((w (gethash elem ht))) - ;; Reduce duplicate weight with exponential decay. - (- w (round (* vertico-sort-history-duplicate + (let ((r (if-let ((r (gethash elem ht))) + ;; Reduce duplicate rank with exponential decay. + (- r (round (* vertico-sort-history-duplicate (exp (* -1.0 vertico-sort-history-decay idx))))) ;; Never outrank the most recent element. (if (= idx 0) (/ most-negative-fixnum 2) idx)))) - (puthash elem w ht))))) + (puthash elem r ht))))) (cdr (setq vertico-sort--history (cons base ht)))))) (defun vertico-sort--length-string< (x y)