Function: define-completion-category
define-completion-category is a byte-compiled function defined in
minibuffer.el.gz.
Signature
(define-completion-category NAME &optional PARENTS DOC &rest DEFAULTS)
Documentation
Define NAME as a completion category, inheriting from PARENTS.
DOC is a documentation string describing the category, and DEFAULTS is a
plist (KEYWORD1 VALUE1 KEYWORD2 VALUE2 ...) specifying properties to
associate with the category in completion-category-defaults. For
example, you can define a category foo that inherits from the file
category but specifies a bespoke group-function, as follows:
(define-completion-category 'foo '(file)
"Completion category for foo."
:group-function #'group-by-baz)
Probably introduced at or before Emacs version 31.1.
Source Code
;; Defined in /usr/src/emacs/lisp/minibuffer.el.gz
(defun define-completion-category (name &optional parents doc &rest defaults)
"Define NAME as a completion category, inheriting from PARENTS.
DOC is a documentation string describing the category, and DEFAULTS is a
plist (KEYWORD1 VALUE1 KEYWORD2 VALUE2 ...) specifying properties to
associate with the category in `completion-category-defaults'. For
example, you can define a category `foo' that inherits from the `file'
category but specifies a bespoke `group-function', as follows:
(define-completion-category \\='foo \\='(file)
\"Completion category for foo.\"
:group-function #\\='group-by-baz)"
(declare (indent defun) (doc-string 3))
(let (alist)
(while defaults
(push
(cons (intern (substring (symbol-name (pop defaults)) 1))
(pop defaults))
alist))
(setf (alist-get name completion-category-defaults) alist))
(put name 'completion-category-documentation doc)
(put name 'completion-category-parents (ensure-list parents))
name)