From: Eshel Yaron Date: Sun, 29 Oct 2023 11:21:17 +0000 (+0100) Subject: Compatibility definition for 'minibuffer--sort-by-length-alpha' X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e3c1a348c41d99fcb544a16c0facb72be0825a2f;p=completion-preview.git Compatibility definition for 'minibuffer--sort-by-length-alpha' --- diff --git a/completion-preview.el b/completion-preview.el index 6c67717..49b8bff 100644 --- a/completion-preview.el +++ b/completion-preview.el @@ -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))