diff options
author | Protesilaos Stavrou <info@protesilaos.com> | 2022-01-19 14:20:19 +0200 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2022-01-24 15:36:11 +0200 |
commit | a46421446ff2e97b01434a1d77fa149d985e6c7d (patch) | |
tree | 98ced13427370904f2eb5212e75622a172410bd3 /lisp | |
parent | ead95479032f342eb7a493499f9edc7f2f2ec759 (diff) | |
download | emacs-a46421446ff2e97b01434a1d77fa149d985e6c7d.tar.gz emacs-a46421446ff2e97b01434a1d77fa149d985e6c7d.tar.bz2 emacs-a46421446ff2e97b01434a1d77fa149d985e6c7d.zip |
Make Completions sorting a user option
* etc/NEWS: Document the new user option.
* lisp/minibuffer.el (completions-sort): Add new user option.
(minibuffer-completion-help): Implement it for the Completions
buffer. (Bug#53362)
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/minibuffer.el | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el index d58c23af8fb..ecede9479d8 100644 --- a/lisp/minibuffer.el +++ b/lisp/minibuffer.el @@ -1173,6 +1173,18 @@ completion candidates than this number." :version "24.1" :type completion--cycling-threshold-type) +(defcustom completions-sort 'alphabetical + "Sort candidates in the *Completions* buffer. + +The value can be nil to disable sorting, `alphabetical' for +alphabetical sorting or a custom sorting function. The sorting +function takes and returns a list of completion candidate +strings." + :type '(choice (const :tag "No sorting" nil) + (const :tag "Alphabetical sorting" alphabetical) + function :tag "Custom function") + :version "29.1") + (defcustom completions-group nil "Enable grouping of completion candidates in the *Completions* buffer. See also `completions-group-format' and `completions-group-sort'." @@ -2268,7 +2280,10 @@ variables.") ;; same, but not always. (setq completions (if sort-fun (funcall sort-fun completions) - (sort completions 'string-lessp))) + (pcase completions-sort + ('nil completions) + ('alphabetical (sort completions #'string-lessp)) + (_ (funcall completions-sort completions))))) ;; After sorting, group the candidates using the ;; `group-function'. |