Function: transient-define-prefix
transient-define-prefix is a macro defined in transient.el.
Signature
(transient-define-prefix NAME ARGLIST [DOCSTRING] [KEYWORD VALUE]... GROUP... [BODY...])
Documentation
Define NAME as a transient prefix command.
ARGLIST are the arguments that command takes. DOCSTRING is the documentation string and is optional.
These arguments can optionally be followed by key-value pairs.
Each key has to be a keyword symbol, either :class or a keyword
argument supported by the constructor of that class. The
transient-prefix(var)/transient-prefix(fun) class is used if the class is not specified
explicitly.
GROUPs add key bindings for infix and suffix commands and specify how these bindings are presented in the menu buffer. At least one GROUP has to be specified. See info node (transient)Binding Suffix and Infix Commands.
The BODY is optional. If it is omitted, then ARGLIST is also ignored and the function definition becomes:
(lambda ()
(interactive)
(transient-setup 'NAME))
If BODY is specified, then it must begin with an interactive
form that matches ARGLIST, and it must call transient-setup.
It may however call that function only when some condition is
satisfied; that is one of the reason why you might want to use
an explicit BODY.
All transients have a (possibly nil) value, which is exported
when suffix commands are called, so that they can consume that
value. For some transients it might be necessary to have a sort
of secondary value, called a scope. Such a scope would usually
be set in the commands interactive form and has to be passed
to the setup function:
(transient-setup 'NAME nil nil :scope SCOPE)
Source Code
;; Defined in ~/.emacs.d/elpa/transient-20260414.1009/transient.el
;;; Define
(defmacro transient-define-prefix (name arglist &rest args)
"Define NAME as a transient prefix command.
ARGLIST are the arguments that command takes.
DOCSTRING is the documentation string and is optional.
These arguments can optionally be followed by key-value pairs.
Each key has to be a keyword symbol, either `:class' or a keyword
argument supported by the constructor of that class. The
`transient-prefix' class is used if the class is not specified
explicitly.
GROUPs add key bindings for infix and suffix commands and specify
how these bindings are presented in the menu buffer. At least
one GROUP has to be specified. See info node `(transient)Binding
Suffix and Infix Commands'.
The BODY is optional. If it is omitted, then ARGLIST is also
ignored and the function definition becomes:
(lambda ()
(interactive)
(transient-setup \\='NAME))
If BODY is specified, then it must begin with an `interactive'
form that matches ARGLIST, and it must call `transient-setup'.
It may however call that function only when some condition is
satisfied; that is one of the reason why you might want to use
an explicit BODY.
All transients have a (possibly nil) value, which is exported
when suffix commands are called, so that they can consume that
value. For some transients it might be necessary to have a sort
of secondary value, called a scope. Such a scope would usually
be set in the commands `interactive' form and has to be passed
to the setup function:
(transient-setup \\='NAME nil nil :scope SCOPE)
\(fn NAME ARGLIST [DOCSTRING] [KEYWORD VALUE]... GROUP... [BODY...])"
(declare (debug ( &define name lambda-list
[&optional lambda-doc]
[&rest keywordp sexp]
[&rest vectorp]
[&optional ("interactive" interactive) def-body]))
(indent defun)
(doc-string 3))
(pcase-let
((`(,class ,slots ,groups ,docstr ,body ,interactive-only)
(transient--expand-define-args args arglist 'transient-define-prefix)))
`(progn
(defalias ',name
,(if body
`(lambda ,arglist ,@body)
`(lambda ()
(interactive)
(transient-setup ',name))))
:autoload-end
(put ',name 'interactive-only ,interactive-only)
(put ',name 'function-documentation ,docstr)
(put ',name 'transient--prefix
(,(or class 'transient-prefix) :command ',name ,@slots))
(transient--set-layout
',name
(list ,@(mapcan (lambda (s) (transient--parse-child name s)) groups))))))