diff options
| author | Jonas Bernoulli | 2025-02-01 18:14:47 +0100 |
|---|---|---|
| committer | Jonas Bernoulli | 2025-02-01 18:14:47 +0100 |
| commit | 3a86774ce55e9dc4dc6de01f6aca19fcaa41a5d3 (patch) | |
| tree | 57dc39d0e5eed587f125e4fffd31da2163ad2ae9 /doc | |
| parent | 5a5706f943ae2677c6d73fed8de11affd3ef04aa (diff) | |
| download | emacs-3a86774ce55e9dc4dc6de01f6aca19fcaa41a5d3.tar.gz emacs-3a86774ce55e9dc4dc6de01f6aca19fcaa41a5d3.zip | |
Update to Transient v0.8.4-7-gabee7353
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/misc/transient.texi | 138 |
1 files changed, 132 insertions, 6 deletions
diff --git a/doc/misc/transient.texi b/doc/misc/transient.texi index fb8b6da145c..4740663e987 100644 --- a/doc/misc/transient.texi +++ b/doc/misc/transient.texi | |||
| @@ -31,7 +31,7 @@ General Public License for more details. | |||
| 31 | @finalout | 31 | @finalout |
| 32 | @titlepage | 32 | @titlepage |
| 33 | @title Transient User and Developer Manual | 33 | @title Transient User and Developer Manual |
| 34 | @subtitle for version 0.8.3 | 34 | @subtitle for version 0.8.4 |
| 35 | @author Jonas Bernoulli | 35 | @author Jonas Bernoulli |
| 36 | @page | 36 | @page |
| 37 | @vskip 0pt plus 1filll | 37 | @vskip 0pt plus 1filll |
| @@ -53,7 +53,7 @@ resource to get over that hurdle is Psionic K's interactive tutorial, | |||
| 53 | available at @uref{https://github.com/positron-solutions/transient-showcase}. | 53 | available at @uref{https://github.com/positron-solutions/transient-showcase}. |
| 54 | 54 | ||
| 55 | @noindent | 55 | @noindent |
| 56 | This manual is for Transient version 0.8.3. | 56 | This manual is for Transient version 0.8.4. |
| 57 | 57 | ||
| 58 | @insertcopying | 58 | @insertcopying |
| 59 | @end ifnottex | 59 | @end ifnottex |
| @@ -93,6 +93,7 @@ Defining New Commands | |||
| 93 | * Binding Suffix and Infix Commands:: | 93 | * Binding Suffix and Infix Commands:: |
| 94 | * Defining Suffix and Infix Commands:: | 94 | * Defining Suffix and Infix Commands:: |
| 95 | * Using Infix Arguments:: | 95 | * Using Infix Arguments:: |
| 96 | * Using Prefix Scope:: | ||
| 96 | * Current Suffix Command:: | 97 | * Current Suffix Command:: |
| 97 | * Current Prefix Command:: | 98 | * Current Prefix Command:: |
| 98 | * Transient State:: | 99 | * Transient State:: |
| @@ -553,6 +554,48 @@ the level specified by @code{transient-default-level} are temporarily | |||
| 553 | available anyway. | 554 | available anyway. |
| 554 | @end table | 555 | @end table |
| 555 | 556 | ||
| 557 | @defun transient-set-default-level suffix level | ||
| 558 | This function sets the default level of the suffix COMMAND to LEVEL@. | ||
| 559 | |||
| 560 | If a suffix command appears in multiple menus, it may make sense to | ||
| 561 | consistently change its level in all those menus at once. For | ||
| 562 | example, the @code{--gpg-sign} argument (which is implemented using the | ||
| 563 | command @code{magit:--gpg-sign}), is bound in all of Magit's menu which | ||
| 564 | create commits. Users who sometimes sign their commits would want | ||
| 565 | that argument to be available in all of these menus, while for users | ||
| 566 | who never sign it is just unnecessary noise in any menus. | ||
| 567 | |||
| 568 | To always make @code{--gpg-sign} available, use: | ||
| 569 | |||
| 570 | @lisp | ||
| 571 | (transient-set-default-level 'magit:--gpg-sign 1) | ||
| 572 | @end lisp | ||
| 573 | |||
| 574 | To never make @code{--gpg-sign} available, use: | ||
| 575 | |||
| 576 | @lisp | ||
| 577 | (transient-set-default-level 'magit:--gpg-sign 0) | ||
| 578 | @end lisp | ||
| 579 | |||
| 580 | This sets the level in the suffix prototype object for this command. | ||
| 581 | Commands only have a suffix prototype if they were defined using one | ||
| 582 | of @code{transient-define-argument}, @code{transient-define-infix} and | ||
| 583 | @code{transient-define-suffix}. For all other commands this would signal | ||
| 584 | an error. (This is one of the reasons why package authors should | ||
| 585 | use one of these functions to define shared suffix commands, and | ||
| 586 | especially shared arguments.) | ||
| 587 | |||
| 588 | If the user changes the level of a suffix in a particular menu, | ||
| 589 | using @kbd{C-x l} as shown above, then that obviously shadows the default. | ||
| 590 | |||
| 591 | It is also possible to set the level of a suffix binding in a | ||
| 592 | particular menu, either when defining the menu using | ||
| 593 | @code{transient-define-prefix,} or later using @code{transient-insert-suffix}. If | ||
| 594 | such bindings specify a level, then that also overrides the default. | ||
| 595 | (Per-suffix default levels is a new feature, so you might encounter | ||
| 596 | this quite often.) | ||
| 597 | @end defun | ||
| 598 | |||
| 556 | @node Other Commands | 599 | @node Other Commands |
| 557 | @section Other Commands | 600 | @section Other Commands |
| 558 | 601 | ||
| @@ -1017,6 +1060,7 @@ signal an error. | |||
| 1017 | * Binding Suffix and Infix Commands:: | 1060 | * Binding Suffix and Infix Commands:: |
| 1018 | * Defining Suffix and Infix Commands:: | 1061 | * Defining Suffix and Infix Commands:: |
| 1019 | * Using Infix Arguments:: | 1062 | * Using Infix Arguments:: |
| 1063 | * Using Prefix Scope:: | ||
| 1020 | * Current Suffix Command:: | 1064 | * Current Suffix Command:: |
| 1021 | * Current Prefix Command:: | 1065 | * Current Prefix Command:: |
| 1022 | * Transient State:: | 1066 | * Transient State:: |
| @@ -1323,6 +1367,13 @@ be replaced with an error. | |||
| 1323 | The boolean @code{:pad-keys} argument controls whether keys of all suffixes | 1367 | The boolean @code{:pad-keys} argument controls whether keys of all suffixes |
| 1324 | contained in a group are right padded, effectively aligning the | 1368 | contained in a group are right padded, effectively aligning the |
| 1325 | descriptions. | 1369 | descriptions. |
| 1370 | |||
| 1371 | @item | ||
| 1372 | If a keyword argument accepts a function as value, you an use a | ||
| 1373 | @code{lambda} expression. As a special case, the @code{##} macro (which returns a | ||
| 1374 | @code{lambda} expression and is implemented in the @code{llama} package) is also | ||
| 1375 | supported. Inside group specifications, the use of @code{##} is not | ||
| 1376 | supported anywhere but directly following a keyword symbol. | ||
| 1326 | @end itemize | 1377 | @end itemize |
| 1327 | 1378 | ||
| 1328 | The @var{ELEMENT}s are either all subgroups, or all suffixes and strings. | 1379 | The @var{ELEMENT}s are either all subgroups, or all suffixes and strings. |
| @@ -1446,6 +1497,12 @@ Finally, details can be specified using optional @var{KEYWORD}-@var{VALUE} pairs | |||
| 1446 | Each keyword has to be a keyword symbol, either @code{:class} or a keyword | 1497 | Each keyword has to be a keyword symbol, either @code{:class} or a keyword |
| 1447 | argument supported by the constructor of that class. @xref{Suffix Slots}. | 1498 | argument supported by the constructor of that class. @xref{Suffix Slots}. |
| 1448 | 1499 | ||
| 1500 | If a keyword argument accepts a function as value, you an use a @code{lambda} | ||
| 1501 | expression. As a special case, the @code{##} macro (which returns a @code{lambda} | ||
| 1502 | expression and is implemented in the @code{llama} package) is also supported. | ||
| 1503 | Inside suffix bindings, the use of @code{##} is not supported anywhere but | ||
| 1504 | directly following a keyword symbol. | ||
| 1505 | |||
| 1449 | @node Defining Suffix and Infix Commands | 1506 | @node Defining Suffix and Infix Commands |
| 1450 | @section Defining Suffix and Infix Commands | 1507 | @section Defining Suffix and Infix Commands |
| 1451 | 1508 | ||
| @@ -1568,6 +1625,55 @@ used if you need the objects (as opposed to just their values) and | |||
| 1568 | if the current command is not being invoked from @var{PREFIX}. | 1625 | if the current command is not being invoked from @var{PREFIX}. |
| 1569 | @end defun | 1626 | @end defun |
| 1570 | 1627 | ||
| 1628 | @node Using Prefix Scope | ||
| 1629 | @section Using Prefix Scope | ||
| 1630 | |||
| 1631 | Some transients have a sort of secondary value, called a scope. A | ||
| 1632 | prefix's scope can be accessed using @code{transient-scope}; similar to how | ||
| 1633 | its value can be accessed using @code{transient-args}. | ||
| 1634 | |||
| 1635 | @defun transient-scope prefixes classes | ||
| 1636 | This function returns the scope of the active or current transient | ||
| 1637 | prefix command. | ||
| 1638 | |||
| 1639 | If optional PREFIXES and CLASSES are both nil, return the scope of | ||
| 1640 | the prefix currently being setup, making this variation useful, e.g., | ||
| 1641 | in @code{:if*} predicates. If no prefix is being setup, but the current | ||
| 1642 | command was invoked from some prefix, then return the scope of that. | ||
| 1643 | |||
| 1644 | If PREFIXES is non-nil, it must be a prefix command or a list of such | ||
| 1645 | commands. If CLASSES is non-nil, it must be a prefix class or a list | ||
| 1646 | of such classes. When this function is called from the body or the | ||
| 1647 | @code{interactive} form of a suffix command, PREFIXES and/or CLASSES should | ||
| 1648 | be non-nil. If either is non-nil, try the following in order: | ||
| 1649 | |||
| 1650 | @itemize | ||
| 1651 | @item | ||
| 1652 | If the current suffix command was invoked from a prefix, which | ||
| 1653 | appears in PREFIXES, return the scope of that prefix. | ||
| 1654 | |||
| 1655 | @item | ||
| 1656 | If the current suffix command was invoked from a prefix, and its | ||
| 1657 | class derives from one of the CLASSES, return the scope of that | ||
| 1658 | prefix. | ||
| 1659 | |||
| 1660 | @item | ||
| 1661 | If a prefix is being setup and it appears in PREFIXES, return its | ||
| 1662 | scope. | ||
| 1663 | |||
| 1664 | @item | ||
| 1665 | If a prefix is being setup and its class derives from one of the | ||
| 1666 | CLASSES, return its scope. | ||
| 1667 | |||
| 1668 | @item | ||
| 1669 | Finally try to return the default scope of the first command in | ||
| 1670 | PREFIXES@. This only works if that slot is set in the respective | ||
| 1671 | class definition or using its `transient-init-scope' method. | ||
| 1672 | @end itemize | ||
| 1673 | |||
| 1674 | If no prefix matches, return nil. | ||
| 1675 | @end defun | ||
| 1676 | |||
| 1571 | @node Current Suffix Command | 1677 | @node Current Suffix Command |
| 1572 | @section Current Suffix Command | 1678 | @section Current Suffix Command |
| 1573 | 1679 | ||
| @@ -2458,8 +2564,9 @@ being initialized. This slot is still experimental. | |||
| 2458 | @code{transient-mode-line-format}. It should have the same type. | 2564 | @code{transient-mode-line-format}. It should have the same type. |
| 2459 | 2565 | ||
| 2460 | @item | 2566 | @item |
| 2461 | @code{column-width} is only respected inside @code{transient-columns} groups and | 2567 | @code{column-widths} is only respected inside @code{transient-columns} groups and |
| 2462 | allows aligning columns across separate instances of that. | 2568 | allows aligning columns across separate instances of that. A list |
| 2569 | of integers. | ||
| 2463 | 2570 | ||
| 2464 | @item | 2571 | @item |
| 2465 | @code{variable-pitch} controls whether alignment is done pixel-wise to | 2572 | @code{variable-pitch} controls whether alignment is done pixel-wise to |
| @@ -2535,8 +2642,9 @@ Also see @ref{Suffix Classes}. | |||
| 2535 | @subheading Slots of @code{transient-child} | 2642 | @subheading Slots of @code{transient-child} |
| 2536 | 2643 | ||
| 2537 | This is the abstract superclass of @code{transient-suffix} and @code{transient-group}. | 2644 | This is the abstract superclass of @code{transient-suffix} and @code{transient-group}. |
| 2538 | This is where the shared @code{if*} and @code{inapt-if*} slots (see @ref{Predicate Slots}) | 2645 | This is where the shared @code{if*} and @code{inapt-if*} slots (see @ref{Predicate Slots}), |
| 2539 | and the @code{level} slot (see @ref{Enabling and Disabling Suffixes}) are defined. | 2646 | the @code{level} slot (see @ref{Enabling and Disabling Suffixes}), and the @code{advice} |
| 2647 | and @code{advice*} slots (see @ref{Slots of @code{transient-suffix}}) are defined. | ||
| 2540 | 2648 | ||
| 2541 | @itemize | 2649 | @itemize |
| 2542 | @item | 2650 | @item |
| @@ -2595,6 +2703,24 @@ for details. | |||
| 2595 | defining a command using @code{transient-define-suffix}. | 2703 | defining a command using @code{transient-define-suffix}. |
| 2596 | @end itemize | 2704 | @end itemize |
| 2597 | 2705 | ||
| 2706 | The following two slots are experimental. They can also be set for a | ||
| 2707 | group, in which case they apply to all suffixes in that group, except | ||
| 2708 | for suffixes that set the same slot to a non-nil value. | ||
| 2709 | |||
| 2710 | @itemize | ||
| 2711 | @item | ||
| 2712 | @code{advice} A function used to advise the command. The advise is called | ||
| 2713 | using @code{(apply advice command args)}, i.e., it behaves like an "around" | ||
| 2714 | advice. | ||
| 2715 | |||
| 2716 | @item | ||
| 2717 | @code{advice*} A function used to advise the command. Unlike @code{advice}, this | ||
| 2718 | advises not only the command body but also its @code{interactive} spec. If | ||
| 2719 | both slots are non-nil, @code{advice} is used for the body and @code{advice*} is | ||
| 2720 | used for the @code{interactive} form. When advising the @code{interactive} spec, | ||
| 2721 | called using @code{(funcall advice #'advice-eval-interactive-spec spec)}. | ||
| 2722 | @end itemize | ||
| 2723 | |||
| 2598 | @anchor{Slots of @code{transient-infix}} | 2724 | @anchor{Slots of @code{transient-infix}} |
| 2599 | @subheading Slots of @code{transient-infix} | 2725 | @subheading Slots of @code{transient-infix} |
| 2600 | 2726 | ||