diff options
| author | Jonas Bernoulli | 2023-01-30 22:39:38 +0100 |
|---|---|---|
| committer | Jonas Bernoulli | 2023-01-30 22:39:38 +0100 |
| commit | 1684e254a3b95b474753275fa9bfc2567a83b2fa (patch) | |
| tree | 6d61473f7f1cbaac1f2239eb0326a6be1b86368e /doc/misc | |
| parent | 327941b211299013868469e65050d92ea513f067 (diff) | |
| download | emacs-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.texi | 149 |
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. | |||
| 64 | Calling a suffix command usually causes the transient to be exited | 64 | Calling a suffix command usually causes the transient to be exited |
| 65 | but suffix commands can also be configured to not exit the transient. | 65 | but suffix commands can also be configured to not exit the transient. |
| 66 | 66 | ||
| 67 | @quotation | ||
| 68 | The second part of this manual, which describes how to modify existing | ||
| 69 | transients and create new transients from scratch, can be hard to | ||
| 70 | digest if you are just getting started. A useful resource to get over | ||
| 71 | that 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 |
| 68 | This manual is for Transient version 0.3.7. | 77 | This 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. | |||
| 447 | Save the value of the active transient persistently across Emacs | 456 | Save the value of the active transient persistently across Emacs |
| 448 | sessions. | 457 | sessions. |
| 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 |
| 453 | Clear the set and saved value of the active transient. | 462 | Clear 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 | ||
| 894 | To an extent, transients can be customized interactively, see | 903 | To 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 |
| 896 | transients can be further modified non-interactively. | 905 | transients can be further modified non-interactively. Let's begin |
| 906 | with an example: | ||
| 907 | |||
| 908 | @lisp | ||
| 909 | (transient-append-suffix 'magit-patch-apply "-3" | ||
| 910 | '("-R" "Apply in reverse" "--reverse")) | ||
| 911 | @end lisp | ||
| 912 | |||
| 913 | This inserts a new infix argument to toggle the @code{--reverse} argument | ||
| 914 | after the infix argument that toggles @code{-3} in @code{magit-patch-apply}. | ||
| 897 | 915 | ||
| 898 | The following functions share a few arguments: | 916 | The 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 |
| 917 | returned by @code{key-description}), or a list specifying coordinates (the | 934 | returned 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 | |||
| 1044 | the branch whose variables are being configured. | 1061 | the branch whose variables are being configured. |
| 1045 | @end defmac | 1062 | @end defmac |
| 1046 | 1063 | ||
| 1064 | It is possible to define one or more groups independently of a prefix | ||
| 1065 | definition, which is useful when those groups are to be used by more | ||
| 1066 | than just one prefix command. | ||
| 1067 | |||
| 1068 | @defmac transient-define-groups name group... | ||
| 1069 | This macro defines one or more groups of infix and suffix commands | ||
| 1070 | and stores them in a property of the symbol @var{NAME}. @var{GROUP} has the | ||
| 1071 | same form as for @code{transient-define-prefix}. Subsequently @var{NAME} can | ||
| 1072 | be used in a @var{GROUP} of @code{transient-define-prefix}, as described in the | ||
| 1073 | next 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 |
| 1141 | The value of @code{:setup-children}, if non-@code{nil}, is a function that takes | 1170 | The value of @code{:setup-children}, if non-@code{nil}, is a function that takes |
| 1142 | two arguments the group object itself and a list of children. | 1171 | one argument, a potentially list of children, and must return a list |
| 1143 | The children are given as a (potentially empty) list consisting | 1172 | of children or an empty list. This can either be used to somehow |
| 1144 | of either group or suffix specifications. It can make arbitrary | 1173 | transform the group's children that were defined the normal way, or |
| 1145 | changes to the children including constructing new children from | 1174 | to dynamically create the children from scratch. |
| 1146 | scratch. Also see @code{transient-setup-children}. | 1175 | |
| 1176 | The returned children must have the same form as stored in the | ||
| 1177 | prefix's @code{transient--layout} property, but it is often more convenient | ||
| 1178 | to use the same form as understood by @code{transient-define-prefix}, | ||
| 1179 | described below. If you use the latter approach, you can use the | ||
| 1180 | @code{transient-parse-child} and @code{transient-parse-children} functions to | ||
| 1181 | transform them from the convenient to the expected form. | ||
| 1147 | 1182 | ||
| 1148 | @item | 1183 | @item |
| 1149 | The boolean @code{:pad-keys} argument controls whether keys of all suffixes | 1184 | The 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 | |||
| 1151 | descriptions. | 1186 | descriptions. |
| 1152 | @end itemize | 1187 | @end itemize |
| 1153 | 1188 | ||
| 1154 | The @var{ELEMENT}s are either all subgroups (vectors), or all suffixes | 1189 | The @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 |
| 1156 | would allow mixing subgroups with commands at the same level, though | 1191 | subgroups with commands at the same level, though in principle there |
| 1157 | in principle there is nothing that prevents that.) | 1192 | is nothing that prevents that.) |
| 1158 | 1193 | ||
| 1159 | If the @var{ELEMENT}s are not subgroups, then they can be a mixture of lists | 1194 | If the @var{ELEMENT}s are not subgroups, then they can be a mixture of lists |
| 1160 | that specify commands and strings. Strings are inserted verbatim. | 1195 | that specify commands and strings. Strings are inserted verbatim into |
| 1161 | The empty string can be used to insert gaps between suffixes, which is | 1196 | the buffer. The empty string can be used to insert gaps between |
| 1162 | particularly useful if the suffixes are outlined as a table. | 1197 | suffixes, which is particularly useful if the suffixes are outlined as |
| 1163 | 1198 | a table. | |
| 1164 | Variables are supported inside group specifications. For example in | 1199 | |
| 1165 | place of a direct subgroup specification, a variable can be used whose | 1200 | Inside group specifications, including inside contained suffix |
| 1166 | value is a vector that qualifies as a group specification. Likewise, | 1201 | specifications, nothing has to be quoted and quoting anyway is |
| 1167 | a variable can be used where a suffix specification is expected. | 1202 | invalid. |
| 1168 | Lists of group or suffix specifications are also supported. Indirect | 1203 | |
| 1169 | specifications are resolved when the transient prefix is being | 1204 | How symbols are treated, depends on context. Inside suffix |
| 1170 | defined. | 1205 | specifications they often name functions. However if they appear in |
| 1206 | a place where a group is expected, then they are treated as indirect | ||
| 1207 | group specifications. Such a symbol must have an associated group | ||
| 1208 | specification, created using @code{transient-define-groups}. | ||
| 1209 | |||
| 1210 | Likewise a symbol can appear in a place where a suffix specification | ||
| 1211 | is expected. The value of the @code{transient--layout} property of that | ||
| 1212 | symbol must be a single suffix specification or a list of such | ||
| 1213 | specifications. Currently no macro exist that would create such a | ||
| 1214 | symbol, and this feature should usually not be used. | ||
| 1215 | |||
| 1216 | The value following a keyword, can be explicitly unquoted using @code{,}. | ||
| 1217 | This feature is experimental and should be avoided as well. | ||
| 1171 | 1218 | ||
| 1172 | The form of suffix specifications is documented in the next node. | 1219 | The 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 | |||
| 1232 | with it (as would be the case if @code{transient-define-suffix} or | 1279 | with 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 | ||
| 1235 | Anonymous, dynamically defined suffix commands are also support. | 1282 | Anonymous, dynamically defined suffix commands are also supported. |
| 1236 | See information about the @code{:setup-children} function in @ref{Group Specifications}. | 1283 | See information about the @code{:setup-children} function in @ref{Group Specifications}. |
| 1237 | 1284 | ||
| 1238 | As mentioned above, the object that is associated with a command can | 1285 | As 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 | ||
| 1518 | The default for suffixes is @code{transient--do-exit}. | 1565 | By default, invoking a suffix causes the transient to be exited. |
| 1566 | |||
| 1567 | If you want a different default behavior for a certain transient | ||
| 1568 | prefix command, then set its @code{:transient-suffix} slot. The value can be | ||
| 1569 | a boolean, answering the question "does the transient stay active, | ||
| 1570 | when a suffix command is invoked?" @code{t} means that the transient stays | ||
| 1571 | active, while @code{nil} means that invoking a suffix exits the transient. | ||
| 1572 | In either case, the exact behavior depends on whether the suffix is | ||
| 1573 | itself a prefix (i.e., a sub-prefix), an infix or a regular suffix. | ||
| 1574 | |||
| 1575 | The behavior for an individual suffix command can be changed by | ||
| 1576 | setting its @code{transient} slot to one of the following pre-commands. | ||
| 1519 | 1577 | ||
| 1520 | @defun transient--do-exit | 1578 | @defun transient--do-exit |
| 1521 | Call the command after exporting variables and exit the transient. | 1579 | Call 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 | ||
| 1569 | The default for non-suffixes, i.e., commands that are bound in other | 1627 | By default, non-suffixes (commands that are bound in other keymaps |
| 1570 | keymaps beside the transient keymap, is @code{transient--do-warn}. Silently | 1628 | beside the transient keymap) cannot be invoked. Trying to invoke |
| 1571 | ignoring the user-error is also an option, though probably not a good | 1629 | such a command results in a warning and the transient stays active. |
| 1572 | one. | ||
| 1573 | 1630 | ||
| 1574 | If you want to let the user invoke non-suffix commands, then use | 1631 | If 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} | 1632 | slot of the transient prefix command. The value can be a boolean, |
| 1576 | slot. | 1633 | answering the question, "is it allowed to invoke non-suffix commands?" |
| 1634 | |||
| 1635 | If the value is @code{t} or @code{transient--do-stay}, then non-suffixes can be | ||
| 1636 | invoked, when it is @code{nil} or @code{transient--do-warn} (the default) then they | ||
| 1637 | cannot be invoked. | ||
| 1638 | |||
| 1639 | The only other recommended value is @code{transient--do-leave}. If that is | ||
| 1640 | used, then non-suffixes can be invoked, but if one is invoked, then | ||
| 1641 | that exits the transient. | ||
| 1577 | 1642 | ||
| 1578 | @defun transient--do-warn | 1643 | @defun transient--do-warn |
| 1579 | Call @code{transient-undefined} and stay transient. | 1644 | Call @code{transient-undefined} and stay transient. |
| 1580 | @end defun | 1645 | @end defun |
| 1581 | 1646 | ||
| 1582 | @defun transient--do-noop | 1647 | @defun transient--do-stay |
| 1583 | Call @code{transient-noop} and stay transient. | 1648 | Call the command without exporting variables and stay transient. |
| 1649 | @end defun | ||
| 1650 | |||
| 1651 | @defun transient--do-leave | ||
| 1652 | Call 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 |
| 1812 | Classes used for infix commands that represent variables should | 1881 | Classes used for infix commands that represent variables should |
| 1813 | derived from the abstract @code{transient-variables} class. | 1882 | derived from the abstract @code{transient-variable} class. |
| 1814 | @end itemize | 1883 | @end itemize |
| 1815 | 1884 | ||
| 1816 | Magit defines additional classes, which can serve as examples for the | 1885 | Magit 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 |
| 2048 | unspecified, the prefix controls how hlep is displayed for its | 2117 | unspecified, the prefix controls how help is displayed for its |
| 2049 | suffixes. | 2118 | suffixes. |
| 2050 | @end itemize | 2119 | @end itemize |
| 2051 | 2120 | ||