Function: completion-metadata
completion-metadata is a byte-compiled function defined in
minibuffer.el.gz.
Signature
(completion-metadata STRING TABLE PRED)
Documentation
Return the metadata of elements to complete at the end of STRING.
This metadata is an alist. Currently understood keys are:
- category: the kind of objects returned by all-completions.
Used by completion-category-overrides.
- annotation-function: function to add annotations in *Completions*.
Takes one argument (STRING), which is a possible completion and
returns a string to append to STRING.
- affixation-function: function to prepend/append a prefix/suffix to
entries. Takes one argument (COMPLETIONS) and should return a list
of annotated completions. The elements of the list must be
three-element lists: completion, its prefix and suffix. This
function takes priority over annotation-function when both are
provided, so only this function is used.
- group-function: function for grouping the completion candidates.
Takes two arguments: a completion candidate (COMPLETION) and a
boolean flag (TRANSFORM). If TRANSFORM is nil, the function
returns the group title of the group to which the candidate
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*.
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.
The metadata of a completion table should be constant between two boundaries.
Source Code
;; Defined in /usr/src/emacs/lisp/minibuffer.el.gz
(defun completion-metadata (string table pred)
"Return the metadata of elements to complete at the end of STRING.
This metadata is an alist. Currently understood keys are:
- `category': the kind of objects returned by `all-completions'.
Used by `completion-category-overrides'.
- `annotation-function': function to add annotations in *Completions*.
Takes one argument (STRING), which is a possible completion and
returns a string to append to STRING.
- `affixation-function': function to prepend/append a prefix/suffix to
entries. Takes one argument (COMPLETIONS) and should return a list
of annotated completions. The elements of the list must be
three-element lists: completion, its prefix and suffix. This
function takes priority over `annotation-function' when both are
provided, so only this function is used.
- `group-function': function for grouping the completion candidates.
Takes two arguments: a completion candidate (COMPLETION) and a
boolean flag (TRANSFORM). If TRANSFORM is nil, the function
returns the group title of the group to which the candidate
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*.
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'.
The metadata of a completion table should be constant between two boundaries."
(let ((metadata (if (functionp table)
(funcall table string pred 'metadata))))
(cons 'metadata
(if (eq (car-safe metadata) 'metadata)
(cdr metadata)))))