(multiple-choice (styles . (basic substring)) (sort-function . identity))
(calendar-month (sort-function . identity))
(keybinding (sort-function . minibuffer-sort-alphabetically))
+ (function (sort-function . minibuffer-sort-alphabetically))
(library (sort-function . minibuffer-sort-alphabetically)))
"Default settings for specific completion categories.
(setq done t)
(message "Done"))))))
+(defun minibuffer--set-action-affixation (cands)
+ "Annotate completion candidates CANDS with their documentation strings."
+ (let ((max (seq-max (cons 0 (mapcar #'string-width cands)))))
+ (mapcar
+ (lambda (cand)
+ (let ((sym (intern cand)))
+ (list cand ""
+ (if-let ((doc (ignore-errors
+ (documentation sym))))
+ (concat (make-string (1+ (- max (string-width cand))) ?\s)
+ (propertize
+ (substring doc 0 (string-search "\n" doc))
+ 'face 'completions-annotations))
+ ""))))
+ cands)))
+
(defvar minibuffer-action-history nil
"History list for `minibuffer-set-action'.")
"Set minibuffer action function of current minibuffer to ACTION-FN."
(interactive
(let ((enable-recursive-minibuffers t))
- (list (completing-read "Action function: " obarray #'fboundp
+ (list (completing-read "Action function: "
+ (completion-table-with-metadata
+ obarray
+ '((category . function)
+ (affixation-function . minibuffer--set-action-affixation)))
+ #'fboundp
nil nil 'minibuffer-action-history)))
minibuffer-mode)
(when (stringp action-fn) (setq action-fn (read action-fn)))