diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2022-11-10 18:38:59 +0100 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2022-11-10 18:38:59 +0100 |
| commit | 6f187a8adb165da5657288b83e429dee1dbb0591 (patch) | |
| tree | 424857c643270c6307add8b7bbe4115e1e89739e | |
| parent | e6e8fa6684396e6efe1c29c4413657f0bb76ce03 (diff) | |
Rename sort predicate, corresponding to Vertico
| -rw-r--r-- | corfu.el | 6 | ||||
| -rw-r--r-- | extensions/corfu-history.el | 10 |
2 files changed, 6 insertions, 10 deletions
@@ -566,13 +566,13 @@ A scroll bar is displayed from LO to LO+BAR." (cons (apply #'completion-all-completions args) hl)) (cons (apply #'completion-all-completions args) hl)))) -(defun corfu--sort-predicate (x y) - "Sorting predicate which compares X and Y." +(defsubst corfu--length-string< (x y) + "Sorting predicate which compares X and Y first by length then by `string<'." (or (< (length x) (length y)) (and (= (length x) (length y)) (string< x y)))) (defun corfu-sort-length-alpha (list) "Sort LIST by length and alphabetically." - (sort list #'corfu--sort-predicate)) + (sort list #'corfu--length-string<)) (defmacro corfu--partition! (list form) "Evaluate FORM for every element and partition LIST." diff --git a/extensions/corfu-history.el b/extensions/corfu-history.el index 9f59a16..41e09b6 100644 --- a/extensions/corfu-history.el +++ b/extensions/corfu-history.el @@ -54,13 +54,9 @@ (defun corfu-history--sort-predicate (x y) "Sorting predicate which compares X and Y." - (pcase-let ((`(,sx . ,hx) x) - (`(,sy . ,hy) y)) - (or (< hx hy) - (and (= hx hy) - (or (< (length sx) (length sy)) - (and (= (length sx) (length sy)) - (string< sx sy))))))) + (or (< (cdr x) (cdr y)) + (and (= (cdr x) (cdr y)) + (corfu--length-string< (car x) (car y))))) (defun corfu-history--sort (candidates) "Sort CANDIDATES by history." |
