diff options
Diffstat (limited to 'extensions')
| -rw-r--r-- | extensions/corfu-history.el | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/extensions/corfu-history.el b/extensions/corfu-history.el index 0ad8ff3..feaaed2 100644 --- a/extensions/corfu-history.el +++ b/extensions/corfu-history.el @@ -55,8 +55,8 @@ or the property `history-length' of `corfu-history'.") (and (= (cdr x) (cdr y)) (corfu--length-string< (car x) (car y))))) -(defun corfu-history--sort (candidates) - "Sort CANDIDATES by history." +(defun corfu-history--sort (cands) + "Sort CANDS by history." (unless corfu-history--hash (setq corfu-history--hash (make-hash-table :test #'equal :size (length corfu-history))) (cl-loop for elem in corfu-history for index from 0 do @@ -65,13 +65,13 @@ or the property `history-length' of `corfu-history'.") ;; Decorate each candidate with (index<<13) + length. This way we sort first by index and then by ;; length. We assume that the candidates are shorter than 2**13 characters and that the history is ;; shorter than 2**16 entries. - (cl-loop for cand on candidates do + (cl-loop for cand on cands do (setcar cand (cons (car cand) (+ (ash (gethash (car cand) corfu-history--hash #xFFFF) 13) (length (car cand)))))) - (setq candidates (sort candidates #'corfu-history--sort-predicate)) - (cl-loop for cand on candidates do (setcar cand (caar cand))) - candidates) + (setq cands (sort cands #'corfu-history--sort-predicate)) + (cl-loop for cand on cands do (setcar cand (caar cand))) + cands) ;;;###autoload (define-minor-mode corfu-history-mode |
