Klimi's new dotfiles with stow.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

2401 rinda
101 KiB

pirms 4 gadiem
  1. This is transient.info, produced by makeinfo version 6.5 from
  2. transient.texi.
  3. Copyright (C) 2018-2019 Jonas Bernoulli <jonas@bernoul.li>
  4. You can redistribute this document and/or modify it under the terms
  5. of the GNU General Public License as published by the Free Software
  6. Foundation, either version 3 of the License, or (at your option)
  7. any later version.
  8. This document is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. INFO-DIR-SECTION Emacs
  13. START-INFO-DIR-ENTRY
  14. * Transient: (transient). Transient Commands.
  15. END-INFO-DIR-ENTRY
  16. 
  17. File: transient.info, Node: Top, Next: Introduction, Up: (dir)
  18. Transient User and Developer Manual
  19. ***********************************
  20. Taking inspiration from prefix keys and prefix arguments, Transient
  21. implements a similar abstraction involving a prefix command, infix
  22. arguments and suffix commands. We could call this abstraction a
  23. "transient command", but because it always involves at least two
  24. commands (a prefix and a suffix) we prefer to call it just a
  25. "transient".
  26. When the user calls a transient prefix command, then a transient
  27. (temporary) keymap is activated, which binds the transient’s infix and
  28. suffix commands, and functions that control the transient state are
  29. added to ‘pre-command-hook’ and ‘post-command-hook’. The available
  30. suffix and infix commands and their state are shown in a popup buffer
  31. until the transient is exited by invoking a suffix command.
  32. Calling an infix command causes its value to be changed, possibly by
  33. reading a new value in the minibuffer.
  34. Calling a suffix command usually causes the transient to be exited
  35. but suffix commands can also be configured to not exit the transient.
  36. This manual is for Transient version 0.1.0 (v0.1.0-90-g4ce1868+1).
  37. Copyright (C) 2018-2019 Jonas Bernoulli <jonas@bernoul.li>
  38. You can redistribute this document and/or modify it under the terms
  39. of the GNU General Public License as published by the Free Software
  40. Foundation, either version 3 of the License, or (at your option)
  41. any later version.
  42. This document is distributed in the hope that it will be useful,
  43. but WITHOUT ANY WARRANTY; without even the implied warranty of
  44. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  45. General Public License for more details.
  46. * Menu:
  47. * Introduction::
  48. * Usage::
  49. * Other Options::
  50. * Modifying Existing Transients::
  51. * Defining New Commands::
  52. * Classes and Methods::
  53. * Related Abstractions and Packages::
  54. * FAQ::
  55. * Keystroke Index::
  56. * Command Index::
  57. * Function Index::
  58. * Variable Index::
  59. — The Detailed Node Listing —
  60. Usage
  61. * Invoking Transients::
  62. * Aborting and Resuming Transients::
  63. * Common Suffix Commands::
  64. * Saving Values::
  65. * Using History::
  66. * Getting Help for Suffix Commands::
  67. * Enabling and Disabling Suffixes::
  68. * Other Commands::
  69. Defining New Commands
  70. * Defining Transients::
  71. * Binding Suffix and Infix Commands::
  72. * Defining Suffix and Infix Commands::
  73. * Using Infix Arguments::
  74. * Transient State::
  75. Binding Suffix and Infix Commands
  76. * Group Specifications::
  77. * Suffix Specifications::
  78. Classes and Methods
  79. * Group Classes::
  80. * Group Methods::
  81. * Prefix Classes::
  82. * Suffix Classes::
  83. * Suffix Methods::
  84. * Prefix Slots::
  85. * Suffix Slots::
  86. * Predicate Slots::
  87. Suffix Methods
  88. * Suffix Value Methods::
  89. * Suffix Format Methods::
  90. Related Abstractions and Packages
  91. * Comparison With Prefix Keys and Prefix Arguments::
  92. * Comparison With Other Packages::
  93. 
  94. File: transient.info, Node: Introduction, Next: Usage, Prev: Top, Up: Top
  95. 1 Introduction
  96. **************
  97. Taking inspiration from prefix keys and prefix arguments, Transient
  98. implements a similar abstraction involving a prefix command, infix
  99. arguments and suffix commands. We could call this abstraction a
  100. "transient command", but because it always involves at least two
  101. commands (a prefix and a suffix) we prefer to call it just a
  102. "transient".
  103. Transient keymaps are a feature provided by Emacs. Transients as
  104. implemented by this package involve the use of transient keymaps.
  105. Emacs provides a feature that it calls "prefix commands". When we
  106. talk about "prefix commands" in this manual, then we mean our own
  107. kind of "prefix commands", unless specified otherwise. To avoid
  108. ambiguity we sometimes use the terms "transient prefix command" for
  109. our kind and "regular prefix command" for Emacs’ kind.
  110. When the user calls a transient prefix command, then a transient
  111. (temporary) keymap is activated, which binds the transient’s infix and
  112. suffix commands, and functions that control the transient state are
  113. added to ‘pre-command-hook’ and ‘post-command-hook’. The available
  114. suffix and infix commands and their state are shown in a popup buffer
  115. until the transient state is exited by invoking a suffix command.
  116. Calling an infix command causes its value to be changed. How that is
  117. done depends on the type of the infix command. The simplest case is an
  118. infix command that represents a command-line argument that does not take
  119. a value. Invoking such an infix command causes the switch to be toggled
  120. on or off. More complex infix commands may read a value from the user,
  121. using the minibuffer.
  122. Calling a suffix command usually causes the transient to be exited;
  123. the transient keymaps and hook functions are removed, the popup buffer
  124. no longer shows information about the (no longer bound) suffix commands,
  125. the values of some public global variables are set, while some internal
  126. global variables are unset, and finally the command is actually called.
  127. Suffix commands can also be configured to not exit the transient.
  128. A suffix command can, but does not have to, use the infix arguments
  129. in much the same way it can choose to use or ignore the prefix
  130. arguments. For a suffix command that was invoked from a transient the
  131. variable ‘current-transient-suffixes’ and the function ‘transient-args’
  132. serve about the same purpose as the variables ‘prefix-arg’ and
  133. ‘current-prefix-arg’ do for any command that was called after the prefix
  134. arguments have been set using a command such as ‘universal-argument’.
  135. The information shown in the popup buffer while a transient is active
  136. looks a bit like this:
  137. ,-----------------------------------------
  138. |Arguments
  139. | -f Force (--force)
  140. | -a Annotate (--annotate)
  141. |
  142. |Create
  143. | t tag
  144. | r telease
  145. `-----------------------------------------
  146. This is a simplified version of ‘magit-tag’. Info manuals do not
  147. support images or colored text, so the above "screenshot" lacks
  148. some information; in practice you would be able to tell whether the
  149. arguments ‘--force’ and ‘--annotate’ are enabled or not based on
  150. their color.
  151. Transient can be used to implement simple "command dispatchers". The
  152. main benefit then is that the user can see all the available commands in
  153. a popup buffer. That is useful by itself because it frees the user from
  154. having to remember all the keys that are valid after a certain prefix
  155. key or command. Magit’s ‘magit-dispatch’ command is an example of using
  156. Transient to merely implement a command dispatcher.
  157. In addition to that, Transient also allows users to interactively
  158. pass arguments to commands. These arguments can be much more complex
  159. than what is reasonable when using prefix arguments. There is a limit
  160. to how many aspects of a command can be controlled using prefix
  161. arguments. Furthermore what a certain prefix argument means for
  162. different commands can be completely different, and users have to read
  163. documentation to learn and then commit to memory what a certain prefix
  164. argument means to a certain command.
  165. Transient suffix commands on the other hand can accept dozens of
  166. different arguments without the user having to remember anything. When
  167. using Transient, then one can call a command with arguments that are
  168. just as complex as when calling the same function non-interactively
  169. using code.
  170. Invoking a transient command with arguments is similar to invoking a
  171. command in a shell with command-line completion and history enabled.
  172. One benefit of the Transient interface is that it remembers history not
  173. only on a global level ("this command was invoked using these arguments
  174. and previously it was invoked using those other arguments"), but also
  175. remembers the values of individual arguments independently. See *note
  176. Using History::.
  177. After a transient prefix command is invoked ‘C-h <key>’ can be used
  178. to show the documentation for the infix or suffix command that ‘<key>’
  179. is bound to (see *note Getting Help for Suffix Commands::) and infixes
  180. and suffixes can be removed from the transient using ‘C-x l <key>’.
  181. Infixes and suffixes that are disabled by default can be enabled the
  182. same way. See *note Enabling and Disabling Suffixes::.
  183. Transient ships with support for a few different types of specialized
  184. infix commands. A command that sets a command line option for example
  185. has different needs than a command that merely toggles a boolean flag.
  186. Additionally Transient provides abstractions for defining new types,
  187. which the author of Transient did not anticipate (or didn’t get around
  188. to implementing yet).
  189. 
  190. File: transient.info, Node: Usage, Next: Other Options, Prev: Introduction, Up: Top
  191. 2 Usage
  192. *******
  193. * Menu:
  194. * Invoking Transients::
  195. * Aborting and Resuming Transients::
  196. * Common Suffix Commands::
  197. * Saving Values::
  198. * Using History::
  199. * Getting Help for Suffix Commands::
  200. * Enabling and Disabling Suffixes::
  201. * Other Commands::
  202. 
  203. File: transient.info, Node: Invoking Transients, Next: Aborting and Resuming Transients, Up: Usage
  204. 2.1 Invoking Transients
  205. =======================
  206. A transient prefix command is invoked like any other command by pressing
  207. the key that is bound to that command. The main difference to other
  208. commands is that a transient prefix commands activates a transient
  209. keymap, which temporarily binds the transient’s infix and suffix
  210. commands. Bindings from other keymaps may, or may not, be disabled
  211. while the transient state is in effect.
  212. There are two kinds of commands that are available after invoking a
  213. transient prefix command; infix and suffix commands. Infix commands set
  214. some value (which is then shown in a popup buffer), without leaving the
  215. transient. Suffix commands on the other hand usually quit the transient
  216. and they may use the values set by the infix commands, i.e. the infix
  217. *arguments*.
  218. Instead of setting arguments to be used by a suffix command, infix
  219. commands may also set some value by side-effect.
  220. 
  221. File: transient.info, Node: Aborting and Resuming Transients, Next: Common Suffix Commands, Prev: Invoking Transients, Up: Usage
  222. 2.2 Aborting and Resuming Transients
  223. ====================================
  224. To quit the transient without invoking a suffix command press ‘C-g’.
  225. Key bindings in transient keymaps may be longer than a single event.
  226. After pressing a valid prefix key, all commands whose bindings do not
  227. begin with that prefix key are temporarily unavailable and grayed out.
  228. To abort the prefix key press ‘C-g’ (which in this case only quits the
  229. prefix key, but not the complete transient).
  230. A transient prefix command can be bound as a suffix of another
  231. transient. Invoking such a suffix replaces the current transient state
  232. with a new transient state, i.e. the available bindings change and the
  233. information displayed in the popup buffer is updated accordingly.
  234. Pressing ‘C-g’ while a nested transient is active only quits the
  235. innermost transient, causing a return to the previous transient.
  236. ‘C-q’ or ‘C-z’ on the other hand always exits all transients. If you
  237. use the latter, then you can later resume the stack of transients using
  238. ‘M-x transient-resume’.
  239. ‘C-g’ (‘transient-quit-seq’)
  240. ‘C-g’ (‘transient-quit-one’)
  241. This key quits the currently active incomplete key sequence, if
  242. any, or else the current transient. When quitting the current
  243. transient, then it returns to the previous transient, if any.
  244. Transient’s predecessor bound ‘q’ instead of ‘C-g’ to the quit
  245. command. To learn how to get that binding back see
  246. ‘transient-bind-q-to-quit’’s doc-string.
  247. ‘C-q’ (‘transient-quit-all’)
  248. This command quits the currently active incomplete key sequence, if
  249. any, and all transients, including the active transient and all
  250. suspended transients, if any.
  251. ‘C-z’ (‘transient-suspend’)
  252. Like ‘transient-quit-all’, this command quits an incomplete key
  253. sequence, if any, and all transients. Additionally it saves the
  254. stack of transients so that it can easily be resumed (which is
  255. particularly useful if you quickly need to do "something else" and
  256. the stack is deeper than a single transient and/or you have already
  257. changed the values of some infix arguments).
  258. Note that only a single stack of transients can be saved at a time.
  259. If another stack is already saved, then saving a new stack discards
  260. the previous stack.
  261. ‘M-x transient-resume’ (‘transient-resume’)
  262. This command resumes the previously suspended stack of transients,
  263. if any.
  264. 
  265. File: transient.info, Node: Common Suffix Commands, Next: Saving Values, Prev: Aborting and Resuming Transients, Up: Usage
  266. 2.3 Common Suffix Commands
  267. ==========================
  268. A few shared suffix commands are available in all transients. These
  269. suffix commands are not shown in the popup buffer by default.
  270. Most of these commands are bound to ‘C-x <key>’ and after pressing
  271. ‘C-x’ a section featuring all common commands is temporarily shown in
  272. the popup buffer. After invoking one of these commands, that section
  273. disappears again. Note however that one of these commands is described
  274. as "Show common permanently"; invoke that if you want the common
  275. commands to always be shown for all transients.
  276. ‘C-x t’ (‘transient-toggle-common’)
  277. This command toggles whether the generic commands that are common
  278. to all transients are always displayed or only after typing the
  279. incomplete prefix key sequence ‘C-x’. This only affects the
  280. current Emacs session.
  281. -- User Option: transient-show-common-commands
  282. This option controls whether shared suffix commands are shown
  283. alongside the transient-specific infix and suffix commands. By
  284. default the shared commands are not shown to avoid overwhelming the
  285. user with to many options.
  286. While a transient is active, pressing ‘C-x’ always shows the common
  287. command. The value of this option can be changed for the current
  288. Emacs session by typing ‘C-x t’ while a transient is active.
  289. The other common commands are describe in either the previous node or
  290. in one of the following nodes.
  291. Some of Transient’s key bindings differ from the respective bindings
  292. of Magit-Popup; see *note FAQ:: for more information.
  293. 
  294. File: transient.info, Node: Saving Values, Next: Using History, Prev: Common Suffix Commands, Up: Usage
  295. 2.4 Saving Values
  296. =================
  297. After setting the infix arguments in a transient, the user can save
  298. those arguments for future invocations.
  299. Most transients will start out with the saved arguments when they are
  300. invoked. There are a few exceptions though. Some transients are
  301. designed so that the value that they use is stored externally as the
  302. buffer-local value of some variable. Invoking such a transient again
  303. uses the buffer-local value. (1)
  304. If the user does not save the value and just exits using a regular
  305. suffix command, then the value is merely saved to the transient’s
  306. history. That value won’t be used when the transient is next invoked
  307. but it is easily accessible (see *note Using History::).
  308. ‘C-x s’ (‘transient-set’)
  309. This command saves the value of the active transient for this Emacs
  310. session.
  311. ‘C-x C-s’ (‘transient-save’)
  312. Save the value of the active transient persistently across Emacs
  313. sessions.
  314. -- User Option: transient-values-file
  315. This file is used to persist the values of transients between Emacs
  316. sessions.
  317. ---------- Footnotes ----------
  318. (1) ‘magit-diff’ and ‘magit-log’ are two prominent examples, and
  319. their handling of buffer-local values is actually a bit more complicated
  320. than outlined above and even customizable. This is something I am
  321. rethinking, but I don’t want to rush any changes.)
  322. 
  323. File: transient.info, Node: Using History, Next: Getting Help for Suffix Commands, Prev: Saving Values, Up: Usage
  324. 2.5 Using History
  325. =================
  326. Every time the user invokes a suffix command the transient’s current
  327. value is saved to its history. This values can be cycled through the
  328. same way one can cycle through the history of commands that read
  329. user-input in the minibuffer.
  330. ‘M-p’ (‘transient-history-prev’)
  331. This command switches to the previous value used for the active
  332. transient.
  333. ‘M-n’ (‘transient-history-next’)
  334. This command switches to the next value used for the active
  335. transient.
  336. In addition to the transient-wide history, Transient of course
  337. supports per-infix history. When an infix reads user-input using the
  338. minibuffer, then the user can use the regular minibuffer history
  339. commands to cycle through previously used values. Usually the same keys
  340. as those mentioned above are bound to those commands.
  341. Authors of transients should arrange for different infix commands
  342. that read the same kind of value to also use the same history key (see
  343. *note Suffix Slots::).
  344. Both kinds of history are saved to a file when Emacs is exited.
  345. -- User Option: transient-history-file
  346. This file is used to persist the history of transients and their
  347. infixes between Emacs sessions.
  348. -- User Option: transient-history-limit
  349. This option controls how many history elements are kept at the time
  350. the history in saved in ‘transient-history-file’.
  351. 
  352. File: transient.info, Node: Getting Help for Suffix Commands, Next: Enabling and Disabling Suffixes, Prev: Using History, Up: Usage
  353. 2.6 Getting Help for Suffix Commands
  354. ====================================
  355. Transients can have many suffixes and infixes that the user might not be
  356. familiar with. To make it trivial to get help for these, Transient
  357. provides access to the documentation directly from the active transient.
  358. ‘C-h’ (‘transient-help’)
  359. This command enters help mode. When help mode is active, then
  360. typing ‘<key>’ shows information about the suffix command that
  361. ‘<key>’ normally is bound to (instead of invoking it). Pressing
  362. ‘C-h’ a second time shows information about the _prefix_ command.
  363. After typing ‘<key>’ the stack of transient states is suspended and
  364. information about the suffix command is shown instead. Typing ‘q’
  365. in the help buffer buries that buffer and resumes the transient
  366. state.
  367. What sort of documentation is shown depends on how the transient was
  368. defined. For infix commands that represent command-line arguments this
  369. ideally shows the appropriate manpage. ‘transient-help’ then tries to
  370. jump to the correct location within that. Info manuals are also
  371. supported. The fallback is to show the commands doc-string, for
  372. non-infix suffixes this is usually appropriate.
  373. 
  374. File: transient.info, Node: Enabling and Disabling Suffixes, Next: Other Commands, Prev: Getting Help for Suffix Commands, Up: Usage
  375. 2.7 Enabling and Disabling Suffixes
  376. ===================================
  377. The user base of a package that uses transients can be very diverse.
  378. This is certainly the case for Magit; some users have been using it and
  379. Git for a decade, while others are just getting started now.
  380. For that reason a mechanism is needed that authors can use to
  381. classify a transient’s infixes and suffixes along the
  382. essentials...everything spectrum. We use the term "levels" to describe
  383. that mechanism.
  384. Each suffix command is placed on a level and each transient has a
  385. level (called transient-level), which controls which suffix commands are
  386. available. Integers between 1 and 7 (inclusive) are valid levels. For
  387. suffixes, 0 is also valid; it means that the suffix is not displayed at
  388. any level.
  389. The levels of individual transients and/or their individual suffixes
  390. can be changed interactively, by invoking the transient and then
  391. pressing ‘C-x l’ to enter the "edit" mode, see below.
  392. The default level for both transients and their suffixes is 4. The
  393. ‘transient-default-level’ option only controls the default for
  394. transients. The default suffix level is always 4. The authors of
  395. transients should place certain suffixes on a higher level, if they
  396. expect that it won’t be of use to most users, and they should place very
  397. important suffixes on a lower level, so that they remain available even
  398. if the user lowers the transient level.
  399. (Magit currently places nearly all suffixes on level 4 and lower
  400. levels are not used at all yet. So for the time being you should not
  401. set a lower default level and using a higher level might not give you as
  402. many additional suffixes as you hoped.)
  403. -- User Option: transient-default-level
  404. This option controls which suffix levels are made available by
  405. default. It sets the transient-level for transients for which the
  406. user has not set that individually.
  407. -- User Option: transient-levels-file
  408. This file is used to persist the levels of transients and their
  409. suffixes between Emacs sessions.
  410. ‘C-x l’ (‘transient-set-level’)
  411. This command enters edit mode. When edit mode is active, then all
  412. infixes and suffixes that are currently usable are displayed along
  413. with their levels. The colors of the levels indicate whether they
  414. are enabled or not. The level of the transient is also displayed
  415. along with some usage information.
  416. In edit mode, pressing the key that would usually invoke a certain
  417. suffix does instead prompt the user for the level that that suffix
  418. should be placed on.
  419. Help mode is available in edit mode.
  420. To change the transient level press ‘C-x l’ again.
  421. To exit edit mode press ‘C-g’.
  422. Note that edit mode does not display any suffixes that are not
  423. currently usable. ‘magit-rebase’ for example shows different
  424. suffixes depending on whether a rebase is already in progress or
  425. not. The predicates also apply in edit mode.
  426. Therefore, to control which suffixes are available given a certain
  427. state, you have to make sure that that state is currently active.
  428. 
  429. File: transient.info, Node: Other Commands, Prev: Enabling and Disabling Suffixes, Up: Usage
  430. 2.8 Other Commands
  431. ==================
  432. When invoking a transient in a small frame, the transient window may not
  433. show the complete buffer, making it necessary to scroll, using the
  434. following commands. These commands are never shown in the transient
  435. window, and the key bindings are the same as for ‘scroll-up-command’ and
  436. ‘scroll-down-command’ in other buffers.
  437. -- Command: transient-scroll-up arg
  438. This command scrolls text of transient popup window upward ARG
  439. lines. If ARG is ‘nil’, then it scrolls near full screen. This is
  440. a wrapper around ‘scroll-up-command’ (which see).
  441. -- Command: transient-scroll-down arg
  442. This command scrolls text of transient popup window down ARG lines.
  443. If ARG is ‘nil’, then it scrolls near full screen. This is a
  444. wrapper around ‘scroll-down-command’ (which see).
  445. 
  446. File: transient.info, Node: Other Options, Next: Modifying Existing Transients, Prev: Usage, Up: Top
  447. 3 Other Options
  448. ***************
  449. -- User Option: transient-show-popup
  450. This option controls whether the current transient’s infix and
  451. suffix commands are shown in the popup buffer.
  452. • If ‘t’ (the default) then the popup buffer is shown as soon as
  453. a transient prefix command is invoked.
  454. • If ‘nil’, then the popup buffer is not shown unless the user
  455. explicitly requests it, by pressing an incomplete prefix key
  456. sequence.
  457. • If a number, then the a brief one-line summary is shown
  458. instead of the popup buffer. If zero or negative, then not
  459. even that summary is shown; only the pressed key itself is
  460. shown.
  461. The popup is shown when the user explicitly requests it by
  462. pressing an incomplete prefix key sequence. Unless this is
  463. zero, then the popup is shown after that many seconds of
  464. inactivity (using the absolute value).
  465. -- User Option: transient-enable-popup-navigation
  466. This option controls whether navigation commands are enabled in the
  467. transient popup.
  468. While a transient is active the transient popup buffer is not the
  469. current buffer, making it necesary to use dedicated commands to act
  470. on that buffer itself. This is disabled by default. If this
  471. option is non-nil, then the following features are available:
  472. • ‘<up>’ moves the cursor to the previous suffix. ‘<down>’
  473. moves the cursor to the next suffix. ‘RET’ invokes the suffix
  474. the cursor is on.
  475. • ‘<mouse-1>’ invokes the clicked on suffix.
  476. • ‘C-s’ and ‘C-r’ start isearch in the popup buffer.
  477. -- User Option: transient-display-buffer-action
  478. This option specifies the action used to display the transient
  479. popup buffer. The transient popup buffer is displayed in a window
  480. using ‘(display-buffer buf transient-display-buffer-action)’.
  481. The value of this option has the form ‘(FUNCTION . ALIST)’, where
  482. FUNCTION is a function or a list of functions. Each such function
  483. should accept two arguments: a buffer to display and an alist of
  484. the same form as ALIST. See *note (elisp)Choosing Window::.
  485. The default is ‘(display-buffer-in-side-window (side . bottom))’.
  486. This displays the window at the bottom of the selected frame.
  487. Another useful value is ‘(display-buffer-below-selected)’. This is
  488. what ‘magit-popup’ used by default. For more alternatives see
  489. *note (elisp)Display Action Functions::.
  490. It may be possible to display the window in another frame, but
  491. whether that works in practice depends on the window-manager. If
  492. the window manager selects the new window (Emacs frame), then it
  493. doesn’t work.
  494. If you change the value of this option, then you might also want to
  495. change the value of ‘transient-mode-line-format’.
  496. -- User Option: transient-mode-line-format
  497. This option controls whether the transient popup buffer has a
  498. mode-line, separator line, or neither.
  499. If ‘nil’, then the buffer has no mode-line. If the buffer is not
  500. displayed right above the echo area, then this probably is not a
  501. good value.
  502. If ‘line’ (the default), then the buffer also has no mode-line, but
  503. a thin line is drawn instead, using the background color of the
  504. face ‘transient-separator’.
  505. Otherwise this can be any mode-line format. See ~*note (elisp)Mode
  506. Line Format:: for details.
  507. -- User Option: transient-read-with~initial-input
  508. This option controls whether the last history element is used as
  509. the initial minibuffer input when reading the value of an infix
  510. argument from the user. If ‘nil’, then there is no initial input
  511. and the first element has to be accessed the same way as the older
  512. elements.
  513. -- User Option: transient-highlight-mismatched-keys
  514. This option controls whether key bindings of infix commands that do
  515. not match the respective command-line argument should be
  516. highlighted. For other infix commands this option has no effect.
  517. When this option is non-nil, then the key binding for an infix
  518. argument is highlighted when only a long argument (e.g.
  519. ‘--verbose’) is specified but no shorthand (e.g ‘-v’). In the rare
  520. case that a shorthand is specified but the key binding does not
  521. match, then it is highlighted differently.
  522. Highlighting mismatched key bindings is useful when learning the
  523. arguments of the underlying command-line tool; you wouldn’t want to
  524. learn any short-hands that do not actually exist.
  525. The highlighting is done using one of the faces
  526. ‘transient-mismatched-key’ and ‘transient-nonstandard-key’.
  527. -- User Option: transient-substitute-key-function
  528. This function is used to modify key bindings. It the value of this
  529. option is nil (the default), then no substitution is performed.
  530. This function is called with one argument, the prefix object, and
  531. must return a key binding description, either the existing key
  532. description it finds in the ‘key’ slot, or key description that
  533. replaces the prefix key. It could be used to make other
  534. substitutions, but that is discouraged.
  535. For example, ‘=’ is hard to reach using my custom keyboard layout,
  536. so I substitute ‘(’ for that, which is easy to reach using a layout
  537. optimized for lisp.
  538. (setq transient-substitute-key-function
  539. (lambda (obj)
  540. (let ((key (oref obj key)))
  541. (if (string-match "\\`\\(=\\)[a-zA-Z]" key)
  542. (replace-match "(" t t key 1)
  543. key))))
  544. -- User Option: transient-detect-key-conflicts
  545. This option controls whether key binding conflicts should be
  546. detected at the time the transient is invoked. If so, then this
  547. results in an error, which prevents the transient from being used.
  548. Because of that, conflicts are ignored by default.
  549. Conflicts cannot be determined earlier, i.e. when the transient is
  550. being defined and when new suffixes are being added, because at
  551. that time there can be false-positives. It is actually valid for
  552. multiple suffixes to share a common key binding, provided the
  553. predicates of those suffixes prevent that more than one of them is
  554. enabled at a time.
  555. 
  556. File: transient.info, Node: Modifying Existing Transients, Next: Defining New Commands, Prev: Other Options, Up: Top
  557. 4 Modifying Existing Transients
  558. *******************************
  559. To an extent transients can be customized interactively, see *note
  560. Enabling and Disabling Suffixes::. This section explains how existing
  561. transients can be further modified non-interactively.
  562. The following functions share a few arguments:
  563. • PREFIX is a transient prefix command, a symbol.
  564. • SUFFIX is a transient infix or suffix specification in the same
  565. form as expected by ‘define-transient-command’. Note that an infix
  566. is a special kind of suffix. Depending on context "suffixes" means
  567. "suffixes (including infixes)" or "non-infix suffixes". Here it
  568. means the former. See *note Suffix Specifications::.
  569. SUFFIX may also be a group in the same form as expected by
  570. ‘define-transient-command’. See *note Group Specifications::.
  571. • LOC is a command, a key vector, a key description (a string as
  572. returned by ‘key-description’), or a list specifying coordinates
  573. (the last element may also be a command or key). For example ‘(1 0
  574. -1)’ identifies the last suffix (‘-1’) of the first subgroup (‘0’)
  575. of the second group (‘1’).
  576. If LOC is a list of coordinates, then it can be used to identify a
  577. group, not just an individual suffix command.
  578. The function ‘transient-get-suffix’ can be useful to determine
  579. whether a certain coordination list identifies the suffix or group
  580. that you expect it to identify. In hairy cases it may be necessary
  581. to look at the definition of the transient prefix command.
  582. These functions operate on the information stored in the
  583. ‘transient--layout’ property of the PREFIX symbol. Suffix entries in
  584. that tree are not objects but have the form ‘(LEVEL CLASS PLIST)’, where
  585. plist should set at least ‘:key’, ‘:description’ and ‘:command’.
  586. -- Function: transient-insert-suffix prefix loc suffix
  587. This function inserts suffix or group SUFFIX into PREFIX before
  588. LOC.
  589. -- Function: transient-append-suffix prefix loc suffix
  590. This function inserts suffix or group SUFFIX into PREFIX after LOC.
  591. -- Function: transient-replace-suffix prefix loc suffix
  592. This function replaces the suffix or group at LOC in PREFIX with
  593. suffix or group SUFFIX.
  594. -- Function: transient-remove-suffix prefix loc
  595. This function removes the suffix or group at LOC in PREFIX.
  596. -- Function: transient-get-suffix prefix loc
  597. This function returns the suffix or group at LOC in PREFIX. The
  598. returned value has the form mentioned above.
  599. -- Function: transient-suffix-put prefix loc prop value
  600. This function edits the suffix or group at LOC in PREFIX, by
  601. setting the PROP of its plist to VALUE.
  602. Most of these functions do not signal an error if they cannot perform
  603. the requested modification. The functions that insert new suffixes show
  604. a warning if LOC cannot be found in PREFIX, without signaling an error.
  605. The reason for doing it like this is that establishing a key binding
  606. (and that is what we essentially are trying to do here) should not
  607. prevent the rest of the configuration from loading. Among these
  608. functions only ‘transient-get-suffix’ and ‘transient-suffix-put’ may
  609. signal an error.
  610. 
  611. File: transient.info, Node: Defining New Commands, Next: Classes and Methods, Prev: Modifying Existing Transients, Up: Top
  612. 5 Defining New Commands
  613. ***********************
  614. * Menu:
  615. * Defining Transients::
  616. * Binding Suffix and Infix Commands::
  617. * Defining Suffix and Infix Commands::
  618. * Using Infix Arguments::
  619. * Transient State::
  620. 
  621. File: transient.info, Node: Defining Transients, Next: Binding Suffix and Infix Commands, Up: Defining New Commands
  622. 5.1 Defining Transients
  623. =======================
  624. A transient consists of a prefix command and at least one suffix
  625. command, though usually a transient has several infix and suffix
  626. commands. The below macro defines the transient prefix command *and* it
  627. binds the transient’s infix and suffix commands. In other words, it
  628. defines the complete transient, not just the transient prefix command
  629. that is used to invoke that transient.
  630. -- Macro: define-transient-command name arglist [docstring] [keyword
  631. value]... group... [body...]
  632. This macro defines NAME as a transient prefix command and binds the
  633. transient’s infix and suffix commands.
  634. ARGLIST are the arguments that the prefix command takes. DOCSTRING
  635. is the documentation string and is optional.
  636. These arguments can optionally be followed by keyword-value pairs.
  637. Each key has to be a keyword symbol, either ‘:class’ or a keyword
  638. argument supported by the constructor of that class. The
  639. ‘transient-prefix’ class is used if the class is not specified
  640. explicitly.
  641. GROUPs add key bindings for infix and suffix commands and specify
  642. how these bindings are presented in the popup buffer. At least one
  643. GROUP has to be specified. See *note Binding Suffix and Infix
  644. Commands::.
  645. The BODY is optional. If it is omitted, then ARGLIST is ignored
  646. and the function definition becomes:
  647. (lambda ()
  648. (interactive)
  649. (transient-setup 'NAME))
  650. If BODY is specified, then it must begin with an ‘interactive’ form
  651. that matches ARGLIST, and it must call ‘transient-setup’. It may
  652. however call that function only when some condition is satisfied.
  653. All transients have a (possibly ‘nil’) value, which is exported
  654. when suffix commands are called, so that they can consume that
  655. value. For some transients it might be necessary to have a sort of
  656. secondary value, called a "scope". Such a scope would usually be
  657. set in the command’s ‘interactive’ form and has to be passed to the
  658. setup function:
  659. (transient-setup 'NAME nil nil :scope SCOPE)
  660. For example, the scope of the ‘magit-branch-configure’ transient is
  661. the branch whose variables are being configured.
  662. 
  663. File: transient.info, Node: Binding Suffix and Infix Commands, Next: Defining Suffix and Infix Commands, Prev: Defining Transients, Up: Defining New Commands
  664. 5.2 Binding Suffix and Infix Commands
  665. =====================================
  666. The macro ‘define-transient-command’ is used to define a transient.
  667. This defines the actual transient prefix command (see *note Defining
  668. Transients::) and adds the transient’s infix and suffix bindings, as
  669. described below.
  670. Users and third-party packages can add additional bindings using
  671. functions such as ‘transient-insert-suffix’ (See *note Modifying
  672. Existing Transients::). These functions take a "suffix specification"
  673. as one of their arguments, which has the same form as the specifications
  674. used in ‘define-transient-command’.
  675. * Menu:
  676. * Group Specifications::
  677. * Suffix Specifications::
  678. 
  679. File: transient.info, Node: Group Specifications, Next: Suffix Specifications, Up: Binding Suffix and Infix Commands
  680. 5.2.1 Group Specifications
  681. --------------------------
  682. The suffix and infix commands of a transient are organized in groups.
  683. The grouping controls how the descriptions of the suffixes are outlined
  684. visually but also makes it possible to set certain properties for a set
  685. of suffixes.
  686. Several group classes exist, some of which organize suffixes in
  687. subgroups. In most cases the class does not have to be specified
  688. explicitly, but see *note Group Classes::.
  689. Groups are specified in the call to ‘define-transient-command’, using
  690. vectors. Because groups are represented using vectors, we cannot use
  691. square brackets to indicate an optional element and instead use curly
  692. brackets to do the latter.
  693. Group specifications then have this form:
  694. [{LEVEL} {DESCRIPTION} {KEYWORD VALUE}... ELEMENT...]
  695. The LEVEL is optional and defaults to 4. See *note Enabling and
  696. Disabling Suffixes::.
  697. The DESCRIPTION is optional. If present it is used as the heading of
  698. the group.
  699. The KEYWORD-VALUE pairs are optional. Each keyword has to be a
  700. keyword symbol, either ‘:class’ or a keyword argument supported by the
  701. constructor of that class.
  702. • One of these keywords, ‘:description’, is equivalent to specifying
  703. DESCRIPTION at the very beginning of the vector. The
  704. recommendation is to use ‘:description’ if some other keyword is
  705. also used, for consistency, or DESCRIPTION otherwise, because it
  706. looks better.
  707. • Likewise ‘:level’ is equivalent to LEVEL.
  708. • Other important keywords include the ‘:if...’ keywords. These
  709. keywords control whether the group is available in a certain
  710. situation.
  711. For example, one group of the ‘magit-rebase’ transient uses ‘:if
  712. magit-rebase-in-progress-p’, which contains the suffixes that are
  713. useful while rebase is already in progress; and another that uses
  714. ‘:if-not magit-rebase-in-progress-p’, which contains the suffixes
  715. that initiate a rebase.
  716. These predicates can also be used on individual suffixes and are
  717. only documented once, see *note Predicate Slots::.
  718. • Finally the value of ‘:hide’, if non-nil, is a predicate that
  719. controls whether the group is hidden by default. The key bindings
  720. for suffixes of a hidden group should all use the same prefix key.
  721. Pressing that prefix key should temporarily show the group and its
  722. suffixes, which assumes that a predicate like this is used:
  723. (lambda ()
  724. (eq (car transient--redisplay-key)
  725. ?\C-c)) ; the prefix key shared by all bindings
  726. The ELEMENTs are either all subgroups (vectors), or all suffixes
  727. (lists) and strings. (At least currently no group type exists that
  728. would allow mixing subgroups with commands at the same level, though in
  729. principle there is nothing that prevents that.)
  730. If the ELEMENTs are not subgroups, then they can be a mixture of
  731. lists that specify commands and strings. Strings are inserted verbatim.
  732. The empty string can be used to insert gaps between suffixes, which is
  733. particularly useful if the suffixes are outlined as a table.
  734. The form of suffix specifications is documented in the next node.
  735. 
  736. File: transient.info, Node: Suffix Specifications, Prev: Group Specifications, Up: Binding Suffix and Infix Commands
  737. 5.2.2 Suffix Specifications
  738. ---------------------------
  739. A transient’s suffix and infix commands are bound when the transient
  740. prefix command is defined using ‘define-transient-command’, see *note
  741. Defining Transients::. The commands are organized into groups, see
  742. *note Group Specifications::. Here we describe the form used to bind an
  743. individual suffix command.
  744. The same form is also used when later binding additional commands
  745. using functions such as ‘transient-insert-suffix’, see *note Modifying
  746. Existing Transients::.
  747. Note that an infix is a special kind of suffix. Depending on context
  748. "suffixes" means "suffixes (including infixes)" or "non-infix suffixes".
  749. Here it means the former.
  750. Suffix specifications have this form:
  751. ([LEVEL] [KEY] [DESCRIPTION] COMMAND|ARGUMENT [KEYWORD VALUE]...)
  752. LEVEL, KEY and DESCRIPTION can also be specified using the KEYWORDs
  753. ‘:level’, ‘:key’ and ‘:description’. If the object that is associated
  754. with COMMAND sets these properties, then they do not have to be
  755. specified here. You can however specify them here anyway, possibly
  756. overriding the objects value just for the binding inside this transient.
  757. • LEVEL is the suffix level, an integer between 1 and 7. See *note
  758. Enabling and Disabling Suffixes::.
  759. • KEY is the key binding, either a vector or key description string.
  760. • DESCRIPTION is the description, either a string or a function that
  761. returns a string. The function should be a lambda expression to
  762. avoid ambiguity. In some cases a symbol that is bound as a
  763. function would also work but to be safe you should use
  764. ‘:description’ in that case.
  765. The next element is either a command or an argument. This is the
  766. only argument that is mandatory in all cases.
  767. • COMMAND is a symbol that is bound as a function, which has to be a
  768. command. Any command will do; it does not need to have an object
  769. associated with it (as would be the case if ‘define-suffix-command’
  770. or ‘define-infix-command’ were used to define it).
  771. As mentioned above the object that is associated with a command can
  772. be used to set the default for certain values that otherwise have
  773. to be set in the suffix specification. Therefore if there is no
  774. object, then you have to make sure to specify the KEY and the
  775. DESCRIPTION.
  776. • The mandatory argument can also be an command-line argument, a
  777. string. In that case an anonymous command is defined and bound.
  778. Instead of a string, this can also be a list of two strings, in
  779. which case the first string is used as the short argument (which
  780. can also be specified using ‘:shortarg’) and the second the long
  781. argument (which can also be specified using ‘:argument’).
  782. Only the long argument is displayed in the popup buffer. See
  783. ‘transient-detect-key-conflicts’ for how the short argument may be
  784. used.
  785. Unless the class is specified explicitly, the appropriate class is
  786. guessed based on the long argument. If the argument ends with "‘"
  787. (e.g. "--format’") then ‘transient-option’ is used, otherwise
  788. ‘transient-switch’.
  789. Finally details can be specified using optional KEYWORD-VALUE pairs.
  790. Each keyword has to be a keyword symbol, either ‘:class’ or a keyword
  791. argument supported by the constructor of that class. See *note Suffix
  792. Slots::.
  793. 
  794. File: transient.info, Node: Defining Suffix and Infix Commands, Next: Using Infix Arguments, Prev: Binding Suffix and Infix Commands, Up: Defining New Commands
  795. 5.3 Defining Suffix and Infix Commands
  796. ======================================
  797. Note that an infix is a special kind of suffix. Depending on context
  798. "suffixes" means "suffixes (including infixes)" or "non-infix suffixes".
  799. -- Macro: define-suffix-command name arglist [docstring] [keyword
  800. value]... body...
  801. This macro defines NAME as a transient suffix command.
  802. ARGLIST are the arguments that the command takes. DOCSTRING is the
  803. documentation string and is optional.
  804. These arguments can optionally be followed by keyword-value pairs.
  805. Each keyword has to be a keyword symbol, either ‘:class’ or a
  806. keyword argument supported by the constructor of that class. The
  807. ‘transient-suffix’ class is used if the class is not specified
  808. explicitly.
  809. The BODY must begin with an ‘interactive’ form that matches
  810. ARGLIST. Use the function ‘transient-args’ or the low-level
  811. variable ‘current-transient-suffixes’ if the former does not give
  812. you all the required details. This should, but does not
  813. necessarily have to be, done inside the ‘interactive’ form; just
  814. like for ‘prefix-arg’ and ‘current-prefix-arg’.
  815. -- Macro: define-infix-command name arglist [docstring] [keyword
  816. value]...
  817. This macro defines NAME as a transient infix command.
  818. ARGLIST is always ignored (but mandatory never-the-less) and
  819. reserved for future use. DOCSTRING is the documentation string and
  820. is optional.
  821. The keyword-value pairs are mandatory. All transient infix
  822. commands are ‘equal’ to each other (but not ‘eq’), so it is
  823. meaningless to define an infix command without also setting at
  824. least ‘:class’ and one other keyword (which it is depends on the
  825. used class, usually ‘:argument’ or ‘:variable’).
  826. Each keyword has to be a keyword symbol, either ‘:class’ or a
  827. keyword argument supported by the constructor of that class. The
  828. ‘transient-switch’ class is used if the class is not specified
  829. explicitly.
  830. The function definitions is always:
  831. (lambda ()
  832. (interactive)
  833. (let ((obj (transient-suffix-object)))
  834. (transient-infix-set obj (transient-infix-read obj)))
  835. (transient--show))
  836. ‘transient-infix-read’ and ‘transient-infix-set’ are generic
  837. functions. Different infix commands behave differently because the
  838. concrete methods are different for different infix command classes.
  839. In rare cases the above command function might not be suitable,
  840. even if you define your own infix command class. In that case you
  841. have to use ‘transient-suffix-command’ to define the infix command
  842. and use ‘t’ as the value of the ‘:transient’ keyword.
  843. -- Macro: define-infix-argument name arglist [docstring] [keyword
  844. value]...
  845. This macro defines NAME as a transient infix command.
  846. It is an alias for ‘define-infix-command’. Only use this alias to
  847. define an infix command that actually sets an infix argument. To
  848. define a infix command that, for example, sets a variable use
  849. ‘define-infix-command’ instead.
  850. 
  851. File: transient.info, Node: Using Infix Arguments, Next: Transient State, Prev: Defining Suffix and Infix Commands, Up: Defining New Commands
  852. 5.4 Using Infix Arguments
  853. =========================
  854. The function and the variables described below allow suffix commands to
  855. access the value of the transient from which they were invoked; which is
  856. the value of its infix arguments. These variables are set when the user
  857. invokes a suffix command that exits the transient, but before actually
  858. calling the command.
  859. When returning to the command-loop after calling the suffix command,
  860. the arguments are reset to ‘nil’ (which causes the function to return
  861. ‘nil’ too).
  862. Like for Emacs’ prefix arguments it is advisable, but not mandatory,
  863. to access the infix arguments inside the command’s ‘interactive’ form.
  864. The preferred way of doing that is to call the ‘transient-args’
  865. function, which for infix arguments serves about the same purpose as
  866. ‘prefix-arg’ serves for prefix arguments.
  867. -- Function: transient-args &optional prefix separate
  868. This function returns the value of the transient from which the
  869. current suffix was called. If the current suffix command was not
  870. called from a transient, then it returns ‘nil’.
  871. If optional PREFIX is non-‘nil’, then it should be a symbol, a
  872. transient prefix command. In that case the value of the transient
  873. is only returned if the suffix was invoked from *that* transient.
  874. Otherwise ‘nil’ is returned. This function is also used
  875. internally, in which PREFIX can also be a ‘transient-prefix’
  876. object.
  877. If optional SEPARATE is non-‘nil’, then the arguments are separated
  878. into two groups. If SEPARATE is ‘t’, they are separated into atoms
  879. and conses (‘nil’ isn’t a valid value, so it doesn’t matter that
  880. that is both an atom and a cons).
  881. SEPARATE can also be a predicate function, in which case the first
  882. element is a list of the values for which it returns non-‘nil’ and
  883. the second element is a list of the values for which it returns
  884. ‘nil’.
  885. For transients that are used to pass arguments to a subprocess
  886. (such as ‘git’), ‘stringp’ is a useful value for SEPARATE, it
  887. separates non-positional arguments from positional arguments. The
  888. value of Magit’s file argument (‘"--"’) for example looks like
  889. this: ‘("--" file...)’."
  890. -- Variable: current-transient-suffixes
  891. The suffixes of the transient from which this suffix command was
  892. invoked. This is a list of objects. Usually it is sufficient to
  893. instead use the function ‘transient-args’, which returns a list of
  894. values. In complex cases it might be necessary to use this
  895. variable instead, i.e. if you need access to information beside
  896. the value.
  897. -- Variable: current-transient-prefix
  898. The transient from which this suffix command was invoked. The
  899. returned value is a ‘transient-prefix’ object, which holds
  900. information associated with the transient prefix command.
  901. -- Variable: current-transient-command
  902. The transient from which this suffix command was invoked. The
  903. returned value is a symbol, the transient prefix command.
  904. 
  905. File: transient.info, Node: Transient State, Prev: Using Infix Arguments, Up: Defining New Commands
  906. 5.5 Transient State
  907. ===================
  908. Invoking a transient prefix command "activates" the respective
  909. transient, i.e. it puts a transient keymap into effect, which binds the
  910. transient’s infix and suffix commands.
  911. The default behavior while a transient is active is as follows:
  912. • Invoking an infix command does not affect the transient state; the
  913. transient remains active.
  914. • Invoking a (non-infix) suffix command "deactivates" the transient
  915. state by removing the transient keymap and performing some
  916. additional cleanup.
  917. • Invoking a command that is bound in a keymap other than the
  918. transient keymap is disallowed and trying to do so results in a
  919. warning. This does not "deactivate" the transient.
  920. But these are just the defaults. Whether a certain command
  921. deactivates or "exits" the transient is configurable. There is more
  922. than one way in which a command can be "transient" or "non-transient";
  923. the exact behavior is implemented by calling a so-called "pre-command"
  924. function. Whether non-suffix commands are allowed to be called is
  925. configurable per transient.
  926. • The transient-ness of suffix commands (including infix commands) is
  927. controlled by the value of their ‘transient’ slot, which can be set
  928. either when defining the command or when adding a binding to a
  929. transient while defining the respective transient prefix command.
  930. Valid values are booleans and the pre-commands described below.
  931. • ‘t’ is equivalent to ‘transient--do-stay’.
  932. • ‘nil’ is equivalent to ‘transient--do-exit’.
  933. • If ‘transient’ is unbound (and that is actually the default
  934. for non-infix suffixes) then the value of the prefix’s
  935. ‘transient-suffix’ slot is used instead. The default value of
  936. that slot is ‘nil’, so the suffix’s ‘transient’ slot being
  937. unbound is essentially equivalent to it being ‘nil’.
  938. • A suffix command can be a prefix command itself, i.e. a
  939. "sub-prefix". While a sub-prefix is active we nearly always want
  940. ‘C-g’ to take the user back to the "super-prefix". However in rare
  941. cases this may not be desirable, and that makes the following
  942. complication necessary:
  943. For ‘transient-suffix’ objects the ‘transient’ slot is unbound. We
  944. can ignore that for the most part because, as stated above, ‘nil’
  945. and the slot being unbound are equivalent, and means "do exit".
  946. That isn’t actually true for suffixes that are sub-prefixes though.
  947. For such suffixes unbound means "do exit but allow going back",
  948. which is the default, while ‘nil’ means "do exit permanently",
  949. which requires that slot to be explicitly set to that value.
  950. • The transient-ness of certain built-in suffix commands is specified
  951. using ‘transient-predicate-map’. This is a special keymap, which
  952. binds commands to pre-commands (as opposed to keys to commands) and
  953. takes precedence over the ‘transient’ slot.
  954. The available pre-command functions are documented below. They are
  955. called by ‘transient--pre-command’, a function on ‘pre-command-hook’ and
  956. the value that they return determines whether the transient is exited.
  957. To do so the value of one of the constants ‘transient--exit’ or
  958. ‘transient--stay’ is used (that way we don’t have to remember if ‘t’
  959. means "exit" or "stay").
  960. Additionally these functions may change the value of ‘this-command’
  961. (which explains why they have to be called using ‘pre-command-hook’),
  962. call ‘transient-export’, ‘transient--stack-zap’ or
  963. ‘transient--stack-push’; and set the values of ‘transient--exitp’,
  964. ‘transient--helpp’ or ‘transient--editp’.
  965. 5.5.1 Pre-commands for Infixes
  966. ------------------------------
  967. The default for infixes is ‘transient--do-stay’. This is also the only
  968. function that makes sense for infixes.
  969. -- Function: transient--do-stay
  970. Call the command without exporting variables and stay transient.
  971. 5.5.2 Pre-commands for Suffixes
  972. -------------------------------
  973. The default for suffixes is ‘transient--do-exit’.
  974. -- Function: transient--do-exit
  975. Call the command after exporting variables and exit the transient.
  976. -- Function: transient--do-call
  977. Call the command after exporting variables and stay transient.
  978. -- Function: transient--do-replace
  979. Call the transient prefix command, replacing the active transient.
  980. This is used for suffix that are prefixes themselves, i.e. for
  981. sub-prefixes.
  982. 5.5.3 Pre-commands for Non-Suffixes
  983. -----------------------------------
  984. The default for non-suffixes, i.e commands that are bound in other
  985. keymaps beside the transient keymap, is ‘transient--do-warn’. Silently
  986. ignoring the user-error is also an option, though probably not a good
  987. one.
  988. If you want to let the user invoke non-suffix commands, then use
  989. ‘transient--do-stay’ as the value of the prefix’s ‘transient-non-suffix’
  990. slot.
  991. -- Function: transient--do-warn
  992. Call ‘transient-undefined’ and stay transient.
  993. -- Function: transient--do-noop
  994. Call ‘transient-noop’ and stay transient.
  995. 5.5.4 Special Pre-Commands
  996. --------------------------
  997. -- Function: transient--do-quit-one
  998. If active, quit help or edit mode, else exit the active transient.
  999. This is used when the user pressed ‘C-g’.
  1000. -- Function: transient--do-quit-all
  1001. Exit all transients without saving the transient stack.
  1002. This is used when the user pressed ‘C-q’.
  1003. -- Function: transient--do-suspend
  1004. Suspend the active transient, saving the transient stack.
  1005. This is used when the user pressed ‘C-z’.
  1006. 
  1007. File: transient.info, Node: Classes and Methods, Next: Related Abstractions and Packages, Prev: Defining New Commands, Up: Top
  1008. 6 Classes and Methods
  1009. *********************
  1010. Transient uses classes and generic functions to make it possible to
  1011. define new types of suffix commands that are similar to existing types,
  1012. but behave differently in some aspects. It does the same for groups and
  1013. prefix commands, though at least for prefix commands that *currently*
  1014. appears to be less important.
  1015. Every prefix, infix and suffix command is associated with an object,
  1016. which holds information that controls certain aspects of its behavior.
  1017. This happens in two ways.
  1018. • Associating a command with a certain class gives the command a
  1019. type. This makes it possible to use generic functions to do
  1020. certain things that have to be done differently depending on what
  1021. type of command it acts on.
  1022. That in turn makes it possible for third-parties to add new types
  1023. without having to convince the maintainer of Transient that that
  1024. new type is important enough to justify adding a special case to a
  1025. dozen or so functions.
  1026. • Associating a command with an object makes it possible to easily
  1027. store information that is specific to that particular command.
  1028. Two commands may have the same type, but obviously their key
  1029. bindings and descriptions still have to be different, for example.
  1030. The values of some slots are functions. The ‘reader’ slot for
  1031. example holds a function that is used to read a new value for an
  1032. infix command. The values of such slots are regular functions.
  1033. Generic functions are used when a function should do something
  1034. different based on the type of the command, i.e. when all commands
  1035. of a certain type should behave the same way but different from the
  1036. behavior for other types. Object slots that hold a regular
  1037. function as value are used when the task that they perform is
  1038. likely to differ even between different commands of the same type.
  1039. * Menu:
  1040. * Group Classes::
  1041. * Group Methods::
  1042. * Prefix Classes::
  1043. * Suffix Classes::
  1044. * Suffix Methods::
  1045. * Prefix Slots::
  1046. * Suffix Slots::
  1047. * Predicate Slots::
  1048. 
  1049. File: transient.info, Node: Group Classes, Next: Group Methods, Up: Classes and Methods
  1050. 6.1 Group Classes
  1051. =================
  1052. The type of a group can be specified using the ‘:class’ property at the
  1053. beginning of the class specification, e.g. ‘[:class transient-columns
  1054. ...]’ in a call to ‘define-transient-command’.
  1055. • The abstract ‘transient-child’ class is the base class of both
  1056. ‘transient-group’ (and therefore all groups) as well as of
  1057. ‘transient-suffix’ (and therefore all suffix and infix commands).
  1058. This class exists because the elements (aka "children") of certain
  1059. groups can be other groups instead of suffix and infix commands.
  1060. • The abstract ‘transient-group’ class is the superclass of all other
  1061. group classes.
  1062. • The ‘transient-column’ class is the simplest group.
  1063. This is the default "flat" group. If the class is not specified
  1064. explicitly and the first element is not a vector (i.e. not a
  1065. group), then this class is used.
  1066. This class displays each element on a separate line.
  1067. • The ‘transient-row’ class displays all elements on a single line.
  1068. • The ‘transient-columns’ class displays commands organized in
  1069. columns.
  1070. Direct elements have to be groups whose elements have to be
  1071. commands or strings. Each subgroup represents a column. This
  1072. class takes care of inserting the subgroups’ elements.
  1073. This is the default "nested" group. If the class is not specified
  1074. explicitly and the first element is a vector (i.e. a group), then
  1075. this class is used.
  1076. • The ‘transient-subgroups’ class wraps other groups.
  1077. Direct elements have to be groups whose elements have to be
  1078. commands or strings. This group inserts an empty line between
  1079. subgroups. The subgroups themselves are responsible for displaying
  1080. their elements.
  1081. 
  1082. File: transient.info, Node: Group Methods, Next: Prefix Classes, Prev: Group Classes, Up: Classes and Methods
  1083. 6.2 Group Methods
  1084. =================
  1085. -- Function: transient--insert-group group
  1086. This generic function formats the group and its elements and
  1087. inserts the result into the current buffer, which is a temporary
  1088. buffer. The contents of that buffer are later inserted into the
  1089. popup buffer.
  1090. Functions that are called by this function may need to operate in
  1091. the buffer from which the transient was called. To do so they can
  1092. temporally make the ‘transient--source-buffer’ the current buffer.
  1093. 
  1094. File: transient.info, Node: Prefix Classes, Next: Suffix Classes, Prev: Group Methods, Up: Classes and Methods
  1095. 6.3 Prefix Classes
  1096. ==================
  1097. Currently the ‘transient-prefix’ class is being used for all prefix
  1098. command and there is only a single generic functions that can be
  1099. specialized based on the class of a prefix command.
  1100. -- Function: transient--history-init obj
  1101. This generic function is called while setting up the transient and
  1102. is responsible for initializing the ‘history’ slot. This is the
  1103. transient-wide history; many individual infixes also have a history
  1104. of their own.
  1105. The default (and currently only) method extracts the value from the
  1106. global variable ‘transient-history’.
  1107. A transient prefix command’s object is stored in the
  1108. ‘transient--prefix’ property of the command symbol. While a transient
  1109. is active, a clone of that object is stored in the variable
  1110. ‘transient--prefix’. A clone is used because some changes that are made
  1111. to the active transient’s object should not affect later invocations.
  1112. 
  1113. File: transient.info, Node: Suffix Classes, Next: Suffix Methods, Prev: Prefix Classes, Up: Classes and Methods
  1114. 6.4 Suffix Classes
  1115. ==================
  1116. • All suffix and infix classes derive from ‘transient-suffix’, which
  1117. in turn derives from ‘transient-child’, from which
  1118. ‘transient-group’ also derives (see *note Group Classes::).
  1119. • All infix classes derived from the abstract ‘transient-infix’
  1120. class, which in turn derives from the ‘transient-suffix’ class.
  1121. Infixes are a special type of suffixes. The primary difference is
  1122. that infixes always use the ‘transient--do-stay’ pre-command, while
  1123. non-infix suffixes use a variety of pre-commands (see *note
  1124. Transient State::). Doing that is most easily achieved by using
  1125. this class, though theoretically it would be possible to define an
  1126. infix class that does not do so. If you do that then you get to
  1127. implement many methods.
  1128. Also infixes and non-infix suffixes are usually defined using
  1129. different macros (see *note Defining Suffix and Infix Commands::).
  1130. • Classes used for infix commands that represent arguments should be
  1131. derived from the abstract ‘transient-argument’ class.
  1132. • The ‘transient-switch’ class (or a derived class) is used for infix
  1133. arguments that represent command-line switches (arguments that do
  1134. not take a value).
  1135. • The ‘transient-option’ class (or a derived class) is used for infix
  1136. arguments that represent command-line options (arguments that do
  1137. take a value).
  1138. • The ‘transient-switches’ class can be used for a set of mutually
  1139. exclusive command-line switches.
  1140. • The ‘transient-files’ class can be used for a "–" argument that
  1141. indicates that all remaining arguments are files.
  1142. • Classes used for infix commands that represent variables should
  1143. derived from the abstract ‘transient-variables’ class.
  1144. Magit defines additional classes, which can serve as examples for the
  1145. fancy things you can do without modifying Transient. Some of these
  1146. classes will likely get generalized and added to Transient. For now
  1147. they are very much subject to change and not documented.
  1148. 
  1149. File: transient.info, Node: Suffix Methods, Next: Prefix Slots, Prev: Suffix Classes, Up: Classes and Methods
  1150. 6.5 Suffix Methods
  1151. ==================
  1152. To get information about the methods implementing these generic
  1153. functions use ‘describe-function’.
  1154. * Menu:
  1155. * Suffix Value Methods::
  1156. * Suffix Format Methods::
  1157. 
  1158. File: transient.info, Node: Suffix Value Methods, Next: Suffix Format Methods, Up: Suffix Methods
  1159. 6.5.1 Suffix Value Methods
  1160. --------------------------
  1161. -- Function: transient-init-value obj
  1162. This generic function sets the initial value of the object OBJ.
  1163. This function is called for all suffix commands, but unless a
  1164. concrete method is implemented this falls through to the default
  1165. implementation, which is a noop. In other words this usually only
  1166. does something for infix commands, but note that this is not
  1167. implemented for the abstract class ‘transient-infix’, so if your
  1168. class derives from that directly, then you must implement a method.
  1169. -- Function: transient-infix-read obj
  1170. This generic function determines the new value of the infix object
  1171. OBJ.
  1172. This function merely determines the value; ‘transient-infix-set’ is
  1173. used to actually store the new value in the object.
  1174. For most infix classes this is done by reading a value from the
  1175. user using the reader specified by the ‘reader’ slot (using the
  1176. ‘transient-infix-value’ method described below).
  1177. For some infix classes the value is changed without reading
  1178. anything in the minibuffer, i.e. the mere act of invoking the
  1179. infix command determines what the new value should be, based on the
  1180. previous value.
  1181. -- Function: transient-prompt obj
  1182. This generic function returns the prompt to be used to read infix
  1183. object OBJ’s value.
  1184. -- Function: transient-infix-set obj value
  1185. This generic function sets the value of infix object OBJ to value.
  1186. -- Function: transient-infix-value obj
  1187. This generic function returns the value of the suffix object OBJ.
  1188. This function is called by ‘transient-args’ (which see), meaning
  1189. this function is how the value of a transient is determined so that
  1190. the invoked suffix command can use it.
  1191. Currently most values are strings, but that is not set in stone.
  1192. ‘nil’ is not a value, it means "no value".
  1193. Usually only infixes have a value, but see the method for
  1194. ‘transient-suffix’.
  1195. -- Function: transient-init-scope obj
  1196. This generic function sets the scope of the suffix object OBJ.
  1197. The scope is actually a property of the transient prefix, not of
  1198. individual suffixes. However it is possible to invoke a suffix
  1199. command directly instead of from a transient. In that case, if the
  1200. suffix expects a scope, then it has to determine that itself and
  1201. store it in its ‘scope’ slot.
  1202. This function is called for all suffix commands, but unless a
  1203. concrete method is implemented this falls through to the default
  1204. implementation, which is a noop.
  1205. 
  1206. File: transient.info, Node: Suffix Format Methods, Prev: Suffix Value Methods, Up: Suffix Methods
  1207. 6.5.2 Suffix Format Methods
  1208. ---------------------------
  1209. -- Function: transient-format obj
  1210. This generic function formats and returns OBJ for display.
  1211. When this function is called, then the current buffer is some
  1212. temporary buffer. If you need the buffer from which the prefix
  1213. command was invoked to be current, then do so by temporarily making
  1214. ‘transient--source-buffer’ current.
  1215. -- Function: transient-format-key obj
  1216. This generic function formats OBJ’s ‘key’ for display and returns
  1217. the result.
  1218. -- Function: transient-format-description obj
  1219. This generic function formats OBJ’s ‘description’ for display and
  1220. returns the result.
  1221. -- Function: transient-format-value obj
  1222. This generic function formats OBJ’s value for display and returns
  1223. the result.
  1224. -- Function: transient-show-help obj
  1225. Show help for the prefix, infix or suffix command represented by
  1226. OBJ.
  1227. For prefixes show the info manual, if that is specified using the
  1228. ‘info-manual’ slot. Otherwise show the manpage if that is
  1229. specified using the ‘man-page’ slot. Otherwise show the command’s
  1230. doc-string.
  1231. For suffixes show the command’s doc-string.
  1232. For infixes show the manpage if that is specified. Otherwise show
  1233. the command’s doc-string.
  1234. 
  1235. File: transient.info, Node: Prefix Slots, Next: Suffix Slots, Prev: Suffix Methods, Up: Classes and Methods
  1236. 6.6 *TODO* Prefix Slots
  1237. =======================
  1238. 
  1239. File: transient.info, Node: Suffix Slots, Next: Predicate Slots, Prev: Prefix Slots, Up: Classes and Methods
  1240. 6.7 Suffix Slots
  1241. ================
  1242. Here we document most of the slots that are only available for suffix
  1243. objects. Some slots are shared by suffix and group objects, they are
  1244. documented in *note Predicate Slots::.
  1245. Also see *note Suffix Classes::.
  1246. 6.7.1 Slots of ‘transient-suffix’
  1247. ---------------------------------
  1248. • ‘key’ The key, a key vector or a key description string.
  1249. • ‘command’ The command, a symbol.
  1250. • ‘transient’ Whether to stay transient. See *note Transient
  1251. State::.
  1252. • ‘format’ The format used to display the suffix in the popup buffer.
  1253. It must contain the following %-placeholders:
  1254. • ‘%k’ For the key.
  1255. • ‘%d’ For the description.
  1256. • ‘%v’ For the infix value. Non-infix suffixes don’t have a
  1257. value.
  1258. • ‘description’ The description, either a string or a function that
  1259. is called with no argument and returns a string.
  1260. 6.7.2 Slots of ‘transient-infix’
  1261. --------------------------------
  1262. Some of these slots are only meaningful for some of the subclasses.
  1263. They are defined here anyway to allow sharing certain methods.
  1264. • ‘argument’ The long argument, e.g. ‘--verbose’.
  1265. • ‘shortarg’ The short argument, e.g. ‘-v’.
  1266. • ‘multi-value’ For options, whether the option can have multiple
  1267. values. If non-nil, then default to use
  1268. ‘completing-read-multiple’.
  1269. • ‘allow-empty’ For options, whether the empty string is a valid
  1270. value.
  1271. • ‘history-key’ The key used to store the history. This defaults to
  1272. the command name. This is useful when multiple infixes should
  1273. share the same history because their values are of the same kind.
  1274. • ‘reader’ The function used to read the value of an infix. Not used
  1275. for switches. The function takes three arguments, PROMPT,
  1276. INITIAL-INPUT and HISTORY, and must return a string.
  1277. • ‘prompt’ The prompt used when reading the value, either a string or
  1278. a function that takes the object as the only argument and which
  1279. returns a prompt string.
  1280. • ‘choices’ A list of valid values. How exactly that is used depends
  1281. on the class of the object.
  1282. 6.7.3 Slots of ‘transient-variable’
  1283. -----------------------------------
  1284. • ‘variable’ The variable.
  1285. 6.7.4 Slots of ‘transient-switches’
  1286. -----------------------------------
  1287. • ‘argument-format’ The display format. Must contain ‘%s’, one of
  1288. the ‘choices’ is substituted for that. E.g. ‘--%s-order’.
  1289. • ‘argument-regexp’ The regexp used to match any one of the switches.
  1290. E.g. ‘\\(--\\(topo\\|author-date\\|date\\)-order\\)’.
  1291. 
  1292. File: transient.info, Node: Predicate Slots, Prev: Suffix Slots, Up: Classes and Methods
  1293. 6.8 Predicate Slots
  1294. ===================
  1295. Suffix and group objects share some predicate slots that control whether
  1296. a group or suffix should be available depending on some state. Only one
  1297. of these slots can be used at the same time. It is undefined what
  1298. happens if you use more than one.
  1299. • ‘if’ Enable if predicate returns non-nil.
  1300. • ‘if-not’ Enable if predicate returns nil.
  1301. • ‘if-non-nil’ Enable if variable’s value is non-nil.
  1302. • ‘if-nil’ Enable if variable’s value is nil.
  1303. • ‘if-mode’ Enable if major-mode matches value.
  1304. • ‘if-not-mode’ Enable if major-mode does not match value.
  1305. • ‘if-derived’ Enable if major-mode derives from value.
  1306. • ‘if-not-derived’ Enable if major-mode does not derive from value.
  1307. One more slot is shared between group and suffix classes, ‘level’.
  1308. Like the slots documented above it is a predicate, but it is used for a
  1309. different purpose. The value has to be an integer between 1 and 7.
  1310. ‘level’ controls whether it should be available depending on whether the
  1311. user wants that or not. See *note Enabling and Disabling Suffixes::.
  1312. 
  1313. File: transient.info, Node: Related Abstractions and Packages, Next: FAQ, Prev: Classes and Methods, Up: Top
  1314. 7 Related Abstractions and Packages
  1315. ***********************************
  1316. * Menu:
  1317. * Comparison With Prefix Keys and Prefix Arguments::
  1318. * Comparison With Other Packages::
  1319. 
  1320. File: transient.info, Node: Comparison With Prefix Keys and Prefix Arguments, Next: Comparison With Other Packages, Up: Related Abstractions and Packages
  1321. 7.1 Comparison With Prefix Keys and Prefix Arguments
  1322. ====================================================
  1323. While transient commands were inspired by regular prefix keys and prefix
  1324. arguments, they are also quite different and much more complex.
  1325. The following diagrams illustrate some of the differences.
  1326. • ‘(c)’ represents a return to the command loop.
  1327. • ‘(+)’ represents the user’s choice to press one key or another.
  1328. • ‘{WORD}’ are possible behaviors.
  1329. • ‘{NUMBER}’ is a footnote.
  1330. 7.1.1 Regular Prefix Commands
  1331. -----------------------------
  1332. See *note (elisp)Prefix Keys::.
  1333. ,--> command1 --> (c)
  1334. |
  1335. (c)-(+)-> prefix command or key --+--> command2 --> (c)
  1336. |
  1337. `--> command3 --> (c)
  1338. 7.1.2 Regular Prefix Arguments
  1339. ------------------------------
  1340. See *note (elisp)Prefix Command Arguments::.
  1341. ,----------------------------------,
  1342. | |
  1343. v |
  1344. (c)-(+)---> prefix argument command --(c)-(+)-> any command --> (c)
  1345. | ^ |
  1346. | | |
  1347. `-- sets or changes --, ,-- maybe used --' |
  1348. | | |
  1349. v | |
  1350. prefix argument state |
  1351. ^ |
  1352. | |
  1353. `-------- discards --------'
  1354. 7.1.3 Transients
  1355. ----------------
  1356. (∩`-´)⊃━☆゚.*・。゚
  1357. This diagram ignores the infix value and external state:
  1358. (c)
  1359. | ,- {stay} ------<-,-<------------<-,-<---,
  1360. (+) | | | |
  1361. | | | | |
  1362. | | ,--> infix1 --| | |
  1363. | | | | | |
  1364. | | |--> infix2 --| | |
  1365. v v | | | |
  1366. prefix -(c)-(+)-> infix3 --' ^ |
  1367. | | |
  1368. |---------------> suffix1 -->--| |
  1369. | | |
  1370. |---------------> suffix2 ----{1}------> {exit} --> (c)
  1371. | |
  1372. |---------------> suffix3 -------------> {exit} --> (c)
  1373. | |
  1374. `--> any command --{2}-> {warn} -->--|
  1375. | |
  1376. |--> {noop} -->--|
  1377. | |
  1378. |--> {call} -->--'
  1379. |
  1380. `------------------> {exit} --> (c)
  1381. This diagram takes the infix value into account to an extend, while
  1382. still ignoring external state:
  1383. (c)
  1384. | ,- {stay} ------<-,-<------------<-,-<---,
  1385. (+) | | | |
  1386. | | | | |
  1387. | | ,--> infix1 --| | |
  1388. | | | | | | |
  1389. | | ,--> infix2 --| | |
  1390. v v | | | | |
  1391. prefix -(c)-(+)-> infix3 --' | |
  1392. | | ^ |
  1393. | | | |
  1394. |---------------> suffix1 -->--| |
  1395. | | ^ | |
  1396. | | | | |
  1397. |---------------> suffix2 ----{1}------> {exit} --> (c)
  1398. | | ^ | |
  1399. | | | | v
  1400. | | | | |
  1401. |---------------> suffix3 -------------> {exit} --> (c)
  1402. | | ^ | |
  1403. | sets | | v
  1404. | | maybe | |
  1405. | | used | |
  1406. | | | | |
  1407. | | infix --' | |
  1408. | `---> value | |
  1409. | ^ | |
  1410. | | | |
  1411. | hides | |
  1412. | | | |
  1413. | `--------------------------<---|
  1414. | | |
  1415. `--> any command --{2}-> {warn} -->--| |
  1416. | | |
  1417. |--> {noop} -->--| |
  1418. | | |
  1419. |--> {call} -->--' ^
  1420. | |
  1421. `------------------> {exit} --> (c)
  1422. This diagram provides more information about the infix value and also
  1423. takes external state into account.
  1424. ,----sets--- "anything"
  1425. |
  1426. v
  1427. ,---------> external
  1428. | state
  1429. | | |
  1430. | initialized | ☉‿⚆
  1431. sets from |
  1432. | | maybe
  1433. | ,----------' used
  1434. | | |
  1435. (c) | | v
  1436. | ,- {stay} --|---<-,-<------|-----<-,-<---,
  1437. (+) | | | | | | |
  1438. | | | v | | | |
  1439. | | ,--> infix1 --| | | |
  1440. | | | | | | | | |
  1441. | | | | v | | | |
  1442. | | ,--> infix2 --| | | |
  1443. | | | | ^ | | | |
  1444. v v | | | | | | |
  1445. prefix -(c)-(+)-> infix3 --' | | |
  1446. | | ^ | ^ |
  1447. | | | v | |
  1448. |---------------> suffix1 -->--| |
  1449. | | | ^ | | |
  1450. | | | | v | |
  1451. |---------------> suffix2 ----{1}------> {exit} --> (c)
  1452. | | | ^ | | |
  1453. | | | | | | v
  1454. | | | | v | |
  1455. |---------------> suffix3 -------------> {exit} --> (c)
  1456. | | | ^ | |
  1457. | sets | | | v
  1458. | | initalized maybe | |
  1459. | | from used | |
  1460. | | | | | |
  1461. | | `-- infix --' | |
  1462. | `---> value -----------------------------> persistent
  1463. | ^ ^ | | across
  1464. | | | | | invocations -,
  1465. | hides | | | |
  1466. | | `----------------------------------------------'
  1467. | | | |
  1468. | `--------------------------<---|
  1469. | | |
  1470. `--> any command --{2}-> {warn} -->--| |
  1471. | | |
  1472. |--> {noop} -->--| |
  1473. | | |
  1474. |--> {call} -->--' ^
  1475. | |
  1476. `------------------> {exit} --> (c)
  1477. • ‘{1}’ Transients can be configured to be exited when a suffix
  1478. command is invoked. The default is to do so for all suffixes
  1479. except for those that are common to all transients and which are
  1480. used to perform tasks such as providing help and saving the value
  1481. of the infix arguments for future invocations. The behavior can
  1482. also be specified for individual suffix commands and may even
  1483. depend on state.
  1484. • ‘{2}’ Transients can be configured to allow the user to invoke
  1485. non-suffix commands. The default is to not allow that and instead
  1486. warn the user.
  1487. Despite already being rather complex, even the last diagram leaves
  1488. out many details. Most importantly it implies that the decision whether
  1489. to remain transient is made later than it actually is made (for the most
  1490. part a function on ‘pre-command-hook’ is responsible). But such
  1491. implementation details are of little relevance to users and are covered
  1492. elsewhere.
  1493. 
  1494. File: transient.info, Node: Comparison With Other Packages, Prev: Comparison With Prefix Keys and Prefix Arguments, Up: Related Abstractions and Packages
  1495. 7.2 Comparison With Other Packages
  1496. ==================================
  1497. 7.2.1 Magit-Popup
  1498. -----------------
  1499. Transient is the successor to Magit-Popup (see *note
  1500. (magit-popup)Top::).
  1501. One major difference between these two implementations of the same
  1502. ideas is that while Transient uses transient keymaps and embraces the
  1503. command-loop, Magit-Popup implemented an inferior mechanism that does
  1504. not use transient keymaps and that instead of using the command-loop
  1505. implements a naive alternative based on ‘read-char’.
  1506. Magit-Popup does not use classes and generic functions and defining a
  1507. new command type is near impossible as it involves adding hard-coded
  1508. special-cases to many functions. Because of that only a single new type
  1509. was added, which was not already part of Magit-Popup’s initial release.
  1510. A lot of things are hard-coded in Magit-Popup. One random example is
  1511. that the key bindings for switches must begin with "-" and those for
  1512. options must begin with "=".
  1513. 7.2.2 Hydra
  1514. -----------
  1515. Hydra (see <https://github.com/abo-abo/hydra>) is another package that
  1516. provides features similar to those of Transient.
  1517. Both packages use transient keymaps to make a set of commands
  1518. temporarily available and show the available commands in a popup buffer.
  1519. A Hydra "body" is equivalent to a Transient "prefix" and a Hydra
  1520. "head" is equivalent to a Transient "suffix". Hydra has no equivalent
  1521. of a Transient "infix".
  1522. Both hydras and transients can be used as simple command dispatchers.
  1523. Used like this they are similar to regular prefix commands and prefix
  1524. keys, except that the available commands are shown in the popup buffer.
  1525. (Another package that does this is ‘which-key’. It does so
  1526. automatically for any incomplete key sequence. The advantage of that
  1527. approach is that no additional work is necessary; the disadvantage is
  1528. that the available commands are not organized semantically.)
  1529. Both Hydra and Transient provide features that go beyond simple
  1530. command dispatchers:
  1531. • Invoking a command from a hydra does not necessarily exit the
  1532. hydra. That makes it possible to invoke the same command again,
  1533. but using a shorter key sequence (i.e. the key that was used to
  1534. enter the hydra does not have to be pressed again).
  1535. Transient supports that too, but for now this feature is not a
  1536. focus and the interface is a bit more complicated. A very basic
  1537. example using the current interface:
  1538. (define-transient-command outline-navigate ()
  1539. :transient-suffix 'transient--do-stay
  1540. :transient-non-suffix 'transient--do-warn
  1541. [("p" "next visible heading" outline-previous-visible-heading)
  1542. ("n" "next visible heading" outline-next-visible-heading)])
  1543. • Transient supports infix arguments; values that are set by infix
  1544. commands and then consumed by the invoked suffix command(s).
  1545. To my knowledge, Hydra does not support that.
  1546. Both packages make it possible to specify how exactly the available
  1547. commands are outlined:
  1548. • With Hydra this is often done using an explicit format string,
  1549. which gives authors a lot of flexibility and makes it possible to
  1550. do fancy things.
  1551. The downside of this is that it becomes harder for a user to add
  1552. additional commands to an existing hydra and to change key
  1553. bindings.
  1554. • Transient allows the author of a transient to organize the commands
  1555. into groups and the use of generic functions allows authors of
  1556. transients to control exactly how a certain command type is
  1557. displayed.
  1558. However while Transient supports giving sections a heading it does
  1559. not currently support giving the displayed information more
  1560. structure by, for example, using box-drawing characters.
  1561. That could be implemented by defining a new group class, which lets
  1562. the author specify a format string. It should be possible to
  1563. implement that without modifying any existing code, but it does not
  1564. currently exist.
  1565. 
  1566. File: transient.info, Node: FAQ, Next: Keystroke Index, Prev: Related Abstractions and Packages, Up: Top
  1567. Appendix A FAQ
  1568. **************
  1569. A.1 Can I control how the popup buffer is displayed?
  1570. ====================================================
  1571. Yes, see ‘transient-display-buffer-action’ in *note Other Options::.
  1572. A.2 Why did some of the key bindings change?
  1573. ============================================
  1574. You may have noticed that the bindings for some of the common commands
  1575. do *not* have the prefix ‘C-x’ and that furthermore some of these
  1576. commands are grayed out while others are not. That unfortunately is a
  1577. bit confusing if the section of common commands is not shown
  1578. permanently, making the following explanation necessary.
  1579. The purpose of usually hiding that section but showing it after the
  1580. user pressed the respective prefix key is to conserve space and not
  1581. overwhelm users with too much noise, while allowing the user to quickly
  1582. list common bindings on demand.
  1583. That however should not keep us from using the best possible key
  1584. bindings. The bindings that do use a prefix do so to avoid wasting too
  1585. many non-prefix bindings, keeping them available for use in individual
  1586. transients. The bindings that do not use a prefix and that are *not*
  1587. grayed out are very important bindings that are *always* available, even
  1588. when invoking the "common command key prefix" or *any other*
  1589. transient-specific prefix. The non-prefix keys that *are* grayed out
  1590. however, are not available when any incomplete prefix key sequence is
  1591. active. They do not use the "common command key prefix" because it is
  1592. likely that users want to invoke them several times in a row and e.g.
  1593. ‘M-p M-p M-p’ is much more convenient than ‘C-x M-p C-x M-p C-x M-p’.
  1594. You may also have noticed that the "Set" command is bound to ‘C-x s’,
  1595. while Magit-Popup used to bind ‘C-c C-c’ instead. I have seen several
  1596. users praise the latter binding (sic), so I did not change it
  1597. willy-nilly. The reason that I changed it is that using different
  1598. prefix keys for different common commands, would have made the temporary
  1599. display of the common commands even more confusing, i.e. after pressing
  1600. ‘C-c’ all the ‘C-x ...’ bindings would be grayed out.
  1601. Using a single prefix for common commands key means that all other
  1602. potential prefix keys can be used for transient-specific commands
  1603. *without* the section of common commands also popping up. ‘C-c’ in
  1604. particular is a prefix that I want (and already do) use for Magit, and
  1605. also using that for a common command would prevent me from doing so.
  1606. (Also see the next question.)
  1607. A.3 Why does ‘q’ not quit popups anymore?
  1608. =========================================
  1609. I agree that ‘q’ is a good binding for commands that quit something.
  1610. This includes quitting whatever transient is currently active, but it
  1611. also includes quitting whatever it is that some specific transient is
  1612. controlling. The transient ‘magit-blame’ for example binds ‘q’ to the
  1613. command that turns ‘magit-blame-mode’ off.
  1614. So I had to decide if ‘q’ should quit the active transient (like
  1615. Magit-Popup used to) or whether ‘C-g’ should do that instead, so that
  1616. ‘q’ could be bound in individual transient to whatever commands make
  1617. sense for them. Because all other letters are already reserved for use
  1618. by individual transients, I have decided to no longer make an exception
  1619. for ‘q’.
  1620. If you want to get ‘q’’s old binding back then you can do so. Doing
  1621. that is a bit more complicated than changing a single key binding, so I
  1622. have implemented a function, ‘transient-bind-q-to-quit’ that makes the
  1623. necessary changes. See its doc-string for more information.
  1624. 
  1625. File: transient.info, Node: Keystroke Index, Next: Command Index, Prev: FAQ, Up: Top
  1626. Appendix B Keystroke Index
  1627. **************************
  1628. [index]
  1629. * Menu:
  1630. * C-g: Aborting and Resuming Transients.
  1631. (line 25)
  1632. * C-g <1>: Aborting and Resuming Transients.
  1633. (line 26)
  1634. * C-h: Getting Help for Suffix Commands.
  1635. (line 10)
  1636. * C-q: Aborting and Resuming Transients.
  1637. (line 36)
  1638. * C-x C-s: Saving Values. (line 25)
  1639. * C-x l: Enabling and Disabling Suffixes.
  1640. (line 49)
  1641. * C-x s: Saving Values. (line 20)
  1642. * C-x t: Common Suffix Commands.
  1643. (line 16)
  1644. * C-z: Aborting and Resuming Transients.
  1645. (line 42)
  1646. * M-n: Using History. (line 16)
  1647. * M-p: Using History. (line 11)
  1648. * M-x transient-resume: Aborting and Resuming Transients.
  1649. (line 55)
  1650. 
  1651. File: transient.info, Node: Command Index, Next: Function Index, Prev: Keystroke Index, Up: Top
  1652. Appendix C Command Index
  1653. ************************
  1654. [index]
  1655. * Menu:
  1656. * transient-help: Getting Help for Suffix Commands.
  1657. (line 10)
  1658. * transient-history-next: Using History. (line 16)
  1659. * transient-history-prev: Using History. (line 11)
  1660. * transient-quit-all: Aborting and Resuming Transients.
  1661. (line 36)
  1662. * transient-quit-one: Aborting and Resuming Transients.
  1663. (line 26)
  1664. * transient-quit-seq: Aborting and Resuming Transients.
  1665. (line 25)
  1666. * transient-resume: Aborting and Resuming Transients.
  1667. (line 55)
  1668. * transient-save: Saving Values. (line 25)
  1669. * transient-scroll-down arg: Other Commands. (line 18)
  1670. * transient-scroll-up arg: Other Commands. (line 12)
  1671. * transient-set: Saving Values. (line 20)
  1672. * transient-set-level: Enabling and Disabling Suffixes.
  1673. (line 49)
  1674. * transient-suspend: Aborting and Resuming Transients.
  1675. (line 42)
  1676. * transient-toggle-common: Common Suffix Commands.
  1677. (line 16)
  1678. 
  1679. File: transient.info, Node: Function Index, Next: Variable Index, Prev: Command Index, Up: Top
  1680. Appendix D Function Index
  1681. *************************
  1682. [index]
  1683. * Menu:
  1684. * define-infix-argument: Defining Suffix and Infix Commands.
  1685. (line 66)
  1686. * define-infix-command: Defining Suffix and Infix Commands.
  1687. (line 30)
  1688. * define-suffix-command: Defining Suffix and Infix Commands.
  1689. (line 9)
  1690. * define-transient-command: Defining Transients. (line 13)
  1691. * transient--do-call: Transient State. (line 98)
  1692. * transient--do-exit: Transient State. (line 94)
  1693. * transient--do-noop: Transient State. (line 125)
  1694. * transient--do-quit-all: Transient State. (line 138)
  1695. * transient--do-quit-one: Transient State. (line 132)
  1696. * transient--do-replace: Transient State. (line 102)
  1697. * transient--do-stay: Transient State. (line 85)
  1698. * transient--do-suspend: Transient State. (line 144)
  1699. * transient--do-warn: Transient State. (line 121)
  1700. * transient--history-init: Prefix Classes. (line 10)
  1701. * transient--insert-group: Group Methods. (line 6)
  1702. * transient-append-suffix: Modifying Existing Transients.
  1703. (line 47)
  1704. * transient-args: Using Infix Arguments.
  1705. (line 22)
  1706. * transient-format: Suffix Format Methods.
  1707. (line 6)
  1708. * transient-format-description: Suffix Format Methods.
  1709. (line 20)
  1710. * transient-format-key: Suffix Format Methods.
  1711. (line 15)
  1712. * transient-format-value: Suffix Format Methods.
  1713. (line 25)
  1714. * transient-get-suffix: Modifying Existing Transients.
  1715. (line 60)
  1716. * transient-infix-read: Suffix Value Methods.
  1717. (line 17)
  1718. * transient-infix-set: Suffix Value Methods.
  1719. (line 39)
  1720. * transient-infix-value: Suffix Value Methods.
  1721. (line 43)
  1722. * transient-init-scope: Suffix Value Methods.
  1723. (line 57)
  1724. * transient-init-value: Suffix Value Methods.
  1725. (line 6)
  1726. * transient-insert-suffix: Modifying Existing Transients.
  1727. (line 42)
  1728. * transient-prompt: Suffix Value Methods.
  1729. (line 34)
  1730. * transient-remove-suffix: Modifying Existing Transients.
  1731. (line 56)
  1732. * transient-replace-suffix: Modifying Existing Transients.
  1733. (line 51)
  1734. * transient-scroll-down: Other Commands. (line 18)
  1735. * transient-scroll-up: Other Commands. (line 12)
  1736. * transient-show-help: Suffix Format Methods.
  1737. (line 30)
  1738. * transient-suffix-put: Modifying Existing Transients.
  1739. (line 65)
  1740. 
  1741. File: transient.info, Node: Variable Index, Prev: Function Index, Up: Top
  1742. Appendix E Variable Index
  1743. *************************
  1744. [index]
  1745. * Menu:
  1746. * current-transient-command: Using Infix Arguments.
  1747. (line 66)
  1748. * current-transient-prefix: Using Infix Arguments.
  1749. (line 60)
  1750. * current-transient-suffixes: Using Infix Arguments.
  1751. (line 51)
  1752. * transient-default-level: Enabling and Disabling Suffixes.
  1753. (line 38)
  1754. * transient-detect-key-conflicts: Other Options. (line 136)
  1755. * transient-display-buffer-action: Other Options. (line 46)
  1756. * transient-enable-popup-navigation: Other Options. (line 28)
  1757. * transient-highlight-mismatched-keys: Other Options. (line 95)
  1758. * transient-history-file: Using History. (line 33)
  1759. * transient-history-limit: Using History. (line 38)
  1760. * transient-levels-file: Enabling and Disabling Suffixes.
  1761. (line 44)
  1762. * transient-mode-line-format: Other Options. (line 71)
  1763. * transient-read-with~initial-input: Other Options. (line 87)
  1764. * transient-show-common-commands: Common Suffix Commands.
  1765. (line 23)
  1766. * transient-show-popup: Other Options. (line 6)
  1767. * transient-substitute-key-function: Other Options. (line 114)
  1768. * transient-values-file: Saving Values. (line 30)
  1769. 
  1770. Tag Table:
  1771. Node: Top751
  1772. Node: Introduction3674
  1773. Node: Usage9461
  1774. Node: Invoking Transients9795
  1775. Node: Aborting and Resuming Transients10828
  1776. Node: Common Suffix Commands13487
  1777. Node: Saving Values15240
  1778. Ref: Saving Values-Footnote-116498
  1779. Node: Using History16768
  1780. Node: Getting Help for Suffix Commands18308
  1781. Node: Enabling and Disabling Suffixes19698
  1782. Node: Other Commands22997
  1783. Node: Other Options23953
  1784. Node: Modifying Existing Transients30567
  1785. Node: Defining New Commands33971
  1786. Node: Defining Transients34307
  1787. Node: Binding Suffix and Infix Commands36742
  1788. Node: Group Specifications37597
  1789. Node: Suffix Specifications40930
  1790. Node: Defining Suffix and Infix Commands44488
  1791. Node: Using Infix Arguments47897
  1792. Node: Transient State51181
  1793. Node: Classes and Methods57053
  1794. Node: Group Classes59267
  1795. Node: Group Methods61184
  1796. Node: Prefix Classes61829
  1797. Node: Suffix Classes62921
  1798. Node: Suffix Methods65165
  1799. Node: Suffix Value Methods65486
  1800. Node: Suffix Format Methods68246
  1801. Node: Prefix Slots69695
  1802. Node: Suffix Slots69859
  1803. Node: Predicate Slots72710
  1804. Node: Related Abstractions and Packages73959
  1805. Node: Comparison With Prefix Keys and Prefix Arguments74246
  1806. Node: Comparison With Other Packages84558
  1807. Node: FAQ88745
  1808. Node: Keystroke Index92476
  1809. Node: Command Index94110
  1810. Node: Function Index95897
  1811. Node: Variable Index100054
  1812. 
  1813. End Tag Table
  1814. 
  1815. Local Variables:
  1816. coding: utf-8
  1817. End: