Function: evil-ex-define-argument-type
evil-ex-define-argument-type is a macro defined in evil-ex.el.
Signature
(evil-ex-define-argument-type ARG-TYPE DOC &rest BODY)
Documentation
Define a new handler for argument-type ARG-TYPE.
DOC is the documentation string. It is followed by a list of keywords and function:
:collection COLLECTION
A collection for completion as required by all-completions.
:completion-at-point FUNC
Function to be called to initialize a potential completion. FUNC
must match the requirements as described for the variable
completion-at-point-functions. When FUNC is called the minibuffer
content is narrowed to exactly match the argument.
:runner FUNC
Function to be called when the type of the current argument changes
or when the content of this argument changes. This function should
take one obligatory argument FLAG followed by an optional argument
ARG. FLAG is one of three symbol start, stop or update. When
the argument type is recognized for the first time and this handler
is started the FLAG is start. If the argument type changes to
something else or ex state finished the handler FLAG is stop. If
the content of the argument has changed FLAG is update. If FLAG is
either start or update then ARG is the current value of this
argument. If FLAG is stop then arg is nil.
Source Code
;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-ex.el
(defmacro evil-ex-define-argument-type (arg-type doc &rest body)
"Define a new handler for argument-type ARG-TYPE.
DOC is the documentation string. It is followed by a list of keywords
and function:
:collection COLLECTION
A collection for completion as required by `all-completions'.
:completion-at-point FUNC
Function to be called to initialize a potential completion. FUNC
must match the requirements as described for the variable
`completion-at-point-functions'. When FUNC is called the minibuffer
content is narrowed to exactly match the argument.
:runner FUNC
Function to be called when the type of the current argument changes
or when the content of this argument changes. This function should
take one obligatory argument FLAG followed by an optional argument
ARG. FLAG is one of three symbol `start', `stop' or `update'. When
the argument type is recognized for the first time and this handler
is started the FLAG is `start'. If the argument type changes to
something else or ex state finished the handler FLAG is `stop'. If
the content of the argument has changed FLAG is `update'. If FLAG is
either `start' or `update' then ARG is the current value of this
argument. If FLAG is `stop' then arg is nil."
(declare (indent defun)
(doc-string 2)
(debug (&define name
[&optional stringp]
[&rest [keywordp function-form]])))
(unless (stringp doc) (push doc body))
(let (runner completer)
(while (keywordp (car body))
(let ((key (pop body))
(func (pop body)))
(cond
((eq key :runner)
(setq runner `#',func))
((eq key :collection)
(setq completer `(cons 'collection #',func)))
((eq key :completion-at-point)
(setq completer `(cons 'completion-at-point #',func))))))
`(evil--add-to-alist evil-ex-argument-types
',arg-type (list ,runner ,completer))))