]> git.eshelyaron.com Git - completion-preview.git/commitdiff
Compatibility definition for 'minibuffer--sort-by-length-alpha'
authorEshel Yaron <me@eshelyaron.com>
Sun, 29 Oct 2023 11:21:17 +0000 (12:21 +0100)
committerEshel Yaron <me@eshelyaron.com>
Sun, 29 Oct 2023 11:21:17 +0000 (12:21 +0100)
completion-preview.el

index 6c6771727af53ebb9991b820983b22d8f078c767..49b8bff7d9e3fbf1d084e2786f59211af075e199 100644 (file)
@@ -70,7 +70,7 @@ all of the functions return non-nil."
 (defvar completion-preview-predicate #'always
   "Completion predicate to use for completion preview.")
 
-(defvar completion-preview-sort-function #'minibuffer--sort-by-length-alpha
+(defvar completion-preview-sort-function #'completion-preview--sort-by-length-alpha
   "Sort function to use for choosing a completion candidate to preview.")
 
 (defface completion-preview
@@ -83,6 +83,15 @@ all of the functions return non-nil."
 
 (defvar-local completion-preview--overlay nil)
 
+(defun completion-preview--sort-by-length-alpha (elems)
+  "Sort ELEMS first by length, then alphabetically.
+
+Compatibility definition for `minibuffer--sort-by-length-alpha'."
+  (sort elems (lambda (c1 c2)
+                (or (< (length c1) (length c2))
+                    (and (= (length c1) (length c2))
+                         (string< c1 c2))))))
+
 (defun completion-preview-require-certain-commands ()
   "Check if `this-command' is one of `completion-preview-commands'."
   (memq this-command completion-preview-commands))