diff options
| author | Eli Zaretskii | 2022-02-18 10:38:47 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2022-02-18 10:38:49 +0200 |
| commit | 2ed240296c181cc677caeef1ec33befd8428aa98 (patch) | |
| tree | 8a7c5af3b20d468dadb6655b8a9827c6c9fc7813 | |
| parent | b16aed76cb2e94dc5a8cb27ba574346a3931ca92 (diff) | |
| parent | c8442df581feb45d50530b372152beff9d23211d (diff) | |
| download | emacs-2ed240296c181cc677caeef1ec33befd8428aa98.tar.gz emacs-2ed240296c181cc677caeef1ec33befd8428aa98.zip | |
Merge from origin/emacs-28
c8442df ; Separate command and concept index in Transient manual
8aa052c ; Fix Transient manual
5b7752a Fix problem with popd for in remote shell buffers
38f6ea1 Import texi source file for transient manual
df34929 Update to Org 9.5.2-15-gc5ceb6
| -rw-r--r-- | doc/misc/Makefile.in | 4 | ||||
| -rw-r--r-- | doc/misc/transient.texi | 2560 | ||||
| -rw-r--r-- | lisp/org/ol-bibtex.el | 6 | ||||
| -rw-r--r-- | lisp/org/org-list.el | 2 | ||||
| -rw-r--r-- | lisp/org/org-version.el | 2 | ||||
| -rw-r--r-- | lisp/shell.el | 2 |
6 files changed, 2569 insertions, 7 deletions
diff --git a/doc/misc/Makefile.in b/doc/misc/Makefile.in index d348dbc194b..5bd8f6a1518 100644 --- a/doc/misc/Makefile.in +++ b/doc/misc/Makefile.in | |||
| @@ -73,8 +73,8 @@ INFO_COMMON = auth autotype bovine calc ccmode cl \ | |||
| 73 | flymake forms gnus emacs-gnutls htmlfontify idlwave ido info.info \ | 73 | flymake forms gnus emacs-gnutls htmlfontify idlwave ido info.info \ |
| 74 | mairix-el message mh-e modus-themes newsticker nxml-mode octave-mode \ | 74 | mairix-el message mh-e modus-themes newsticker nxml-mode octave-mode \ |
| 75 | org pcl-cvs pgg rcirc remember reftex sasl \ | 75 | org pcl-cvs pgg rcirc remember reftex sasl \ |
| 76 | sc semantic ses sieve smtpmail speedbar srecode todo-mode tramp \ | 76 | sc semantic ses sieve smtpmail speedbar srecode todo-mode transient \ |
| 77 | url vhdl-mode vip viper widget wisent woman | 77 | tramp url vhdl-mode vip viper widget wisent woman |
| 78 | 78 | ||
| 79 | ## Info files to install on current platform. | 79 | ## Info files to install on current platform. |
| 80 | INFO_INSTALL = $(INFO_COMMON) $(DOCMISC_W32) | 80 | INFO_INSTALL = $(INFO_COMMON) $(DOCMISC_W32) |
diff --git a/doc/misc/transient.texi b/doc/misc/transient.texi new file mode 100644 index 00000000000..bf048841a65 --- /dev/null +++ b/doc/misc/transient.texi | |||
| @@ -0,0 +1,2560 @@ | |||
| 1 | \input texinfo @c -*- texinfo -*- | ||
| 2 | @c %**start of header | ||
| 3 | @setfilename transient.info | ||
| 4 | @settitle Transient User and Developer Manual | ||
| 5 | @documentencoding UTF-8 | ||
| 6 | @documentlanguage en | ||
| 7 | @c %**end of header | ||
| 8 | |||
| 9 | @copying | ||
| 10 | @quotation | ||
| 11 | Copyright (C) 2018-2022 Free Software Foundation, Inc. | ||
| 12 | |||
| 13 | You can redistribute this document and/or modify it under the terms | ||
| 14 | of the GNU General Public License as published by the Free Software | ||
| 15 | Foundation, either version 3 of the License, or (at your option) any | ||
| 16 | later version. | ||
| 17 | |||
| 18 | This document is distributed in the hope that it will be useful, | ||
| 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE@. See the GNU | ||
| 21 | General Public License for more details. | ||
| 22 | |||
| 23 | @end quotation | ||
| 24 | @end copying | ||
| 25 | |||
| 26 | @dircategory Emacs | ||
| 27 | @direntry | ||
| 28 | * Transient: (transient). Transient Commands. | ||
| 29 | @end direntry | ||
| 30 | |||
| 31 | @finalout | ||
| 32 | @titlepage | ||
| 33 | @title Transient User and Developer Manual | ||
| 34 | @subtitle for version 0.3.7 | ||
| 35 | @author Jonas Bernoulli | ||
| 36 | @page | ||
| 37 | @vskip 0pt plus 1filll | ||
| 38 | @insertcopying | ||
| 39 | @end titlepage | ||
| 40 | |||
| 41 | @contents | ||
| 42 | |||
| 43 | @ifnottex | ||
| 44 | @node Top | ||
| 45 | @top Transient User and Developer Manual | ||
| 46 | |||
| 47 | Taking inspiration from prefix keys and prefix arguments, Transient | ||
| 48 | implements a similar abstraction involving a prefix command, infix | ||
| 49 | arguments and suffix commands. We could call this abstraction a | ||
| 50 | ``transient command'', but because it always involves at least two | ||
| 51 | commands (a prefix and a suffix) we prefer to call it just a | ||
| 52 | ``transient''. | ||
| 53 | |||
| 54 | When the user calls a transient prefix command, a transient | ||
| 55 | (temporary) keymap is activated, which binds the transient's infix | ||
| 56 | and suffix commands, and functions that control the transient state | ||
| 57 | are added to @code{pre-command-hook} and @code{post-command-hook}. The available | ||
| 58 | suffix and infix commands and their state are shown in a popup buffer | ||
| 59 | until the transient is exited by invoking a suffix command. | ||
| 60 | |||
| 61 | Calling an infix command causes its value to be changed, possibly by | ||
| 62 | reading a new value in the minibuffer. | ||
| 63 | |||
| 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. | ||
| 66 | |||
| 67 | @noindent | ||
| 68 | This manual is for Transient version 0.3.7. | ||
| 69 | |||
| 70 | @insertcopying | ||
| 71 | @end ifnottex | ||
| 72 | |||
| 73 | @menu | ||
| 74 | * Introduction:: | ||
| 75 | * Usage:: | ||
| 76 | * Modifying Existing Transients:: | ||
| 77 | * Defining New Commands:: | ||
| 78 | * Classes and Methods:: | ||
| 79 | * Related Abstractions and Packages:: | ||
| 80 | * FAQ:: | ||
| 81 | * Keystroke Index:: | ||
| 82 | * Command and Function Index:: | ||
| 83 | * Variable Index:: | ||
| 84 | * Concept Index:: | ||
| 85 | * GNU General Public License:: | ||
| 86 | |||
| 87 | @detailmenu | ||
| 88 | --- The Detailed Node Listing --- | ||
| 89 | |||
| 90 | Usage | ||
| 91 | |||
| 92 | * Invoking Transients:: | ||
| 93 | * Aborting and Resuming Transients:: | ||
| 94 | * Common Suffix Commands:: | ||
| 95 | * Saving Values:: | ||
| 96 | * Using History:: | ||
| 97 | * Getting Help for Suffix Commands:: | ||
| 98 | * Enabling and Disabling Suffixes:: | ||
| 99 | * Other Commands:: | ||
| 100 | * Other Options:: | ||
| 101 | |||
| 102 | Defining New Commands | ||
| 103 | |||
| 104 | * Defining Transients:: | ||
| 105 | * Binding Suffix and Infix Commands:: | ||
| 106 | * Defining Suffix and Infix Commands:: | ||
| 107 | * Using Infix Arguments:: | ||
| 108 | * Transient State:: | ||
| 109 | |||
| 110 | Binding Suffix and Infix Commands | ||
| 111 | |||
| 112 | * Group Specifications:: | ||
| 113 | * Suffix Specifications:: | ||
| 114 | |||
| 115 | |||
| 116 | Classes and Methods | ||
| 117 | |||
| 118 | * Group Classes:: | ||
| 119 | * Group Methods:: | ||
| 120 | * Prefix Classes:: | ||
| 121 | * Suffix Classes:: | ||
| 122 | * Suffix Methods:: | ||
| 123 | * Prefix Slots:: | ||
| 124 | * Suffix Slots:: | ||
| 125 | * Predicate Slots:: | ||
| 126 | |||
| 127 | Suffix Methods | ||
| 128 | |||
| 129 | * Suffix Value Methods:: | ||
| 130 | * Suffix Format Methods:: | ||
| 131 | |||
| 132 | |||
| 133 | Related Abstractions and Packages | ||
| 134 | |||
| 135 | * Comparison With Prefix Keys and Prefix Arguments:: | ||
| 136 | * Comparison With Other Packages:: | ||
| 137 | |||
| 138 | @end detailmenu | ||
| 139 | @end menu | ||
| 140 | |||
| 141 | @node Introduction | ||
| 142 | @chapter Introduction | ||
| 143 | |||
| 144 | Taking inspiration from prefix keys and prefix arguments, Transient | ||
| 145 | implements a similar abstraction involving a prefix command, infix | ||
| 146 | arguments and suffix commands. We could call this abstraction a | ||
| 147 | ``transient command'', but because it always involves at least two | ||
| 148 | commands (a prefix and a suffix) we prefer to call it just a | ||
| 149 | ``transient''. | ||
| 150 | |||
| 151 | @quotation | ||
| 152 | Transient keymaps are a feature provided by Emacs. Transients as | ||
| 153 | implemented by this package involve the use of transient keymaps. | ||
| 154 | |||
| 155 | @cindex transient prefix command | ||
| 156 | Emacs provides a feature that it calls @dfn{prefix commands}. When we | ||
| 157 | talk about ``prefix commands'' in this manual, then we mean our own kind | ||
| 158 | of ``prefix commands'', unless specified otherwise. To avoid ambiguity | ||
| 159 | we sometimes use the terms @dfn{transient prefix command} for our kind and | ||
| 160 | ``regular prefix command'' for the Emacs' kind. | ||
| 161 | |||
| 162 | @end quotation | ||
| 163 | |||
| 164 | When the user calls a transient prefix command, a transient | ||
| 165 | (temporary) keymap is activated, which binds the transient's infix and | ||
| 166 | suffix commands, and functions that control the transient state are | ||
| 167 | added to @code{pre-command-hook} and @code{post-command-hook}. The available suffix | ||
| 168 | and infix commands and their state are shown in a popup buffer until | ||
| 169 | the transient state is exited by invoking a suffix command. | ||
| 170 | |||
| 171 | Calling an infix command causes its value to be changed. How that is | ||
| 172 | done depends on the type of the infix command. The simplest case is | ||
| 173 | an infix command that represents a command-line argument that does not | ||
| 174 | take a value. Invoking such an infix command causes the switch to be | ||
| 175 | toggled on or off. More complex infix commands may read a value from | ||
| 176 | the user, using the minibuffer. | ||
| 177 | |||
| 178 | Calling a suffix command usually causes the transient to be exited; | ||
| 179 | the transient keymaps and hook functions are removed, the popup buffer | ||
| 180 | no longer shows information about the (no longer bound) suffix | ||
| 181 | commands, the values of some public global variables are set, while | ||
| 182 | some internal global variables are unset, and finally the command is | ||
| 183 | actually called. Suffix commands can also be configured to not exit | ||
| 184 | the transient. | ||
| 185 | |||
| 186 | A suffix command can, but does not have to, use the infix arguments in | ||
| 187 | much the same way any command can choose to use or ignore the prefix | ||
| 188 | arguments. For a suffix command that was invoked from a transient, the | ||
| 189 | variable @code{transient-current-suffixes} and the function @code{transient-args} | ||
| 190 | serve about the same purpose as the variables @code{prefix-arg} and | ||
| 191 | @code{current-prefix-arg} do for any command that was called after the prefix | ||
| 192 | arguments have been set using a command such as @code{universal-argument}. | ||
| 193 | |||
| 194 | The information shown in the popup buffer while a transient is active | ||
| 195 | looks a bit like this: | ||
| 196 | |||
| 197 | @example | ||
| 198 | ,----------------------------------------- | ||
| 199 | |Arguments | ||
| 200 | | -f Force (--force) | ||
| 201 | | -a Annotate (--annotate) | ||
| 202 | | | ||
| 203 | |Create | ||
| 204 | | t tag | ||
| 205 | | r release | ||
| 206 | `----------------------------------------- | ||
| 207 | @end example | ||
| 208 | |||
| 209 | @quotation | ||
| 210 | This is a simplified version of @code{magit-tag}. Info manuals do not | ||
| 211 | support images or colored text, so the above ``screenshot'' lacks some | ||
| 212 | information; in practice you would be able to tell whether the | ||
| 213 | arguments @code{--force} and @code{--annotate} are enabled or not based on their | ||
| 214 | color. | ||
| 215 | |||
| 216 | @end quotation | ||
| 217 | |||
| 218 | @cindex command dispatchers | ||
| 219 | Transient can be used to implement simple ``command dispatchers''. The | ||
| 220 | main benefit then is that the user can see all the available commands | ||
| 221 | in a popup buffer. That is useful by itself because it frees the user | ||
| 222 | from having to remember all the keys that are valid after a certain | ||
| 223 | prefix key or command. Magit's @code{magit-dispatch} (on @code{C-x M-g}) command is | ||
| 224 | an example of using Transient to merely implement a command | ||
| 225 | dispatcher. | ||
| 226 | |||
| 227 | In addition to that, Transient also allows users to interactively pass | ||
| 228 | arguments to commands. These arguments can be much more complex than | ||
| 229 | what is reasonable when using prefix arguments. There is a limit to | ||
| 230 | how many aspects of a command can be controlled using prefix | ||
| 231 | arguments. Furthermore, what a certain prefix argument means for | ||
| 232 | different commands can be completely different, and users have to read | ||
| 233 | documentation to learn and then commit to memory what a certain prefix | ||
| 234 | argument means to a certain command. | ||
| 235 | |||
| 236 | Transient suffix commands, on the other hand, can accept dozens of | ||
| 237 | different arguments without the user having to remember anything. | ||
| 238 | When using Transient, one can call a command with arguments that | ||
| 239 | are just as complex as when calling the same function non-interactively | ||
| 240 | from Lisp. | ||
| 241 | |||
| 242 | Invoking a transient command with arguments is similar to invoking a | ||
| 243 | command in a shell with command-line completion and history enabled. | ||
| 244 | One benefit of the Transient interface is that it remembers history | ||
| 245 | not only on a global level (``this command was invoked using these | ||
| 246 | arguments, and previously it was invoked using those other arguments''), | ||
| 247 | but also remembers the values of individual arguments independently. | ||
| 248 | @xref{Using History}. | ||
| 249 | |||
| 250 | After a transient prefix command is invoked, @kbd{C-h @var{key}} can be used to | ||
| 251 | show the documentation for the infix or suffix command that @kbd{@var{key}} is | ||
| 252 | bound to (@pxref{Getting Help for Suffix Commands}), and infixes and | ||
| 253 | suffixes can be removed from the transient using @kbd{C-x l @var{key}}. Infixes | ||
| 254 | and suffixes that are disabled by default can be enabled the same way. | ||
| 255 | @xref{Enabling and Disabling Suffixes}. | ||
| 256 | |||
| 257 | Transient ships with support for a few different types of specialized | ||
| 258 | infix commands. A command that sets a command line option, for example, | ||
| 259 | has different needs than a command that merely toggles a boolean flag. | ||
| 260 | Additionally, Transient provides abstractions for defining new types, | ||
| 261 | which the author of Transient did not anticipate (or didn't get around | ||
| 262 | to implementing yet). | ||
| 263 | |||
| 264 | @node Usage | ||
| 265 | @chapter Usage | ||
| 266 | |||
| 267 | @menu | ||
| 268 | * Invoking Transients:: | ||
| 269 | * Aborting and Resuming Transients:: | ||
| 270 | * Common Suffix Commands:: | ||
| 271 | * Saving Values:: | ||
| 272 | * Using History:: | ||
| 273 | * Getting Help for Suffix Commands:: | ||
| 274 | * Enabling and Disabling Suffixes:: | ||
| 275 | * Other Commands:: | ||
| 276 | * Other Options:: | ||
| 277 | @end menu | ||
| 278 | |||
| 279 | @node Invoking Transients | ||
| 280 | @section Invoking Transients | ||
| 281 | @cindex invoking transients | ||
| 282 | |||
| 283 | A transient prefix command is invoked like any other command by | ||
| 284 | pressing the key that is bound to that command. The main difference | ||
| 285 | to other commands is that a transient prefix command activates a | ||
| 286 | transient keymap, which temporarily binds the transient's infix and | ||
| 287 | suffix commands. Bindings from other keymaps may, or may not, be | ||
| 288 | disabled while the transient state is in effect. | ||
| 289 | |||
| 290 | There are two kinds of commands that are available after invoking a | ||
| 291 | transient prefix command; infix and suffix commands. Infix commands | ||
| 292 | set some value (which is then shown in a popup buffer), without | ||
| 293 | leaving the transient. Suffix commands, on the other hand, usually quit | ||
| 294 | the transient and they may use the values set by the infix commands, | ||
| 295 | i.e.@: the infix @strong{arguments}. | ||
| 296 | |||
| 297 | Instead of setting arguments to be used by a suffix command, infix | ||
| 298 | commands may also set some value by side-effect, e.g., by setting the | ||
| 299 | value of some variable. | ||
| 300 | |||
| 301 | @node Aborting and Resuming Transients | ||
| 302 | @section Aborting and Resuming Transients | ||
| 303 | @cindex aborting transients | ||
| 304 | @cindex resuming transients | ||
| 305 | |||
| 306 | @cindex quit transient | ||
| 307 | To quit the transient without invoking a suffix command press @code{C-g}. | ||
| 308 | |||
| 309 | Key bindings in transient keymaps may be longer than a single event. | ||
| 310 | After pressing a valid prefix key, all commands whose bindings do not | ||
| 311 | begin with that prefix key are temporarily unavailable and grayed out. | ||
| 312 | To abort the prefix key press @kbd{C-g} (which in this case only quits the | ||
| 313 | prefix key, but not the complete transient). | ||
| 314 | |||
| 315 | A transient prefix command can be bound as a suffix of another | ||
| 316 | transient. Invoking such a suffix replaces the current transient | ||
| 317 | state with a new transient state, i.e.@: the available bindings change | ||
| 318 | and the information displayed in the popup buffer is updated | ||
| 319 | accordingly. Pressing @kbd{C-g} while a nested transient is active only | ||
| 320 | quits the innermost transient, causing a return to the previous | ||
| 321 | transient. | ||
| 322 | |||
| 323 | @kbd{C-q} or @kbd{C-z} on the other hand always exits all transients. If you use | ||
| 324 | the latter, then you can later resume the stack of transients using | ||
| 325 | @kbd{M-x transient-resume}. | ||
| 326 | |||
| 327 | @table @asis | ||
| 328 | @kindex C-g | ||
| 329 | @findex transient-quit-seq | ||
| 330 | @item @kbd{C-g} @tie{}@tie{}@tie{}@tie{}(@code{transient-quit-seq}) | ||
| 331 | @kindex C-g | ||
| 332 | @findex transient-quit-one | ||
| 333 | @item @kbd{C-g} @tie{}@tie{}@tie{}@tie{}(@code{transient-quit-one}) | ||
| 334 | |||
| 335 | This key quits the currently active incomplete key sequence, if any, | ||
| 336 | or else the current transient. When quitting the current transient, | ||
| 337 | it returns to the previous transient, if any. | ||
| 338 | @end table | ||
| 339 | |||
| 340 | Transient's predecessor bound @kbd{q} instead of @kbd{C-g} to the quit command. | ||
| 341 | To learn how to get that binding back see @code{transient-bind-q-to-quit}'s | ||
| 342 | doc string. | ||
| 343 | |||
| 344 | @table @asis | ||
| 345 | @kindex C-q | ||
| 346 | @findex transient-quit-all | ||
| 347 | @item @kbd{C-q} @tie{}@tie{}@tie{}@tie{}(@code{transient-quit-all}) | ||
| 348 | |||
| 349 | This command quits the currently active incomplete key sequence, if | ||
| 350 | any, and all transients, including the active transient and all | ||
| 351 | suspended transients, if any. | ||
| 352 | |||
| 353 | @kindex C-z | ||
| 354 | @findex transient-suspend | ||
| 355 | @item @kbd{C-z} @tie{}@tie{}@tie{}@tie{}(@code{transient-suspend}) | ||
| 356 | |||
| 357 | Like @code{transient-quit-all}, this command quits an incomplete key | ||
| 358 | sequence, if any, and all transients. Additionally, it saves the | ||
| 359 | stack of transients so that it can easily be resumed (which is | ||
| 360 | particularly useful if you quickly need to do ``something else'', and | ||
| 361 | the stack is deeper than a single transient, and/or you have already | ||
| 362 | changed the values of some infix arguments). | ||
| 363 | |||
| 364 | Note that only a single stack of transients can be saved at a time. | ||
| 365 | If another stack is already saved, then saving a new stack discards | ||
| 366 | the previous stack. | ||
| 367 | |||
| 368 | @kindex M-x transient-resume | ||
| 369 | @findex transient-resume | ||
| 370 | @item @kbd{M-x transient-resume} @tie{}@tie{}@tie{}@tie{}(@code{transient-resume}) | ||
| 371 | |||
| 372 | This command resumes the previously suspended stack of transients, | ||
| 373 | if any. | ||
| 374 | @end table | ||
| 375 | |||
| 376 | @node Common Suffix Commands | ||
| 377 | @section Common Suffix Commands | ||
| 378 | @cindex common suffix commands | ||
| 379 | |||
| 380 | A few shared suffix commands are available in all transients. These | ||
| 381 | suffix commands are not shown in the popup buffer by default. | ||
| 382 | |||
| 383 | This includes the aborting commands mentioned in the previous section, as | ||
| 384 | well as some other commands that are all bound to @kbd{C-x @var{key}}. After | ||
| 385 | @kbd{C-x} is pressed, a section featuring all these common commands is | ||
| 386 | temporarily shown in the popup buffer. After invoking one of them, | ||
| 387 | the section disappears again. Note, however, that one of these commands | ||
| 388 | is described as ``Show common permanently''; invoke that if you want the | ||
| 389 | common commands to always be shown for all transients. | ||
| 390 | |||
| 391 | @table @asis | ||
| 392 | @kindex C-x t | ||
| 393 | @findex transient-toggle-common | ||
| 394 | @item @kbd{C-x t} @tie{}@tie{}@tie{}@tie{}(@code{transient-toggle-common}) | ||
| 395 | |||
| 396 | This command toggles whether the generic commands that are common to | ||
| 397 | all transients are always displayed or only after typing the | ||
| 398 | incomplete prefix key sequence @kbd{C-x}. This only affects the current | ||
| 399 | Emacs session. | ||
| 400 | |||
| 401 | @end table | ||
| 402 | |||
| 403 | @defopt transient-show-common-commands | ||
| 404 | |||
| 405 | This option controls whether shared suffix commands are shown | ||
| 406 | alongside the transient-specific infix and suffix commands. By | ||
| 407 | default, the shared commands are not shown to avoid overwhelming | ||
| 408 | the user with too many options. | ||
| 409 | |||
| 410 | While a transient is active, pressing @kbd{C-x} always shows the common | ||
| 411 | commands. The value of this option can be changed for the current | ||
| 412 | Emacs session by typing @kbd{C-x t} while a transient is active. | ||
| 413 | @end defopt | ||
| 414 | |||
| 415 | The other common commands are described in either the previous or | ||
| 416 | in one of the following sections. | ||
| 417 | |||
| 418 | Some of Transient's key bindings differ from the respective bindings | ||
| 419 | of Magit-Popup; see @ref{FAQ} for more information. | ||
| 420 | |||
| 421 | @node Saving Values | ||
| 422 | @section Saving Values | ||
| 423 | @cindex saving values of arguments | ||
| 424 | |||
| 425 | After setting the infix arguments in a transient, the user can save | ||
| 426 | those arguments for future invocations. | ||
| 427 | |||
| 428 | Most transients will start out with the saved arguments when they are | ||
| 429 | invoked. There are a few exceptions, though. Some transients are | ||
| 430 | designed so that the value that they use is stored externally as the | ||
| 431 | buffer-local value of some variable. Invoking such a transient again | ||
| 432 | uses the buffer-local value.@footnote{ | ||
| 433 | @code{magit-diff} and @code{magit-log} are two prominent examples, and their | ||
| 434 | handling of buffer-local values is actually a bit more complicated | ||
| 435 | than outlined above and even customizable.} | ||
| 436 | |||
| 437 | If the user does not save the value and just exits using a regular | ||
| 438 | suffix command, then the value is merely saved to the transient's | ||
| 439 | history. That value won't be used when the transient is next invoked, | ||
| 440 | but it is easily accessible (@pxref{Using History}). | ||
| 441 | |||
| 442 | @table @asis | ||
| 443 | @kindex C-x s | ||
| 444 | @findex transient-set | ||
| 445 | @item @kbd{C-x s} @tie{}@tie{}@tie{}@tie{}(@code{transient-set}) | ||
| 446 | |||
| 447 | This command saves the value of the active transient for this Emacs | ||
| 448 | session. | ||
| 449 | |||
| 450 | @kindex C-x C-s | ||
| 451 | @findex transient-save | ||
| 452 | @item @kbd{C-x C-s} @tie{}@tie{}@tie{}@tie{}(@code{transient-save}) | ||
| 453 | |||
| 454 | Save the value of the active transient persistently across Emacs | ||
| 455 | sessions. | ||
| 456 | |||
| 457 | @end table | ||
| 458 | |||
| 459 | @defopt transient-values-file | ||
| 460 | |||
| 461 | This option names the file that is used to persist the values of | ||
| 462 | transients between Emacs sessions. | ||
| 463 | @end defopt | ||
| 464 | |||
| 465 | @node Using History | ||
| 466 | @section Using History | ||
| 467 | @cindex value history | ||
| 468 | |||
| 469 | Every time the user invokes a suffix command the transient's current | ||
| 470 | value is saved to its history. These values can be cycled through the | ||
| 471 | same way one can cycle through the history of commands that read | ||
| 472 | user-input in the minibuffer. | ||
| 473 | |||
| 474 | @table @asis | ||
| 475 | @kindex C-M-p | ||
| 476 | @findex transient-history-prev | ||
| 477 | @item @kbd{C-M-p} @tie{}@tie{}@tie{}@tie{}(@code{transient-history-prev}) | ||
| 478 | @kindex C-x p | ||
| 479 | @findex transient-history-prev | ||
| 480 | @item @kbd{C-x p} @tie{}@tie{}@tie{}@tie{}(@code{transient-history-prev}) | ||
| 481 | |||
| 482 | This command switches to the previous value used for the active | ||
| 483 | transient. | ||
| 484 | |||
| 485 | @kindex C-M-n | ||
| 486 | @findex transient-history-next | ||
| 487 | @item @kbd{C-M-n} @tie{}@tie{}@tie{}@tie{}(@code{transient-history-next}) | ||
| 488 | @kindex C-x n | ||
| 489 | @findex transient-history-next | ||
| 490 | @item @kbd{C-x n} @tie{}@tie{}@tie{}@tie{}(@code{transient-history-next}) | ||
| 491 | |||
| 492 | This command switches to the next value used for the active | ||
| 493 | transient. | ||
| 494 | @end table | ||
| 495 | |||
| 496 | In addition to the transient-wide history, Transient of course | ||
| 497 | supports per-infix history. When an infix reads user-input using the | ||
| 498 | minibuffer, the user can use the regular minibuffer history | ||
| 499 | commands to cycle through previously used values. Usually the same | ||
| 500 | keys as those mentioned above are bound to those commands. | ||
| 501 | |||
| 502 | Authors of transients should arrange for different infix commands that | ||
| 503 | read the same kind of value to also use the same history key | ||
| 504 | (@pxref{Suffix Slots}). | ||
| 505 | |||
| 506 | Both kinds of history are saved to a file when Emacs is exited. | ||
| 507 | |||
| 508 | @defopt transient-history-file | ||
| 509 | |||
| 510 | This option names the file that is used to persist the history of | ||
| 511 | transients and their infixes between Emacs sessions. | ||
| 512 | @end defopt | ||
| 513 | |||
| 514 | @defopt transient-history-limit | ||
| 515 | |||
| 516 | This option controls how many history elements are kept at the time | ||
| 517 | the history is saved in @code{transient-history-file}. | ||
| 518 | @end defopt | ||
| 519 | |||
| 520 | @node Getting Help for Suffix Commands | ||
| 521 | @section Getting Help for Suffix Commands | ||
| 522 | @cindex getting help | ||
| 523 | |||
| 524 | Transients can have many suffixes and infixes that the user might not | ||
| 525 | be familiar with. To make it trivial to get help for these, Transient | ||
| 526 | provides access to the documentation directly from the active | ||
| 527 | transient. | ||
| 528 | |||
| 529 | @table @asis | ||
| 530 | @kindex C-h | ||
| 531 | @findex transient-help | ||
| 532 | @item @kbd{C-h} @tie{}@tie{}@tie{}@tie{}(@code{transient-help}) | ||
| 533 | |||
| 534 | This command enters help mode. When help mode is active, | ||
| 535 | typing a key shows information about the suffix command that the key | ||
| 536 | is normally bound to (instead of invoking it). Pressing @kbd{C-h} a | ||
| 537 | second time shows information about the @emph{prefix} command. | ||
| 538 | |||
| 539 | After typing a key, the stack of transient states is suspended and | ||
| 540 | information about the suffix command is shown instead. Typing @kbd{q} in | ||
| 541 | the help buffer buries that buffer and resumes the transient state. | ||
| 542 | @end table | ||
| 543 | |||
| 544 | What sort of documentation is shown depends on how the transient was | ||
| 545 | defined. For infix commands that represent command-line arguments | ||
| 546 | this ideally shows the appropriate manpage. @code{transient-help} then tries | ||
| 547 | to jump to the correct location within that. Info manuals are also | ||
| 548 | supported. The fallback is to show the command's doc string, for | ||
| 549 | non-infix suffixes this is usually appropriate. | ||
| 550 | |||
| 551 | @node Enabling and Disabling Suffixes | ||
| 552 | @section Enabling and Disabling Suffixes | ||
| 553 | @cindex enabling suffixes | ||
| 554 | @cindex disabling suffixes | ||
| 555 | |||
| 556 | The user base of a package that uses transients can be very diverse. | ||
| 557 | This is certainly the case for Magit; some users have been using it and | ||
| 558 | Git for a decade, while others are just getting started now. | ||
| 559 | |||
| 560 | @cindex levels | ||
| 561 | For that reason a mechanism is needed that authors can use to classify a | ||
| 562 | transient's infixes and suffixes along the essentials@dots{}everything | ||
| 563 | spectrum. We use the term @dfn{levels} to describe that mechanism. | ||
| 564 | |||
| 565 | @cindex transient-level | ||
| 566 | Each suffix command is placed on a level and each transient has a | ||
| 567 | level (called @dfn{transient-level}), which controls which suffix commands | ||
| 568 | are available. Integers between 1 and 7 (inclusive) are valid levels. | ||
| 569 | For suffixes, 0 is also valid; it means that the suffix is not | ||
| 570 | displayed at any level. | ||
| 571 | |||
| 572 | The levels of individual transients and/or their individual suffixes | ||
| 573 | can be changed interactively, by invoking the transient and then | ||
| 574 | pressing @kbd{C-x l} to enter the ``edit'' mode, see below. | ||
| 575 | |||
| 576 | The default level for both transients and their suffixes is 4. The | ||
| 577 | @code{transient-default-level} option only controls the default for | ||
| 578 | transients. The default suffix level is always 4. The authors of | ||
| 579 | transients should place certain suffixes on a higher level, if they | ||
| 580 | expect that it won't be of use to most users, and they should place | ||
| 581 | very important suffixes on a lower level, so that they remain | ||
| 582 | available even if the user lowers the transient level. | ||
| 583 | |||
| 584 | @defopt transient-default-level | ||
| 585 | |||
| 586 | This option controls which suffix levels are made available by | ||
| 587 | default. It sets the transient-level for transients for which the | ||
| 588 | user has not set that individually. | ||
| 589 | @end defopt | ||
| 590 | |||
| 591 | @defopt transient-levels-file | ||
| 592 | |||
| 593 | This option names the file that is used to persist the levels of | ||
| 594 | transients and their suffixes between Emacs sessions. | ||
| 595 | @end defopt | ||
| 596 | |||
| 597 | @table @asis | ||
| 598 | @kindex C-x l | ||
| 599 | @findex transient-set-level | ||
| 600 | @item @kbd{C-x l} @tie{}@tie{}@tie{}@tie{}(@code{transient-set-level}) | ||
| 601 | |||
| 602 | This command enters edit mode. When edit mode is active, then all | ||
| 603 | infixes and suffixes that are currently usable are displayed along | ||
| 604 | with their levels. The colors of the levels indicate whether they | ||
| 605 | are enabled or not. The level of the transient is also displayed | ||
| 606 | along with some usage information. | ||
| 607 | |||
| 608 | In edit mode, pressing the key that would usually invoke a certain | ||
| 609 | suffix instead prompts the user for the level that suffix should be | ||
| 610 | placed on. | ||
| 611 | |||
| 612 | Help mode is available in edit mode. | ||
| 613 | |||
| 614 | To change the transient level press @kbd{C-x l} again. | ||
| 615 | |||
| 616 | To exit edit mode press @kbd{C-g}. | ||
| 617 | |||
| 618 | Note that edit mode does not display any suffixes that are not | ||
| 619 | currently usable. @code{magit-rebase}, for example, shows different suffixes | ||
| 620 | depending on whether a rebase is already in progress or not. The | ||
| 621 | predicates also apply in edit mode. | ||
| 622 | |||
| 623 | Therefore, to control which suffixes are available given a certain | ||
| 624 | state, you have to make sure that that state is currently active. | ||
| 625 | @end table | ||
| 626 | |||
| 627 | @node Other Commands | ||
| 628 | @section Other Commands | ||
| 629 | |||
| 630 | When invoking a transient in a small frame, the transient window may | ||
| 631 | not show the complete buffer, making it necessary to scroll, using the | ||
| 632 | following commands. These commands are never shown in the transient | ||
| 633 | window, and the key bindings are the same as for @code{scroll-up-command} and | ||
| 634 | @code{scroll-down-command} in other buffers. | ||
| 635 | |||
| 636 | @findex transient-scroll-up arg | ||
| 637 | @deffn Command transient-scroll-up arg | ||
| 638 | |||
| 639 | This command scrolls text of transient popup window upward @var{arg} | ||
| 640 | lines. If @var{arg} is @code{nil}, then it scrolls near full screen. This | ||
| 641 | is a wrapper around @code{scroll-up-command} (which see). | ||
| 642 | @end deffn | ||
| 643 | |||
| 644 | @findex transient-scroll-down arg | ||
| 645 | @deffn Command transient-scroll-down arg | ||
| 646 | |||
| 647 | This command scrolls text of transient popup window down @var{arg} | ||
| 648 | lines. If @var{arg} is @code{nil}, then it scrolls near full screen. This | ||
| 649 | is a wrapper around @code{scroll-down-command} (which see). | ||
| 650 | @end deffn | ||
| 651 | |||
| 652 | @node Other Options | ||
| 653 | @section Other Options | ||
| 654 | |||
| 655 | @defopt transient-show-popup | ||
| 656 | |||
| 657 | This option controls whether the current transient's infix and | ||
| 658 | suffix commands are shown in the popup buffer. | ||
| 659 | |||
| 660 | @itemize | ||
| 661 | @item | ||
| 662 | If @code{t} (the default) then the popup buffer is shown as soon as a | ||
| 663 | transient prefix command is invoked. | ||
| 664 | |||
| 665 | |||
| 666 | @item | ||
| 667 | If @code{nil}, then the popup buffer is not shown unless the user | ||
| 668 | explicitly requests it, by pressing an incomplete prefix key | ||
| 669 | sequence. | ||
| 670 | |||
| 671 | |||
| 672 | @item | ||
| 673 | If a number, then the a brief one-line summary is shown instead of | ||
| 674 | the popup buffer. If zero or negative, then not even that summary | ||
| 675 | is shown; only the pressed key itself is shown. | ||
| 676 | |||
| 677 | The popup is shown when the user explicitly requests it by | ||
| 678 | pressing an incomplete prefix key sequence. Unless this is zero, | ||
| 679 | the popup is shown after that many seconds of inactivity | ||
| 680 | (using the absolute value). | ||
| 681 | @end itemize | ||
| 682 | @end defopt | ||
| 683 | |||
| 684 | @defopt transient-enable-popup-navigation | ||
| 685 | |||
| 686 | This option controls whether navigation commands are enabled in the | ||
| 687 | transient popup buffer. | ||
| 688 | |||
| 689 | While a transient is active the transient popup buffer is not the | ||
| 690 | current buffer, making it necessary to use dedicated commands to act | ||
| 691 | on that buffer itself. This is disabled by default. If this option | ||
| 692 | is non-nil, then the following features are available: | ||
| 693 | |||
| 694 | @itemize | ||
| 695 | @item | ||
| 696 | @key{UP} moves the cursor to the previous suffix. | ||
| 697 | @key{DOWN} moves the cursor to the next suffix. | ||
| 698 | @key{RET} invokes the suffix the cursor is on. | ||
| 699 | |||
| 700 | @item | ||
| 701 | @key{mouse-1} invokes the clicked on suffix. | ||
| 702 | |||
| 703 | @item | ||
| 704 | @kbd{C-s} and @kbd{C-r} start isearch in the popup buffer. | ||
| 705 | @end itemize | ||
| 706 | @end defopt | ||
| 707 | |||
| 708 | @defopt transient-display-buffer-action | ||
| 709 | |||
| 710 | This option specifies the action used to display the transient popup | ||
| 711 | buffer. The transient popup buffer is displayed in a window using | ||
| 712 | @code{(display-buffer @var{buffer} transient-display-buffer-action)}. | ||
| 713 | |||
| 714 | The value of this option has the form @code{(@var{function} . @var{alist})}, | ||
| 715 | where @var{function} is a function or a list of functions. Each such | ||
| 716 | function should accept two arguments: a buffer to display and an | ||
| 717 | alist of the same form as @var{alist}. @xref{Choosing Window,,,elisp,}, | ||
| 718 | for details. | ||
| 719 | |||
| 720 | The default is: | ||
| 721 | |||
| 722 | @lisp | ||
| 723 | (display-buffer-in-side-window | ||
| 724 | (side . bottom) | ||
| 725 | (inhibit-same-window . t) | ||
| 726 | (window-parameters (no-other-window . t))) | ||
| 727 | @end lisp | ||
| 728 | |||
| 729 | This displays the window at the bottom of the selected frame. | ||
| 730 | Another useful @var{function} is @code{display-buffer-below-selected}, which | ||
| 731 | is what @code{magit-popup} used by default. For more alternatives see | ||
| 732 | @ref{Display Action Functions,,,elisp,}, and see @ref{Buffer Display | ||
| 733 | Action Alists,,,elisp,}. | ||
| 734 | |||
| 735 | Note that the buffer that was current before the transient buffer | ||
| 736 | is shown should remain the current buffer. Many suffix commands | ||
| 737 | act on the thing at point, if appropriate, and if the transient | ||
| 738 | buffer became the current buffer, then that would change what is | ||
| 739 | at point. To that effect @code{inhibit-same-window} ensures that the | ||
| 740 | selected window is not used to show the transient buffer. | ||
| 741 | |||
| 742 | It may be possible to display the window in another frame, but | ||
| 743 | whether that works in practice depends on the window-manager. | ||
| 744 | If the window manager selects the new window (Emacs frame), | ||
| 745 | then that unfortunately changes which buffer is current. | ||
| 746 | |||
| 747 | If you change the value of this option, then you might also | ||
| 748 | want to change the value of @code{transient-mode-line-format}. | ||
| 749 | @end defopt | ||
| 750 | |||
| 751 | @defopt transient-mode-line-format | ||
| 752 | |||
| 753 | This option controls whether the transient popup buffer has a | ||
| 754 | mode-line, separator line, or neither. | ||
| 755 | |||
| 756 | If @code{nil}, then the buffer has no mode-line. If the buffer is not | ||
| 757 | displayed right above the echo area, then this probably is not a | ||
| 758 | good value. | ||
| 759 | |||
| 760 | If @code{line} (the default), then the buffer also has no mode-line, but a | ||
| 761 | thin line is drawn instead, using the background color of the face | ||
| 762 | @code{transient-separator}. Text-mode frames cannot display thin lines, and | ||
| 763 | therefore fall back to treating @code{line} like @code{nil}. | ||
| 764 | |||
| 765 | Otherwise this can be any mode-line format. @xref{Mode Line | ||
| 766 | Format,,,elisp,}, for details. | ||
| 767 | @end defopt | ||
| 768 | |||
| 769 | @defopt transient-read-with-initial-input | ||
| 770 | |||
| 771 | This option controls whether the last history element is used as the | ||
| 772 | initial minibuffer input when reading the value of an infix argument | ||
| 773 | from the user. If @code{nil}, there is no initial input and the first | ||
| 774 | element has to be accessed the same way as the older elements. | ||
| 775 | @end defopt | ||
| 776 | |||
| 777 | @defopt transient-highlight-mismatched-keys | ||
| 778 | |||
| 779 | This option controls whether key bindings of infix commands that do | ||
| 780 | not match the respective command-line argument should be highlighted. | ||
| 781 | For other infix commands this option has no effect. | ||
| 782 | |||
| 783 | When this option is non-@code{nil}, the key binding for an infix argument | ||
| 784 | is highlighted when only a long argument (e.g., @code{--verbose}) is | ||
| 785 | specified but no shorthand (e.g., @code{-v}). In the rare case that a | ||
| 786 | shorthand is specified but the key binding does not match, then it | ||
| 787 | is highlighted differently. | ||
| 788 | |||
| 789 | Highlighting mismatched key bindings is useful when learning the | ||
| 790 | arguments of the underlying command-line tool; you wouldn't want to | ||
| 791 | learn any short-hands that do not actually exist. | ||
| 792 | |||
| 793 | The highlighting is done using one of the faces | ||
| 794 | @code{transient-mismatched-key} and @code{transient-nonstandard-key}. | ||
| 795 | @end defopt | ||
| 796 | |||
| 797 | @defopt transient-substitute-key-function | ||
| 798 | |||
| 799 | This function is used to modify key bindings. If the value of this | ||
| 800 | option is @code{nil} (the default), then no substitution is performed. | ||
| 801 | |||
| 802 | This function is called with one argument, the prefix object, and | ||
| 803 | must return a key binding description, either the existing key | ||
| 804 | description it finds in the @code{key} slot, or the key description that | ||
| 805 | replaces the prefix key. It could be used to make other | ||
| 806 | substitutions, but that is discouraged. | ||
| 807 | |||
| 808 | For example, @kbd{=} is hard to reach using my custom keyboard layout, | ||
| 809 | so I substitute @kbd{(} for that, which is easy to reach using a layout | ||
| 810 | optimized for lisp. | ||
| 811 | |||
| 812 | @lisp | ||
| 813 | (setq transient-substitute-key-function | ||
| 814 | (lambda (obj) | ||
| 815 | (let ((key (oref obj key))) | ||
| 816 | (if (string-match "\\`\\(=\\)[a-zA-Z]" key) | ||
| 817 | (replace-match "(" t t key 1) | ||
| 818 | key)))) | ||
| 819 | @end lisp | ||
| 820 | @end defopt | ||
| 821 | |||
| 822 | @defopt transient-detect-key-conflicts | ||
| 823 | |||
| 824 | This option controls whether key binding conflicts should be | ||
| 825 | detected at the time the transient is invoked. If so, this | ||
| 826 | results in an error, which prevents the transient from being used. | ||
| 827 | Because of that, conflicts are ignored by default. | ||
| 828 | |||
| 829 | Conflicts cannot be determined earlier, i.e.@: when the transient is | ||
| 830 | being defined and when new suffixes are being added, because at that | ||
| 831 | time there can be false-positives. It is actually valid for | ||
| 832 | multiple suffixes to share a common key binding, provided the | ||
| 833 | predicates of those suffixes prevent that more than one of them is | ||
| 834 | enabled at a time. | ||
| 835 | @end defopt | ||
| 836 | |||
| 837 | @defopt transient-force-fixed-pitch | ||
| 838 | |||
| 839 | This option controls whether to force the use of a monospaced font | ||
| 840 | in popup buffer. Even if you use a proportional font for the | ||
| 841 | @code{default} face, you might still want to use a monospaced font in | ||
| 842 | transient's popup buffer. Setting this option to @code{t} causes @code{default} | ||
| 843 | to be remapped to @code{fixed-pitch} in that buffer. | ||
| 844 | @end defopt | ||
| 845 | |||
| 846 | @node Modifying Existing Transients | ||
| 847 | @chapter Modifying Existing Transients | ||
| 848 | @cindex modifying existing transients | ||
| 849 | |||
| 850 | To an extent, transients can be customized interactively, see @ref{Enabling and Disabling Suffixes}. This section explains how existing transients | ||
| 851 | can be further modified non-interactively. | ||
| 852 | |||
| 853 | The following functions share a few arguments: | ||
| 854 | |||
| 855 | @itemize | ||
| 856 | @item | ||
| 857 | @var{prefix} is a transient prefix command, a symbol. | ||
| 858 | |||
| 859 | |||
| 860 | @item | ||
| 861 | @var{suffix} is a transient infix or suffix specification in the same form | ||
| 862 | as expected by @code{transient-define-prefix}. Note that an infix is a | ||
| 863 | special kind of suffix. Depending on context ``suffixes'' means | ||
| 864 | ``suffixes (including infixes)'' or ``non-infix suffixes''. Here it | ||
| 865 | means the former. @xref{Suffix Specifications}. | ||
| 866 | |||
| 867 | @var{suffix} may also be a group in the same form as expected by | ||
| 868 | @code{transient-define-prefix}. @xref{Group Specifications}. | ||
| 869 | |||
| 870 | |||
| 871 | @item | ||
| 872 | @var{loc} is a command, a key vector, a key description (a string as | ||
| 873 | returned by @code{key-description}), or a list specifying coordinates (the | ||
| 874 | last element may also be a command or key). For example @code{(1 0 -1)} | ||
| 875 | identifies the last suffix (@code{-1}) of the first subgroup (@code{0}) of the | ||
| 876 | second group (@code{1}). | ||
| 877 | |||
| 878 | If @var{loc} is a list of coordinates, then it can be used to identify a | ||
| 879 | group, not just an individual suffix command. | ||
| 880 | |||
| 881 | The function @code{transient-get-suffix} can be useful to determine whether | ||
| 882 | a certain coordination list identifies the suffix or group that you | ||
| 883 | expect it to identify. In hairy cases it may be necessary to look | ||
| 884 | at the definition of the transient prefix command. | ||
| 885 | @end itemize | ||
| 886 | |||
| 887 | These functions operate on the information stored in the | ||
| 888 | @code{transient--layout} property of the @var{prefix} symbol. Suffix entries in | ||
| 889 | that tree are not objects but have the form @code{(@var{level} | ||
| 890 | @var{class} @var{plist})}, where | ||
| 891 | @var{plist} should set at least @code{:key}, @code{:description} and | ||
| 892 | @code{:command}. | ||
| 893 | |||
| 894 | @defun transient-insert-suffix prefix loc suffix | ||
| 895 | |||
| 896 | This function inserts suffix or group @var{suffix} into @var{prefix} | ||
| 897 | before @var{loc}. | ||
| 898 | @end defun | ||
| 899 | |||
| 900 | @defun transient-append-suffix prefix loc suffix | ||
| 901 | |||
| 902 | This function inserts suffix or group @var{suffix} into @var{prefix} | ||
| 903 | after @var{loc}. | ||
| 904 | @end defun | ||
| 905 | |||
| 906 | @defun transient-replace-suffix prefix loc suffix | ||
| 907 | |||
| 908 | This function replaces the suffix or group at @var{loc} in @var{prefix} with | ||
| 909 | suffix or group @var{suffix}. | ||
| 910 | @end defun | ||
| 911 | |||
| 912 | @defun transient-remove-suffix prefix loc | ||
| 913 | |||
| 914 | This function removes the suffix or group at @var{loc} in @var{prefix}. | ||
| 915 | @end defun | ||
| 916 | |||
| 917 | @defun transient-get-suffix prefix loc | ||
| 918 | |||
| 919 | This function returns the suffix or group at @var{loc} in @var{prefix}. The | ||
| 920 | returned value has the form mentioned above. | ||
| 921 | @end defun | ||
| 922 | |||
| 923 | @defun transient-suffix-put prefix loc prop value | ||
| 924 | |||
| 925 | This function edits the suffix or group at @var{loc} in @var{prefix}, | ||
| 926 | by setting the @var{prop} of its plist to @var{value}. | ||
| 927 | @end defun | ||
| 928 | |||
| 929 | Most of these functions do not signal an error if they cannot perform | ||
| 930 | the requested modification. The functions that insert new suffixes | ||
| 931 | show a warning if @var{loc} cannot be found in @var{prefix}, without | ||
| 932 | signaling an error. The reason for doing it like this is that | ||
| 933 | establishing a key binding (and that is what we essentially are trying | ||
| 934 | to do here) should not prevent the rest of the configuration from | ||
| 935 | loading. Among these functions only @code{transient-get-suffix} and | ||
| 936 | @code{transient-suffix-put} may signal an error. | ||
| 937 | |||
| 938 | @node Defining New Commands | ||
| 939 | @chapter Defining New Commands | ||
| 940 | |||
| 941 | @menu | ||
| 942 | * Defining Transients:: | ||
| 943 | * Binding Suffix and Infix Commands:: | ||
| 944 | * Defining Suffix and Infix Commands:: | ||
| 945 | * Using Infix Arguments:: | ||
| 946 | * Transient State:: | ||
| 947 | @end menu | ||
| 948 | |||
| 949 | @node Defining Transients | ||
| 950 | @section Defining Transients | ||
| 951 | |||
| 952 | A transient consists of a prefix command and at least one suffix | ||
| 953 | command, though usually a transient has several infix and suffix | ||
| 954 | commands. The below macro defines the transient prefix command @strong{and} | ||
| 955 | binds the transient's infix and suffix commands. In other words, it | ||
| 956 | defines the complete transient, not just the transient prefix command | ||
| 957 | that is used to invoke that transient. | ||
| 958 | |||
| 959 | @defmac transient-define-prefix name arglist [docstring] [keyword value]@dots{} group@dots{} [body@dots{}] | ||
| 960 | |||
| 961 | This macro defines @var{name} as a transient prefix command and binds the | ||
| 962 | transient's infix and suffix commands. | ||
| 963 | |||
| 964 | @var{arglist} are the arguments that the prefix command takes. | ||
| 965 | @var{docstring} is the documentation string and is optional. | ||
| 966 | |||
| 967 | These arguments can optionally be followed by keyword-value pairs. | ||
| 968 | Each key has to be a keyword symbol, either @code{:class} or a keyword | ||
| 969 | argument supported by the constructor of that class. The | ||
| 970 | @code{transient-prefix} class is used if the class is not specified | ||
| 971 | explicitly. | ||
| 972 | |||
| 973 | @var{group}s add key bindings for infix and suffix commands and specify | ||
| 974 | how these bindings are presented in the popup buffer. At least one | ||
| 975 | @var{group} has to be specified. @xref{Binding Suffix and Infix Commands}. | ||
| 976 | |||
| 977 | The @var{body} is optional. If it is omitted, then @var{arglist} is ignored and | ||
| 978 | the function definition becomes: | ||
| 979 | |||
| 980 | @lisp | ||
| 981 | (lambda () | ||
| 982 | (interactive) | ||
| 983 | (transient-setup 'NAME)) | ||
| 984 | @end lisp | ||
| 985 | |||
| 986 | If @var{body} is specified, then it must begin with an @code{interactive} form | ||
| 987 | that matches @var{arglist}, and it must call @code{transient-setup}. It may, | ||
| 988 | however, call that function only when some condition is satisfied. | ||
| 989 | |||
| 990 | @cindex scope of a transient | ||
| 991 | All transients have a (possibly @code{nil}) value, which is exported when | ||
| 992 | suffix commands are called, so that they can consume that value. | ||
| 993 | For some transients it might be necessary to have a sort of | ||
| 994 | secondary value, called a ``scope''. Such a scope would usually be | ||
| 995 | set in the command's @code{interactive} form and has to be passed to the | ||
| 996 | setup function: | ||
| 997 | |||
| 998 | @lisp | ||
| 999 | (transient-setup 'NAME nil nil :scope SCOPE) | ||
| 1000 | @end lisp | ||
| 1001 | |||
| 1002 | For example, the scope of the @code{magit-branch-configure} transient is | ||
| 1003 | the branch whose variables are being configured. | ||
| 1004 | @end defmac | ||
| 1005 | |||
| 1006 | @node Binding Suffix and Infix Commands | ||
| 1007 | @section Binding Suffix and Infix Commands | ||
| 1008 | |||
| 1009 | The macro @code{transient-define-prefix} is used to define a transient. | ||
| 1010 | This defines the actual transient prefix command (@pxref{Defining | ||
| 1011 | Transients}) and adds the transient's infix and suffix bindings, as | ||
| 1012 | described below. | ||
| 1013 | |||
| 1014 | Users and third-party packages can add additional bindings using | ||
| 1015 | functions such as @code{transient-insert-suffix} (@pxref{Modifying | ||
| 1016 | Existing Transients}). These functions take a ``suffix | ||
| 1017 | specification'' as one of their arguments, which has the same form as | ||
| 1018 | the specifications used in @code{transient-define-prefix}. | ||
| 1019 | |||
| 1020 | @menu | ||
| 1021 | * Group Specifications:: | ||
| 1022 | * Suffix Specifications:: | ||
| 1023 | @end menu | ||
| 1024 | |||
| 1025 | @node Group Specifications | ||
| 1026 | @subsection Group Specifications | ||
| 1027 | @cindex group specifications | ||
| 1028 | |||
| 1029 | The suffix and infix commands of a transient are organized in groups. | ||
| 1030 | The grouping controls how the descriptions of the suffixes are | ||
| 1031 | outlined visually but also makes it possible to set certain properties | ||
| 1032 | for a set of suffixes. | ||
| 1033 | |||
| 1034 | Several group classes exist, some of which organize suffixes in | ||
| 1035 | subgroups. In most cases the class does not have to be specified | ||
| 1036 | explicitly, but see @ref{Group Classes}. | ||
| 1037 | |||
| 1038 | Groups are specified in the call to @code{transient-define-prefix}, using | ||
| 1039 | vectors. Because groups are represented using vectors, we cannot use | ||
| 1040 | square brackets to indicate an optional element and instead use curly | ||
| 1041 | brackets to do the latter. | ||
| 1042 | |||
| 1043 | Group specifications then have this form: | ||
| 1044 | |||
| 1045 | @lisp | ||
| 1046 | [@{@var{level}@} @{@var{description}@} | ||
| 1047 | @{@var{keyword} @var{value}@}... | ||
| 1048 | @var{element}...] | ||
| 1049 | @end lisp | ||
| 1050 | |||
| 1051 | The @var{level} is optional and defaults to 4. @xref{Enabling and | ||
| 1052 | Disabling Suffixes}. | ||
| 1053 | |||
| 1054 | The @var{description} is optional. If present, it is used as the heading of | ||
| 1055 | the group. | ||
| 1056 | |||
| 1057 | The @var{keyword}-@var{value} pairs are optional. Each keyword has to be a | ||
| 1058 | keyword symbol, either @code{:class} or a keyword argument supported by the | ||
| 1059 | constructor of that class. | ||
| 1060 | |||
| 1061 | @itemize | ||
| 1062 | @item | ||
| 1063 | One of these keywords, @code{:description}, is equivalent to specifying | ||
| 1064 | @var{description} at the very beginning of the vector. The recommendation | ||
| 1065 | is to use @code{:description} if some other keyword is also used, for | ||
| 1066 | consistency, or @var{description} otherwise, because it looks better. | ||
| 1067 | |||
| 1068 | @item | ||
| 1069 | Likewise @code{:level} is equivalent to @var{level}. | ||
| 1070 | |||
| 1071 | @item | ||
| 1072 | Other important keywords include the @code{:if...} keywords. These | ||
| 1073 | keywords control whether the group is available in a certain | ||
| 1074 | situation. | ||
| 1075 | |||
| 1076 | For example, one group of the @code{magit-rebase} transient uses | ||
| 1077 | @code{:if magit-rebase-in-progress-p}, which contains the suffixes | ||
| 1078 | that are useful while rebase is already in progress; and another that uses | ||
| 1079 | @code{:if-not magit-rebase-in-progress-p}, which contains the suffixes that | ||
| 1080 | initiate a rebase. | ||
| 1081 | |||
| 1082 | These predicates can also be used on individual suffixes and are | ||
| 1083 | only documented once, see @ref{Predicate Slots}. | ||
| 1084 | |||
| 1085 | @item | ||
| 1086 | The value of @code{:hide}, if non-@code{nil}, is a predicate that controls | ||
| 1087 | whether the group is hidden by default. The key bindings for | ||
| 1088 | suffixes of a hidden group should all use the same prefix key. | ||
| 1089 | Pressing that prefix key should temporarily show the group and its | ||
| 1090 | suffixes, which assumes that a predicate like this is used: | ||
| 1091 | |||
| 1092 | @lisp | ||
| 1093 | (lambda () | ||
| 1094 | (eq (car transient--redisplay-key) | ||
| 1095 | ?\C-c)) ; the prefix key shared by all bindings | ||
| 1096 | @end lisp | ||
| 1097 | |||
| 1098 | @item | ||
| 1099 | The value of @code{:setup-children}, if non-@code{nil}, is a function | ||
| 1100 | that takes two arguments the group object itself and a list of children. | ||
| 1101 | The children are given as a, potentially empty, list consisting | ||
| 1102 | of either group or suffix specifications. It can make arbitrary | ||
| 1103 | changes to the children including constructing new children from | ||
| 1104 | scratch. Also see @code{transient-setup-children}. | ||
| 1105 | |||
| 1106 | @item | ||
| 1107 | The boolean @code{:pad-keys} argument controls whether keys of all suffixes | ||
| 1108 | contained in a group are right padded, effectively aligning the | ||
| 1109 | descriptions. | ||
| 1110 | @end itemize | ||
| 1111 | |||
| 1112 | The @var{element}s are either all subgroups (vectors), or all suffixes | ||
| 1113 | (lists) and strings. (At least currently no group type exists that | ||
| 1114 | would allow mixing subgroups with commands at the same level, though | ||
| 1115 | in principle there is nothing that prevents that.) | ||
| 1116 | |||
| 1117 | If the @var{element}s are not subgroups, then they can be a mixture of lists | ||
| 1118 | that specify commands and strings. Strings are inserted verbatim. | ||
| 1119 | The empty string can be used to insert gaps between suffixes, which is | ||
| 1120 | particularly useful if the suffixes are outlined as a table. | ||
| 1121 | |||
| 1122 | Variables are supported inside group specifications. For example in | ||
| 1123 | place of a direct subgroup specification, a variable can be used whose | ||
| 1124 | value is a vector that qualifies as a group specification. Likewise, a | ||
| 1125 | variable can be used where a suffix specification is expected. Lists | ||
| 1126 | of group or suffix specifications are also supported. Indirect | ||
| 1127 | specifications are resolved when the transient prefix is being | ||
| 1128 | defined. | ||
| 1129 | |||
| 1130 | The form of suffix specifications is documented in the next node. | ||
| 1131 | |||
| 1132 | @node Suffix Specifications | ||
| 1133 | @subsection Suffix Specifications | ||
| 1134 | @cindex suffix specifications | ||
| 1135 | |||
| 1136 | A transient's suffix and infix commands are bound when the transient | ||
| 1137 | prefix command is defined using @code{transient-define-prefix}, see | ||
| 1138 | @ref{Defining Transients}. The commands are organized into groups, see | ||
| 1139 | @ref{Group Specifications}. Here we describe the form used to bind an | ||
| 1140 | individual suffix command. | ||
| 1141 | |||
| 1142 | The same form is also used when later binding additional commands | ||
| 1143 | using functions such as @code{transient-insert-suffix}, | ||
| 1144 | see @ref{Modifying Existing Transients}. | ||
| 1145 | |||
| 1146 | Note that an infix is a special kind of suffix. Depending on context | ||
| 1147 | ``suffixes'' means ``suffixes (including infixes)'' or ``non-infix | ||
| 1148 | suffixes''. Here it means the former. | ||
| 1149 | |||
| 1150 | Suffix specifications have this form: | ||
| 1151 | |||
| 1152 | @lisp | ||
| 1153 | ([@var{level}] | ||
| 1154 | [@var{key}] [@var{description}] | ||
| 1155 | @var{command}|@var{argument} [@var{keyword} @var{value}]...) | ||
| 1156 | @end lisp | ||
| 1157 | |||
| 1158 | @var{level}, @var{key} and @var{description} can also be specified using the @var{keyword}s | ||
| 1159 | @code{:level}, @code{:key} and @code{:description}. If the object that is associated with | ||
| 1160 | @var{command} sets these properties, then they do not have to be specified | ||
| 1161 | here. You can however specify them here anyway, possibly overriding | ||
| 1162 | the object's values just for the binding inside this transient. | ||
| 1163 | |||
| 1164 | @itemize | ||
| 1165 | @item | ||
| 1166 | @var{level} is the suffix level, an integer between 1 and 7. | ||
| 1167 | @xref{Enabling and Disabling Suffixes}. | ||
| 1168 | |||
| 1169 | @item | ||
| 1170 | @var{key} is the key binding, either a vector or key description string. | ||
| 1171 | |||
| 1172 | @item | ||
| 1173 | @var{description} is the description, either a string or a function that | ||
| 1174 | returns a string. The function should be a lambda expression to | ||
| 1175 | avoid ambiguity. In some cases a symbol that is bound as a function | ||
| 1176 | would also work but to be safe you should use @code{:description} in that | ||
| 1177 | case. | ||
| 1178 | @end itemize | ||
| 1179 | |||
| 1180 | The next element is either a command or an argument. This is the only | ||
| 1181 | argument that is mandatory in all cases. | ||
| 1182 | |||
| 1183 | @itemize | ||
| 1184 | @item | ||
| 1185 | Usually @var{command} is a symbol that is bound as a function, which has | ||
| 1186 | to be defined or at least autoloaded as a command by the time the | ||
| 1187 | containing prefix command is invoked. | ||
| 1188 | |||
| 1189 | Any command will do; it does not need to have an object associated | ||
| 1190 | with it (as would be the case if @code{transient-define-suffix} or | ||
| 1191 | @code{transient-define-infix} were used to define it). | ||
| 1192 | |||
| 1193 | The command can also be a closure or lambda expression, but that | ||
| 1194 | should only be used for dynamic transients whose suffixes are | ||
| 1195 | defined when the prefix command is invoked. See information about | ||
| 1196 | the @code{:setup-children} function in @ref{Group Specifications}. | ||
| 1197 | |||
| 1198 | As mentioned above, the object that is associated with a command can | ||
| 1199 | be used to set the default for certain values that otherwise have to | ||
| 1200 | be set in the suffix specification. Therefore if there is no object, | ||
| 1201 | then you have to make sure to specify the @var{key} and the @var{description}. | ||
| 1202 | |||
| 1203 | As a special case, if you want to add a command that might be neither | ||
| 1204 | defined nor autoloaded, you can use a workaround like: | ||
| 1205 | |||
| 1206 | @lisp | ||
| 1207 | (transient-insert-suffix 'some-prefix "k" | ||
| 1208 | '("!" "Ceci n'est pas une commande" no-command | ||
| 1209 | :if (lambda () (featurep 'no-library)))) | ||
| 1210 | @end lisp | ||
| 1211 | |||
| 1212 | Instead of @code{featurep} you could also use @code{require} with a | ||
| 1213 | non-nil value for @var{noerror}. | ||
| 1214 | |||
| 1215 | @item | ||
| 1216 | The mandatory argument can also be a command-line argument, a | ||
| 1217 | string. In that case an anonymous command is defined and bound. | ||
| 1218 | |||
| 1219 | Instead of a string, this can also be a list of two strings, in | ||
| 1220 | which case the first string is used as the short argument (which can | ||
| 1221 | also be specified using @code{:shortarg}) and the second as the long argument | ||
| 1222 | (which can also be specified using @code{:argument}). | ||
| 1223 | |||
| 1224 | Only the long argument is displayed in the popup buffer. See | ||
| 1225 | @code{transient-detect-key-conflicts} for how the short argument may be | ||
| 1226 | used. | ||
| 1227 | |||
| 1228 | Unless the class is specified explicitly, the appropriate class is | ||
| 1229 | guessed based on the long argument. If the argument ends with @samp{=} | ||
| 1230 | (e.g. @samp{--format=}) then @code{transient-option} is used, otherwise | ||
| 1231 | @code{transient-switch}. | ||
| 1232 | @end itemize | ||
| 1233 | |||
| 1234 | Finally, details can be specified using optional | ||
| 1235 | @var{keyword}-@var{value} pairs. | ||
| 1236 | Each keyword has to be a keyword symbol, either @code{:class} or a keyword | ||
| 1237 | argument supported by the constructor of that class. See @ref{Suffix Slots}. | ||
| 1238 | |||
| 1239 | @node Defining Suffix and Infix Commands | ||
| 1240 | @section Defining Suffix and Infix Commands | ||
| 1241 | @cindex defining suffix commands | ||
| 1242 | @cindex defining infix commands | ||
| 1243 | |||
| 1244 | Note that an infix is a special kind of suffix. Depending on context | ||
| 1245 | ``suffixes'' means ``suffixes (including infixes)'' or ``non-infix | ||
| 1246 | suffixes''. | ||
| 1247 | |||
| 1248 | @defmac transient-define-suffix name arglist [docstring] [keyword value]@dots{} body@dots{} | ||
| 1249 | |||
| 1250 | This macro defines @var{name} as a transient suffix command. | ||
| 1251 | |||
| 1252 | @var{arglist} are the arguments that the command takes. | ||
| 1253 | @var{docstring} is the documentation string and is optional. | ||
| 1254 | |||
| 1255 | These arguments can optionally be followed by keyword-value pairs. | ||
| 1256 | Each keyword has to be a keyword symbol, either @code{:class} or a keyword | ||
| 1257 | argument supported by the constructor of that class. The | ||
| 1258 | @code{transient-suffix} class is used if the class is not specified | ||
| 1259 | explicitly. | ||
| 1260 | |||
| 1261 | The @var{body} must begin with an @code{interactive} form that matches @var{arglist}. | ||
| 1262 | The infix arguments are usually accessed by using @code{transient-args} | ||
| 1263 | inside @code{interactive}. | ||
| 1264 | @end defmac | ||
| 1265 | |||
| 1266 | @defmac transient-define-infix name arglist [docstring] [keyword value]@dots{} | ||
| 1267 | |||
| 1268 | This macro defines @var{name} as a transient infix command. | ||
| 1269 | |||
| 1270 | @var{arglist} is always ignored (but mandatory never-the-less) and | ||
| 1271 | reserved for future use. @var{docstring} is the documentation string and | ||
| 1272 | is optional. | ||
| 1273 | |||
| 1274 | The keyword-value pairs are mandatory. All transient infix commands | ||
| 1275 | are @code{equal} to each other (but not @code{eq}), so it is meaningless to define | ||
| 1276 | an infix command without also setting at least @code{:class} and one other | ||
| 1277 | keyword (which it is depends on the used class, usually @code{:argument} or | ||
| 1278 | @code{:variable}). | ||
| 1279 | |||
| 1280 | Each keyword has to be a keyword symbol, either @code{:class} or a keyword | ||
| 1281 | argument supported by the constructor of that class. The | ||
| 1282 | @code{transient-switch} class is used if the class is not specified | ||
| 1283 | explicitly. | ||
| 1284 | |||
| 1285 | The function definition is always: | ||
| 1286 | |||
| 1287 | @lisp | ||
| 1288 | (lambda () | ||
| 1289 | (interactive) | ||
| 1290 | (let ((obj (transient-suffix-object))) | ||
| 1291 | (transient-infix-set obj (transient-infix-read obj))) | ||
| 1292 | (transient--show)) | ||
| 1293 | @end lisp | ||
| 1294 | |||
| 1295 | @code{transient-infix-read} and @code{transient-infix-set} are generic functions. | ||
| 1296 | Different infix commands behave differently because the concrete | ||
| 1297 | methods are different for different infix command classes. In rare | ||
| 1298 | cases the above command function might not be suitable, even if you | ||
| 1299 | define your own infix command class. In that case you have to use | ||
| 1300 | @code{transient-suffix-command} to define the infix command and use @code{t} as | ||
| 1301 | the value of the @code{:transient} keyword. | ||
| 1302 | @end defmac | ||
| 1303 | |||
| 1304 | @defmac transient-define-argument name arglist [docstring] [keyword value]@dots{} | ||
| 1305 | |||
| 1306 | This macro defines @var{name} as a transient infix command. | ||
| 1307 | |||
| 1308 | This is an alias for @code{transient-define-infix}. Only use this alias | ||
| 1309 | to define an infix command that actually sets an infix argument. | ||
| 1310 | To define an infix command that, for example, sets a variable, use | ||
| 1311 | @code{transient-define-infix} instead. | ||
| 1312 | @end defmac | ||
| 1313 | |||
| 1314 | @node Using Infix Arguments | ||
| 1315 | @section Using Infix Arguments | ||
| 1316 | @cindex using infix arguments | ||
| 1317 | |||
| 1318 | The functions and the variables described below allow suffix commands | ||
| 1319 | to access the value of the transient from which they were invoked; | ||
| 1320 | which is the value of its infix arguments. These variables are set | ||
| 1321 | when the user invokes a suffix command that exits the transient, but | ||
| 1322 | before actually calling the command. | ||
| 1323 | |||
| 1324 | When returning to the command-loop after calling the suffix command, | ||
| 1325 | the arguments are reset to @code{nil} (which causes the function to return | ||
| 1326 | @code{nil} too). | ||
| 1327 | |||
| 1328 | Like for Emacs' prefix arguments, it is advisable, but not mandatory, | ||
| 1329 | to access the infix arguments inside the command's @code{interactive} form. | ||
| 1330 | The preferred way of doing that is to call the @code{transient-args} | ||
| 1331 | function, which for infix arguments serves about the same purpose as | ||
| 1332 | @code{prefix-arg} serves for prefix arguments. | ||
| 1333 | |||
| 1334 | @defun transient-args prefix | ||
| 1335 | |||
| 1336 | This function returns the value of the transient prefix command | ||
| 1337 | @var{prefix}. | ||
| 1338 | |||
| 1339 | If the current command was invoked from the transient prefix command | ||
| 1340 | @var{prefix}, then it returns the active infix arguments. If the current | ||
| 1341 | command was not invoked from @var{prefix}, then it returns the set, saved | ||
| 1342 | or default value for @var{prefix}. | ||
| 1343 | @end defun | ||
| 1344 | |||
| 1345 | @defun transient-arg-value arg args | ||
| 1346 | |||
| 1347 | This function return the value of @var{arg} as it appears in @var{args}. | ||
| 1348 | |||
| 1349 | For a switch a boolean is returned. For an option the value is | ||
| 1350 | returned as a string, using the empty string for the empty value, | ||
| 1351 | or @code{nil} if the option does not appear in @var{args}. | ||
| 1352 | @end defun | ||
| 1353 | |||
| 1354 | @defun transient-suffixes prefix | ||
| 1355 | |||
| 1356 | This function returns the suffixes of the transient prefix command | ||
| 1357 | @var{prefix}. This is a list of objects. This function should only be | ||
| 1358 | used if you need the objects (as opposed to just their values) and | ||
| 1359 | if the current command is not being invoked from @var{prefix}. | ||
| 1360 | @end defun | ||
| 1361 | |||
| 1362 | @defvar transient-current-suffixes | ||
| 1363 | |||
| 1364 | The suffixes of the transient from which this suffix command was | ||
| 1365 | invoked. This is a list of objects. Usually it is sufficient to | ||
| 1366 | instead use the function @code{transient-args}, which returns a list of | ||
| 1367 | values. In complex cases it might be necessary to use this variable | ||
| 1368 | instead, i.e.@: if you need access to information beside the value. | ||
| 1369 | @end defvar | ||
| 1370 | |||
| 1371 | @defvar transient-current-prefix | ||
| 1372 | |||
| 1373 | The transient from which this suffix command was invoked. The | ||
| 1374 | returned value is a @code{transient-prefix} object, which holds information | ||
| 1375 | associated with the transient prefix command. | ||
| 1376 | @end defvar | ||
| 1377 | |||
| 1378 | @defvar transient-current-command | ||
| 1379 | |||
| 1380 | The transient from which this suffix command was invoked. The | ||
| 1381 | returned value is a symbol, the transient prefix command. | ||
| 1382 | @end defvar | ||
| 1383 | |||
| 1384 | @node Transient State | ||
| 1385 | @section Transient State | ||
| 1386 | @cindex transient state | ||
| 1387 | |||
| 1388 | Invoking a transient prefix command ``activates'' the respective | ||
| 1389 | transient, i.e.@: it puts a transient keymap into effect, which binds | ||
| 1390 | the transient's infix and suffix commands. | ||
| 1391 | |||
| 1392 | The default behavior while a transient is active is as follows: | ||
| 1393 | |||
| 1394 | @itemize | ||
| 1395 | @item | ||
| 1396 | Invoking an infix command does not affect the transient state; the | ||
| 1397 | transient remains active. | ||
| 1398 | |||
| 1399 | @item | ||
| 1400 | Invoking a (non-infix) suffix command ``deactivates'' the transient | ||
| 1401 | state by removing the transient keymap and performing some | ||
| 1402 | additional cleanup. | ||
| 1403 | |||
| 1404 | @item | ||
| 1405 | Invoking a command that is bound in a keymap other than the | ||
| 1406 | transient keymap is disallowed and trying to do so results in a | ||
| 1407 | warning. This does not ``deactivate'' the transient. | ||
| 1408 | @end itemize | ||
| 1409 | |||
| 1410 | But these are just the defaults. Whether a certain command | ||
| 1411 | deactivates or ``exits'' the transient is configurable. There is more | ||
| 1412 | than one way in which a command can be ``transient'' or ``non-transient''; | ||
| 1413 | the exact behavior is implemented by calling a so-called ``pre-command'' | ||
| 1414 | function. Whether non-suffix commands are allowed to be called is | ||
| 1415 | configurable per transient. | ||
| 1416 | |||
| 1417 | @itemize | ||
| 1418 | @item | ||
| 1419 | The transient-ness of suffix commands (including infix commands) is | ||
| 1420 | controlled by the value of their @code{transient} slot, which can be set | ||
| 1421 | either when defining the command or when adding a binding to a | ||
| 1422 | transient while defining the respective transient prefix command. | ||
| 1423 | |||
| 1424 | Valid values are booleans and the pre-commands described below. | ||
| 1425 | |||
| 1426 | @itemize | ||
| 1427 | @item | ||
| 1428 | @code{t} is equivalent to @code{transient--do-stay}. | ||
| 1429 | |||
| 1430 | @item | ||
| 1431 | @code{nil} is equivalent to @code{transient--do-exit}. | ||
| 1432 | |||
| 1433 | @item | ||
| 1434 | If @code{transient} is unbound (and that is actually the default for | ||
| 1435 | non-infix suffixes) then the value of the prefix's | ||
| 1436 | @code{transient-suffix} slot is used instead. The default value of that | ||
| 1437 | slot is @code{nil}, so the suffix's @code{transient} slot being unbound is | ||
| 1438 | essentially equivalent to it being @code{nil}. | ||
| 1439 | @end itemize | ||
| 1440 | |||
| 1441 | @item | ||
| 1442 | A suffix command can be a prefix command itself, i.e. a | ||
| 1443 | ``sub-prefix''. While a sub-prefix is active we nearly always want | ||
| 1444 | @kbd{C-g} to take the user back to the ``super-prefix''. However in rare | ||
| 1445 | cases this may not be desirable, and that makes the following | ||
| 1446 | complication necessary: | ||
| 1447 | |||
| 1448 | For @code{transient-suffix} objects the @code{transient} slot is unbound. We can | ||
| 1449 | ignore that for the most part because, as stated above, @code{nil} and the | ||
| 1450 | slot being unbound are equivalent, and mean ``do exit''. That isn't | ||
| 1451 | actually true for suffixes that are sub-prefixes though. For such | ||
| 1452 | suffixes unbound means ``do exit but allow going back'', which is the | ||
| 1453 | default, while @code{nil} means ``do exit permanently'', which requires that | ||
| 1454 | slot to be explicitly set to that value. | ||
| 1455 | |||
| 1456 | @item | ||
| 1457 | The transient-ness of certain built-in suffix commands is specified | ||
| 1458 | using @code{transient-predicate-map}. This is a special keymap, which | ||
| 1459 | binds commands to pre-commands (as opposed to keys to commands) and | ||
| 1460 | takes precedence over the @code{transient} slot. | ||
| 1461 | @end itemize | ||
| 1462 | |||
| 1463 | The available pre-command functions are documented below. They are | ||
| 1464 | called by @code{transient--pre-command}, a function on @code{pre-command-hook} and | ||
| 1465 | the value that they return determines whether the transient is exited. | ||
| 1466 | To do so the value of one of the constants @code{transient--exit} or | ||
| 1467 | @code{transient--stay} is used (that way we don't have to remember if @code{t} means | ||
| 1468 | ``exit'' or ``stay''). | ||
| 1469 | |||
| 1470 | Additionally, these functions may change the value of @code{this-command} | ||
| 1471 | (which explains why they have to be called using @code{pre-command-hook}), | ||
| 1472 | call @code{transient-export}, @code{transient--stack-zap} or @code{transient--stack-push}; | ||
| 1473 | and set the values of @code{transient--exitp}, @code{transient--helpp} or | ||
| 1474 | @code{transient--editp}. | ||
| 1475 | |||
| 1476 | @anchor{Pre-commands for Infixes} | ||
| 1477 | @subheading Pre-commands for Infixes | ||
| 1478 | |||
| 1479 | The default for infixes is @code{transient--do-stay}. This is also the only | ||
| 1480 | function that makes sense for infixes. | ||
| 1481 | |||
| 1482 | @defun transient--do-stay | ||
| 1483 | |||
| 1484 | Call the command without exporting variables and stay transient. | ||
| 1485 | @end defun | ||
| 1486 | |||
| 1487 | @anchor{Pre-commands for Suffixes} | ||
| 1488 | @subheading Pre-commands for Suffixes | ||
| 1489 | |||
| 1490 | The default for suffixes is @code{transient--do-exit}. | ||
| 1491 | |||
| 1492 | @defun transient--do-exit | ||
| 1493 | |||
| 1494 | Call the command after exporting variables and exit the transient. | ||
| 1495 | @end defun | ||
| 1496 | |||
| 1497 | @defun transient--do-call | ||
| 1498 | |||
| 1499 | Call the command after exporting variables and stay transient. | ||
| 1500 | @end defun | ||
| 1501 | |||
| 1502 | @defun transient--do-replace | ||
| 1503 | |||
| 1504 | Call the transient prefix command, replacing the active transient. | ||
| 1505 | |||
| 1506 | This is used for suffixes that are prefixes themselves, i.e.@: for | ||
| 1507 | sub-prefixes. | ||
| 1508 | @end defun | ||
| 1509 | |||
| 1510 | @anchor{Pre-commands for Non-Suffixes} | ||
| 1511 | @subheading Pre-commands for Non-Suffixes | ||
| 1512 | |||
| 1513 | The default for non-suffixes, i.e@: commands that are bound in other | ||
| 1514 | keymaps beside the transient keymap, is @code{transient--do-warn}. Silently | ||
| 1515 | ignoring the user-error is also an option, though probably not a good | ||
| 1516 | one. | ||
| 1517 | |||
| 1518 | If you want to let the user invoke non-suffix commands, then use | ||
| 1519 | @code{transient--do-stay} as the value of the prefix's @code{transient-non-suffix} | ||
| 1520 | slot. | ||
| 1521 | |||
| 1522 | @defun transient--do-warn | ||
| 1523 | |||
| 1524 | Call @code{transient-undefined} and stay transient. | ||
| 1525 | @end defun | ||
| 1526 | |||
| 1527 | @defun transient--do-noop | ||
| 1528 | |||
| 1529 | Call @code{transient-noop} and stay transient. | ||
| 1530 | @end defun | ||
| 1531 | |||
| 1532 | @anchor{Special Pre-Commands} | ||
| 1533 | @subheading Special Pre-Commands | ||
| 1534 | |||
| 1535 | @defun transient--do-quit-one | ||
| 1536 | |||
| 1537 | If active, quit help or edit mode, else exit the active transient. | ||
| 1538 | |||
| 1539 | This is used when the user pressed @kbd{C-g}. | ||
| 1540 | @end defun | ||
| 1541 | |||
| 1542 | @defun transient--do-quit-all | ||
| 1543 | |||
| 1544 | Exit all transients without saving the transient stack. | ||
| 1545 | |||
| 1546 | This is used when the user pressed @kbd{C-q}. | ||
| 1547 | @end defun | ||
| 1548 | |||
| 1549 | @defun transient--do-suspend | ||
| 1550 | |||
| 1551 | Suspend the active transient, saving the transient stack. | ||
| 1552 | |||
| 1553 | This is used when the user pressed @kbd{C-z}. | ||
| 1554 | @end defun | ||
| 1555 | |||
| 1556 | @node Classes and Methods | ||
| 1557 | @chapter Classes and Methods | ||
| 1558 | @cindex classes and methods | ||
| 1559 | |||
| 1560 | Transient uses classes and generic functions to make it possible to | ||
| 1561 | define new types of suffix commands that are similar to existing | ||
| 1562 | types, but behave differently in some aspects. It does the same for | ||
| 1563 | groups and prefix commands, though at least for prefix commands that | ||
| 1564 | @strong{currently} appears to be less important. | ||
| 1565 | |||
| 1566 | Every prefix, infix and suffix command is associated with an object, | ||
| 1567 | which holds information that controls certain aspects of its behavior. | ||
| 1568 | This happens in two ways. | ||
| 1569 | |||
| 1570 | @itemize | ||
| 1571 | @item | ||
| 1572 | Associating a command with a certain class gives the command a type. | ||
| 1573 | This makes it possible to use generic functions to do certain things | ||
| 1574 | that have to be done differently depending on what type of command | ||
| 1575 | it acts on. | ||
| 1576 | |||
| 1577 | That in turn makes it possible for third-parties to add new types | ||
| 1578 | without having to convince the maintainer of Transient that that new | ||
| 1579 | type is important enough to justify adding a special case to a dozen | ||
| 1580 | or so functions. | ||
| 1581 | |||
| 1582 | @item | ||
| 1583 | Associating a command with an object makes it possible to easily | ||
| 1584 | store information that is specific to that particular command. | ||
| 1585 | |||
| 1586 | Two commands may have the same type, but obviously their key | ||
| 1587 | bindings and descriptions still have to be different, for example. | ||
| 1588 | |||
| 1589 | The values of some slots are functions. The @code{reader} slot for example | ||
| 1590 | holds a function that is used to read a new value for an infix | ||
| 1591 | command. The values of such slots are regular functions. | ||
| 1592 | |||
| 1593 | Generic functions are used when a function should do something | ||
| 1594 | different based on the type of the command, i.e. when all commands | ||
| 1595 | of a certain type should behave the same way but different from the | ||
| 1596 | behavior for other types. Object slots that hold a regular function | ||
| 1597 | as value are used when the task that they perform is likely to | ||
| 1598 | differ even between different commands of the same type. | ||
| 1599 | @end itemize | ||
| 1600 | |||
| 1601 | @menu | ||
| 1602 | * Group Classes:: | ||
| 1603 | * Group Methods:: | ||
| 1604 | * Prefix Classes:: | ||
| 1605 | * Suffix Classes:: | ||
| 1606 | * Suffix Methods:: | ||
| 1607 | * Prefix Slots:: | ||
| 1608 | * Suffix Slots:: | ||
| 1609 | * Predicate Slots:: | ||
| 1610 | @end menu | ||
| 1611 | |||
| 1612 | @node Group Classes | ||
| 1613 | @section Group Classes | ||
| 1614 | |||
| 1615 | The type of a group can be specified using the @code{:class} property at the | ||
| 1616 | beginning of the class specification, e.g. @code{[:class transient-columns | ||
| 1617 | ...]} in a call to @code{transient-define-prefix}. | ||
| 1618 | |||
| 1619 | @itemize | ||
| 1620 | @item | ||
| 1621 | The abstract @code{transient-child} class is the base class of both | ||
| 1622 | @code{transient-group} (and therefore all groups) as well as of | ||
| 1623 | @code{transient-suffix} (and therefore all suffix and infix commands). | ||
| 1624 | |||
| 1625 | This class exists because the elements (a.k.a.@: ``children'') of certain | ||
| 1626 | groups can be other groups instead of suffix and infix commands. | ||
| 1627 | |||
| 1628 | @item | ||
| 1629 | The abstract @code{transient-group} class is the superclass of all other | ||
| 1630 | group classes. | ||
| 1631 | |||
| 1632 | @item | ||
| 1633 | The @code{transient-column} class is the simplest group. | ||
| 1634 | |||
| 1635 | This is the default ``flat'' group. If the class is not specified | ||
| 1636 | explicitly and the first element is not a vector (i.e. not a group), | ||
| 1637 | then this class is used. | ||
| 1638 | |||
| 1639 | This class displays each element on a separate line. | ||
| 1640 | |||
| 1641 | @item | ||
| 1642 | The @code{transient-row} class displays all elements on a single line. | ||
| 1643 | |||
| 1644 | @item | ||
| 1645 | The @code{transient-columns} class displays commands organized in columns. | ||
| 1646 | |||
| 1647 | Direct elements have to be groups whose elements have to be commands | ||
| 1648 | or strings. Each subgroup represents a column. This class takes | ||
| 1649 | care of inserting the subgroups' elements. | ||
| 1650 | |||
| 1651 | This is the default ``nested'' group. If the class is not specified | ||
| 1652 | explicitly and the first element is a vector (i.e.@: a group), then | ||
| 1653 | this class is used. | ||
| 1654 | |||
| 1655 | @item | ||
| 1656 | The @code{transient-subgroups} class wraps other groups. | ||
| 1657 | |||
| 1658 | Direct elements have to be groups whose elements have to be commands | ||
| 1659 | or strings. This group inserts an empty line between subgroups. | ||
| 1660 | The subgroups themselves are responsible for displaying their | ||
| 1661 | elements. | ||
| 1662 | @end itemize | ||
| 1663 | |||
| 1664 | @node Group Methods | ||
| 1665 | @section Group Methods | ||
| 1666 | |||
| 1667 | @defun transient-setup-children group children | ||
| 1668 | |||
| 1669 | This generic function can be used to setup the children or a group. | ||
| 1670 | |||
| 1671 | The default implementation usually just returns the children | ||
| 1672 | unchanged, but if the @code{setup-children} slot of @var{group} is non-nil, then | ||
| 1673 | it calls that function with @var{children} as the only argument and | ||
| 1674 | returns the value. | ||
| 1675 | |||
| 1676 | The children are given as a (potentially empty) list consisting of | ||
| 1677 | either group or suffix specifications. These functions can make | ||
| 1678 | arbitrary changes to the children including constructing new | ||
| 1679 | children from scratch. | ||
| 1680 | @end defun | ||
| 1681 | |||
| 1682 | @defun transient--insert-group group | ||
| 1683 | |||
| 1684 | This generic function formats the group and its elements and inserts | ||
| 1685 | the result into the current buffer, which is a temporary buffer. | ||
| 1686 | The contents of that buffer are later inserted into the popup buffer. | ||
| 1687 | |||
| 1688 | Functions that are called by this function may need to operate in | ||
| 1689 | the buffer from which the transient was called. To do so they can | ||
| 1690 | temporarily make the @code{transient--source-buffer} the current buffer. | ||
| 1691 | @end defun | ||
| 1692 | |||
| 1693 | @node Prefix Classes | ||
| 1694 | @section Prefix Classes | ||
| 1695 | |||
| 1696 | Currently the @code{transient-prefix} class is being used for all prefix | ||
| 1697 | commands and there is only a single generic function that can be | ||
| 1698 | specialized based on the class of a prefix command. | ||
| 1699 | |||
| 1700 | @defun transient--history-init obj | ||
| 1701 | |||
| 1702 | This generic function is called while setting up the transient and | ||
| 1703 | is responsible for initializing the @code{history} slot. This is the | ||
| 1704 | transient-wide history; many individual infixes also have a history | ||
| 1705 | of their own. | ||
| 1706 | |||
| 1707 | The default (and currently only) method extracts the value from the | ||
| 1708 | global variable @code{transient-history}. | ||
| 1709 | @end defun | ||
| 1710 | |||
| 1711 | A transient prefix command's object is stored in the @code{transient--prefix} | ||
| 1712 | property of the command symbol. While a transient is active, a clone | ||
| 1713 | of that object is stored in the variable @code{transient--prefix}. A clone | ||
| 1714 | is used because some changes that are made to the active transient's | ||
| 1715 | object should not affect later invocations. | ||
| 1716 | |||
| 1717 | @node Suffix Classes | ||
| 1718 | @section Suffix Classes | ||
| 1719 | |||
| 1720 | @itemize | ||
| 1721 | @item | ||
| 1722 | All suffix and infix classes derive from @code{transient-suffix}, which in | ||
| 1723 | turn derives from @code{transient-child}, from which @code{transient-group} also | ||
| 1724 | derives (@pxref{Group Classes}). | ||
| 1725 | |||
| 1726 | @item | ||
| 1727 | All infix classes derive from the abstract @code{transient-infix} class, | ||
| 1728 | which in turn derives from the @code{transient-suffix} class. | ||
| 1729 | |||
| 1730 | Infixes are a special type of suffixes. The primary difference is | ||
| 1731 | that infixes always use the @code{transient--do-stay} pre-command, while | ||
| 1732 | non-infix suffixes use a variety of pre-commands (see @ref{Transient State}). Doing that is most easily achieved by using this class, | ||
| 1733 | though theoretically it would be possible to define an infix class | ||
| 1734 | that does not do so. If you do that then you get to implement many | ||
| 1735 | methods. | ||
| 1736 | |||
| 1737 | Also, infixes and non-infix suffixes are usually defined using | ||
| 1738 | different macros (@pxref{Defining Suffix and Infix Commands}). | ||
| 1739 | |||
| 1740 | @item | ||
| 1741 | Classes used for infix commands that represent arguments should | ||
| 1742 | be derived from the abstract @code{transient-argument} class. | ||
| 1743 | |||
| 1744 | @item | ||
| 1745 | The @code{transient-switch} class (or a derived class) is used for infix | ||
| 1746 | arguments that represent command-line switches (arguments that do | ||
| 1747 | not take a value). | ||
| 1748 | |||
| 1749 | @item | ||
| 1750 | The @code{transient-option} class (or a derived class) is used for infix | ||
| 1751 | arguments that represent command-line options (arguments that do | ||
| 1752 | take a value). | ||
| 1753 | |||
| 1754 | @item | ||
| 1755 | The @code{transient-switches} class can be used for a set of mutually | ||
| 1756 | exclusive command-line switches. | ||
| 1757 | |||
| 1758 | @item | ||
| 1759 | The @code{transient-files} class can be used for a @samp{--} argument that | ||
| 1760 | indicates that all remaining arguments are files. | ||
| 1761 | |||
| 1762 | @item | ||
| 1763 | Classes used for infix commands that represent variables should | ||
| 1764 | derived from the abstract @code{transient-variables} class. | ||
| 1765 | @end itemize | ||
| 1766 | |||
| 1767 | Magit defines additional classes, which can serve as examples for the | ||
| 1768 | fancy things you can do without modifying Transient. Some of these | ||
| 1769 | classes will likely get generalized and added to Transient. For now | ||
| 1770 | they are very much subject to change and not documented. | ||
| 1771 | |||
| 1772 | @node Suffix Methods | ||
| 1773 | @section Suffix Methods | ||
| 1774 | |||
| 1775 | To get information about the methods implementing these generic | ||
| 1776 | functions use @code{describe-function}. | ||
| 1777 | |||
| 1778 | @menu | ||
| 1779 | * Suffix Value Methods:: | ||
| 1780 | * Suffix Format Methods:: | ||
| 1781 | @end menu | ||
| 1782 | |||
| 1783 | @node Suffix Value Methods | ||
| 1784 | @subsection Suffix Value Methods | ||
| 1785 | |||
| 1786 | @defun transient-init-value obj | ||
| 1787 | |||
| 1788 | This generic function sets the initial value of the object @var{obj}. | ||
| 1789 | |||
| 1790 | This function is called for all suffix commands, but unless a | ||
| 1791 | concrete method is implemented this falls through to the default | ||
| 1792 | implementation, which is a noop. In other words this usually | ||
| 1793 | only does something for infix commands, but note that this is | ||
| 1794 | not implemented for the abstract class @code{transient-infix}, so if | ||
| 1795 | your class derives from that directly, then you must implement | ||
| 1796 | a method. | ||
| 1797 | @end defun | ||
| 1798 | |||
| 1799 | @defun transient-infix-read obj | ||
| 1800 | |||
| 1801 | This generic function determines the new value of the infix object | ||
| 1802 | @var{obj}. | ||
| 1803 | |||
| 1804 | This function merely determines the value; @code{transient-infix-set} is | ||
| 1805 | used to actually store the new value in the object. | ||
| 1806 | |||
| 1807 | For most infix classes this is done by reading a value from the | ||
| 1808 | user using the reader specified by the @code{reader} slot (using the | ||
| 1809 | @code{transient-infix-value} method described below). | ||
| 1810 | |||
| 1811 | For some infix classes the value is changed without reading | ||
| 1812 | anything in the minibuffer, i.e.@: the mere act of invoking the | ||
| 1813 | infix command determines what the new value should be, based | ||
| 1814 | on the previous value. | ||
| 1815 | @end defun | ||
| 1816 | |||
| 1817 | @defun transient-prompt obj | ||
| 1818 | |||
| 1819 | This generic function returns the prompt to be used to read infix | ||
| 1820 | object @var{obj}'s value. | ||
| 1821 | @end defun | ||
| 1822 | |||
| 1823 | @defun transient-infix-set obj value | ||
| 1824 | |||
| 1825 | This generic function sets the value of infix object @var{obj} to @var{value}. | ||
| 1826 | @end defun | ||
| 1827 | |||
| 1828 | @defun transient-infix-value obj | ||
| 1829 | |||
| 1830 | This generic function returns the value of the suffix object @var{obj}. | ||
| 1831 | |||
| 1832 | This function is called by @code{transient-args} (which see), meaning this | ||
| 1833 | function is how the value of a transient is determined so that the | ||
| 1834 | invoked suffix command can use it. | ||
| 1835 | |||
| 1836 | Currently most values are strings, but that is not set in stone. | ||
| 1837 | @code{nil} is not a value, it means ``no value''. | ||
| 1838 | |||
| 1839 | Usually only infixes have a value, but see the method for | ||
| 1840 | @code{transient-suffix}. | ||
| 1841 | @end defun | ||
| 1842 | |||
| 1843 | @defun transient-init-scope obj | ||
| 1844 | |||
| 1845 | This generic function sets the scope of the suffix object @var{obj}. | ||
| 1846 | |||
| 1847 | The scope is actually a property of the transient prefix, not of | ||
| 1848 | individual suffixes. However it is possible to invoke a suffix | ||
| 1849 | command directly instead of from a transient. In that case, if | ||
| 1850 | the suffix expects a scope, then it has to determine that itself | ||
| 1851 | and store it in its @code{scope} slot. | ||
| 1852 | |||
| 1853 | This function is called for all suffix commands, but unless a | ||
| 1854 | concrete method is implemented this falls through to the default | ||
| 1855 | implementation, which is a noop. | ||
| 1856 | @end defun | ||
| 1857 | |||
| 1858 | @node Suffix Format Methods | ||
| 1859 | @subsection Suffix Format Methods | ||
| 1860 | |||
| 1861 | @defun transient-format obj | ||
| 1862 | |||
| 1863 | This generic function formats and returns @var{obj} for display. | ||
| 1864 | |||
| 1865 | When this function is called, then the current buffer is some | ||
| 1866 | temporary buffer. If you need the buffer from which the prefix | ||
| 1867 | command was invoked to be current, then do so by temporarily | ||
| 1868 | making @code{transient--source-buffer} current. | ||
| 1869 | @end defun | ||
| 1870 | |||
| 1871 | @defun transient-format-key obj | ||
| 1872 | |||
| 1873 | This generic function formats @var{obj}'s @code{key} for display and returns the | ||
| 1874 | result. | ||
| 1875 | @end defun | ||
| 1876 | |||
| 1877 | @defun transient-format-description obj | ||
| 1878 | |||
| 1879 | This generic function formats @var{obj}'s @code{description} for display and | ||
| 1880 | returns the result. | ||
| 1881 | @end defun | ||
| 1882 | |||
| 1883 | @defun transient-format-value obj | ||
| 1884 | |||
| 1885 | This generic function formats @var{obj}'s value for display and returns | ||
| 1886 | the result. | ||
| 1887 | @end defun | ||
| 1888 | |||
| 1889 | @defun transient-show-help obj | ||
| 1890 | |||
| 1891 | Show help for the prefix, infix or suffix command represented by | ||
| 1892 | @var{obj}. | ||
| 1893 | |||
| 1894 | For prefixes, show the info manual, if that is specified using the | ||
| 1895 | @code{info-manual} slot. Otherwise, show the manpage if that is specified | ||
| 1896 | using the @code{man-page} slot. Otherwise, show the command's doc string. | ||
| 1897 | |||
| 1898 | For suffixes, show the command's doc string. | ||
| 1899 | |||
| 1900 | For infixes, show the manpage if that is specified. Otherwise show | ||
| 1901 | the command's doc string. | ||
| 1902 | @end defun | ||
| 1903 | |||
| 1904 | @node Prefix Slots | ||
| 1905 | @section Prefix Slots | ||
| 1906 | |||
| 1907 | @itemize | ||
| 1908 | @item | ||
| 1909 | @code{man-page} or @code{info-manual} can be used to specify the documentation for | ||
| 1910 | the prefix and its suffixes. The command @code{transient-help} uses the | ||
| 1911 | method @code{transient-show-help} (which see) to lookup and use these | ||
| 1912 | values. | ||
| 1913 | |||
| 1914 | @item | ||
| 1915 | @code{history-key} If multiple prefix commands should share a single value, | ||
| 1916 | then this slot has to be set to the same value for all of them. You | ||
| 1917 | probably don't want that. | ||
| 1918 | |||
| 1919 | @item | ||
| 1920 | @code{transient-suffix} and @code{transient-non-suffix} play a part when | ||
| 1921 | determining whether the currently active transient prefix command | ||
| 1922 | remains active/transient when a suffix or abitrary non-suffix | ||
| 1923 | command is invoked. @xref{Transient State}. | ||
| 1924 | |||
| 1925 | @item | ||
| 1926 | @code{incompatible} A list of lists. Each sub-list specifies a set of | ||
| 1927 | mutually exclusive arguments. Enabling one of these arguments | ||
| 1928 | causes the others to be disabled. An argument may appear in | ||
| 1929 | multiple sub-lists. | ||
| 1930 | |||
| 1931 | @item | ||
| 1932 | @code{scope} For some transients it might be necessary to have a sort of | ||
| 1933 | secondary value, called a ``scope''. See @code{transient-define-prefix}. | ||
| 1934 | @end itemize | ||
| 1935 | |||
| 1936 | @anchor{Internal Prefix Slots} | ||
| 1937 | @subheading Internal Prefix Slots | ||
| 1938 | |||
| 1939 | These slots are mostly intended for internal use. They should not be | ||
| 1940 | set in calls to @code{transient-define-prefix}. | ||
| 1941 | |||
| 1942 | @itemize | ||
| 1943 | @item | ||
| 1944 | @code{prototype} When a transient prefix command is invoked, then a clone | ||
| 1945 | of that object is stored in the global variable @code{transient--prefix} | ||
| 1946 | and the prototype is stored in the clone's @code{prototype} slot. | ||
| 1947 | |||
| 1948 | @item | ||
| 1949 | @code{command} The command, a symbol. Each transient prefix command | ||
| 1950 | consists of a command, which is stored in a symbol's function slot | ||
| 1951 | and an object, which is stored in the @code{transient--prefix} property | ||
| 1952 | of the same symbol. | ||
| 1953 | |||
| 1954 | @item | ||
| 1955 | @code{level} The level of the prefix commands. The suffix commands whose | ||
| 1956 | layer is equal or lower are displayed. @pxref{Enabling and Disabling Suffixes}. | ||
| 1957 | |||
| 1958 | @item | ||
| 1959 | @code{value} The likely outdated value of the prefix. Instead of accessing | ||
| 1960 | this slot directly you should use the function @code{transient-get-value}, | ||
| 1961 | which is guaranteed to return the up-to-date value. | ||
| 1962 | |||
| 1963 | @item | ||
| 1964 | @code{history} and @code{history-pos} are used to keep track of historic values. | ||
| 1965 | Unless you implement your own @code{transient-infix-read} method you should | ||
| 1966 | not have to deal with these slots. | ||
| 1967 | @end itemize | ||
| 1968 | |||
| 1969 | @node Suffix Slots | ||
| 1970 | @section Suffix Slots | ||
| 1971 | |||
| 1972 | Here we document most of the slots that are only available for suffix | ||
| 1973 | objects. Some slots are shared by suffix and group objects, they are | ||
| 1974 | documented in @ref{Predicate Slots}. | ||
| 1975 | |||
| 1976 | Also see @ref{Suffix Classes}. | ||
| 1977 | |||
| 1978 | @anchor{Slots of @code{transient-suffix}} | ||
| 1979 | @subheading Slots of @code{transient-suffix} | ||
| 1980 | |||
| 1981 | @itemize | ||
| 1982 | @item | ||
| 1983 | @code{key} The key, a key vector or a key description string. | ||
| 1984 | |||
| 1985 | @item | ||
| 1986 | @code{command} The command, a symbol. | ||
| 1987 | |||
| 1988 | @item | ||
| 1989 | @code{transient} Whether to stay transient. @xref{Transient State}. | ||
| 1990 | |||
| 1991 | @item | ||
| 1992 | @code{format} The format used to display the suffix in the popup buffer. | ||
| 1993 | It must contain the following %-placeholders: | ||
| 1994 | |||
| 1995 | @itemize | ||
| 1996 | @item | ||
| 1997 | @code{%k} For the key. | ||
| 1998 | |||
| 1999 | @item | ||
| 2000 | @code{%d} For the description. | ||
| 2001 | |||
| 2002 | @item | ||
| 2003 | @code{%v} For the infix value. Non-infix suffixes don't have a value. | ||
| 2004 | @end itemize | ||
| 2005 | |||
| 2006 | @item | ||
| 2007 | @code{description} The description, either a string or a function that is | ||
| 2008 | called with no argument and returns a string. | ||
| 2009 | @end itemize | ||
| 2010 | |||
| 2011 | @anchor{Slots of @code{transient-infix}} | ||
| 2012 | @subheading Slots of @code{transient-infix} | ||
| 2013 | |||
| 2014 | Some of these slots are only meaningful for some of the subclasses. | ||
| 2015 | They are defined here anyway to allow sharing certain methods. | ||
| 2016 | |||
| 2017 | @itemize | ||
| 2018 | @item | ||
| 2019 | @code{argument} The long argument, e.g. @code{--verbose}. | ||
| 2020 | |||
| 2021 | @item | ||
| 2022 | @code{shortarg} The short argument, e.g. @code{-v}. | ||
| 2023 | |||
| 2024 | @item | ||
| 2025 | @code{value} The value. Should not be accessed directly. | ||
| 2026 | |||
| 2027 | @item | ||
| 2028 | @code{init-value} Function that is responsable for setting the object's | ||
| 2029 | value. If bound, then this is called with the object as the only | ||
| 2030 | argument. Usually this is not bound, in which case the object's | ||
| 2031 | primary @code{transient-init-value} method is called instead. | ||
| 2032 | |||
| 2033 | @item | ||
| 2034 | @code{unsavable} Whether the value of the suffix is not saved as part of | ||
| 2035 | the prefixes. | ||
| 2036 | |||
| 2037 | @item | ||
| 2038 | @code{multi-value} For options, whether the option can have multiple | ||
| 2039 | values. If non-nil, then default to use @code{completing-read-multiple}. | ||
| 2040 | |||
| 2041 | @item | ||
| 2042 | @code{always-read} For options, whether to read a value on every invocation. | ||
| 2043 | If this is nil, then options that have a value are simply unset and | ||
| 2044 | have to be invoked a second time to set a new value. | ||
| 2045 | |||
| 2046 | @item | ||
| 2047 | @code{allow-empty} For options, whether the empty string is a valid value. | ||
| 2048 | |||
| 2049 | @item | ||
| 2050 | @code{history-key} The key used to store the history. This defaults to the | ||
| 2051 | command name. This is useful when multiple infixes should share the | ||
| 2052 | same history because their values are of the same kind. | ||
| 2053 | |||
| 2054 | @item | ||
| 2055 | @code{reader} The function used to read the value of an infix. Not used | ||
| 2056 | for switches. The function takes three arguments, @var{prompt}, | ||
| 2057 | @var{initial-input} and @var{history}, and must return a string. | ||
| 2058 | |||
| 2059 | @item | ||
| 2060 | @code{prompt} The prompt used when reading the value, either a string or a | ||
| 2061 | function that takes the object as the only argument and which | ||
| 2062 | returns a prompt string. | ||
| 2063 | |||
| 2064 | @item | ||
| 2065 | @code{choices} A list of valid values. How exactly that is used depends on | ||
| 2066 | the class of the object. | ||
| 2067 | @end itemize | ||
| 2068 | |||
| 2069 | @anchor{Slots of @code{transient-variable}} | ||
| 2070 | @subheading Slots of @code{transient-variable} | ||
| 2071 | |||
| 2072 | @itemize | ||
| 2073 | @item | ||
| 2074 | @code{variable} The variable. | ||
| 2075 | @end itemize | ||
| 2076 | |||
| 2077 | @anchor{Slots of @code{transient-switches}} | ||
| 2078 | @subheading Slots of @code{transient-switches} | ||
| 2079 | |||
| 2080 | @itemize | ||
| 2081 | @item | ||
| 2082 | @code{argument-format} The display format. Must contain @code{%s}, one of the | ||
| 2083 | @code{choices} is substituted for that. E.g., @code{--%s-order}. | ||
| 2084 | |||
| 2085 | @item | ||
| 2086 | @code{argument-regexp} The regexp used to match any one of the switches. | ||
| 2087 | E.g., @code{\\(--\\(topo\\|author-date\\|date\\)-order\\)}. | ||
| 2088 | @end itemize | ||
| 2089 | |||
| 2090 | @node Predicate Slots | ||
| 2091 | @section Predicate Slots | ||
| 2092 | |||
| 2093 | Suffix and group objects share some predicate slots that control | ||
| 2094 | whether a group or suffix should be available depending on some state. | ||
| 2095 | Only one of these slots can be used at the same time. It is undefined | ||
| 2096 | what happens if you use more than one. | ||
| 2097 | |||
| 2098 | @itemize | ||
| 2099 | @item | ||
| 2100 | @code{if} Enable if predicate returns non-@code{nil}. | ||
| 2101 | |||
| 2102 | @item | ||
| 2103 | @code{if-not} Enable if predicate returns @code{nil}. | ||
| 2104 | |||
| 2105 | @item | ||
| 2106 | @code{if-non-nil} Enable if variable's value is non-@code{nil}. | ||
| 2107 | |||
| 2108 | @item | ||
| 2109 | @code{if-nil} Enable if variable's value is @code{nil}. | ||
| 2110 | |||
| 2111 | @item | ||
| 2112 | @code{if-mode} Enable if major-mode matches value. | ||
| 2113 | |||
| 2114 | @item | ||
| 2115 | @code{if-not-mode} Enable if major-mode does not match value. | ||
| 2116 | |||
| 2117 | @item | ||
| 2118 | @code{if-derived} Enable if major-mode derives from value. | ||
| 2119 | |||
| 2120 | @item | ||
| 2121 | @code{if-not-derived} Enable if major-mode does not derive from value. | ||
| 2122 | @end itemize | ||
| 2123 | |||
| 2124 | One more slot is shared between group and suffix classes, @code{level}. Like | ||
| 2125 | the slots documented above, it is a predicate, but it is used for a | ||
| 2126 | different purpose. The value has to be an integer between 1 | ||
| 2127 | and 7. @code{level} controls whether a suffix or a group should be | ||
| 2128 | available depending on user preference. | ||
| 2129 | @xref{Enabling and Disabling Suffixes}. | ||
| 2130 | |||
| 2131 | @node Related Abstractions and Packages | ||
| 2132 | @chapter Related Abstractions and Packages | ||
| 2133 | |||
| 2134 | @menu | ||
| 2135 | * Comparison With Prefix Keys and Prefix Arguments:: | ||
| 2136 | * Comparison With Other Packages:: | ||
| 2137 | @end menu | ||
| 2138 | |||
| 2139 | @node Comparison With Prefix Keys and Prefix Arguments | ||
| 2140 | @section Comparison With Prefix Keys and Prefix Arguments | ||
| 2141 | |||
| 2142 | While transient commands were inspired by regular prefix keys and | ||
| 2143 | prefix arguments, they are also quite different and much more complex. | ||
| 2144 | |||
| 2145 | The following diagrams illustrate some of the differences. | ||
| 2146 | |||
| 2147 | @itemize | ||
| 2148 | @item | ||
| 2149 | @code{(c)} represents a return to the command loop. | ||
| 2150 | |||
| 2151 | @item | ||
| 2152 | @code{(+)} represents the user's choice to press one key or another. | ||
| 2153 | |||
| 2154 | @item | ||
| 2155 | @code{@{@var{word}@}} are possible behaviors. | ||
| 2156 | |||
| 2157 | @item | ||
| 2158 | @code{@{@var{number}@}} is a footnote. | ||
| 2159 | @end itemize | ||
| 2160 | |||
| 2161 | @anchor{Regular Prefix Commands} | ||
| 2162 | @subheading Regular Prefix Commands | ||
| 2163 | |||
| 2164 | @xref{Prefix Keys,,,elisp,}. | ||
| 2165 | |||
| 2166 | @example | ||
| 2167 | ,--> command1 --> (c) | ||
| 2168 | | | ||
| 2169 | (c)-(+)-> prefix command or key --+--> command2 --> (c) | ||
| 2170 | | | ||
| 2171 | `--> command3 --> (c) | ||
| 2172 | @end example | ||
| 2173 | |||
| 2174 | @anchor{Regular Prefix Arguments} | ||
| 2175 | @subheading Regular Prefix Arguments | ||
| 2176 | |||
| 2177 | @xref{Prefix Command Arguments,,,elisp,}. | ||
| 2178 | |||
| 2179 | @example | ||
| 2180 | ,----------------------------------, | ||
| 2181 | | | | ||
| 2182 | v | | ||
| 2183 | (c)-(+)---> prefix argument command --(c)-(+)-> any command --> (c) | ||
| 2184 | | ^ | | ||
| 2185 | | | | | ||
| 2186 | `-- sets or changes --, ,-- maybe used --' | | ||
| 2187 | | | | | ||
| 2188 | v | | | ||
| 2189 | prefix argument state | | ||
| 2190 | ^ | | ||
| 2191 | | | | ||
| 2192 | `-------- discards --------' | ||
| 2193 | @end example | ||
| 2194 | |||
| 2195 | @anchor{Transients} | ||
| 2196 | @subheading Transients | ||
| 2197 | |||
| 2198 | (∩`-´)⊃━☆゚.*・。゚ | ||
| 2199 | |||
| 2200 | This diagram ignores the infix value and external state: | ||
| 2201 | |||
| 2202 | @example | ||
| 2203 | (c) | ||
| 2204 | | ,- @{stay@} ------<-,-<------------<-,-<---, | ||
| 2205 | (+) | | | | | ||
| 2206 | | | | | | | ||
| 2207 | | | ,--> infix1 --| | | | ||
| 2208 | | | | | | | | ||
| 2209 | | | |--> infix2 --| | | | ||
| 2210 | v v | | | | | ||
| 2211 | prefix -(c)-(+)-> infix3 --' ^ | | ||
| 2212 | | | | | ||
| 2213 | |---------------> suffix1 -->--| | | ||
| 2214 | | | | | ||
| 2215 | |---------------> suffix2 ----@{1@}------> @{exit@} --> (c) | ||
| 2216 | | | | ||
| 2217 | |---------------> suffix3 -------------> @{exit@} --> (c) | ||
| 2218 | | | | ||
| 2219 | `--> any command --@{2@}-> @{warn@} -->--| | ||
| 2220 | | | | ||
| 2221 | |--> @{noop@} -->--| | ||
| 2222 | | | | ||
| 2223 | |--> @{call@} -->--' | ||
| 2224 | | | ||
| 2225 | `------------------> @{exit@} --> (c) | ||
| 2226 | @end example | ||
| 2227 | |||
| 2228 | This diagram takes the infix value into account to an extend, while | ||
| 2229 | still ignoring external state: | ||
| 2230 | |||
| 2231 | @example | ||
| 2232 | (c) | ||
| 2233 | | ,- @{stay@} ------<-,-<------------<-,-<---, | ||
| 2234 | (+) | | | | | ||
| 2235 | | | | | | | ||
| 2236 | | | ,--> infix1 --| | | | ||
| 2237 | | | | | | | | | ||
| 2238 | | | ,--> infix2 --| | | | ||
| 2239 | v v | | | | | | ||
| 2240 | prefix -(c)-(+)-> infix3 --' | | | ||
| 2241 | | | ^ | | ||
| 2242 | | | | | | ||
| 2243 | |---------------> suffix1 -->--| | | ||
| 2244 | | | ^ | | | ||
| 2245 | | | | | | | ||
| 2246 | |---------------> suffix2 ----@{1@}------> @{exit@} --> (c) | ||
| 2247 | | | ^ | | | ||
| 2248 | | | | | v | ||
| 2249 | | | | | | | ||
| 2250 | |---------------> suffix3 -------------> @{exit@} --> (c) | ||
| 2251 | | | ^ | | | ||
| 2252 | | sets | | v | ||
| 2253 | | | maybe | | | ||
| 2254 | | | used | | | ||
| 2255 | | | | | | | ||
| 2256 | | | infix --' | | | ||
| 2257 | | `---> value | | | ||
| 2258 | | ^ | | | ||
| 2259 | | | | | | ||
| 2260 | | hides | | | ||
| 2261 | | | | | | ||
| 2262 | | `--------------------------<---| | ||
| 2263 | | | | | ||
| 2264 | `--> any command --@{2@}-> @{warn@} -->--| | | ||
| 2265 | | | | | ||
| 2266 | |--> @{noop@} -->--| | | ||
| 2267 | | | | | ||
| 2268 | |--> @{call@} -->--' ^ | ||
| 2269 | | | | ||
| 2270 | `------------------> @{exit@} --> (c) | ||
| 2271 | @end example | ||
| 2272 | |||
| 2273 | This diagram provides more information about the infix value | ||
| 2274 | and also takes external state into account. | ||
| 2275 | |||
| 2276 | @example | ||
| 2277 | ,----sets--- "anything" | ||
| 2278 | | | ||
| 2279 | v | ||
| 2280 | ,---------> external | ||
| 2281 | | state | ||
| 2282 | | | | | ||
| 2283 | | initialized | ☉‿⚆ | ||
| 2284 | sets from | | ||
| 2285 | | | maybe | ||
| 2286 | | ,----------' used | ||
| 2287 | | | | | ||
| 2288 | (c) | | v | ||
| 2289 | | ,- @{stay@} --|---<-,-<------|-----<-,-<---, | ||
| 2290 | (+) | | | | | | | | ||
| 2291 | | | | v | | | | | ||
| 2292 | | | ,--> infix1 --| | | | | ||
| 2293 | | | | | | | | | | | ||
| 2294 | | | | | v | | | | | ||
| 2295 | | | ,--> infix2 --| | | | | ||
| 2296 | | | | | ^ | | | | | ||
| 2297 | v v | | | | | | | | ||
| 2298 | prefix -(c)-(+)-> infix3 --' | | | | ||
| 2299 | | | ^ | ^ | | ||
| 2300 | | | | v | | | ||
| 2301 | |---------------> suffix1 -->--| | | ||
| 2302 | | | | ^ | | | | ||
| 2303 | | | | | v | | | ||
| 2304 | |---------------> suffix2 ----@{1@}------> @{exit@} --> (c) | ||
| 2305 | | | | ^ | | | | ||
| 2306 | | | | | | | v | ||
| 2307 | | | | | v | | | ||
| 2308 | |---------------> suffix3 -------------> @{exit@} --> (c) | ||
| 2309 | | | | ^ | | | ||
| 2310 | | sets | | | v | ||
| 2311 | | | initialized maybe | | | ||
| 2312 | | | from used | | | ||
| 2313 | | | | | | | | ||
| 2314 | | | `-- infix ---' | | | ||
| 2315 | | `---> value -----------------------------> persistent | ||
| 2316 | | ^ ^ | | across | ||
| 2317 | | | | | | invocations -, | ||
| 2318 | | hides | | | | | ||
| 2319 | | | `----------------------------------------------' | ||
| 2320 | | | | | | ||
| 2321 | | `--------------------------<---| | ||
| 2322 | | | | | ||
| 2323 | `--> any command --@{2@}-> @{warn@} -->--| | | ||
| 2324 | | | | | ||
| 2325 | |--> @{noop@} -->--| | | ||
| 2326 | | | | | ||
| 2327 | |--> @{call@} -->--' ^ | ||
| 2328 | | | | ||
| 2329 | `------------------> @{exit@} --> (c) | ||
| 2330 | @end example | ||
| 2331 | |||
| 2332 | @itemize | ||
| 2333 | @item | ||
| 2334 | @code{@{1@}} Transients can be configured to be exited when a suffix command | ||
| 2335 | is invoked. The default is to do so for all suffixes except for | ||
| 2336 | those that are common to all transients and which are used to | ||
| 2337 | perform tasks such as providing help and saving the value of the | ||
| 2338 | infix arguments for future invocations. The behavior can also be | ||
| 2339 | specified for individual suffix commands and may even depend on | ||
| 2340 | state. | ||
| 2341 | |||
| 2342 | @item | ||
| 2343 | @code{@{2@}} Transients can be configured to allow the user to invoke | ||
| 2344 | non-suffix commands. The default is to not allow that and instead | ||
| 2345 | warn the user. | ||
| 2346 | @end itemize | ||
| 2347 | |||
| 2348 | Despite already being rather complex, even the last diagram leaves out | ||
| 2349 | many details. Most importantly it implies that the decision whether | ||
| 2350 | to remain transient is made later than it actually is made (for the | ||
| 2351 | most part a function on @code{pre-command-hook} is responsible). But such | ||
| 2352 | implementation details are of little relevance to users and are | ||
| 2353 | covered elsewhere. | ||
| 2354 | |||
| 2355 | @node Comparison With Other Packages | ||
| 2356 | @section Comparison With Other Packages | ||
| 2357 | |||
| 2358 | @anchor{Magit-Popup} | ||
| 2359 | @subheading Magit-Popup | ||
| 2360 | |||
| 2361 | Transient is the successor to Magit-Popup (@pxref{Top,,,magit-popup,}). | ||
| 2362 | |||
| 2363 | One major difference between these two implementations of the same | ||
| 2364 | ideas is that while Transient uses transient keymaps and embraces the | ||
| 2365 | command-loop, Magit-Popup implemented an inferior mechanism that does | ||
| 2366 | not use transient keymaps and that instead of using the command-loop | ||
| 2367 | implements a naive alternative based on @code{read-char}. | ||
| 2368 | |||
| 2369 | Magit-Popup does not use classes and generic functions and defining a | ||
| 2370 | new command type is near impossible as it involves adding hard-coded | ||
| 2371 | special-cases to many functions. Because of that only a single new | ||
| 2372 | type was added, which was not already part of Magit-Popup's initial | ||
| 2373 | release. | ||
| 2374 | |||
| 2375 | A lot of things are hard-coded in Magit-Popup. One random example is | ||
| 2376 | that the key bindings for switches must begin with @code{-} and those for | ||
| 2377 | options must begin with @code{=}. | ||
| 2378 | |||
| 2379 | @anchor{Hydra} | ||
| 2380 | @subheading Hydra | ||
| 2381 | |||
| 2382 | Hydra (see @uref{https://github.com/abo-abo/hydra}) is another package that | ||
| 2383 | provides features similar to those of Transient. | ||
| 2384 | |||
| 2385 | Both packages use transient keymaps to make a set of commands | ||
| 2386 | temporarily available and show the available commands in a popup | ||
| 2387 | buffer. | ||
| 2388 | |||
| 2389 | A Hydra ``body'' is equivalent to a Transient ``prefix'' and a Hydra | ||
| 2390 | ``head'' is equivalent to a Transient ``suffix''. Hydra has no equivalent | ||
| 2391 | of a Transient ``infix''. | ||
| 2392 | |||
| 2393 | Both hydras and transients can be used as simple command dispatchers. | ||
| 2394 | Used like this they are similar to regular prefix commands and prefix | ||
| 2395 | keys, except that the available commands are shown in the popup buffer. | ||
| 2396 | |||
| 2397 | (Another package that does this is @code{which-key}. It does so automatically | ||
| 2398 | for any incomplete key sequence. The advantage of that approach is | ||
| 2399 | that no additional work is necessary; the disadvantage is that the | ||
| 2400 | available commands are not organized semantically.) | ||
| 2401 | |||
| 2402 | Both Hydra and Transient provide features that go beyond simple | ||
| 2403 | command dispatchers: | ||
| 2404 | |||
| 2405 | @itemize | ||
| 2406 | @item | ||
| 2407 | Invoking a command from a hydra does not necessarily exit the hydra. | ||
| 2408 | That makes it possible to invoke the same command again, but using a | ||
| 2409 | shorter key sequence (i.e. the key that was used to enter the hydra | ||
| 2410 | does not have to be pressed again). | ||
| 2411 | |||
| 2412 | Transient supports that too, but for now this feature is not a focus | ||
| 2413 | and the interface is a bit more complicated. A very basic example | ||
| 2414 | using the current interface: | ||
| 2415 | |||
| 2416 | @lisp | ||
| 2417 | (transient-define-prefix outline-navigate () | ||
| 2418 | :transient-suffix 'transient--do-stay | ||
| 2419 | :transient-non-suffix 'transient--do-warn | ||
| 2420 | [("p" "previous visible heading" outline-previous-visible-heading) | ||
| 2421 | ("n" "next visible heading" outline-next-visible-heading)]) | ||
| 2422 | @end lisp | ||
| 2423 | |||
| 2424 | |||
| 2425 | @item | ||
| 2426 | Transient supports infix arguments; values that are set by infix | ||
| 2427 | commands and then consumed by the invoked suffix command(s). | ||
| 2428 | |||
| 2429 | To my knowledge, Hydra does not support that. | ||
| 2430 | @end itemize | ||
| 2431 | |||
| 2432 | Both packages make it possible to specify how exactly the available | ||
| 2433 | commands are outlined: | ||
| 2434 | |||
| 2435 | @itemize | ||
| 2436 | @item | ||
| 2437 | With Hydra this is often done using an explicit format string, which | ||
| 2438 | gives authors a lot of flexibility and makes it possible to do fancy | ||
| 2439 | things. | ||
| 2440 | |||
| 2441 | The downside of this is that it becomes harder for a user to add | ||
| 2442 | additional commands to an existing hydra and to change key bindings. | ||
| 2443 | |||
| 2444 | @item | ||
| 2445 | Transient allows the author of a transient to organize the commands | ||
| 2446 | into groups and the use of generic functions allows authors of | ||
| 2447 | transients to control exactly how a certain command type is | ||
| 2448 | displayed. | ||
| 2449 | |||
| 2450 | However while Transient supports giving sections a heading it does | ||
| 2451 | not currently support giving the displayed information more | ||
| 2452 | structure by, for example, using box-drawing characters. | ||
| 2453 | |||
| 2454 | That could be implemented by defining a new group class, which lets | ||
| 2455 | the author specify a format string. It should be possible to | ||
| 2456 | implement that without modifying any existing code, but it does not | ||
| 2457 | currently exist. | ||
| 2458 | @end itemize | ||
| 2459 | |||
| 2460 | @node FAQ | ||
| 2461 | @appendix FAQ | ||
| 2462 | |||
| 2463 | |||
| 2464 | |||
| 2465 | @anchor{Can I control how the popup buffer is displayed?} | ||
| 2466 | @appendixsec Can I control how the popup buffer is displayed? | ||
| 2467 | |||
| 2468 | Yes, see @code{transient-display-buffer-action} in @ref{Other Options}. | ||
| 2469 | |||
| 2470 | @anchor{Why did some of the key bindings change?} | ||
| 2471 | @appendixsec Why did some of the key bindings change? | ||
| 2472 | |||
| 2473 | You may have noticed that the bindings for some of the common commands | ||
| 2474 | do @strong{not} have the prefix @code{C-x} and that furthermore some of these commands | ||
| 2475 | are grayed out while others are not. That unfortunately is a bit | ||
| 2476 | confusing if the section of common commands is not shown permanently, | ||
| 2477 | making the following explanation necessary. | ||
| 2478 | |||
| 2479 | The purpose of usually hiding that section but showing it after the | ||
| 2480 | user pressed the respective prefix key is to conserve space and not | ||
| 2481 | overwhelm users with too much noise, while allowing the user to | ||
| 2482 | quickly list common bindings on demand. | ||
| 2483 | |||
| 2484 | That however should not keep us from using the best possible key | ||
| 2485 | bindings. The bindings that do use a prefix do so to avoid wasting | ||
| 2486 | too many non-prefix bindings, keeping them available for use in | ||
| 2487 | individual transients. The bindings that do not use a prefix and that | ||
| 2488 | are @strong{not} grayed out are very important bindings that are @strong{always} | ||
| 2489 | available, even when invoking the ``common command key prefix'' or @strong{any | ||
| 2490 | other} transient-specific prefix. The non-prefix keys that @strong{are} grayed | ||
| 2491 | out however, are not available when any incomplete prefix key sequence | ||
| 2492 | is active. They do not use the ``common command key prefix'' because it | ||
| 2493 | is likely that users want to invoke them several times in a row and | ||
| 2494 | e.g. @kbd{M-p M-p M-p} is much more convenient than | ||
| 2495 | @kbd{C-x M-p C-x M-p C-x M-p}. | ||
| 2496 | |||
| 2497 | You may also have noticed that the "Set" command is bound to @kbd{C-x s}, | ||
| 2498 | while Magit-Popup used to bind @kbd{C-c C-c} instead. I have seen several | ||
| 2499 | users praise the latter binding (sic), so I did not change it | ||
| 2500 | willy-nilly. The reason that I changed it is that using different | ||
| 2501 | prefix keys for different common commands, would have made the | ||
| 2502 | temporary display of the common commands even more confusing, | ||
| 2503 | i.e. after pressing @kbd{C-c} all the @kbd{C-x ...} bindings would be grayed out. | ||
| 2504 | |||
| 2505 | Using a single prefix for common commands key means that all other | ||
| 2506 | potential prefix keys can be used for transient-specific commands | ||
| 2507 | @strong{without} the section of common commands also popping up. @code{C-c} in | ||
| 2508 | particular is a prefix that I want to (and already do) use for Magit, and | ||
| 2509 | also using that for a common command would prevent me from doing so. | ||
| 2510 | |||
| 2511 | (Also see the next question.) | ||
| 2512 | |||
| 2513 | @anchor{Why does @code{q} not quit popups anymore?} | ||
| 2514 | @appendixsec Why does @code{q} not quit popups anymore? | ||
| 2515 | |||
| 2516 | I agree that @kbd{q} is a good binding for commands that quit something. | ||
| 2517 | This includes quitting whatever transient is currently active, but it | ||
| 2518 | also includes quitting whatever it is that some specific transient is | ||
| 2519 | controlling. The transient @code{magit-blame} for example binds @code{q} to the | ||
| 2520 | command that turns @code{magit-blame-mode} off. | ||
| 2521 | |||
| 2522 | So I had to decide if @kbd{q} should quit the active transient (like | ||
| 2523 | Magit-Popup used to) or whether @kbd{C-g} should do that instead, so | ||
| 2524 | that @kbd{q} | ||
| 2525 | could be bound in individual transient to whatever commands make sense | ||
| 2526 | for them. Because all other letters are already reserved for use by | ||
| 2527 | individual transients, I have decided to no longer make an exception | ||
| 2528 | for @kbd{q}. | ||
| 2529 | |||
| 2530 | If you want to get @kbd{q}'s old binding back then you can do so. Doing | ||
| 2531 | that is a bit more complicated than changing a single key binding, so | ||
| 2532 | I have implemented a function, @code{transient-bind-q-to-quit} that makes the | ||
| 2533 | necessary changes. See its doc string for more information. | ||
| 2534 | |||
| 2535 | @node Keystroke Index | ||
| 2536 | @appendix Keystroke Index | ||
| 2537 | |||
| 2538 | @printindex ky | ||
| 2539 | |||
| 2540 | @node Command and Function Index | ||
| 2541 | @appendix Command and Function Index | ||
| 2542 | |||
| 2543 | @printindex fn | ||
| 2544 | |||
| 2545 | @node Variable Index | ||
| 2546 | @appendix Variable Index | ||
| 2547 | |||
| 2548 | @printindex vr | ||
| 2549 | |||
| 2550 | @node Concept Index | ||
| 2551 | @appendix Concept and Feature Index | ||
| 2552 | |||
| 2553 | @printindex cp | ||
| 2554 | |||
| 2555 | @node GNU General Public License | ||
| 2556 | @appendix GNU General Public License | ||
| 2557 | |||
| 2558 | @include gpl.texi | ||
| 2559 | |||
| 2560 | @bye | ||
diff --git a/lisp/org/ol-bibtex.el b/lisp/org/ol-bibtex.el index 218f8f17ed5..81b99167b8e 100644 --- a/lisp/org/ol-bibtex.el +++ b/lisp/org/ol-bibtex.el | |||
| @@ -655,7 +655,8 @@ With a prefix arg, query for optional fields." | |||
| 655 | 655 | ||
| 656 | (defun org-bibtex-read () | 656 | (defun org-bibtex-read () |
| 657 | "Read a bibtex entry and save to `org-bibtex-entries'. | 657 | "Read a bibtex entry and save to `org-bibtex-entries'. |
| 658 | This uses `bibtex-parse-entry'." | 658 | This uses `bibtex-parse-entry'. |
| 659 | Return the new value of `org-bibtex-entries'." | ||
| 659 | (interactive) | 660 | (interactive) |
| 660 | (let ((keyword (lambda (str) (intern (concat ":" (downcase str))))) | 661 | (let ((keyword (lambda (str) (intern (concat ":" (downcase str))))) |
| 661 | (clean-space (lambda (str) (replace-regexp-in-string | 662 | (clean-space (lambda (str) (replace-regexp-in-string |
| @@ -678,7 +679,8 @@ This uses `bibtex-parse-entry'." | |||
| 678 | (funcall clean-space (funcall strip-delim (cdr pair))))) | 679 | (funcall clean-space (funcall strip-delim (cdr pair))))) |
| 679 | (save-excursion (bibtex-beginning-of-entry) (bibtex-parse-entry))) | 680 | (save-excursion (bibtex-beginning-of-entry) (bibtex-parse-entry))) |
| 680 | org-bibtex-entries) | 681 | org-bibtex-entries) |
| 681 | (unless (car org-bibtex-entries) (pop org-bibtex-entries)))) | 682 | (unless (car org-bibtex-entries) (pop org-bibtex-entries)) |
| 683 | org-bibtex-entries)) | ||
| 682 | 684 | ||
| 683 | (defun org-bibtex-read-buffer (buffer) | 685 | (defun org-bibtex-read-buffer (buffer) |
| 684 | "Read all bibtex entries in BUFFER and save to `org-bibtex-entries'. | 686 | "Read all bibtex entries in BUFFER and save to `org-bibtex-entries'. |
diff --git a/lisp/org/org-list.el b/lisp/org/org-list.el index 0dd8139a977..da309f8c6da 100644 --- a/lisp/org/org-list.el +++ b/lisp/org/org-list.el | |||
| @@ -1442,7 +1442,7 @@ This function returns, destructively, the new list structure." | |||
| 1442 | (save-excursion | 1442 | (save-excursion |
| 1443 | (goto-char (org-list-get-last-item item struct prevs)) | 1443 | (goto-char (org-list-get-last-item item struct prevs)) |
| 1444 | (point-at-eol))) | 1444 | (point-at-eol))) |
| 1445 | ((string-match-p "\\`[0-9]+\\'" dest) | 1445 | ((and (stringp dest) (string-match-p "\\`[0-9]+\\'" dest)) |
| 1446 | (let* ((all (org-list-get-all-items item struct prevs)) | 1446 | (let* ((all (org-list-get-all-items item struct prevs)) |
| 1447 | (len (length all)) | 1447 | (len (length all)) |
| 1448 | (index (mod (string-to-number dest) len))) | 1448 | (index (mod (string-to-number dest) len))) |
diff --git a/lisp/org/org-version.el b/lisp/org/org-version.el index 572203711c0..336347b29c2 100644 --- a/lisp/org/org-version.el +++ b/lisp/org/org-version.el | |||
| @@ -11,7 +11,7 @@ Inserted by installing Org mode or when a release is made." | |||
| 11 | (defun org-git-version () | 11 | (defun org-git-version () |
| 12 | "The Git version of Org mode. | 12 | "The Git version of Org mode. |
| 13 | Inserted by installing Org or when a release is made." | 13 | Inserted by installing Org or when a release is made." |
| 14 | (let ((org-git-version "release_9.5.2-13-gdd6486")) | 14 | (let ((org-git-version "release_9.5.2-15-gc5ceb6")) |
| 15 | org-git-version)) | 15 | org-git-version)) |
| 16 | 16 | ||
| 17 | (provide 'org-version) | 17 | (provide 'org-version) |
diff --git a/lisp/shell.el b/lisp/shell.el index c0a82bca183..6198214abee 100644 --- a/lisp/shell.el +++ b/lisp/shell.el | |||
| @@ -942,7 +942,7 @@ Environment variables are expanded, see function `substitute-in-file-name'." | |||
| 942 | dir | 942 | dir |
| 943 | (if (file-name-absolute-p dir) | 943 | (if (file-name-absolute-p dir) |
| 944 | ;; The name is absolute, so prepend the prefix. | 944 | ;; The name is absolute, so prepend the prefix. |
| 945 | (concat comint-file-name-prefix dir) | 945 | (concat comint-file-name-prefix (file-local-name dir)) |
| 946 | ;; For relative name we assume default-directory already has the prefix. | 946 | ;; For relative name we assume default-directory already has the prefix. |
| 947 | (expand-file-name dir)))) | 947 | (expand-file-name dir)))) |
| 948 | 948 | ||