(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
(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))