Function: orderless-define-completion-style
orderless-define-completion-style is a macro defined in orderless.el.
Signature
(orderless-define-completion-style NAME &optional DOCSTRING &rest CONFIGURATION)
Documentation
Define an orderless completion style with given CONFIGURATION.
The CONFIGURATION should be a list of bindings that you could use
with let to configure orderless. You can include bindings for
orderless-matching-styles and orderless-style-dispatchers,
for example.
The completion style consists of two functions that this macro
defines for you, NAME-try-completion and NAME-all-completions.
This macro registers those in completion-styles-alist as
forming the completion style NAME.
The optional DOCSTRING argument is used as the documentation string for the completion style.
Source Code
;; Defined in ~/.emacs.d/elpa/orderless-20260519.1029/orderless.el
(defmacro orderless-define-completion-style
(name &optional docstring &rest configuration)
"Define an orderless completion style with given CONFIGURATION.
The CONFIGURATION should be a list of bindings that you could use
with `let' to configure orderless. You can include bindings for
`orderless-matching-styles' and `orderless-style-dispatchers',
for example.
The completion style consists of two functions that this macro
defines for you, NAME-try-completion and NAME-all-completions.
This macro registers those in `completion-styles-alist' as
forming the completion style NAME.
The optional DOCSTRING argument is used as the documentation
string for the completion style."
(declare (doc-string 2) (indent 1))
(unless (stringp docstring)
(push docstring configuration)
(setq docstring nil))
(let* ((fn-name (lambda (string) (intern (concat (symbol-name name) string))))
(try-completion (funcall fn-name "-try-completion"))
(all-completions (funcall fn-name "-all-completions"))
(doc-fmt "`%s' function for the %s style.
This function delegates to `orderless-%s'.
The orderless configuration is locally modified
specifically for the %s style.")
(fn-doc (lambda (fn) (format doc-fmt fn name fn name name))))
`(progn
(defun ,try-completion (string table pred point)
,(funcall fn-doc "try-completion")
(let ,configuration
(orderless-try-completion string table pred point)))
(defun ,all-completions (string table pred point)
,(funcall fn-doc "all-completions")
(let ,configuration
(orderless-all-completions string table pred point)))
(add-to-list 'completion-styles-alist
'(,name ,try-completion ,all-completions ,docstring)))))