diff options
| author | Protesilaos Stavrou | 2022-01-19 14:20:19 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2022-01-24 15:36:11 +0200 |
| commit | a46421446ff2e97b01434a1d77fa149d985e6c7d (patch) | |
| tree | 98ced13427370904f2eb5212e75622a172410bd3 | |
| parent | ead95479032f342eb7a493499f9edc7f2f2ec759 (diff) | |
| download | emacs-a46421446ff2e97b01434a1d77fa149d985e6c7d.tar.gz 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)
| -rw-r--r-- | etc/NEWS | 5 | ||||
| -rw-r--r-- | lisp/minibuffer.el | 17 |
2 files changed, 21 insertions, 1 deletions
| @@ -429,6 +429,11 @@ When non-nil, the commands 'next-completion' and 'previous-completion' | |||
| 429 | automatically wrap around on reaching the beginning or the end of | 429 | automatically wrap around on reaching the beginning or the end of |
| 430 | the "*Completions*" buffer. | 430 | the "*Completions*" buffer. |
| 431 | 431 | ||
| 432 | *** New user option 'completions-sort'. | ||
| 433 | This option controls the sorting of the completion candidates in | ||
| 434 | the *Completions* buffer. Available styles are no sorting, | ||
| 435 | alphabetical (the default), or a custom sort function. | ||
| 436 | |||
| 432 | ** Isearch and Replace | 437 | ** Isearch and Replace |
| 433 | 438 | ||
| 434 | +++ | 439 | +++ |
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." | |||
| 1173 | :version "24.1" | 1173 | :version "24.1" |
| 1174 | :type completion--cycling-threshold-type) | 1174 | :type completion--cycling-threshold-type) |
| 1175 | 1175 | ||
| 1176 | (defcustom completions-sort 'alphabetical | ||
| 1177 | "Sort candidates in the *Completions* buffer. | ||
| 1178 | |||
| 1179 | The value can be nil to disable sorting, `alphabetical' for | ||
| 1180 | alphabetical sorting or a custom sorting function. The sorting | ||
| 1181 | function takes and returns a list of completion candidate | ||
| 1182 | strings." | ||
| 1183 | :type '(choice (const :tag "No sorting" nil) | ||
| 1184 | (const :tag "Alphabetical sorting" alphabetical) | ||
| 1185 | function :tag "Custom function") | ||
| 1186 | :version "29.1") | ||
| 1187 | |||
| 1176 | (defcustom completions-group nil | 1188 | (defcustom completions-group nil |
| 1177 | "Enable grouping of completion candidates in the *Completions* buffer. | 1189 | "Enable grouping of completion candidates in the *Completions* buffer. |
| 1178 | See also `completions-group-format' and `completions-group-sort'." | 1190 | See also `completions-group-format' and `completions-group-sort'." |
| @@ -2268,7 +2280,10 @@ variables.") | |||
| 2268 | ;; same, but not always. | 2280 | ;; same, but not always. |
| 2269 | (setq completions (if sort-fun | 2281 | (setq completions (if sort-fun |
| 2270 | (funcall sort-fun completions) | 2282 | (funcall sort-fun completions) |
| 2271 | (sort completions 'string-lessp))) | 2283 | (pcase completions-sort |
| 2284 | ('nil completions) | ||
| 2285 | ('alphabetical (sort completions #'string-lessp)) | ||
| 2286 | (_ (funcall completions-sort completions))))) | ||
| 2272 | 2287 | ||
| 2273 | ;; After sorting, group the candidates using the | 2288 | ;; After sorting, group the candidates using the |
| 2274 | ;; `group-function'. | 2289 | ;; `group-function'. |