('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
(funcall (or (alist-get 'adjust-base-function all-md) #'identity)
(setq all (delete-dups all))
(setq last (last all))
- (cond
- (sort-fun (setq all (funcall sort-fun all)))
- ((and completions-group group-fun)
- ;; TODO: experiment with re-grouping here. Might be slow
- ;; if the group-fun (given by the table and out of our
- ;; control) is slow and/or allocates too much.
- )
- (t
- ;; If the table doesn't stipulate a sorting function or a
- ;; group function, sort first by length and
- ;; alphabetically.
- (setq all (minibuffer--sort-by-length-alpha all))
- ;; Then sort by history position, and put the default, if it
- ;; exists, on top.
- (when (minibufferp)
- (setq all (minibuffer--sort-by-position
- (minibuffer--sort-preprocess-history full-base)
- all)))))
+ (when sort-fun (setq all (funcall sort-fun all)))
;; Cache input for `minibuffer-restore-completion-input',
;; unless STRING is an exact and sole completion.