Personal emacs config
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2519 lines
106 KiB

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