]> git.eshelyaron.com Git - emacs.git/commitdiff
New completions sort order 'minibuffer-sort-by-length'
authorEshel Yaron <me@eshelyaron.com>
Mon, 18 Mar 2024 15:38:18 +0000 (16:38 +0100)
committerEshel Yaron <me@eshelyaron.com>
Mon, 18 Mar 2024 15:38:18 +0000 (16:38 +0100)
lisp/minibuffer.el

index b67ce30e974c498d1afab6e79bb4b470a05c0da7..0c5c67e1e951a2ab2ace20c589e6d3577491cf8b 100644 (file)
@@ -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