The suffix and infix commands of a transient are organized in groups. The grouping controls how the descriptions of the suffixes are outlined visually but also makes it possible to set certain properties for a set of suffixes.
Several group classes exist, some of which organize suffixes in subgroups. In most cases the class does not have to be specified explicitly, but see Group Classes.
Groups are specified in the call to transient-define-prefix
, using
vectors. Because groups are represented using vectors, we cannot use
square brackets to indicate an optional element and instead use curly
brackets to do the latter.
Group specifications then have this form:
[{LEVEL} {DESCRIPTION} {KEYWORD VALUE}... ELEMENT...]
The LEVEL is optional and defaults to 4. See Enabling and Disabling Suffixes.
The DESCRIPTION is optional. If present, it is used as the heading of the group.
The KEYWORD-VALUE pairs are optional. Each keyword has to be a
keyword symbol, either :class
or a keyword argument supported by the
constructor of that class.
:description
, is equivalent to specifying
DESCRIPTION at the very beginning of the vector. The recommendation
is to use :description
if some other keyword is also used, for
consistency, or DESCRIPTION otherwise, because it looks better.
:level
is equivalent to LEVEL.
:if...
keywords. These
keywords control whether the group is available in a certain
situation.
For example, one group of the magit-rebase
transient uses :if
magit-rebase-in-progress-p
, which contains the suffixes that are
useful while rebase is already in progress; and another that uses
:if-not magit-rebase-in-progress-p
, which contains the suffixes that
initiate a rebase.
These predicates can also be used on individual suffixes and are only documented once, see Predicate Slots.
:hide
, if non-nil
, is a predicate that controls
whether the group is hidden by default. The key bindings for
suffixes of a hidden group should all use the same prefix key.
Pressing that prefix key should temporarily show the group and its
suffixes, which assumes that a predicate like this is used:
(lambda () (eq (car transient--redisplay-key) ?\C-c)) ; the prefix key shared by all bindings
:setup-children
, if non-nil
, is a function that takes
one argument, a potentially list of children, and must return a list
of children or an empty list. This can either be used to somehow
transform the group’s children that were defined the normal way, or
to dynamically create the children from scratch.
The returned children must have the same form as stored in the
prefix’s transient--layout
property, but it is often more convenient
to use the same form as understood by transient-define-prefix
,
described below. If you use the latter approach, you can use the
transient-parse-child
and transient-parse-children
functions to
transform them from the convenient to the expected form.
:pad-keys
argument controls whether keys of all suffixes
contained in a group are right padded, effectively aligning the
descriptions.
The ELEMENTs are either all subgroups, or all suffixes and strings. (At least currently no group type exists that would allow mixing subgroups with commands at the same level, though in principle there is nothing that prevents that.)
If the ELEMENTs are not subgroups, then they can be a mixture of lists that specify commands and strings. Strings are inserted verbatim into the buffer. The empty string can be used to insert gaps between suffixes, which is particularly useful if the suffixes are outlined as a table.
Inside group specifications, including inside contained suffix
specifications, nothing has to be quoted and quoting anyway is
invalid. The value following a keyword, can be explicitly unquoted
using ,
. This feature is experimental and should be avoided.
The form of suffix specifications is documented in the next node.