emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/corfu 6f187a8adb: Rename sort predicate, corresponding


From: ELPA Syncer
Subject: [elpa] externals/corfu 6f187a8adb: Rename sort predicate, corresponding to Vertico
Date: Thu, 10 Nov 2022 12:57:25 -0500 (EST)

branch: externals/corfu
commit 6f187a8adb165da5657288b83e429dee1dbb0591
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    Rename sort predicate, corresponding to Vertico
---
 corfu.el                    |  6 +++---
 extensions/corfu-history.el | 10 +++-------
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/corfu.el b/corfu.el
index 818cc8d40e..651e6f5d57 100644
--- a/corfu.el
+++ b/corfu.el
@@ -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 9f59a16669..41e09b6c47 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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]