aboutsummaryrefslogtreecommitdiffstats
path: root/doc/misc
diff options
context:
space:
mode:
authorJonas Bernoulli2023-01-30 22:39:38 +0100
committerJonas Bernoulli2023-01-30 22:39:38 +0100
commit1684e254a3b95b474753275fa9bfc2567a83b2fa (patch)
tree6d61473f7f1cbaac1f2239eb0326a6be1b86368e /doc/misc
parent327941b211299013868469e65050d92ea513f067 (diff)
downloademacs-1684e254a3b95b474753275fa9bfc2567a83b2fa.tar.gz
emacs-1684e254a3b95b474753275fa9bfc2567a83b2fa.zip
Update to Transient v0.3.7-196-gb91f509
Diffstat (limited to 'doc/misc')
-rw-r--r--doc/misc/transient.texi149
1 files changed, 109 insertions, 40 deletions
diff --git a/doc/misc/transient.texi b/doc/misc/transient.texi
index 2cd4e985dd2..8ac5df9904c 100644
--- a/doc/misc/transient.texi
+++ b/doc/misc/transient.texi
@@ -31,7 +31,7 @@ General Public License for more details.
31@finalout 31@finalout
32@titlepage 32@titlepage
33@title Transient User and Developer Manual 33@title Transient User and Developer Manual
34@subtitle for version 0.3.7 34@subtitle for version 0.3.7.50
35@author Jonas Bernoulli 35@author Jonas Bernoulli
36@page 36@page
37@vskip 0pt plus 1filll 37@vskip 0pt plus 1filll
@@ -64,8 +64,17 @@ reading a new value in the minibuffer.
64Calling a suffix command usually causes the transient to be exited 64Calling a suffix command usually causes the transient to be exited
65but suffix commands can also be configured to not exit the transient. 65but suffix commands can also be configured to not exit the transient.
66 66
67@quotation
68The second part of this manual, which describes how to modify existing
69transients and create new transients from scratch, can be hard to
70digest if you are just getting started. A useful resource to get over
71that hurdle is Psionic K's interactive tutorial, available at
72@uref{https://github.com/positron-solutions/transient-showcase}.
73
74@end quotation
75
67@noindent 76@noindent
68This manual is for Transient version 0.3.7. 77This manual is for Transient version 0.3.7.50.
69 78
70@insertcopying 79@insertcopying
71@end ifnottex 80@end ifnottex
@@ -447,10 +456,10 @@ session.
447Save the value of the active transient persistently across Emacs 456Save the value of the active transient persistently across Emacs
448sessions. 457sessions.
449 458
450@item @kbd{C-x C-k} (@code{transient-save}) 459@item @kbd{C-x C-k} (@code{transient-reset})
451@kindex C-x C-k 460@kindex C-x C-k
452@findex transient-save 461@findex transient-reset
453Clear the set and saved value of the active transient. 462Clear the set and saved values of the active transient.
454@end table 463@end table
455 464
456@defopt transient-values-file 465@defopt transient-values-file
@@ -893,7 +902,16 @@ same customization.
893 902
894To an extent, transients can be customized interactively, see 903To an extent, transients can be customized interactively, see
895@ref{Enabling and Disabling Suffixes}. This section explains how existing 904@ref{Enabling and Disabling Suffixes}. This section explains how existing
896transients can be further modified non-interactively. 905transients can be further modified non-interactively. Let's begin
906with an example:
907
908@lisp
909(transient-append-suffix 'magit-patch-apply "-3"
910 '("-R" "Apply in reverse" "--reverse"))
911@end lisp
912
913This inserts a new infix argument to toggle the @code{--reverse} argument
914after the infix argument that toggles @code{-3} in @code{magit-patch-apply}.
897 915
898The following functions share a few arguments: 916The following functions share a few arguments:
899 917
@@ -911,7 +929,6 @@ means the former. @xref{Suffix Specifications}.
911@var{SUFFIX} may also be a group in the same form as expected by 929@var{SUFFIX} may also be a group in the same form as expected by
912@code{transient-define-prefix}. @xref{Group Specifications}. 930@code{transient-define-prefix}. @xref{Group Specifications}.
913 931
914
915@item 932@item
916@var{LOC} is a command, a key vector, a key description (a string as 933@var{LOC} is a command, a key vector, a key description (a string as
917returned by @code{key-description}), or a list specifying coordinates (the 934returned by @code{key-description}), or a list specifying coordinates (the
@@ -1044,6 +1061,18 @@ For example, the scope of the @code{magit-branch-configure} transient is
1044the branch whose variables are being configured. 1061the branch whose variables are being configured.
1045@end defmac 1062@end defmac
1046 1063
1064It is possible to define one or more groups independently of a prefix
1065definition, which is useful when those groups are to be used by more
1066than just one prefix command.
1067
1068@defmac transient-define-groups name group...
1069This macro defines one or more groups of infix and suffix commands
1070and stores them in a property of the symbol @var{NAME}. @var{GROUP} has the
1071same form as for @code{transient-define-prefix}. Subsequently @var{NAME} can
1072be used in a @var{GROUP} of @code{transient-define-prefix}, as described in the
1073next section.
1074@end defmac
1075
1047@node Binding Suffix and Infix Commands 1076@node Binding Suffix and Infix Commands
1048@section Binding Suffix and Infix Commands 1077@section Binding Suffix and Infix Commands
1049 1078
@@ -1139,11 +1168,17 @@ suffixes, which assumes that a predicate like this is used:
1139 1168
1140@item 1169@item
1141The value of @code{:setup-children}, if non-@code{nil}, is a function that takes 1170The value of @code{:setup-children}, if non-@code{nil}, is a function that takes
1142two arguments the group object itself and a list of children. 1171one argument, a potentially list of children, and must return a list
1143The children are given as a (potentially empty) list consisting 1172of children or an empty list. This can either be used to somehow
1144of either group or suffix specifications. It can make arbitrary 1173transform the group's children that were defined the normal way, or
1145changes to the children including constructing new children from 1174to dynamically create the children from scratch.
1146scratch. Also see @code{transient-setup-children}. 1175
1176The returned children must have the same form as stored in the
1177prefix's @code{transient--layout} property, but it is often more convenient
1178to use the same form as understood by @code{transient-define-prefix},
1179described below. If you use the latter approach, you can use the
1180@code{transient-parse-child} and @code{transient-parse-children} functions to
1181transform them from the convenient to the expected form.
1147 1182
1148@item 1183@item
1149The boolean @code{:pad-keys} argument controls whether keys of all suffixes 1184The boolean @code{:pad-keys} argument controls whether keys of all suffixes
@@ -1151,23 +1186,35 @@ contained in a group are right padded, effectively aligning the
1151descriptions. 1186descriptions.
1152@end itemize 1187@end itemize
1153 1188
1154The @var{ELEMENT}s are either all subgroups (vectors), or all suffixes 1189The @var{ELEMENT}s are either all subgroups, or all suffixes and strings.
1155(lists) and strings. (At least currently no group type exists that 1190(At least currently no group type exists that would allow mixing
1156would allow mixing subgroups with commands at the same level, though 1191subgroups with commands at the same level, though in principle there
1157in principle there is nothing that prevents that.) 1192is nothing that prevents that.)
1158 1193
1159If the @var{ELEMENT}s are not subgroups, then they can be a mixture of lists 1194If the @var{ELEMENT}s are not subgroups, then they can be a mixture of lists
1160that specify commands and strings. Strings are inserted verbatim. 1195that specify commands and strings. Strings are inserted verbatim into
1161The empty string can be used to insert gaps between suffixes, which is 1196the buffer. The empty string can be used to insert gaps between
1162particularly useful if the suffixes are outlined as a table. 1197suffixes, which is particularly useful if the suffixes are outlined as
1163 1198a table.
1164Variables are supported inside group specifications. For example in 1199
1165place of a direct subgroup specification, a variable can be used whose 1200Inside group specifications, including inside contained suffix
1166value is a vector that qualifies as a group specification. Likewise, 1201specifications, nothing has to be quoted and quoting anyway is
1167a variable can be used where a suffix specification is expected. 1202invalid.
1168Lists of group or suffix specifications are also supported. Indirect 1203
1169specifications are resolved when the transient prefix is being 1204How symbols are treated, depends on context. Inside suffix
1170defined. 1205specifications they often name functions. However if they appear in
1206a place where a group is expected, then they are treated as indirect
1207group specifications. Such a symbol must have an associated group
1208specification, created using @code{transient-define-groups}.
1209
1210Likewise a symbol can appear in a place where a suffix specification
1211is expected. The value of the @code{transient--layout} property of that
1212symbol must be a single suffix specification or a list of such
1213specifications. Currently no macro exist that would create such a
1214symbol, and this feature should usually not be used.
1215
1216The value following a keyword, can be explicitly unquoted using @code{,}.
1217This feature is experimental and should be avoided as well.
1171 1218
1172The form of suffix specifications is documented in the next node. 1219The form of suffix specifications is documented in the next node.
1173 1220
@@ -1232,7 +1279,7 @@ Any command will do; it does not need to have an object associated
1232with it (as would be the case if @code{transient-define-suffix} or 1279with it (as would be the case if @code{transient-define-suffix} or
1233@code{transient-define-infix} were used to define it). 1280@code{transient-define-infix} were used to define it).
1234 1281
1235Anonymous, dynamically defined suffix commands are also support. 1282Anonymous, dynamically defined suffix commands are also supported.
1236See information about the @code{:setup-children} function in @ref{Group Specifications}. 1283See information about the @code{:setup-children} function in @ref{Group Specifications}.
1237 1284
1238As mentioned above, the object that is associated with a command can 1285As mentioned above, the object that is associated with a command can
@@ -1515,7 +1562,18 @@ Call the command without exporting variables and stay transient.
1515@anchor{Pre-commands for Suffixes} 1562@anchor{Pre-commands for Suffixes}
1516@subheading Pre-commands for Suffixes 1563@subheading Pre-commands for Suffixes
1517 1564
1518The default for suffixes is @code{transient--do-exit}. 1565By default, invoking a suffix causes the transient to be exited.
1566
1567If you want a different default behavior for a certain transient
1568prefix command, then set its @code{:transient-suffix} slot. The value can be
1569a boolean, answering the question "does the transient stay active,
1570when a suffix command is invoked?" @code{t} means that the transient stays
1571active, while @code{nil} means that invoking a suffix exits the transient.
1572In either case, the exact behavior depends on whether the suffix is
1573itself a prefix (i.e., a sub-prefix), an infix or a regular suffix.
1574
1575The behavior for an individual suffix command can be changed by
1576setting its @code{transient} slot to one of the following pre-commands.
1519 1577
1520@defun transient--do-exit 1578@defun transient--do-exit
1521Call the command after exporting variables and exit the transient. 1579Call the command after exporting variables and exit the transient.
@@ -1566,21 +1624,32 @@ be added to @code{transient-predicate-map}.
1566@anchor{Pre-commands for Non-Suffixes} 1624@anchor{Pre-commands for Non-Suffixes}
1567@subheading Pre-commands for Non-Suffixes 1625@subheading Pre-commands for Non-Suffixes
1568 1626
1569The default for non-suffixes, i.e., commands that are bound in other 1627By default, non-suffixes (commands that are bound in other keymaps
1570keymaps beside the transient keymap, is @code{transient--do-warn}. Silently 1628beside the transient keymap) cannot be invoked. Trying to invoke
1571ignoring the user-error is also an option, though probably not a good 1629such a command results in a warning and the transient stays active.
1572one.
1573 1630
1574If you want to let the user invoke non-suffix commands, then use 1631If you want a different behavior, then set the @code{:transient-non-suffix}
1575@code{transient--do-stay} as the value of the prefix's @code{transient-non-suffix} 1632slot of the transient prefix command. The value can be a boolean,
1576slot. 1633answering the question, "is it allowed to invoke non-suffix commands?"
1634
1635If the value is @code{t} or @code{transient--do-stay}, then non-suffixes can be
1636invoked, when it is @code{nil} or @code{transient--do-warn} (the default) then they
1637cannot be invoked.
1638
1639The only other recommended value is @code{transient--do-leave}. If that is
1640used, then non-suffixes can be invoked, but if one is invoked, then
1641that exits the transient.
1577 1642
1578@defun transient--do-warn 1643@defun transient--do-warn
1579Call @code{transient-undefined} and stay transient. 1644Call @code{transient-undefined} and stay transient.
1580@end defun 1645@end defun
1581 1646
1582@defun transient--do-noop 1647@defun transient--do-stay
1583Call @code{transient-noop} and stay transient. 1648Call the command without exporting variables and stay transient.
1649@end defun
1650
1651@defun transient--do-leave
1652Call the command without exporting variables and exit the transient.
1584@end defun 1653@end defun
1585 1654
1586@anchor{Special Pre-Commands} 1655@anchor{Special Pre-Commands}
@@ -1810,7 +1879,7 @@ indicates that all remaining arguments are files.
1810 1879
1811@item 1880@item
1812Classes used for infix commands that represent variables should 1881Classes used for infix commands that represent variables should
1813derived from the abstract @code{transient-variables} class. 1882derived from the abstract @code{transient-variable} class.
1814@end itemize 1883@end itemize
1815 1884
1816Magit defines additional classes, which can serve as examples for the 1885Magit defines additional classes, which can serve as examples for the
@@ -2045,7 +2114,7 @@ called with no argument and returns a string.
2045 2114
2046@item 2115@item
2047@code{show-help} A function used to display help for the suffix. If 2116@code{show-help} A function used to display help for the suffix. If
2048unspecified, the prefix controls how hlep is displayed for its 2117unspecified, the prefix controls how help is displayed for its
2049suffixes. 2118suffixes.
2050@end itemize 2119@end itemize
2051 2120