dotemacs

My Emacs configuration
git clone git://git.entf.net/dotemacs
Log | Files | Refs | LICENSE

transient.org (90907B)


      1 #+title: Transient User and Developer Manual
      2 :PREAMBLE:
      3 #+author: Jonas Bernoulli
      4 #+email: jonas@bernoul.li
      5 #+date: 2018-{{{year}}}
      6 
      7 #+texinfo_dir_category: Emacs misc features
      8 #+texinfo_dir_title: Transient: (transient).
      9 #+texinfo_dir_desc: Transient Commands
     10 #+subtitle: for version 0.6.0
     11 
     12 #+setupfile: .orgconfig
     13 
     14 Transient is the library used to implement the keyboard-driven “menus”
     15 in Magit.  It is distributed as a separate package, so that it can be
     16 used to implement similar menus in other packages.
     17 
     18 This manual can be bit hard to digest when getting started.  A useful
     19 resource to get over that hurdle is Psionic K's interactive tutorial,
     20 available at https://github.com/positron-solutions/transient-showcase.
     21 
     22 #+texinfo: @noindent
     23 This manual is for Transient version 0.6.0.
     24 
     25 #+texinfo: @insertcopying
     26 :END:
     27 * Introduction
     28 
     29 Transient is the library used to implement the keyboard-driven {{{dfn(menus)}}}
     30 in Magit.  It is distributed as a separate package, so that it can be
     31 used to implement similar menus in other packages.
     32 
     33 This manual can be bit hard to digest when getting started.  A useful
     34 resource to get over that hurdle is Psionic K's interactive tutorial,
     35 available at https://github.com/positron-solutions/transient-showcase.
     36 
     37 ** Some things that Transient can do
     38 :PROPERTIES:
     39 :UNNUMBERED: notoc
     40 :END:
     41 
     42 - Display current state of arguments
     43 - Display and manage lifecycle of modal bindings
     44 - Contextual user interface
     45 - Flow control for wizard-like composition of interactive forms
     46 - History & persistence
     47 - Rendering arguments for controlling CLI programs
     48 
     49 ** Complexity in CLI programs
     50 :PROPERTIES:
     51 :UNNUMBERED: notoc
     52 :END:
     53 
     54 Complexity tends to grow with time.  How do you manage the complexity
     55 of commands?  Consider the humble shell command =ls=.  It now has over
     56 /fifty/ command line options.  Some of these are boolean flags (=ls -l=).
     57 Some take arguments (=ls --sort=s=).  Some have no effect unless paired
     58 with other flags (=ls -lh=).  Some are mutually exclusive.  Some shell
     59 commands even have so many options that they introduce /subcommands/
     60 (=git branch=, =git commit=), each with their own rich set of options
     61 (=git branch -f=).
     62 
     63 ** Using Transient for composing interactive commands
     64 :PROPERTIES:
     65 :UNNUMBERED: notoc
     66 :END:
     67 
     68 What about Emacs commands used interactively? How do these handle
     69 options?  One solution is to make many versions of the same command,
     70 so you don't need to! Consider: =delete-other-windows= vs.
     71 =delete-other-windows-vertically= (among many similar examples).
     72 
     73 Some Emacs commands will simply prompt you for the next "argument"
     74 (=M-x switch-to-buffer=).  Another common solution is to use prefix
     75 arguments which usually start with =C-u=.  Sometimes these are sensibly
     76 numerical in nature (=C-u 4 M-x forward-paragraph= to move forward 4
     77 paragraphs).  But sometimes they function instead as boolean
     78 "switches" (=C-u C-SPACE= to jump to the last mark instead of just
     79 setting it, =C-u C-u C-SPACE= to unconditionally set the mark).  Since
     80 there aren't many standards for the use of prefix options, you have to
     81 read the command's documentation to find out what the possibilities
     82 are.
     83 
     84 But when an Emacs command grows to have a truly large set of options
     85 and arguments, with dependencies between them, lots of option values,
     86 etc., these simple approaches just don't scale.  Transient is designed
     87 to solve this issue.  Think of it as the humble prefix argument =C-u=,
     88 /raised to the power of 10/.  Like =C-u=, it is key driven.  Like the
     89 shell, it supports boolean "flag" options, options that take
     90 arguments, and even "sub-commands", with their own options.  But
     91 instead of searching through a man page or command documentation,
     92 well-designed transients /guide/ their users to the relevant set of
     93 options (and even their possible values!) directly, taking into
     94 account any important pre-existing Emacs settings.  And while for
     95 shell commands like =ls=, there is only one way to "execute" (hit
     96 =Return=!), transients can "execute" using multiple different keys tied
     97 to one of many self-documenting /actions/ (imagine having 5 different
     98 colored return keys on your keyboard!).  Transients make navigating
     99 and setting large, complex groups of command options and arguments
    100 easy.  Fun even.  Once you've tried it, it's hard to go back to the
    101 =C-u what can I do here again?= way.
    102 
    103 * Usage
    104 ** Invoking Transients
    105 #+cindex: invoking transients
    106 
    107 A transient prefix command is invoked like any other command by
    108 pressing the key that is bound to that command.  The main difference
    109 to other commands is that a transient prefix command activates a
    110 transient keymap, which temporarily binds the transient's infix and
    111 suffix commands.  Bindings from other keymaps may, or may not, be
    112 disabled while the transient state is in effect.
    113 
    114 There are two kinds of commands that are available after invoking a
    115 transient prefix command; infix and suffix commands.  Infix commands
    116 set some value (which is then shown in a popup buffer), without
    117 leaving the transient.  Suffix commands, on the other hand, usually
    118 quit the transient and they may use the values set by the infix
    119 commands, i.e., the infix *arguments*.
    120 
    121 Instead of setting arguments to be used by a suffix command, infix
    122 commands may also set some value by side-effect, e.g., by setting the
    123 value of some variable.
    124 
    125 ** Aborting and Resuming Transients
    126 #+cindex: aborting transients
    127 #+cindex: resuming transients
    128 
    129 #+cindex: quit transient
    130 To quit the transient without invoking a suffix command press {{{kbd(C-g)}}}.
    131 
    132 Key bindings in transient keymaps may be longer than a single event.
    133 After pressing a valid prefix key, all commands whose bindings do not
    134 begin with that prefix key are temporarily unavailable and grayed out.
    135 To abort the prefix key press {{{kbd(C-g)}}} (which in this case only quits the
    136 prefix key, but not the complete transient).
    137 
    138 A transient prefix command can be bound as a suffix of another
    139 transient.  Invoking such a suffix replaces the current transient
    140 state with a new transient state, i.e., the available bindings change
    141 and the information displayed in the popup buffer is updated
    142 accordingly.  Pressing {{{kbd(C-g)}}} while a nested transient is active only
    143 quits the innermost transient, causing a return to the previous
    144 transient.
    145 
    146 {{{kbd(C-q)}}} or {{{kbd(C-z)}}} on the other hand always exits all transients.  If you use
    147 the latter, then you can later resume the stack of transients using
    148 {{{kbd(M-x transient-resume)}}}.
    149 
    150 #+attr_texinfo: :compact t
    151 - Key: C-g (transient-quit-seq) ::
    152 - Key: C-g (transient-quit-one) ::
    153 
    154   This key quits the currently active incomplete key sequence, if any,
    155   or else the current transient.  When quitting the current transient,
    156   it returns to the previous transient, if any.
    157 
    158 Transient's predecessor bound {{{kbd(q)}}} instead of {{{kbd(C-g)}}} to the quit command.
    159 To learn how to get that binding back see ~transient-bind-q-to-quit~'s
    160 documentation string.
    161 
    162 - Key: C-q (transient-quit-all) ::
    163 
    164   This command quits the currently active incomplete key sequence, if
    165   any, and all transients, including the active transient and all
    166   suspended transients, if any.
    167 
    168 - Key: C-z (transient-suspend) ::
    169 
    170   Like ~transient-quit-all~, this command quits an incomplete key
    171   sequence, if any, and all transients.  Additionally, it saves the
    172   stack of transients so that it can easily be resumed (which is
    173   particularly useful if you quickly need to do “something else” and
    174   the stack is deeper than a single transient, and/or you have already
    175   changed the values of some infix arguments).
    176 
    177   Note that only a single stack of transients can be saved at a time.
    178   If another stack is already saved, then saving a new stack discards
    179   the previous stack.
    180 
    181 - Key: M-x transient-resume ::
    182 
    183   This command resumes the previously suspended stack of transients,
    184   if any.
    185 
    186 ** Common Suffix Commands
    187 #+cindex: common suffix commands
    188 
    189 A few shared suffix commands are available in all transients.  These
    190 suffix commands are not shown in the popup buffer by default.
    191 
    192 This includes the aborting commands mentioned in the previous section,
    193 as well as some other commands that are all bound to {{{kbdvar(C-x <KEY>)}}}.  After
    194 {{{kbd(C-x)}}} is pressed, a section featuring all these common commands is
    195 temporarily shown in the popup buffer.  After invoking one of them,
    196 the section disappears again.  Note, however, that one of these
    197 commands is described as “Show common permanently”; invoke that if you
    198 want the common commands to always be shown for all transients.
    199 
    200 - Key: C-x t (transient-toggle-common) ::
    201 
    202   This command toggles whether the generic commands that are common to
    203   all transients are always displayed or only after typing the
    204   incomplete prefix key sequence {{{kbd(C-x)}}}.  This only affects the current
    205   Emacs session.
    206 
    207 - User Option: transient-show-common-commands ::
    208 
    209   This option controls whether shared suffix commands are shown
    210   alongside the transient-specific infix and suffix commands.  By
    211   default, the shared commands are not shown to avoid overwhelming
    212   the user with too many options.
    213 
    214   While a transient is active, pressing {{{kbd(C-x)}}} always shows the common
    215   commands.  The value of this option can be changed for the current
    216   Emacs session by typing {{{kbd(C-x t)}}} while a transient is active.
    217 
    218 The other common commands are described in either the previous or in
    219 one of the following sections.
    220 
    221 Some of Transient's key bindings differ from the respective bindings
    222 of Magit-Popup; see [[*FAQ]] for more information.
    223 
    224 ** Saving Values
    225 #+cindex: saving values of arguments
    226 
    227 After setting the infix arguments in a transient, the user can save
    228 those arguments for future invocations.
    229 
    230 Most transients will start out with the saved arguments when they are
    231 invoked.  There are a few exceptions, though.  Some transients are
    232 designed so that the value that they use is stored externally as the
    233 buffer-local value of some variable.  Invoking such a transient again
    234 uses the buffer-local value. [fn:1]
    235 
    236 If the user does not save the value and just exits using a regular
    237 suffix command, then the value is merely saved to the transient's
    238 history.  That value won't be used when the transient is next invoked,
    239 but it is easily accessible (see [[*Using History]]).
    240 
    241 - Key: C-x s (transient-set) ::
    242 
    243   This command saves the value of the active transient for this Emacs
    244   session.
    245 
    246 - Key: C-x C-s (transient-save) ::
    247 
    248   Save the value of the active transient persistently across Emacs
    249   sessions.
    250 
    251 - Key: C-x C-k (transient-reset) ::
    252 
    253   Clear the set and saved values of the active transient.
    254 
    255 - User Option: transient-values-file ::
    256 
    257   This option names the file that is used to persist the values of
    258   transients between Emacs sessions.
    259 
    260 [fn:1] ~magit-diff~ and ~magit-log~ are two prominent examples, and their
    261 handling of buffer-local values is actually a bit more complicated
    262 than outlined above and even customizable.
    263 
    264 ** Using History
    265 #+cindex: value history
    266 
    267 Every time the user invokes a suffix command the transient's current
    268 value is saved to its history.  These values can be cycled through the
    269 same way one can cycle through the history of commands that read
    270 user-input in the minibuffer.
    271 
    272 #+attr_texinfo: :compact t
    273 - Key: C-M-p (transient-history-prev) ::
    274 - Key: C-x p ::
    275 
    276   This command switches to the previous value used for the active
    277   transient.
    278 
    279 - Key: C-M-n (transient-history-next) ::
    280 - Key: C-x n ::
    281 
    282   This command switches to the next value used for the active
    283   transient.
    284 
    285 In addition to the transient-wide history, Transient of course
    286 supports per-infix history.  When an infix reads user-input using the
    287 minibuffer, the user can use the regular minibuffer history commands
    288 to cycle through previously used values.  Usually the same keys as
    289 those mentioned above are bound to those commands.
    290 
    291 Authors of transients should arrange for different infix commands that
    292 read the same kind of value to also use the same history key (see
    293 [[*Suffix Slots]]).
    294 
    295 Both kinds of history are saved to a file when Emacs is exited.
    296 
    297 - User Option: transient-history-file ::
    298 
    299   This option names the file that is used to persist the history of
    300   transients and their infixes between Emacs sessions.
    301 
    302 - User Option: transient-history-limit ::
    303 
    304   This option controls how many history elements are kept at the time
    305   the history is saved in ~transient-history-file~.
    306 
    307 ** Getting Help for Suffix Commands
    308 #+cindex: getting help
    309 
    310 Transients can have many suffixes and infixes that the user might not
    311 be familiar with.  To make it trivial to get help for these, Transient
    312 provides access to the documentation directly from the active
    313 transient.
    314 
    315 - Key: C-h (transient-help) ::
    316 
    317   This command enters help mode.  When help mode is active, typing a
    318   key shows information about the suffix command that the key normally
    319   is bound to (instead of invoking it).  Pressing {{{kbd(C-h)}}} a second time
    320   shows information about the /prefix/ command.
    321 
    322   After typing a key, the stack of transient states is suspended and
    323   information about the suffix command is shown instead.  Typing {{{kbd(q)}}} in
    324   the help buffer buries that buffer and resumes the transient state.
    325 
    326 What sort of documentation is shown depends on how the transient was
    327 defined.  For infix commands that represent command-line arguments
    328 this ideally shows the appropriate manpage.  ~transient-help~ then tries
    329 to jump to the correct location within that.  Info manuals are also
    330 supported.  The fallback is to show the command's documentation
    331 string, for non-infix suffixes this is usually appropriate.
    332 
    333 ** Enabling and Disabling Suffixes
    334 #+cindex: enabling suffixes
    335 #+cindex: disabling suffixes
    336 
    337 The user base of a package that uses transients can be very diverse.
    338 This is certainly the case for Magit; some users have been using it and
    339 Git for a decade, while others are just getting started now.
    340 
    341 #+cindex: levels
    342 For that reason a mechanism is needed that authors can use to classify a
    343 transient's infixes and suffixes along the essentials...everything
    344 spectrum.  We use the term {{{dfn(levels)}}} to describe that mechanism.
    345 
    346 #+cindex: transient-level
    347 Each suffix command is placed on a level and each transient has a
    348 level (called {{{dfn(transient-level)}}}), which controls which suffix commands
    349 are available.  Integers between 1 and 7 (inclusive) are valid levels.
    350 For suffixes, 0 is also valid; it means that the suffix is not
    351 displayed at any level.
    352 
    353 The levels of individual transients and/or their individual suffixes
    354 can be changed interactively, by invoking the transient and then
    355 pressing {{{kbd(C-x l)}}} to enter the “edit” mode, see below.
    356 
    357 The default level for both transients and their suffixes is 4.  The
    358 ~transient-default-level~ option only controls the default for
    359 transients.  The default suffix level is always 4.  The authors of
    360 transients should place certain suffixes on a higher level, if they
    361 expect that it won't be of use to most users, and they should place
    362 very important suffixes on a lower level, so that they remain
    363 available even if the user lowers the transient level.
    364 
    365 - User Option: transient-default-level ::
    366 
    367   This option controls which suffix levels are made available by
    368   default.  It sets the transient-level for transients for which the
    369   user has not set that individually.
    370 
    371 - User Option: transient-levels-file ::
    372 
    373   This option names the file that is used to persist the levels of
    374   transients and their suffixes between Emacs sessions.
    375 
    376 - Key: C-x l (transient-set-level) ::
    377 
    378   This command enters edit mode.  When edit mode is active, then all
    379   infixes and suffixes that are currently usable are displayed along
    380   with their levels.  The colors of the levels indicate whether they
    381   are enabled or not.  The level of the transient is also displayed
    382   along with some usage information.
    383 
    384   In edit mode, pressing the key that would usually invoke a certain
    385   suffix instead prompts the user for the level that suffix should be
    386   placed on.
    387 
    388   Help mode is available in edit mode.
    389 
    390   To change the transient level press {{{kbd(C-x l)}}} again.
    391 
    392   To exit edit mode press {{{kbd(C-g)}}}.
    393 
    394   Note that edit mode does not display any suffixes that are not
    395   currently usable.  ~magit-rebase~, for example, shows different
    396   suffixes depending on whether a rebase is already in progress or
    397   not.  The predicates also apply in edit mode.
    398 
    399   Therefore, to control which suffixes are available given a certain
    400   state, you have to make sure that that state is currently active.
    401 
    402 - Key: C-x a (transient-toggle-level-limit) ::
    403 
    404   This command toggle whether suffixes that are on levels higher than
    405   the level specified by ~transient-default-level~ are temporarily
    406   available anyway.
    407 
    408 ** Other Commands
    409 
    410 When invoking a transient in a small frame, the transient window may
    411 not show the complete buffer, making it necessary to scroll, using the
    412 following commands.  These commands are never shown in the transient
    413 window, and the key bindings are the same as for ~scroll-up-command~ and
    414 ~scroll-down-command~ in other buffers.
    415 
    416 - Command: transient-scroll-up arg ::
    417 
    418   This command scrolls text of transient popup window upward {{{var(ARG)}}}
    419   lines.  If {{{var(ARG)}}} is ~nil~, then it scrolls near full screen.  This
    420   is a wrapper around ~scroll-up-command~ (which see).
    421 
    422 - Command: transient-scroll-down arg ::
    423 
    424   This command scrolls text of transient popup window down {{{var(ARG)}}}
    425   lines.  If {{{var(ARG)}}} is ~nil~, then it scrolls near full screen.  This
    426   is a wrapper around ~scroll-down-command~ (which see).
    427 
    428 ** Configuration
    429 
    430 More options are described in [[* Common Suffix Commands]], in [[* Saving
    431 Values]], in [[* Using History]] and in [[* Enabling and Disabling Suffixes]].
    432 
    433 *** Essential Options
    434 :PROPERTIES:
    435 :UNNUMBERED: notoc
    436 :END:
    437 
    438 Also see [[* Common Suffix Commands]].
    439 
    440 - User Option: transient-show-popup ::
    441 
    442   This option controls whether the current transient's infix and
    443   suffix commands are shown in the popup buffer.
    444 
    445   - If ~t~ (the default) then the popup buffer is shown as soon as a
    446     transient prefix command is invoked.
    447 
    448   - If ~nil~, then the popup buffer is not shown unless the user
    449     explicitly requests it, by pressing an incomplete prefix key
    450     sequence.
    451 
    452   - If a number, then the a brief one-line summary is shown instead of
    453     the popup buffer.  If zero or negative, then not even that summary
    454     is shown; only the pressed key itself is shown.
    455 
    456     The popup is shown when the user explicitly requests it by
    457     pressing an incomplete prefix key sequence.  Unless this is zero,
    458     the popup is shown after that many seconds of inactivity (using
    459     the absolute value).
    460 
    461 - User Option: transient-enable-popup-navigation ::
    462 
    463   This option controls whether navigation commands are enabled in the
    464   transient popup buffer.
    465 
    466   While a transient is active the transient popup buffer is not the
    467   current buffer, making it necessary to use dedicated commands to act
    468   on that buffer itself.  This is disabled by default.  If this option
    469   is non-~nil~, then the following features are available:
    470 
    471   - {{{kbd(UP)}}} moves the cursor to the previous suffix.
    472   - {{{kbd(DOWN)}}} moves the cursor to the next suffix.
    473   - {{{kbd(RET)}}} invokes the suffix the cursor is on.
    474   - {{{kbd(mouse-1)}}} invokes the clicked on suffix.
    475   - {{{kbd(C-s)}}} and {{{kbd(C-r)}}} start isearch in the popup buffer.
    476 
    477 - User Option: transient-display-buffer-action ::
    478 
    479   This option specifies the action used to display the transient popup
    480   buffer.  The transient popup buffer is displayed in a window using
    481   {{{codevar((display-buffer BUFFER transient-display-buffer-action))}}}.
    482 
    483   The value of this option has the form {{{codevar((FUNCTION . ALIST))}}},
    484   where {{{var(FUNCTION)}}} is a function or a list of functions.  Each such
    485   function should accept two arguments: a buffer to display and an
    486   alist of the same form as {{{var(ALIST)}}}.  See [[info:elisp#Choosing Window]],
    487   for details.
    488 
    489   The default is:
    490 
    491   #+BEGIN_SRC emacs-lisp
    492     (display-buffer-in-side-window
    493       (side . bottom)
    494       (inhibit-same-window . t)
    495       (window-parameters (no-other-window . t)))
    496   #+END_SRC
    497 
    498   This displays the window at the bottom of the selected frame.
    499   Another useful {{{var(FUNCTION)}}} is ~display-buffer-below-selected~, which
    500   is what ~magit-popup~ used by default.  For more alternatives see
    501   [[info:elisp#Buffer Display Action Functions]], and [[info:elisp#Buffer
    502   Display Action Alists]].
    503 
    504   Note that the buffer that was current before the transient buffer
    505   is shown should remain the current buffer.  Many suffix commands
    506   act on the thing at point, if appropriate, and if the transient
    507   buffer became the current buffer, then that would change what is
    508   at point.  To that effect ~inhibit-same-window~ ensures that the
    509   selected window is not used to show the transient buffer.
    510 
    511   It may be possible to display the window in another frame, but
    512   whether that works in practice depends on the window-manager.
    513   If the window manager selects the new window (Emacs frame),
    514   then that unfortunately changes which buffer is current.
    515 
    516   If you change the value of this option, then you might also
    517   want to change the value of ~transient-mode-line-format~.
    518 
    519 *** Accessibility Options
    520 :PROPERTIES:
    521 :UNNUMBERED: notoc
    522 :END:
    523 
    524 - User Option: transient-force-single-column ::
    525 
    526   This option controls whether the use of a single column to display
    527   suffixes is enforced.  This might be useful for users with low
    528   vision who use large text and might otherwise have to scroll in two
    529   dimensions.
    530 
    531 *** Auxiliary Options
    532 :PROPERTIES:
    533 :UNNUMBERED: notoc
    534 :END:
    535 
    536 - User Option: transient-mode-line-format ::
    537 
    538   This option controls whether the transient popup buffer has a
    539   mode-line, separator line, or neither.
    540 
    541   If ~nil~, then the buffer has no mode-line.  If the buffer is not
    542   displayed right above the echo area, then this probably is not a
    543   good value.
    544 
    545   If ~line~ (the default) or a natural number, then the buffer
    546   has no mode-line, but a line is drawn is drawn in its place.
    547   If a number is used, that specifies the thickness of the line.
    548   On termcap frames we cannot draw lines, so there ~line~ and
    549   numbers are synonyms for ~nil~.
    550 
    551   The color of the line is used to indicate if non-suffixes are
    552   allowed and whether they exit the transient.  The foreground
    553   color of ~transient-key-noop~ (if non-suffix are disallowed),
    554   ~transient-key-stay~ (if allowed and transient stays active), or
    555   ~transient-key-exit~ (if allowed and they exit the transient) is
    556   used to draw the line.
    557 
    558   Otherwise this can be any mode-line format.  See [[info:elisp#Mode
    559   Line Format]], for details.
    560 
    561 - User Option: transient-semantic-coloring ::
    562 
    563   This option controls whether colors are used to indicate the
    564   transient behavior of commands.
    565 
    566   If non-~nil~, then the key binding of each suffix is colorized to
    567   indicate whether it exits the transient state or not.  The color of
    568   the prefix is indicated using the line that is drawn when the value
    569   of ~transient-mode-line-format~ is ~line~.
    570 
    571 - User Option: transient-highlight-mismatched-keys ::
    572 
    573   This option controls whether key bindings of infix commands that do
    574   not match the respective command-line argument should be highlighted.
    575   For other infix commands this option has no effect.
    576 
    577   When this option is non-~nil~, the key binding for an infix argument
    578   is highlighted when only a long argument (e.g., ~--verbose~) is
    579   specified but no shorthand (e.g., ~-v~).  In the rare case that a
    580   shorthand is specified but the key binding does not match, then it
    581   is highlighted differently.
    582 
    583   Highlighting mismatched key bindings is useful when learning the
    584   arguments of the underlying command-line tool; you wouldn't want to
    585   learn any short-hands that do not actually exist.
    586 
    587   The highlighting is done using one of the faces
    588   ~transient-mismatched-key~ and ~transient-nonstandard-key~.
    589 
    590 - User Option: transient-substitute-key-function ::
    591 
    592   This function is used to modify key bindings.  If the value of this
    593   option is ~nil~ (the default), then no substitution is performed.
    594 
    595   This function is called with one argument, the prefix object, and
    596   must return a key binding description, either the existing key
    597   description it finds in the ~key~ slot, or the key description that
    598   replaces the prefix key.  It could be used to make other
    599   substitutions, but that is discouraged.
    600 
    601   For example, {{{kbd(=)}}} is hard to reach using my custom keyboard layout,
    602   so I substitute {{{kbd(()}}} for that, which is easy to reach using a layout
    603   optimized for lisp.
    604 
    605   #+BEGIN_SRC emacs-lisp
    606     (setq transient-substitute-key-function
    607           (lambda (obj)
    608             (let ((key (oref obj key)))
    609               (if (string-match "\\`\\(=\\)[a-zA-Z]" key)
    610                   (replace-match "(" t t key 1)
    611                 key))))
    612   #+END_SRC
    613 
    614 - User Option: transient-read-with-initial-input ::
    615 
    616   This option controls whether the last history element is used as the
    617   initial minibuffer input when reading the value of an infix argument
    618   from the user.  If ~nil~, there is no initial input and the first
    619   element has to be accessed the same way as the older elements.
    620 
    621 - User Option: transient-hide-during-minibuffer-read ::
    622 
    623   This option controls whether the transient buffer is hidden while
    624   user input is being read in the minibuffer.
    625 
    626 - User Option: transient-align-variable-pitch ::
    627 
    628   This option controls whether columns are aligned pixel-wise in the
    629   popup buffer.
    630 
    631   If this is non-~nil~, then columns are aligned pixel-wise to support
    632   variable-pitch fonts.  Keys are not aligned, so you should use a
    633   fixed-pitch font for the ~transient-key~ face.  Other key faces
    634   inherit from that face unless a theme is used that breaks that
    635   relationship.
    636 
    637   This option is intended for users who use a variable-pitch font for
    638   the ~default~ face.
    639 
    640 - User Option: transient-force-fixed-pitch ::
    641 
    642   This option controls whether to force the use of a monospaced font
    643   in popup buffer.  Even if you use a proportional font for the
    644   ~default~ face, you might still want to use a monospaced font in
    645   transient's popup buffer.  Setting this option to ~t~ causes ~default~
    646   to be remapped to ~fixed-pitch~ in that buffer.
    647 
    648 *** Developer Options
    649 :PROPERTIES:
    650 :UNNUMBERED: notoc
    651 :END:
    652 
    653 These options are mainly intended for developers.
    654 
    655 - User Option: transient-detect-key-conflicts ::
    656 
    657   This option controls whether key binding conflicts should be
    658   detected at the time the transient is invoked.  If so, this results
    659   in an error, which prevents the transient from being used.  Because
    660   of that, conflicts are ignored by default.
    661 
    662   Conflicts cannot be determined earlier, i.e., when the transient is
    663   being defined and when new suffixes are being added, because at that
    664   time there can be false-positives.  It is actually valid for
    665   multiple suffixes to share a common key binding, provided the
    666   predicates of those suffixes prevent that more than one of them is
    667   enabled at a time.
    668 
    669 - User Option: transient-highlight-higher-levels ::
    670 
    671   This option controls whether suffixes that would not be available by
    672   default are highlighted.
    673 
    674   When non-~nil~ then the descriptions of suffixes are highlighted if
    675   their level is above 4, the default of ~transient-default-level~.
    676   Assuming you have set that variable to 7, this highlights all
    677   suffixes that won't be available to users without them making the
    678   same customization.
    679 
    680 * Modifying Existing Transients
    681 #+cindex: modifying existing transients
    682 
    683 To an extent, transients can be customized interactively, see
    684 [[*Enabling and Disabling Suffixes]].  This section explains how existing
    685 transients can be further modified non-interactively.  Let's begin
    686 with an example:
    687 
    688 #+begin_src emacs-lisp
    689   (transient-append-suffix 'magit-patch-apply "-3"
    690     '("-R" "Apply in reverse" "--reverse"))
    691 #+end_src
    692 
    693 This inserts a new infix argument to toggle the ~--reverse~ argument
    694 after the infix argument that toggles ~-3~ in ~magit-patch-apply~.
    695 
    696 The following functions share a few arguments:
    697 
    698 - {{{var(PREFIX)}}} is a transient prefix command, a symbol.
    699 
    700 - {{{var(SUFFIX)}}} is a transient infix or suffix specification in the same form
    701   as expected by ~transient-define-prefix~.  Note that an infix is a
    702   special kind of suffix.  Depending on context “suffixes” means
    703   “suffixes (including infixes)” or “non-infix suffixes”.  Here it
    704   means the former.  See [[*Suffix Specifications]].
    705 
    706   {{{var(SUFFIX)}}} may also be a group in the same form as expected by
    707   ~transient-define-prefix~.  See [[*Group Specifications]].
    708 
    709 - {{{var(LOC)}}} is a command, a key vector, a key description (a string as
    710   returned by ~key-description~), or a list specifying coordinates (the
    711   last element may also be a command or key).  For example ~(1 0 -1)~
    712   identifies the last suffix (~-1~) of the first subgroup (~0~) of the
    713   second group (~1~).
    714 
    715   If {{{var(LOC)}}} is a list of coordinates, then it can be used to identify a
    716   group, not just an individual suffix command.
    717 
    718   The function ~transient-get-suffix~ can be useful to determine whether
    719   a certain coordination list identifies the suffix or group that you
    720   expect it to identify.  In hairy cases it may be necessary to look
    721   at the definition of the transient prefix command.
    722 
    723 These functions operate on the information stored in the
    724 ~transient--layout~ property of the {{{var(PREFIX)}}} symbol.  Suffix entries in
    725 that tree are not objects but have the form {{{codevar((LEVEL CLASS PLIST))}}}, where
    726 {{{var(PLIST)}}} should set at least ~:key~, ~:description~ and ~:command~.
    727 
    728 - Function: transient-insert-suffix prefix loc suffix &optional keep-other ::
    729 - Function: transient-append-suffix prefix loc suffix &optional keep-other ::
    730 
    731   These functions insert the suffix or group {{{var(SUFFIX)}}} into {{{var(PREFIX)}}} before
    732   or after {{{var(LOC)}}}.
    733 
    734   Conceptually adding a binding to a transient prefix is similar to
    735   adding a binding to a keymap, but this is complicated by the fact
    736   that multiple suffix commands can be bound to the same key, provided
    737   they are never active at the same time, see [[*Predicate Slots]].
    738 
    739   Unfortunately both false-positives and false-negatives are possible.
    740   To deal with the former use non-~nil~ {{{var(KEEP-OTHER.)}}}  To deal with the
    741   latter remove the conflicting binding explicitly.
    742 
    743 - Function: transient-replace-suffix prefix loc suffix ::
    744 
    745   This function replaces the suffix or group at {{{var(LOC)}}} in {{{var(PREFIX)}}} with
    746   suffix or group {{{var(SUFFIX)}}}.
    747 
    748 - Function: transient-remove-suffix prefix loc ::
    749 
    750   This function removes the suffix or group at {{{var(LOC)}}} in {{{var(PREFIX)}}}.
    751 
    752 - Function: transient-get-suffix prefix loc ::
    753 
    754   This function returns the suffix or group at {{{var(LOC)}}} in {{{var(PREFIX)}}}.  The
    755   returned value has the form mentioned above.
    756 
    757 - Function: transient-suffix-put prefix loc prop value ::
    758 
    759   This function edits the suffix or group at {{{var(LOC)}}} in {{{var(PREFIX)}}}, by setting
    760   the {{{var(PROP)}}} of its plist to {{{var(VALUE)}}}.
    761 
    762 Most of these functions do not signal an error if they cannot perform
    763 the requested modification.  The functions that insert new suffixes
    764 show a warning if {{{var(LOC)}}} cannot be found in {{{var(PREFIX,)}}} without signaling an
    765 error.  The reason for doing it like this is that establishing a key
    766 binding (and that is what we essentially are trying to do here) should
    767 not prevent the rest of the configuration from loading.  Among these
    768 functions only ~transient-get-suffix~ and ~transient-suffix-put~ may
    769 signal an error.
    770 
    771 * Defining New Commands
    772 ** Technical Introduction
    773 
    774 Taking inspiration from prefix keys and prefix arguments, Transient
    775 implements a similar abstraction involving a prefix command, infix
    776 arguments and suffix commands.
    777 
    778 When the user calls a transient prefix command, a transient
    779 (temporary) keymap is activated, which binds the transient's infix and
    780 suffix commands, and functions that control the transient state are
    781 added to ~pre-command-hook~ and ~post-command-hook~.  The available suffix
    782 and infix commands and their state are shown in a popup buffer until
    783 the transient state is exited by invoking a suffix command.
    784 
    785 Calling an infix command causes its value to be changed.  How that is
    786 done depends on the type of the infix command.  The simplest case is
    787 an infix command that represents a command-line argument that does not
    788 take a value.  Invoking such an infix command causes the switch to be
    789 toggled on or off.  More complex infix commands may read a value from
    790 the user, using the minibuffer.
    791 
    792 Calling a suffix command usually causes the transient to be exited;
    793 the transient keymaps and hook functions are removed, the popup buffer
    794 no longer shows information about the (no longer bound) suffix
    795 commands, the values of some public global variables are set, while
    796 some internal global variables are unset, and finally the command is
    797 actually called.  Suffix commands can also be configured to not exit
    798 the transient.
    799 
    800 A suffix command can, but does not have to, use the infix arguments in
    801 much the same way any command can choose to use or ignore the prefix
    802 arguments.  For a suffix command that was invoked from a transient, the
    803 variable ~transient-current-suffixes~ and the function ~transient-args~
    804 serve about the same purpose as the variables ~prefix-arg~ and
    805 ~current-prefix-arg~ do for any command that was called after the prefix
    806 arguments have been set using a command such as ~universal-argument~.
    807 
    808 #+cindex: command dispatchers
    809 Transient can be used to implement simple “command dispatchers”.  The
    810 main benefit then is that the user can see all the available commands
    811 in a popup buffer, which can be thought of as a “menus”.  That is
    812 useful by itself because it frees the user from having to remember all
    813 the keys that are valid after a certain prefix key or command.
    814 Magit's ~magit-dispatch~ (on {{{kbd(C-x M-g)}}}) command is an example of using
    815 Transient to merely implement a command dispatcher.
    816 
    817 In addition to that, Transient also allows users to interactively pass
    818 arguments to commands.  These arguments can be much more complex than
    819 what is reasonable when using prefix arguments.  There is a limit to
    820 how many aspects of a command can be controlled using prefix
    821 arguments.  Furthermore, what a certain prefix argument means for
    822 different commands can be completely different, and users have to read
    823 documentation to learn and then commit to memory what a certain prefix
    824 argument means to a certain command.
    825 
    826 Transient suffix commands, on the other hand, can accept dozens of
    827 different arguments without the user having to remember anything.
    828 When using Transient, one can call a command with arguments that are
    829 just as complex as when calling the same function non-interactively
    830 from Lisp.
    831 
    832 Invoking a transient suffix command with arguments is similar to
    833 invoking a command in a shell with command-line completion and history
    834 enabled.  One benefit of the Transient interface is that it remembers
    835 history not only on a global level (“this command was invoked using
    836 these arguments, and previously it was invoked using those other
    837 arguments”), but also remembers the values of individual arguments
    838 independently.  See [[*Using History]].
    839 
    840 After a transient prefix command is invoked, {{{kbdvar(C-h <KEY>)}}} can be used to
    841 show the documentation for the infix or suffix command that {{{kbdvar(<KEY>)}}} is
    842 bound to (see [[*Getting Help for Suffix Commands]]), and infixes and
    843 suffixes can be removed from the transient using {{{kbdvar(C-x l <KEY>)}}}. Infixes
    844 and suffixes that are disabled by default can be enabled the same way.
    845 See [[*Enabling and Disabling Suffixes]].
    846 
    847 Transient ships with support for a few different types of specialized
    848 infix commands.  A command that sets a command line option, for example,
    849 has different needs than a command that merely toggles a boolean flag.
    850 Additionally, Transient provides abstractions for defining new types,
    851 which the author of Transient did not anticipate (or didn't get around
    852 to implementing yet).
    853 
    854 Note that suffix commands also support regular prefix arguments.  A
    855 suffix command may even be called with both infix and prefix arguments
    856 at the same time.  If you invoke a command as a suffix of a transient
    857 prefix command, but also want to pass prefix arguments to it, then
    858 first invoke the prefix command, and only after doing that invoke the
    859 prefix arguments, before finally invoking the suffix command.  If you
    860 instead began by providing the prefix arguments, then those would
    861 apply to the prefix command, not the suffix command.  Likewise, if you
    862 want to change infix arguments before invoking a suffix command with
    863 prefix arguments, then change the infix arguments before invoking the
    864 prefix arguments.  In other words, regular prefix arguments always
    865 apply to the next command, and since transient prefix, infix and
    866 suffix commands are just regular commands, the same applies to them.
    867 (Regular prefix keys behave differently because they are not commands
    868 at all, instead they are just incomplete key sequences, and those
    869 cannot be interrupted with prefix commands.)
    870 
    871 ** Defining Transients
    872 
    873 A transient consists of a prefix command and at least one suffix
    874 command, though usually a transient has several infix and suffix
    875 commands.  The below macro defines the transient prefix command *and*
    876 binds the transient's infix and suffix commands.  In other words, it
    877 defines the complete transient, not just the transient prefix command
    878 that is used to invoke that transient.
    879 
    880 - Macro: transient-define-prefix name arglist [docstring] [keyword value]... group... [body...] ::
    881 
    882   This macro defines {{{var(NAME)}}} as a transient prefix command and binds the
    883   transient's infix and suffix commands.
    884 
    885   {{{var(ARGLIST)}}} are the arguments that the prefix command takes.
    886   {{{var(DOCSTRING)}}} is the documentation string and is optional.
    887 
    888   These arguments can optionally be followed by keyword-value pairs.
    889   Each key has to be a keyword symbol, either ~:class~ or a keyword
    890   argument supported by the constructor of that class.  The
    891   ~transient-prefix~ class is used if the class is not specified
    892   explicitly.
    893 
    894   {{{var(GROUP)}}}s add key bindings for infix and suffix commands and specify
    895   how these bindings are presented in the popup buffer.  At least one
    896   {{{var(GROUP)}}} has to be specified.  See [[*Binding Suffix and Infix Commands]].
    897 
    898   The {{{var(BODY)}}} is optional.  If it is omitted, then {{{var(ARGLIST)}}} is ignored and
    899   the function definition becomes:
    900 
    901   #+BEGIN_SRC emacs-lisp
    902     (lambda ()
    903       (interactive)
    904       (transient-setup 'NAME))
    905   #+END_SRC
    906 
    907   If {{{var(BODY)}}} is specified, then it must begin with an ~interactive~ form
    908   that matches {{{var(ARGLIST)}}}, and it must call ~transient-setup~.  It may,
    909   however, call that function only when some condition is satisfied.
    910 
    911   #+cindex: scope of a transient
    912   All transients have a (possibly ~nil~) value, which is exported when
    913   suffix commands are called, so that they can consume that value.
    914   For some transients it might be necessary to have a sort of
    915   secondary value, called a “scope”.  Such a scope would usually be
    916   set in the command's ~interactive~ form and has to be passed to the
    917   setup function:
    918 
    919   #+BEGIN_SRC emacs-lisp
    920     (transient-setup 'NAME nil nil :scope SCOPE)
    921   #+END_SRC
    922 
    923   For example, the scope of the ~magit-branch-configure~ transient is
    924   the branch whose variables are being configured.
    925 
    926 ** Binding Suffix and Infix Commands
    927 
    928 The macro ~transient-define-prefix~ is used to define a transient.
    929 This defines the actual transient prefix command (see [[*Defining
    930 Transients]]) and adds the transient's infix and suffix bindings, as
    931 described below.
    932 
    933 Users and third-party packages can add additional bindings using
    934 functions such as ~transient-insert-suffix~ (see [[*Modifying Existing
    935 Transients]]).  These functions take a “suffix specification” as one of
    936 their arguments, which has the same form as the specifications used in
    937 ~transient-define-prefix~.
    938 
    939 *** Group Specifications
    940 #+cindex: group specifications
    941 
    942 The suffix and infix commands of a transient are organized in groups.
    943 The grouping controls how the descriptions of the suffixes are
    944 outlined visually but also makes it possible to set certain properties
    945 for a set of suffixes.
    946 
    947 Several group classes exist, some of which organize suffixes in
    948 subgroups.  In most cases the class does not have to be specified
    949 explicitly, but see [[*Group Classes]].
    950 
    951 Groups are specified in the call to ~transient-define-prefix~, using
    952 vectors.  Because groups are represented using vectors, we cannot use
    953 square brackets to indicate an optional element and instead use curly
    954 brackets to do the latter.
    955 
    956 Group specifications then have this form:
    957 
    958 #+begin_src emacs-lisp
    959   [{LEVEL} {DESCRIPTION} {KEYWORD VALUE}... ELEMENT...]
    960 #+end_src
    961 
    962 The {{{var(LEVEL)}}} is optional and defaults to 4.  See [[*Enabling and Disabling
    963 Suffixes]].
    964 
    965 The {{{var(DESCRIPTION)}}} is optional.  If present, it is used as the heading of
    966 the group.
    967 
    968 The {{{var(KEYWORD)}}}-{{{var(VALUE)}}} pairs are optional.  Each keyword has to be a
    969 keyword symbol, either ~:class~ or a keyword argument supported by the
    970 constructor of that class.
    971 
    972 - One of these keywords, ~:description~, is equivalent to specifying
    973   {{{var(DESCRIPTION)}}} at the very beginning of the vector.  The recommendation
    974   is to use ~:description~ if some other keyword is also used, for
    975   consistency, or {{{var(DESCRIPTION)}}} otherwise, because it looks better.
    976 
    977 - Likewise ~:level~ is equivalent to {{{var(LEVEL)}}}.
    978 
    979 - Other important keywords include the ~:if...~ keywords.  These
    980   keywords control whether the group is available in a certain
    981   situation.
    982 
    983   For example, one group of the ~magit-rebase~ transient uses ~:if
    984   magit-rebase-in-progress-p~, which contains the suffixes that are
    985   useful while rebase is already in progress; and another that uses
    986   ~:if-not magit-rebase-in-progress-p~, which contains the suffixes that
    987   initiate a rebase.
    988 
    989   These predicates can also be used on individual suffixes and are
    990   only documented once, see [[*Predicate Slots]].
    991 
    992 - The value of ~:hide~, if non-~nil~, is a predicate that controls
    993   whether the group is hidden by default.  The key bindings for
    994   suffixes of a hidden group should all use the same prefix key.
    995   Pressing that prefix key should temporarily show the group and its
    996   suffixes, which assumes that a predicate like this is used:
    997 
    998   #+BEGIN_SRC emacs-lisp
    999     (lambda ()
   1000       (eq (car transient--redisplay-key)
   1001           ?\C-c)) ; the prefix key shared by all bindings
   1002   #+END_SRC
   1003 
   1004 - The value of ~:setup-children~, if non-~nil~, is a function that takes
   1005   one argument, a potentially list of children, and must return a list
   1006   of children or an empty list.  This can either be used to somehow
   1007   transform the group's children that were defined the normal way, or
   1008   to dynamically create the children from scratch.
   1009 
   1010   The returned children must have the same form as stored in the
   1011   prefix's ~transient--layout~ property, but it is often more convenient
   1012   to use the same form as understood by ~transient-define-prefix~,
   1013   described below.  If you use the latter approach, you can use the
   1014   ~transient-parse-suffixes~ and ~transient-parse-suffix~ functions to
   1015   transform them from the convenient to the expected form.
   1016 
   1017   If you explicitly specify children and then transform them using
   1018   ~:setup-chilren~, then the class of the group is determined as usual,
   1019   based on explicitly specified children.
   1020 
   1021   If you do not explicitly specify children and thus rely solely on
   1022   ~:setup-children~, then you must specify the class using ~:class~.
   1023   For backward compatibility, if you fail to do so, ~transient-column~
   1024   is used and a warning is displayed.  This warning will eventually
   1025   be replaced with an error.
   1026 
   1027 - The boolean ~:pad-keys~ argument controls whether keys of all suffixes
   1028   contained in a group are right padded, effectively aligning the
   1029   descriptions.
   1030 
   1031 The {{{var(ELEMENT)}}}s are either all subgroups, or all suffixes and strings.
   1032 (At least currently no group type exists that would allow mixing
   1033 subgroups with commands at the same level, though in principle there
   1034 is nothing that prevents that.)
   1035 
   1036 If the {{{var(ELEMENT)}}}s are not subgroups, then they can be a mixture of
   1037 lists, which specify commands, and strings.  Strings are inserted
   1038 verbatim into the buffer.  The empty string can be used to insert gaps
   1039 between suffixes, which is particularly useful if the suffixes are
   1040 outlined as a table.
   1041 
   1042 Inside group specifications, including inside contained suffix
   1043 specifications, nothing has to be quoted and quoting anyway is
   1044 invalid.  The value following a keyword, can be explicitly unquoted
   1045 using ~,~.  This feature is experimental and should be avoided.
   1046 
   1047 The form of suffix specifications is documented in the next node.
   1048 
   1049 *** Suffix Specifications
   1050 #+cindex: suffix specifications
   1051 
   1052 A transient's suffix and infix commands are bound when the transient
   1053 prefix command is defined using ~transient-define-prefix~, see
   1054 [[*Defining Transients]].  The commands are organized into groups, see
   1055 [[*Group Specifications]].  Here we describe the form used to bind an
   1056 individual suffix command.
   1057 
   1058 The same form is also used when later binding additional commands
   1059 using functions such as ~transient-insert-suffix~, see [[*Modifying
   1060 Existing Transients]].
   1061 
   1062 Note that an infix is a special kind of suffix. Depending on context
   1063 “suffixes” means “suffixes (including infixes)” or “non-infix
   1064 suffixes”.  Here it means the former.
   1065 
   1066 Suffix specifications have this form:
   1067 
   1068 #+begin_src emacs-lisp
   1069   ([LEVEL] [KEY [DESCRIPTION]] COMMAND|ARGUMENT [KEYWORD VALUE]...)
   1070 #+end_src
   1071 
   1072 {{{var(LEVEL)}}}, {{{var(KEY)}}} and {{{var(DESCRIPTION)}}} can also be specified using the {{{var(KEYWORD)}}}s
   1073 ~:level~, ~:key~ and ~:description~.  If the object that is associated with
   1074 {{{var(COMMAND)}}} sets these properties, then they do not have to be specified
   1075 here.  You can however specify them here anyway, possibly overriding
   1076 the object's values just for the binding inside this transient.
   1077 
   1078 - {{{var(LEVEL)}}} is the suffix level, an integer between 1 and 7.  See
   1079   [[*Enabling and Disabling Suffixes]].
   1080 
   1081 - {{{var(KEY)}}} is the key binding, either a vector or key description string.
   1082 
   1083 - {{{var(DESCRIPTION)}}} is the description, either a string or a function that
   1084   takes zero or one arguments (the suffix object) and returns a string.
   1085   The function should be a lambda expression to avoid ambiguity.  In
   1086   some cases a symbol that is bound as a function would also work but
   1087   to be safe you should use ~:description~ in that case.
   1088 
   1089 The next element is either a command or an argument.  This is the only
   1090 argument that is mandatory in all cases.
   1091 
   1092 - {{{var(COMMAND)}}} should be a symbol that is bound as a function, which has
   1093   to be defined or at least autoloaded as a command by the time the
   1094   containing prefix command is invoked.
   1095 
   1096   Any command will do; it does not need to have an object associated
   1097   with it (as would be the case if ~transient-define-suffix~ or
   1098   ~transient-define-infix~ were used to define it).
   1099 
   1100   COMMAND can also be a ~lambda~ expression.
   1101 
   1102   As mentioned above, the object that is associated with a command can
   1103   be used to set the default for certain values that otherwise have to
   1104   be set in the suffix specification.  Therefore if there is no object,
   1105   then you have to make sure to specify the {{{var(KEY)}}} and the {{{var(DESCRIPTION)}}}.
   1106 
   1107   As a special case, if you want to add a command that might be neither
   1108   defined nor autoloaded, you can use a workaround like:
   1109 
   1110   #+BEGIN_SRC emacs-lisp
   1111     (transient-insert-suffix 'some-prefix "k"
   1112       '("!" "Ceci n'est pas une commande" no-command
   1113         :if (lambda () (featurep 'no-library))))
   1114   #+END_SRC
   1115 
   1116   Instead of ~featurep~ you could also use ~require~ with a non-~nil~ value
   1117   for {{{var(NOERROR)}}}.
   1118 
   1119 - The mandatory argument can also be a command-line argument, a
   1120   string.  In that case an anonymous command is defined and bound.
   1121 
   1122   Instead of a string, this can also be a list of two strings, in
   1123   which case the first string is used as the short argument (which can
   1124   also be specified using ~:shortarg~) and the second as the long argument
   1125   (which can also be specified using ~:argument~).
   1126 
   1127   Only the long argument is displayed in the popup buffer.  See
   1128   ~transient-detect-key-conflicts~ for how the short argument may be
   1129   used.
   1130 
   1131   Unless the class is specified explicitly, the appropriate class is
   1132   guessed based on the long argument.  If the argument ends with ===
   1133   (e.g., =--format==) then ~transient-option~ is used, otherwise
   1134   ~transient-switch~.
   1135 
   1136 Finally, details can be specified using optional {{{var(KEYWORD)}}}-{{{var(VALUE)}}} pairs.
   1137 Each keyword has to be a keyword symbol, either ~:class~ or a keyword
   1138 argument supported by the constructor of that class.  See [[*Suffix
   1139 Slots]].
   1140 
   1141 ** Defining Suffix and Infix Commands
   1142 #+cindex: defining suffix commands
   1143 #+cindex: defining infix commands
   1144 
   1145 Note that an infix is a special kind of suffix. Depending on context
   1146 “suffixes” means “suffixes (including infixes)” or “non-infix
   1147 suffixes”.
   1148 
   1149 - Macro: transient-define-suffix name arglist [docstring] [keyword value]... body... ::
   1150 
   1151   This macro defines {{{var(NAME)}}} as a transient suffix command.
   1152 
   1153   {{{var(ARGLIST)}}} are the arguments that the command takes.
   1154   {{{var(DOCSTRING)}}} is the documentation string and is optional.
   1155 
   1156   These arguments can optionally be followed by keyword-value pairs.
   1157   Each keyword has to be a keyword symbol, either ~:class~ or a keyword
   1158   argument supported by the constructor of that class.  The
   1159   ~transient-suffix~ class is used if the class is not specified
   1160   explicitly.
   1161 
   1162   The {{{var(BODY)}}} must begin with an ~interactive~ form that matches {{{var(ARGLIST)}}}.
   1163   The infix arguments are usually accessed by using ~transient-args~
   1164   inside ~interactive~.
   1165 
   1166 - Macro: transient-define-infix name arglist [docstring] [keyword value]... ::
   1167 
   1168   This macro defines {{{var(NAME)}}} as a transient infix command.
   1169 
   1170   {{{var(ARGLIST)}}} is always ignored (but mandatory never-the-less) and
   1171   reserved for future use.  {{{var(DOCSTRING)}}} is the documentation string and
   1172   is optional.
   1173 
   1174   The keyword-value pairs are mandatory.  All transient infix commands
   1175   are ~equal~ to each other (but not ~eq~), so it is meaningless to define
   1176   an infix command without also setting at least ~:class~ and one other
   1177   keyword (which it is depends on the used class, usually ~:argument~ or
   1178   ~:variable~).
   1179 
   1180   Each keyword has to be a keyword symbol, either ~:class~ or a keyword
   1181   argument supported by the constructor of that class.  The
   1182   ~transient-switch~ class is used if the class is not specified
   1183   explicitly.
   1184 
   1185   The function definition is always:
   1186 
   1187   #+BEGIN_SRC emacs-lisp
   1188     (lambda ()
   1189       (interactive)
   1190       (let ((obj (transient-suffix-object)))
   1191         (transient-infix-set obj (transient-infix-read obj)))
   1192       (transient--show))
   1193   #+END_SRC
   1194 
   1195   ~transient-infix-read~ and ~transient-infix-set~ are generic functions.
   1196   Different infix commands behave differently because the concrete
   1197   methods are different for different infix command classes.  In rare
   1198   cases the above command function might not be suitable, even if you
   1199   define your own infix command class.  In that case you have to use
   1200   ~transient-define-suffix~ to define the infix command and use ~t~ as the
   1201   value of the ~:transient~ keyword.
   1202 
   1203 - Macro: transient-define-argument name arglist [docstring] [keyword value]... ::
   1204 
   1205   This macro defines {{{var(NAME)}}} as a transient infix command.
   1206 
   1207   This is an alias for ~transient-define-infix~.  Only use this alias
   1208   to define an infix command that actually sets an infix argument.
   1209   To define an infix command that, for example, sets a variable, use
   1210   ~transient-define-infix~ instead.
   1211 
   1212 ** Using Infix Arguments
   1213 
   1214 The functions and the variables described below allow suffix commands
   1215 to access the value of the transient from which they were invoked;
   1216 which is the value of its infix arguments.  These variables are set
   1217 when the user invokes a suffix command that exits the transient, but
   1218 before actually calling the command.
   1219 
   1220 When returning to the command-loop after calling the suffix command,
   1221 the arguments are reset to ~nil~ (which causes the function to return
   1222 ~nil~ too).
   1223 
   1224 Like for Emacs' prefix arguments, it is advisable, but not mandatory,
   1225 to access the infix arguments inside the command's ~interactive~ form.
   1226 The preferred way of doing that is to call the ~transient-args~
   1227 function, which for infix arguments serves about the same purpose as
   1228 ~prefix-arg~ serves for prefix arguments.
   1229 
   1230 - Function: transient-args prefix ::
   1231 
   1232   This function returns the value of the transient prefix command
   1233   {{{var(PREFIX)}}}.
   1234 
   1235   If the current command was invoked from the transient prefix command
   1236   {{{var(PREFIX)}}}, then it returns the active infix arguments.  If the current
   1237   command was not invoked from {{{var(PREFIX)}}}, then it returns the set, saved
   1238   or default value for {{{var(PREFIX)}}}.
   1239 
   1240 - Function: transient-arg-value arg args ::
   1241 
   1242   This function return the value of {{{var(ARG)}}} as it appears in {{{var(ARGS)}}}.
   1243 
   1244   For a switch a boolean is returned.  For an option the value is
   1245   returned as a string, using the empty string for the empty value,
   1246   or ~nil~ if the option does not appear in {{{var(ARGS)}}}.
   1247 
   1248 - Function: transient-suffixes prefix ::
   1249 
   1250   This function returns the suffixes of the transient prefix command
   1251   {{{var(PREFIX)}}}.  This is a list of objects.  This function should only be
   1252   used if you need the objects (as opposed to just their values) and
   1253   if the current command is not being invoked from {{{var(PREFIX)}}}.
   1254 
   1255 - Variable: transient-current-suffixes ::
   1256 
   1257   The suffixes of the transient from which this suffix command was
   1258   invoked.  This is a list of objects.  Usually it is sufficient to
   1259   instead use the function ~transient-args~, which returns a list of
   1260   values.  In complex cases it might be necessary to use this variable
   1261   instead, i.e., if you need access to information beside the value.
   1262 
   1263 - Variable: transient-current-prefix ::
   1264 
   1265   The transient from which this suffix command was invoked.  The
   1266   returned value is a ~transient-prefix~ object, which holds information
   1267   associated with the transient prefix command.
   1268 
   1269 - Variable: transient-current-command ::
   1270 
   1271   The transient from which this suffix command was invoked.  The
   1272   returned value is a symbol, the transient prefix command.
   1273 
   1274 ** Transient State
   1275 #+cindex: transient state
   1276 
   1277 Invoking a transient prefix command “activates” the respective
   1278 transient, i.e., it puts a transient keymap into effect, which binds
   1279 the transient's infix and suffix commands.
   1280 
   1281 The default behavior while a transient is active is as follows:
   1282 
   1283 - Invoking an infix command does not affect the transient state; the
   1284   transient remains active.
   1285 
   1286 - Invoking a (non-infix) suffix command “deactivates” the transient
   1287   state by removing the transient keymap and performing some
   1288   additional cleanup.
   1289 
   1290 - Invoking a command that is bound in a keymap other than the
   1291   transient keymap is disallowed and trying to do so results in a
   1292   warning.  This does not “deactivate” the transient.
   1293 
   1294 The behavior can be changed for all suffixes of a particular prefix
   1295 and/or for individual suffixes.  The values should nearly always be
   1296 booleans, but certain functions, called “pre-commands”, can also be
   1297 used.  These functions are named ~transient--do-VERB~, and the symbol
   1298 ~VERB~ can be used as a shorthand.
   1299 
   1300 A boolean is interpreted as answering the question "does the
   1301 transient stay active, when this command is invoked?"  ~t~ means that
   1302 the transient stays active, while ~nil~ means that invoking the command
   1303 exits the transient.
   1304 
   1305 Note that when the suffix is a “sub-prefix”, invoking that command
   1306 always activates that sub-prefix, causing the outer prefix to no
   1307 longer be active and displayed.  Here ~t~ means that when you exit the
   1308 inner prefix, then the outer prefix becomes active again, while ~nil~
   1309 means that all outer prefixes are exited at once.
   1310 
   1311 - The behavior for non-suffixes can be set for a particular prefix,
   1312   by the prefix's ~transient-non-suffix~ slot to a boolean, a suitable
   1313   pre-command function, or a shorthand for such a function.  See
   1314   [[*Pre-commands for Non-Suffixes]].
   1315 
   1316 - The common behavior for the suffixes of a particular prefix can be
   1317   set using the prefix's ~transient-suffixes~ slot.
   1318 
   1319   The value specified in this slot does *not* affect infixes.  Because
   1320   it affects both regular suffixes as well as sub-prefixes, which
   1321   have different needs, it is best to avoid explicitly specifying a
   1322   function.
   1323 
   1324 - The behavior of an individual suffix can be changed using its
   1325   ~transient~ slot.  While it is usually best to use a boolean, for this
   1326   slot it can occasionally make sense to specify a function explicitly.
   1327 
   1328   Note that this slot can be set when defining a suffix command using
   1329   ~transient-define-suffix~ and/or in the definition of the prefix.  If
   1330   set in both places, then the latter takes precedence, as usual.
   1331 
   1332 The available pre-command functions are documented in the following
   1333 sub-sections.  They are called by ~transient--pre-command~, a function
   1334 on ~pre-command-hook~, and the value that they return determines whether
   1335 the transient is exited.  To do so the value of one of the constants
   1336 ~transient--exit~ or ~transient--stay~ is used (that way we don't have to
   1337 remember if ~t~ means “exit” or “stay”).
   1338 
   1339 Additionally, these functions may change the value of ~this-command~
   1340 (which explains why they have to be called using ~pre-command-hook~),
   1341 call ~transient-export~, ~transient--stack-zap~ or ~transient--stack-push~;
   1342 and set the values of ~transient--exitp~, ~transient--helpp~ or
   1343 ~transient--editp~.
   1344 
   1345 For completeness sake, some notes about complications:
   1346 
   1347 - The transient-ness of certain built-in suffix commands is specified
   1348   using ~transient-predicate-map~.  This is a special keymap, which
   1349   binds commands to pre-commands (as opposed to keys to commands) and
   1350   takes precedence over the prefix's ~transient-suffix~ slot, but not
   1351   the suffix's ~transient~ slot.
   1352 
   1353 - While a sub-prefix is active we nearly always want {{{kbd(C-g)}}} to take the
   1354   user back to the “super-prefix”, even when the other suffixes don't
   1355   do that.  However, in rare cases this may not be desirable, and that
   1356   makes the following complication necessary:
   1357 
   1358   For ~transient-suffix~ objects the ~transient~ slot is unbound.  We can
   1359   ignore that for the most part because ~nil~ and the slot being unbound
   1360   are treated as equivalent, and mean “do exit”.  That isn't actually
   1361   true for suffixes that are sub-prefixes though.  For such suffixes
   1362   unbound means “do exit but allow going back”, which is the default,
   1363   while ~nil~ means “do exit permanently”, which requires that slot to
   1364   be explicitly set to that value.
   1365 
   1366 *** Pre-commands for Infixes
   1367 :PROPERTIES:
   1368 :UNNUMBERED: notoc
   1369 :END:
   1370 
   1371 The default for infixes is ~transient--do-stay~.  This is also the only
   1372 function that makes sense for infixes, which is why this predicate is
   1373 used even if the value of the prefix's ~transient-suffix~ slot is ~t~.  In
   1374 extremely rare cases, one might want to use something else, which can
   1375 be done by setting the infix's ~transient~ slot directly.
   1376 
   1377 - Function: transient--do-stay ::
   1378 
   1379   Call the command without exporting variables and stay transient.
   1380 
   1381 *** Pre-commands for Suffixes
   1382 :PROPERTIES:
   1383 :UNNUMBERED: notoc
   1384 :END:
   1385 
   1386 By default, invoking a suffix causes the transient to be exited.
   1387 
   1388 The behavior for an individual suffix command can be changed by
   1389 setting its ~transient~ slot to a boolean (which is highly recommended),
   1390 or to one of the following pre-commands.
   1391 
   1392 - Function: transient--do-exit ::
   1393 
   1394   Call the command after exporting variables and exit the transient.
   1395 
   1396 - Function: transient--do-return ::
   1397 
   1398   Call the command after exporting variables and return to the parent
   1399   prefix.  If there is no parent prefix, then call ~transient--do-exit~.
   1400 
   1401 - Function: transient--do-call ::
   1402 
   1403   Call the command after exporting variables and stay transient.
   1404 
   1405 The following pre-commands are only suitable for sub-prefixes.  It is
   1406 not necessary to explicitly use these predicates because the correct
   1407 predicate is automatically picked based on the value of the ~transient~
   1408 slot for the sub-prefix itself.
   1409 
   1410 - Function: transient--do-recurse ::
   1411 
   1412   Call the transient prefix command, preparing for return to active
   1413   transient.
   1414 
   1415   Whether we actually return to the parent transient is ultimately
   1416   under the control of each invoked suffix.  The difference between
   1417   this pre-command and ~transient--do-stack~ is that it changes the
   1418   value of the ~transient-suffix~ slot to ~t~.
   1419 
   1420   If there is no parent transient, then only call this command and
   1421   skip the second step.
   1422 
   1423 - Function: transient--do-stack ::
   1424 
   1425   Call the transient prefix command, stacking the active transient.
   1426   Push the active transient to the transient stack.
   1427 
   1428   Unless ~transient--do-recurse~ is explicitly used, this pre-command
   1429   is automatically used for suffixes that are prefixes themselves,
   1430   i.e., for sub-prefixes.
   1431 
   1432 - Function: transient--do-replace ::
   1433 
   1434   Call the transient prefix command, replacing the active transient.
   1435   Do not push the active transient to the transient stack.
   1436 
   1437   Unless ~transient--do-recurse~ is explicitly used, this pre-command
   1438   is automatically used for suffixes that are prefixes themselves,
   1439   i.e., for sub-prefixes.
   1440 
   1441 - Function: transient--do-suspend ::
   1442 
   1443   Suspend the active transient, saving the transient stack.
   1444 
   1445   This is used by the command ~transient-suspend~ and optionally also by
   1446   “external events” such as ~handle-switch-frame~.  Such bindings should
   1447   be added to ~transient-predicate-map~.
   1448 
   1449 *** Pre-commands for Non-Suffixes
   1450 :PROPERTIES:
   1451 :UNNUMBERED: notoc
   1452 :END:
   1453 
   1454 By default, non-suffixes (commands that are bound in other keymaps
   1455 beside the transient keymap) cannot be invoked.  Trying to invoke
   1456 such a command results in a warning and the transient stays active.
   1457 
   1458 If you want a different behavior, then set the ~transient-non-suffix~
   1459 slot of the transient prefix command.  The value should be a boolean,
   1460 answering the question, "is it allowed to invoke non-suffix commands?,
   1461 a pre-command function, or a shorthand for such a function.
   1462 
   1463 If the value is ~t~, then non-suffixes can be invoked, when it is ~nil~
   1464 (the default) then they cannot be invoked.
   1465 
   1466 The only other recommended value is ~leave~.  If that is used, then
   1467 non-suffixes can be invoked, but if one is invoked, then that exits
   1468 the transient.
   1469 
   1470 - Function: transient--do-warn ::
   1471 
   1472   Call ~transient-undefined~ and stay transient.
   1473 
   1474 - Function: transient--do-stay ::
   1475 
   1476   Call the command without exporting variables and stay transient.
   1477 
   1478 - Function: transient--do-leave ::
   1479 
   1480   Call the command without exporting variables and exit the transient.
   1481 
   1482 # transient--do-noop intentionally left undocumented.
   1483 
   1484 *** Special Pre-Commands
   1485 :PROPERTIES:
   1486 :UNNUMBERED: notoc
   1487 :END:
   1488 
   1489 - Function: transient--do-quit-one ::
   1490 
   1491   If active, quit help or edit mode, else exit the active transient.
   1492 
   1493   This is used when the user pressed {{{kbd(C-g)}}}.
   1494 
   1495 - Function: transient--do-quit-all ::
   1496 
   1497   Exit all transients without saving the transient stack.
   1498 
   1499   This is used when the user pressed {{{kbd(C-q)}}}.
   1500 
   1501 - Function: transient--do-suspend ::
   1502 
   1503   Suspend the active transient, saving the transient stack.
   1504 
   1505   This is used when the user pressed {{{kbd(C-z)}}}.
   1506 
   1507 * Classes and Methods
   1508 #+cindex: classes and methods
   1509 
   1510 Transient uses classes and generic functions to make it possible to
   1511 define new types of suffix commands that are similar to existing
   1512 types, but behave differently in some aspects.  It does the same for
   1513 groups and prefix commands, though at least for prefix commands that
   1514 *currently* appears to be less important.
   1515 
   1516 Every prefix, infix and suffix command is associated with an object,
   1517 which holds information that controls certain aspects of its behavior.
   1518 This happens in two ways.
   1519 
   1520 - Associating a command with a certain class gives the command a type.
   1521   This makes it possible to use generic functions to do certain things
   1522   that have to be done differently depending on what type of command
   1523   it acts on.
   1524 
   1525   That in turn makes it possible for third-parties to add new types
   1526   without having to convince the maintainer of Transient that that new
   1527   type is important enough to justify adding a special case to a dozen
   1528   or so functions.
   1529 
   1530 - Associating a command with an object makes it possible to easily
   1531   store information that is specific to that particular command.
   1532 
   1533   Two commands may have the same type, but obviously their key
   1534   bindings and descriptions still have to be different, for example.
   1535 
   1536   The values of some slots are functions.  The ~reader~ slot for example
   1537   holds a function that is used to read a new value for an infix
   1538   command.  The values of such slots are regular functions.
   1539 
   1540   Generic functions are used when a function should do something
   1541   different based on the type of the command, i.e., when all commands
   1542   of a certain type should behave the same way but different from the
   1543   behavior for other types.  Object slots that hold a regular function
   1544   as value are used when the task that they perform is likely to
   1545   differ even between different commands of the same type.
   1546 
   1547 ** Group Classes
   1548 
   1549 The type of a group can be specified using the ~:class~ property at the
   1550 beginning of the class specification, e.g., ~[:class transient-columns
   1551 ...]~ in a call to ~transient-define-prefix~.
   1552 
   1553 - The abstract ~transient-child~ class is the base class of both
   1554   ~transient-group~ (and therefore all groups) as well as of
   1555   ~transient-suffix~ (and therefore all suffix and infix commands).
   1556 
   1557   This class exists because the elements (or “children”) of certain
   1558   groups can be other groups instead of suffix and infix commands.
   1559 
   1560 - The abstract ~transient-group~ class is the superclass of all other
   1561   group classes.
   1562 
   1563 - The ~transient-column~ class is the simplest group.
   1564 
   1565   This is the default “flat” group.  If the class is not specified
   1566   explicitly and the first element is not a vector (i.e., not a group),
   1567   then this class is used.
   1568 
   1569   This class displays each element on a separate line.
   1570 
   1571 - The ~transient-row~ class displays all elements on a single line.
   1572 
   1573 - The ~transient-columns~ class displays commands organized in columns.
   1574 
   1575   Direct elements have to be groups whose elements have to be commands
   1576   or strings.  Each subgroup represents a column.  This class takes
   1577   care of inserting the subgroups' elements.
   1578 
   1579   This is the default “nested” group.  If the class is not specified
   1580   explicitly and the first element is a vector (i.e., a group), then
   1581   this class is used.
   1582 
   1583 - The ~transient-subgroups~ class wraps other groups.
   1584 
   1585   Direct elements have to be groups whose elements have to be commands
   1586   or strings.  This group inserts an empty line between subgroups.
   1587   The subgroups themselves are responsible for displaying their
   1588   elements.
   1589 
   1590 ** Group Methods
   1591 
   1592 - Function: transient-setup-children group children ::
   1593 
   1594   This generic function can be used to setup the children or a group.
   1595 
   1596   The default implementation usually just returns the children
   1597   unchanged, but if the ~setup-children~ slot of {{{var(GROUP)}}} is non-~nil~, then
   1598   it calls that function with {{{var(CHILDREN)}}} as the only argument and
   1599   returns the value.
   1600 
   1601   The children are given as a (potentially empty) list consisting of
   1602   either group or suffix specifications.  These functions can make
   1603   arbitrary changes to the children including constructing new
   1604   children from scratch.
   1605 
   1606 - Function: transient--insert-group group ::
   1607 
   1608   This generic function formats the group and its elements and inserts
   1609   the result into the current buffer, which is a temporary buffer.
   1610   The contents of that buffer are later inserted into the popup buffer.
   1611 
   1612   Functions that are called by this function may need to operate in
   1613   the buffer from which the transient was called.  To do so they can
   1614   temporarily make the ~transient--source-buffer~ the current buffer.
   1615 
   1616 ** Prefix Classes
   1617 
   1618 Currently the ~transient-prefix~ class is being used for all prefix
   1619 commands and there is only a single generic function that can be
   1620 specialized based on the class of a prefix command.
   1621 
   1622 - Function: transient--history-init obj ::
   1623 
   1624   This generic function is called while setting up the transient and
   1625   is responsible for initializing the ~history~ slot.  This is the
   1626   transient-wide history; many individual infixes also have a history
   1627   of their own.
   1628 
   1629   The default (and currently only) method extracts the value from the
   1630   global variable ~transient-history~.
   1631 
   1632 A transient prefix command's object is stored in the ~transient--prefix~
   1633 property of the command symbol.  While a transient is active, a clone
   1634 of that object is stored in the variable ~transient--prefix~.  A clone
   1635 is used because some changes that are made to the active transient's
   1636 object should not affect later invocations.
   1637 
   1638 ** Suffix Classes
   1639 
   1640 - All suffix and infix classes derive from ~transient-suffix~, which in
   1641   turn derives from ~transient-child~, from which ~transient-group~ also
   1642   derives (see [[*Group Classes]]).
   1643 
   1644 - All infix classes derive from the abstract ~transient-infix~ class,
   1645   which in turn derives from the ~transient-suffix~ class.
   1646 
   1647   Infixes are a special type of suffixes.  The primary difference is
   1648   that infixes always use the ~transient--do-stay~ pre-command, while
   1649   non-infix suffixes use a variety of pre-commands (see [[*Transient
   1650   State]]).  Doing that is most easily achieved by using this class,
   1651   though theoretically it would be possible to define an infix class
   1652   that does not do so.  If you do that then you get to implement many
   1653   methods.
   1654 
   1655   Also, infixes and non-infix suffixes are usually defined using
   1656   different macros (see [[*Defining Suffix and Infix Commands]]).
   1657 
   1658 - Classes used for infix commands that represent arguments should
   1659   be derived from the abstract ~transient-argument~ class.
   1660 
   1661 - The ~transient-switch~ class (or a derived class) is used for infix
   1662   arguments that represent command-line switches (arguments that do
   1663   not take a value).
   1664 
   1665 - The ~transient-option~ class (or a derived class) is used for infix
   1666   arguments that represent command-line options (arguments that do
   1667   take a value).
   1668 
   1669 - The ~transient-switches~ class can be used for a set of mutually
   1670   exclusive command-line switches.
   1671 
   1672 - The ~transient-files~ class can be used for a =--= argument that
   1673   indicates that all remaining arguments are files.
   1674 
   1675 - Classes used for infix commands that represent variables should
   1676   derived from the abstract ~transient-variable~ class.
   1677 
   1678 - The ~transient-information~ class is special in that suffixes that use
   1679   this class are not associated with a command and thus also not with
   1680   any key binding.  Such suffixes are only used to display arbitrary
   1681   information, and that anywhere a suffix can appear.  Display-only
   1682   suffix specifications take this form:
   1683 
   1684   #+begin_src emacs-lisp
   1685     ([LEVEL] :info DESCRIPTION [KEYWORD VALUE]...)
   1686   #+end_src
   1687 
   1688   The ~:info~ keyword argument replaces the ~:description~ keyword used for
   1689   other suffix classes.  Other keyword arguments that you might want to
   1690   set, include ~:face~, predicate keywords (such as ~:if~), and ~:format~.
   1691   By default the value of ~:format~ includes ~%k~, which for this class is
   1692   replaced with the empty string or spaces, if keys are being padded in
   1693   the containing group.
   1694 
   1695 Magit defines additional classes, which can serve as examples for the
   1696 fancy things you can do without modifying Transient.  Some of these
   1697 classes will likely get generalized and added to Transient.  For now
   1698 they are very much subject to change and not documented.
   1699 
   1700 ** Suffix Methods
   1701 
   1702 To get information about the methods implementing these generic
   1703 functions use ~describe-function~.
   1704 
   1705 *** Suffix Value Methods
   1706 
   1707 - Function: transient-init-value obj ::
   1708 
   1709   This generic function sets the initial value of the object {{{var(OBJ)}}}.
   1710 
   1711   This function is called for all suffix commands, but unless a
   1712   concrete method is implemented this falls through to the default
   1713   implementation, which is a noop.  In other words this usually
   1714   only does something for infix commands, but note that this is
   1715   not implemented for the abstract class ~transient-infix~, so if
   1716   your class derives from that directly, then you must implement
   1717   a method.
   1718 
   1719 - Function: transient-infix-read obj ::
   1720 
   1721   This generic function determines the new value of the infix object
   1722   {{{var(OBJ)}}}.
   1723 
   1724   This function merely determines the value; ~transient-infix-set~ is
   1725   used to actually store the new value in the object.
   1726 
   1727   For most infix classes this is done by reading a value from the
   1728   user using the reader specified by the ~reader~ slot (using the
   1729   ~transient-infix-value~ method described below).
   1730 
   1731   For some infix classes the value is changed without reading
   1732   anything in the minibuffer, i.e., the mere act of invoking the
   1733   infix command determines what the new value should be, based
   1734   on the previous value.
   1735 
   1736 - Function: transient-prompt obj ::
   1737 
   1738   This generic function returns the prompt to be used to read infix
   1739   object {{{var(OBJ)}}}'s value.
   1740 
   1741 - Function: transient-infix-set obj value ::
   1742 
   1743   This generic function sets the value of infix object {{{var(OBJ)}}} to {{{var(VALUE)}}}.
   1744 
   1745 - Function: transient-infix-value obj ::
   1746 
   1747   This generic function returns the value of the suffix object {{{var(OBJ)}}}.
   1748 
   1749   This function is called by ~transient-args~ (which see), meaning this
   1750   function is how the value of a transient is determined so that the
   1751   invoked suffix command can use it.
   1752 
   1753   Currently most values are strings, but that is not set in stone.
   1754   ~nil~ is not a value, it means “no value”.
   1755 
   1756   Usually only infixes have a value, but see the method for
   1757   ~transient-suffix~.
   1758 
   1759 - Function: transient-init-scope obj ::
   1760 
   1761   This generic function sets the scope of the suffix object {{{var(OBJ)}}}.
   1762 
   1763   The scope is actually a property of the transient prefix, not of
   1764   individual suffixes.  However it is possible to invoke a suffix
   1765   command directly instead of from a transient.  In that case, if
   1766   the suffix expects a scope, then it has to determine that itself
   1767   and store it in its ~scope~ slot.
   1768 
   1769   This function is called for all suffix commands, but unless a
   1770   concrete method is implemented this falls through to the default
   1771   implementation, which is a noop.
   1772 
   1773 *** Suffix Format Methods
   1774 
   1775 - Function: transient-format obj ::
   1776 
   1777   This generic function formats and returns {{{var(OBJ)}}} for display.
   1778 
   1779   When this function is called, then the current buffer is some
   1780   temporary buffer.  If you need the buffer from which the prefix
   1781   command was invoked to be current, then do so by temporarily
   1782   making ~transient--source-buffer~ current.
   1783 
   1784 - Function: transient-format-key obj ::
   1785 
   1786   This generic function formats {{{var(OBJ)}}}'s ~key~ for display and returns the
   1787   result.
   1788 
   1789 - Function: transient-format-description obj ::
   1790 
   1791   This generic function formats {{{var(OBJ)}}}'s ~description~ for display and
   1792   returns the result.
   1793 
   1794 - Function: transient-format-value obj ::
   1795 
   1796   This generic function formats {{{var(OBJ)}}}'s value for display and returns
   1797   the result.
   1798 
   1799 - Function: transient-show-help obj ::
   1800 
   1801   Show help for the prefix, infix or suffix command represented by
   1802   {{{var(OBJ)}}}.
   1803 
   1804   For prefixes, show the info manual, if that is specified using the
   1805   ~info-manual~ slot.  Otherwise, show the manpage if that is specified
   1806   using the ~man-page~ slot.  Otherwise, show the command's
   1807   documentation string.
   1808 
   1809   For suffixes, show the command's documentation string.
   1810 
   1811   For infixes, show the manpage if that is specified.  Otherwise show
   1812   the command's documentation string.
   1813 
   1814 ** Prefix Slots
   1815 
   1816 - ~show-help~, ~man-page~ or ~info-manual~ can be used to specify the
   1817   documentation for the prefix and its suffixes.  The command
   1818   ~transient-help~ uses the method ~transient-show-help~ (which see) to
   1819   lookup and use these values.
   1820 
   1821 - ~history-key~ If multiple prefix commands should share a single value,
   1822   then this slot has to be set to the same value for all of them.  You
   1823   probably don't want that.
   1824 
   1825 - ~transient-suffix~ and ~transient-non-suffix~ play a part when
   1826   determining whether the currently active transient prefix command
   1827   remains active/transient when a suffix or arbitrary non-suffix
   1828   command is invoked.  See [[*Transient State]].
   1829 
   1830 - ~refresh-suffixes~ Normally suffix objects and keymaps are only setup
   1831   once, when the prefix is invoked.  Setting this to ~t~, causes them to
   1832   be recreated after every command.  This is useful when using ~:if...~
   1833   predicates, and those need to be rerun for some reason.  Doing this
   1834   is somewhat costly, and there is a risk of losing state, so this is
   1835   disabled by default and still considered experimental.
   1836 
   1837 - ~incompatible~ A list of lists.  Each sub-list specifies a set of
   1838   mutually exclusive arguments.  Enabling one of these arguments
   1839   causes the others to be disabled.  An argument may appear in
   1840   multiple sub-lists.  Arguments must me given in the same form as
   1841   used in the ~argument~ or ~argument-format~ slot of the respective
   1842   suffix objects, usually something like ~--switch~ or ~--option=%s~.  For
   1843   options and ~transient-switches~ suffixes it is also possible to match
   1844   against a specific value, as returned by ~transient-infix-value~,
   1845   for example, ~--option=one~.
   1846 
   1847 - ~scope~ For some transients it might be necessary to have a sort of
   1848   secondary value, called a “scope”.  See ~transient-define-prefix~.
   1849 
   1850 *** Internal Prefix Slots
   1851 :PROPERTIES:
   1852 :UNNUMBERED: notoc
   1853 :END:
   1854 
   1855 These slots are mostly intended for internal use.  They should not be
   1856 set in calls to ~transient-define-prefix~.
   1857 
   1858 - ~prototype~ When a transient prefix command is invoked, then a clone
   1859   of that object is stored in the global variable ~transient--prefix~
   1860   and the prototype is stored in the clone's ~prototype~ slot.
   1861 
   1862 - ~command~ The command, a symbol.  Each transient prefix command
   1863   consists of a command, which is stored in a symbol's function slot
   1864   and an object, which is stored in the ~transient--prefix~ property
   1865   of the same symbol.
   1866 
   1867 - ~level~ The level of the prefix commands.  The suffix commands whose
   1868   layer is equal or lower are displayed.  See [[*Enabling and Disabling
   1869   Suffixes]].
   1870 
   1871 - ~value~ The likely outdated value of the prefix.  Instead of accessing
   1872   this slot directly you should use the function ~transient-get-value~,
   1873   which is guaranteed to return the up-to-date value.
   1874 
   1875 - ~history~ and ~history-pos~ are used to keep track of historic values.
   1876   Unless you implement your own ~transient-infix-read~ method you should
   1877   not have to deal with these slots.
   1878 
   1879 ** Suffix Slots
   1880 
   1881 Here we document most of the slots that are only available for suffix
   1882 objects.  Some slots are shared by suffix and group objects, they are
   1883 documented in [[*Predicate Slots]].
   1884 
   1885 Also see [[*Suffix Classes]].
   1886 
   1887 *** Slots of ~transient-suffix~
   1888 :PROPERTIES:
   1889 :UNNUMBERED: notoc
   1890 :END:
   1891 
   1892 - ~key~ The key, a key vector or a key description string.
   1893 
   1894 - ~command~ The command, a symbol.
   1895 
   1896 - ~transient~ Whether to stay transient.  See [[*Transient State]].
   1897 
   1898 - ~format~ The format used to display the suffix in the popup buffer.
   1899   It must contain the following %-placeholders:
   1900 
   1901   - ~%k~ For the key.
   1902   - ~%d~ For the description.
   1903   - ~%v~ For the infix value.  Non-infix suffixes don't have a value.
   1904 
   1905 - ~description~ The description, either a string or a function, which is
   1906   called with zero or one argument (the suffix object), and returns a
   1907   string.
   1908 
   1909 - ~face~ Face used for the description.  In simple cases it is easier
   1910   to use this instead of using a function as ~description~ and adding
   1911   the styling there.  ~face~ is appended using ~add-face-text-property~.
   1912 
   1913 - ~show-help~ A function used to display help for the suffix.  If
   1914   unspecified, the prefix controls how help is displayed for its
   1915   suffixes.
   1916 
   1917 *** Slots of ~transient-infix~
   1918 :PROPERTIES:
   1919 :UNNUMBERED: notoc
   1920 :END:
   1921 
   1922 Some of these slots are only meaningful for some of the subclasses.
   1923 They are defined here anyway to allow sharing certain methods.
   1924 
   1925 - ~argument~ The long argument, e.g., ~--verbose~.
   1926 
   1927 - ~shortarg~ The short argument, e.g., ~-v~.
   1928 
   1929 - ~value~ The value.  Should not be accessed directly.
   1930 
   1931 - ~init-value~ Function that is responsible for setting the object's
   1932   value.  If bound, then this is called with the object as the only
   1933   argument.  Usually this is not bound, in which case the object's
   1934   primary ~transient-init-value~ method is called instead.
   1935 
   1936 - ~unsavable~ Whether the value of the suffix is not saved as part of
   1937   the prefixes.
   1938 
   1939 - ~multi-value~ For options, whether the option can have multiple
   1940   values.  If this is non-~nil~, then the values are read using
   1941   ~completing-read-multiple~ by default and if you specify your own
   1942   reader, then it should read the values using that function or
   1943   similar.
   1944 
   1945   Supported non-~nil~ values are:
   1946 
   1947   - Use ~rest~ for an option that can have multiple values.  This is
   1948     useful e.g., for an ~--~ argument that indicates that all remaining
   1949     arguments are files (such as ~git log -- file1 file2~).
   1950 
   1951     In the list returned by ~transient-args~ such an option and its
   1952     values are represented by a single list of the form ~(ARGUMENT
   1953     . VALUES)~.
   1954 
   1955   - Use ~repeat~ for an option that can be specified multiple times.
   1956 
   1957     In the list returned by ~transient-args~ each instance of the option
   1958     and its value appears separately in the usual from, for example:
   1959     ~("--another-argument" "--option=first" "--option=second")~.
   1960 
   1961   In both cases the option's values have to be specified in the
   1962   default value of a prefix using the same format as returned by
   1963   ~transient-args~, e.g., ~("--other" "--o=1" "--o=2" ("--" "f1" "f2"))~.
   1964 
   1965 - ~always-read~ For options, whether to read a value on every invocation.
   1966   If this is ~nil~, then options that have a value are simply unset and
   1967   have to be invoked a second time to set a new value.
   1968 
   1969 - ~allow-empty~ For options, whether the empty string is a valid value.
   1970 
   1971 - ~history-key~ The key used to store the history.  This defaults to the
   1972   command name.  This is useful when multiple infixes should share the
   1973   same history because their values are of the same kind.
   1974 
   1975 - ~reader~ The function used to read the value of an infix.  Not used
   1976   for switches.  The function takes three arguments, {{{var(PROMPT)}}},
   1977   {{{var(INITIAL-INPUT)}}} and {{{var(HISTORY)}}}, and must return a string.
   1978 
   1979 - ~prompt~ The prompt used when reading the value, either a string or a
   1980   function that takes the object as the only argument and which
   1981   returns a prompt string.
   1982 
   1983 - ~choices~ A list of valid values, or a function that returns such a
   1984   list.  The latter is not implemented for ~transient-switches~, because
   1985   I couldn't think of a use-case.  How exactly the choices are used
   1986   varies depending on the class of the suffix.
   1987 
   1988 *** Slots of ~transient-variable~
   1989 :PROPERTIES:
   1990 :UNNUMBERED: notoc
   1991 :END:
   1992 
   1993 - ~variable~ The variable.
   1994 
   1995 *** Slots of ~transient-switches~
   1996 :PROPERTIES:
   1997 :UNNUMBERED: notoc
   1998 :END:
   1999 
   2000 - ~argument-format~ The display format.  Must contain ~%s~, one of the
   2001   ~choices~ is substituted for that.  E.g., ~--%s-order~.
   2002 
   2003 - ~argument-regexp~ The regexp used to match any one of the switches.
   2004   E.g., ~\\(--\\(topo\\|author-date\\|date\\)-order\\)~.
   2005 
   2006 ** Predicate Slots
   2007 
   2008 Suffix and group objects share some predicate slots that control
   2009 whether a group or suffix should be available depending on some state.
   2010 Only one of these slots can be used at the same time.  It is undefined
   2011 what happens if you use more than one.
   2012 
   2013 - ~if~ Enable if predicate returns non-~nil~.
   2014 - ~if-not~ Enable if predicate returns ~nil~.
   2015 - ~if-non-nil~ Enable if variable's value is non-~nil~.
   2016 - ~if-nil~ Enable if variable's value is ~nil~.
   2017 - ~if-mode~ Enable if major-mode matches value.
   2018 - ~if-not-mode~ Enable if major-mode does not match value.
   2019 - ~if-derived~ Enable if major-mode derives from value.
   2020 - ~if-not-derived~ Enable if major-mode does not derive from value.
   2021 
   2022 By default these predicates run when the prefix command is invoked,
   2023 but this can be changes, using the ~refresh-suffixes~ prefix slot.
   2024 See [[*Prefix Slots]].
   2025 
   2026 One more slot is shared between group and suffix classes, ~level~.  Like
   2027 the slots documented above, it is a predicate, but it is used for a
   2028 different purpose.  The value has to be an integer between 1
   2029 and 7.  ~level~ controls whether a suffix or a group should be
   2030 available depending on user preference.
   2031 See [[*Enabling and Disabling Suffixes]].
   2032 
   2033 * FAQ
   2034 :PROPERTIES:
   2035 :APPENDIX:   t
   2036 :END:
   2037 
   2038 ** Can I control how the popup buffer is displayed?
   2039 :PROPERTIES:
   2040 :UNNUMBERED: notoc
   2041 :END:
   2042 
   2043 Yes, see ~transient-display-buffer-action~ in [[*Configuration]].
   2044 
   2045 ** How can I copy text from the popup buffer?
   2046 :PROPERTIES:
   2047 :UNNUMBERED: notoc
   2048 :END:
   2049 
   2050 To be able to mark text in Transient's popup buffer using the mouse,
   2051 you have to add the below binding.  Note that for technical reasons,
   2052 the region won't be visualized, while doing so.  After you have quit
   2053 the transient popup, you will be able to yank it in another buffer.
   2054 
   2055 #+begin_src emacs-lisp
   2056   (keymap-set transient-predicate-map
   2057               "<mouse-set-region>"
   2058               #'transient--do-stay)
   2059 #+end_src
   2060 
   2061 ** How does Transient compare to prefix keys and universal arguments?
   2062 :PROPERTIES:
   2063 :UNNUMBERED: notoc
   2064 :END:
   2065 
   2066 See https://github.com/magit/transient/wiki/Comparison-with-prefix-keys-and-universal-arguments.
   2067 
   2068 ** How does Transient compare to Magit-Popup and Hydra?
   2069 :PROPERTIES:
   2070 :UNNUMBERED: notoc
   2071 :END:
   2072 
   2073 See https://github.com/magit/transient/wiki/Comparison-with-other-packages.
   2074 
   2075 ** Why did some of the key bindings change?
   2076 :PROPERTIES:
   2077 :UNNUMBERED: notoc
   2078 :END:
   2079 
   2080 You may have noticed that the bindings for some of the common commands
   2081 do *not* have the prefix {{{kbd(C-x)}}} and that furthermore some of these commands
   2082 are grayed out while others are not.  That unfortunately is a bit
   2083 confusing if the section of common commands is not shown permanently,
   2084 making the following explanation necessary.
   2085 
   2086 The purpose of usually hiding that section but showing it after the
   2087 user pressed the respective prefix key is to conserve space and not
   2088 overwhelm users with too much noise, while allowing the user to
   2089 quickly list common bindings on demand.
   2090 
   2091 That however should not keep us from using the best possible key
   2092 bindings.  The bindings that do use a prefix do so to avoid wasting
   2093 too many non-prefix bindings, keeping them available for use in
   2094 individual transients.  The bindings that do not use a prefix and that
   2095 are *not* grayed out are very important bindings that are *always*
   2096 available, even when invoking the “common command key prefix” or *any
   2097 other* transient-specific prefix.  The non-prefix keys that *are* grayed
   2098 out however, are not available when any incomplete prefix key sequence
   2099 is active.  They do not use the “common command key prefix” because it
   2100 is likely that users want to invoke them several times in a row and
   2101 e.g., {{{kbd(M-p M-p M-p)}}} is much more convenient than {{{kbd(C-x M-p C-x M-p C-x M-p)}}}.
   2102 
   2103 You may also have noticed that the “Set” command is bound to {{{kbd(C-x s)}}},
   2104 while Magit-Popup used to bind {{{kbd(C-c C-c)}}} instead.  I have seen several
   2105 users praise the latter binding (sic), so I did not change it
   2106 willy-nilly.  The reason that I changed it is that using different
   2107 prefix keys for different common commands, would have made the
   2108 temporary display of the common commands even more confusing, i.e.,
   2109 after pressing {{{kbd(C-c)}}} all the bindings that begin with the {{{kbd(C-x)}}} prefix
   2110 would be grayed out.
   2111 
   2112 Using a single prefix for common commands key means that all other
   2113 potential prefix keys can be used for transient-specific commands
   2114 *without* the section of common commands also popping up.  {{{kbd(C-c)}}} in
   2115 particular is a prefix that I want to (and already do) use for Magit, and
   2116 also using that for a common command would prevent me from doing so.
   2117 
   2118 (Also see the next question.)
   2119 
   2120 ** Why does {{{kbd(q)}}} not quit popups anymore?
   2121 :PROPERTIES:
   2122 :UNNUMBERED: notoc
   2123 :END:
   2124 
   2125 I agree that {{{kbd(q)}}} is a good binding for commands that quit something.
   2126 This includes quitting whatever transient is currently active, but it
   2127 also includes quitting whatever it is that some specific transient is
   2128 controlling.  The transient ~magit-blame~ for example binds {{{kbd(q)}}} to the
   2129 command that turns ~magit-blame-mode~ off.
   2130 
   2131 So I had to decide if {{{kbd(q)}}} should quit the active transient (like
   2132 Magit-Popup used to) or whether {{{kbd(C-g)}}} should do that instead, so that {{{kbd(q)}}}
   2133 could be bound in individual transient to whatever commands make sense
   2134 for them.  Because all other letters are already reserved for use by
   2135 individual transients, I have decided to no longer make an exception
   2136 for {{{kbd(q)}}}.
   2137 
   2138 If you want to get {{{kbd(q)}}}'s old binding back then you can do so.  Doing
   2139 that is a bit more complicated than changing a single key binding, so
   2140 I have implemented a function, ~transient-bind-q-to-quit~ that makes the
   2141 necessary changes.  See its documentation string for more information.
   2142 
   2143 * Keystroke Index
   2144 :PROPERTIES:
   2145 :APPENDIX:   t
   2146 :INDEX:      ky
   2147 :COOKIE_DATA: recursive
   2148 :END:
   2149 * Command and Function Index
   2150 :PROPERTIES:
   2151 :APPENDIX:   t
   2152 :INDEX:      fn
   2153 :END:
   2154 * Variable Index
   2155 :PROPERTIES:
   2156 :APPENDIX:   t
   2157 :INDEX:      vr
   2158 :END:
   2159 * Concept Index
   2160 :PROPERTIES:
   2161 :APPENDIX:   t
   2162 :INDEX:      cp
   2163 :END:
   2164 
   2165 * GNU General Public License
   2166 :PROPERTIES:
   2167 :APPENDIX:   t
   2168 :END:
   2169 #+texinfo: @include gpl.texi
   2170 
   2171 * Copying
   2172 :PROPERTIES:
   2173 :COPYING:    t
   2174 :END:
   2175 
   2176 #+begin_quote
   2177 Copyright (C) 2018--{{{year}}} Free Software Foundation, Inc.
   2178 
   2179 You can redistribute this document and/or modify it under the terms
   2180 of the GNU General Public License as published by the Free Software
   2181 Foundation, either version 3 of the License, or (at your option) any
   2182 later version.
   2183 
   2184 This document is distributed in the hope that it will be useful,
   2185 but WITHOUT ANY WARRANTY; without even the implied warranty of
   2186 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   2187 General Public License for more details.
   2188 #+end_quote
   2189 
   2190 #  LocalWords:  ARGLIST ARGS DOCSTRING ELEMENTs EVAL GROUPs Infixes
   2191 #  LocalWords:  Infixes KEYWORDs LOC LocalWords MERCHANTABILITY Magit
   2192 #  LocalWords:  Magit's Makefile OBJ OBJ's Pre arglist
   2193 #  LocalWords:  args boolean booleans customizable docstring eval
   2194 #  LocalWords:  featurep infixes init keymap keymaps loc magit manpage
   2195 #  LocalWords:  minibuffer ness nilly noop plist pre prev
   2196 #  LocalWords:  rebase src subclass subclasses subprocess superclass
   2197 #  LocalWords:  utils
   2198 
   2199 # IMPORTANT: Also update ORG_ARGS and ORG_EVAL in the Makefile.
   2200 # Local Variables:
   2201 # indent-tabs-mode: nil
   2202 # org-hide-macro-markers: t
   2203 # org-src-preserve-indentation: nil
   2204 # End: