From: Eshel Yaron Date: Mon, 18 Mar 2024 15:38:18 +0000 (+0100) Subject: New completions sort order 'minibuffer-sort-by-length' X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=0d18e2e462d63d5abc7ceae636f9b6b5d7c61f4c;p=emacs.git New completions sort order 'minibuffer-sort-by-length' --- diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index b67ce30e974..0c5c67e1e95 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1919,6 +1919,10 @@ Remove completion BASE prefix string from history elements." (substring c base-size))) hist))))) +(defun minibuffer-sort-by-length (completions) + "Sort COMPLETIONS by length." + (sort completions (lambda (a b) (< (length a) (length b))))) + (defun minibuffer-sort-alphabetically (completions) "Sort COMPLETIONS alphabetically. @@ -2688,11 +2692,12 @@ temporarily override the default completions sorting.") (defcustom minibuffer-completions-sort-orders '((?a "alphabetical" "Sort alphabetically" - minibuffer-sort-alphabetically "sorted alphabetically") + minibuffer-sort-alphabetically "alphabetically") (?h "historical" "Sort by position in minibuffer history" - minibuffer-sort-by-history "sorted by position in minibuffer history") + minibuffer-sort-by-history "position in minibuffer history") (?i "identity" "Disable sorting" identity nil) - (?d "default" "Default sort order" nil nil)) + (?d "default" "Default sort order" nil nil) + (?l "length" "Sort by length" minibuffer-sort-by-length "length")) "List of minibuffer completions sort orders. Each element is a list of the form (CHAR NAME HELP FUNC DESC), where CHAR is a character that you type to select this sort order