belongs. The returned title may be nil. Otherwise the function
returns the transformed candidate. The transformation can remove a
redundant prefix, which is displayed in the group title.
-- `display-sort-function': function to sort entries in *Completions*.
+- `sort-function': function to sort completion candidates.
Takes one argument (COMPLETIONS) and should return a new list
of completions. Can operate destructively.
-- `cycle-sort-function': function to sort entries when cycling.
- Works like `display-sort-function'.
- `narrow-completions-function': function for
narrowing (restricting) the completions list. This function
overrides `minibuffer-narrow-completions-function', which see.
consulted. Note that the keys of the
`completion-extra-properties' plist are keyword symbols, not
plain symbols."
- (if-let (((not (eq prop 'category)))
- (cat (completion--metadata-get-1 metadata 'category))
- (over (completion--category-override cat prop)))
- (cdr over)
- (completion--metadata-get-1 metadata prop)))
+ (let ((cat (completion--metadata-get-1 metadata 'category)))
+ (cond
+ ((eq prop 'category) cat)
+ ((eq prop 'sort-function)
+ (or (cdr (completion--category-override cat 'sort-function))
+ (completion--metadata-get-1 metadata 'sort-function)
+ (cdr (completion--category-override cat 'cycle-sort-function))
+ (completion--metadata-get-1 metadata 'cycle-sort-function)
+ (cdr (completion--category-override cat 'display-sort-function))
+ (completion--metadata-get-1 metadata 'display-sort-function)))
+ (t (or (cdr (completion--category-override cat prop))
+ (completion--metadata-get-1 metadata prop))))))
(defun complete-with-action (action collection string predicate)
"Perform completion according to ACTION.
(xref-location (styles . (substring)))
(info-menu (styles . (basic substring)))
(symbol-help (styles . (basic shorthand substring)))
- (calendar-month (display-sort-function . identity)))
+ (calendar-month (sort-function . identity)))
"Default settings for specific completion categories.
Each entry has the shape (CATEGORY . ALIST) where ALIST is
an association list that can specify properties such as:
- `styles': the list of `completion-styles' to use for that category.
- `cycle': the `completion-cycle-threshold' to use for that category.
-- `cycle-sort-function': function to sort entries when cycling.
-- `display-sort-function': function to sort entries in *Completions*.
+- `sort-function': function to sort entries when cycling.
- `group-function': function for grouping the completion candidates.
- `annotation-function': function to add annotations in *Completions*.
- `affixation-function': function to prepend/append a prefix/suffix.
an association list that can specify properties such as:
- `styles': the list of `completion-styles' to use for that category.
- `cycle': the `completion-cycle-threshold' to use for that category.
-- `cycle-sort-function': function to sort entries when cycling.
-- `display-sort-function': nil means to use either the sorting
+- `sort-function': function to sort entries when cycling.
function from metadata, or if that is nil, fall back to `completions-sort';
`identity' disables sorting and keeps the original order; and other
possible values are the same as in `completions-sort'.
(cons :tag "Cycling threshold"
(const cycle)
,completion--cycling-threshold-type)
- (cons :tag "Cycle order"
- (const cycle-sort-function) function)
- (cons :tag "Sorting for display"
- (const display-sort-function)
+ (cons :tag "Sort order"
+ (const sort-function)
(choice
(const :tag "Default sorting" nil)
(const :tag "No sorting" identity)
strings, which it may modify; it should return a sorted list,
which may be the same.
-If the completion-specific metadata provides a
-`display-sort-function', that function overrides the value of
-this variable."
+If the completion-specific metadata provides a `sort-function', that
+function overrides the value of this variable."
:type '(choice (const :tag "No sorting" nil)
(const :tag "Alphabetical sorting" alphabetical)
(const :tag "Historical sorting" historical)
COMPLETIONS are sorted alphabetically by `string-lessp'.
This is a suitable function to use for `completions-sort' or to
-include as `display-sort-function' in completion metadata."
+include as `sort-function' in completion metadata."
(sort completions #'string-lessp))
(defvar minibuffer-completion-base nil
`minibuffer-sort-alphbetically'.
This is a suitable function to use for `completions-sort' or to
-include as `display-sort-function' in completion metadata."
+include as `sort-function' in completion metadata."
(let ((alphabetized (sort completions #'string-lessp)))
;; Only use history when it's specific to these completions.
(if (eq minibuffer-history-variable
minibuffer-completion-predicate))
(sort-fun
(or minibuffer-completions-sort-function
- (completion-metadata-get all-md 'cycle-sort-function)))
+ (completion-metadata-get all-md 'sort-function)
+ (pcase completions-sort
+ ('nil #'identity)
+ ('alphabetical #'minibuffer-sort-alphabetically)
+ ('historical #'minibuffer-sort-by-history)
+ (_ completions-sort))))
(group-fun (completion-metadata-get all-md 'group-function))
(full-base (substring string 0 base-size))
(minibuffer-completion-base
When the value of this variable is a function,
`minibuffer-completion-help' uses that function to sort the
-completions list instead of using the `display-sort-function'
+completions list instead of using the `sort-function'
from the completion table or the value of `completions-sort'.
`minibuffer-sort-completions' sets the value of this variable to
`:group-function': Function for grouping the completion candidates.
-`:display-sort-function': Function to sort entries in *Completions*.
-
-`:cycle-sort-function': Function to sort entries when cycling.
+`:sort-function': Function to sort completion candidates.
`:narrow-completions-function': function for narrowing the completions list.
(or (completion-metadata-get
(completion--field-metadata
(minibuffer-prompt-end))
- 'display-sort-function)
+ 'sort-function)
(pcase completions-sort
('nil #'identity)
('alphabetical #'minibuffer-sort-alphabetically)
minibuffer-completion-predicate))
(ann-fun (completion-metadata-get all-md 'annotation-function))
(aff-fun (completion-metadata-get all-md 'affixation-function))
- (sort-fun (completion-metadata-get all-md 'display-sort-function))
+ (sort-fun (completion-metadata-get all-md 'sort-function))
(group-fun (completion-metadata-get all-md 'group-function))
(category (completion-metadata-get all-md 'category))
(minibuffer-completion-base
comp))
completions)))
- ;; Sort first using the `display-sort-function'.
+ ;; Sort first using the `sort-function'.
;; FIXME: This function is for the output of
;; all-completions, not
;; completion-all-completions. Often it's the
(if (eq action 'metadata)
`(metadata
(category . buffer)
- (cycle-sort-function . identity)
- (display-sort-function . identity)
+ (sort-function . identity)
(narrow-completions-function . minibuffer-narrow-buffer-completions)
,@(when completions-detailed
'((affixation-function . completion-buffer-name-affixation))))
(defun completion--flex-adjust-metadata (metadata)
"If `flex' is actually doing filtering, adjust sorting."
(let ((flex-is-filtering-p completion-pcm--regexp)
- (existing-dsf
- (completion-metadata-get metadata 'display-sort-function))
- (existing-csf
- (completion-metadata-get metadata 'cycle-sort-function)))
+ (existing-sf (completion-metadata-get metadata 'sort-function)))
(cl-flet
((compose-flex-sort-fn (existing-sort-fn)
(lambda (completions)
sorted))))
`(metadata
,@(and flex-is-filtering-p
- `((display-sort-function . ,(compose-flex-sort-fn existing-dsf))))
- ,@(and flex-is-filtering-p
- `((cycle-sort-function . ,(compose-flex-sort-fn existing-csf))))
+ `((sort-function . ,(compose-flex-sort-fn existing-sf))))
,@(cdr metadata)))))
(defun completion-flex--make-flex-pattern (pattern)
(completion-in-region
(minibuffer--completion-prompt-end) (point-max)
(completion-table-with-metadata
- completions '((display-sort-function . identity)
- (cycle-sort-function . identity)))))))
+ completions '((sort-function . identity)))))))
(defun minibuffer-complete-defaults ()
"Complete minibuffer defaults as far as possible.
(completion-in-region
(minibuffer--completion-prompt-end) (point-max)
(completion-table-with-metadata
- completions '((display-sort-function . identity)
- (cycle-sort-function . identity))))))
+ completions '((sort-function . identity))))))
(define-key minibuffer-local-map [?\C-x up] 'minibuffer-complete-history)
(define-key minibuffer-local-map [?\C-x down] 'minibuffer-complete-defaults)