README-elpa (2762B)
1 1 Transient commands 2 ════════════════════ 3 4 Taking inspiration from prefix keys and prefix arguments, Transient 5 implements a similar abstraction involving a prefix command, infix 6 arguments and suffix commands. We could call this abstraction a 7 "transient command", but because it always involves at least two 8 commands (a prefix and a suffix) we prefer to call it just a 9 "transient". 10 11 Transient keymaps are a feature provided by Emacs. 12 Transients as implemented by this package involve the use 13 of transient keymaps. 14 15 Emacs provides a feature that it calls "prefix commands". 16 When we talk about "prefix commands" in Transient's 17 documentation, then we mean our own kind of "prefix 18 commands", unless specified otherwise. To avoid ambiguity 19 we sometimes use the terms "transient prefix command" for 20 our kind and "regular prefix command" for Emacs' kind. 21 22 When the user calls a transient prefix command, then a transient 23 (temporary) keymap is activated, which binds the transient's infix and 24 suffix commands, and functions that control the transient state are 25 added to `pre-command-hook' and `post-command-hook'. The available 26 suffix and infix commands and their state are shown in a popup buffer 27 until the transient is exited by invoking a suffix command. 28 29 Calling an infix command causes its value to be changed. How that is 30 done depends on the type of the infix command. The simplest case is 31 an infix command that represents a command-line argument that does not 32 take a value. Invoking such an infix command causes the switch to be 33 toggled on or off. More complex infix commands may read a value from 34 the user, using the minibuffer. 35 36 Calling a suffix command usually causes the transient to be exited; 37 the transient keymaps and hook functions are removed, the popup buffer 38 no longer shows information about the (no longer bound) suffix 39 commands, the values of some public global variables are set, while 40 some internal global variables are unset, and finally the command is 41 actually called. Suffix commands can also be configured to not exit 42 the transient. 43 44 A suffix command can, but does not have to, use the infix arguments in 45 much the same way it can choose to use or ignore the prefix arguments. 46 For a suffix command that was invoked from a transient the variable 47 `transient-current-suffixes' and the function `transient-args' serve 48 about the same purpose as the variables `prefix-arg' and 49 `current-prefix-arg' do for any command that was called after the 50 prefix arguments have been set using a command such as 51 `universal-argument'. 52 53 <http://readme.emacsair.me/transient.png>