mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-16 09:14:18 +00:00
Update to Transient v0.12.0-15-gfe5214e6
This commit is contained in:
parent
93793260ea
commit
b0aa799b00
2 changed files with 430 additions and 415 deletions
|
|
@ -25,13 +25,13 @@ General Public License for more details.
|
|||
|
||||
@dircategory Emacs misc features
|
||||
@direntry
|
||||
* Transient: (transient). Transient Commands.
|
||||
* Transient: (transient). Transient Commands.
|
||||
@end direntry
|
||||
|
||||
@finalout
|
||||
@titlepage
|
||||
@title Transient User and Developer Manual
|
||||
@subtitle for version 0.11.0
|
||||
@subtitle for version 0.12.0
|
||||
@author Jonas Bernoulli
|
||||
@page
|
||||
@vskip 0pt plus 1filll
|
||||
|
|
@ -53,7 +53,7 @@ resource to get over that hurdle is Psionic K's interactive tutorial,
|
|||
available at @uref{https://github.com/positron-solutions/transient-showcase}.
|
||||
|
||||
@noindent
|
||||
This manual is for Transient version 0.11.0.
|
||||
This manual is for Transient version 0.12.0.
|
||||
|
||||
@insertcopying
|
||||
@end ifnottex
|
||||
|
|
@ -385,7 +385,7 @@ than outlined above and even customizable.}
|
|||
If the user does not save the value and just exits using a regular
|
||||
suffix command, then the value is merely saved to the transient's
|
||||
history. That value won't be used when the transient is next invoked,
|
||||
but it is easily accessible (see @ref{Using History}).
|
||||
but it is easily accessible (@pxref{Using History}).
|
||||
|
||||
Option @code{transient-common-command-prefix} controls the prefix key used
|
||||
in the following bindings. For simplicity's sake the default, @kbd{C-x},
|
||||
|
|
@ -454,8 +454,8 @@ previously used values. Usually the same keys as those mentioned
|
|||
above are bound to those commands.
|
||||
|
||||
Authors of transients should arrange for different infix commands that
|
||||
read the same kind of value to also use the same history key (see
|
||||
@ref{Suffix Slots}).
|
||||
read the same kind of value to also use the same history key
|
||||
(@pxref{Suffix Slots}).
|
||||
|
||||
Both kinds of history are saved to a file when Emacs is exited.
|
||||
|
||||
|
|
@ -785,7 +785,7 @@ menu buffer. The menu buffer is displayed in a window using
|
|||
The value of this option has the form @code{(@var{FUNCTION} . @var{ALIST})},
|
||||
where @var{FUNCTION} is a function or a list of functions. Each such
|
||||
function should accept two arguments: a buffer to display and an
|
||||
alist of the same form as @var{ALIST}. See @ref{Choosing Window,,,elisp,},
|
||||
alist of the same form as @var{ALIST}. @xref{Choosing Window,,,elisp,},
|
||||
for details.
|
||||
|
||||
The default is:
|
||||
|
|
@ -798,8 +798,8 @@ The default is:
|
|||
@end lisp
|
||||
|
||||
This displays the window at the bottom of the selected frame.
|
||||
For alternatives see @ref{Buffer Display Action Functions,,,elisp,},
|
||||
and @ref{Buffer Display Action Alists,,,elisp,}.
|
||||
For alternatives @xref{Buffer Display Action Functions,,,elisp,},
|
||||
and @xref{Buffer Display Action Alists,,,elisp,}.
|
||||
|
||||
When you switch to a different ACTION, you should keep the ALIST
|
||||
entries for @code{dedicated} and @code{inhibit-same-window} in most cases.
|
||||
|
|
@ -861,7 +861,7 @@ used to draw the line.
|
|||
This user option may be overridden if @code{:mode-line-format} is passed
|
||||
when creating a new prefix with @code{transient-define-prefix}.
|
||||
|
||||
Otherwise this can be any mode-line format. See @ref{Mode Line Format,,,elisp,}, for details.
|
||||
Otherwise this can be any mode-line format. @xref{Mode Line Format,,,elisp,}, for details.
|
||||
@end defopt
|
||||
|
||||
@defopt transient-semantic-coloring
|
||||
|
|
@ -1002,8 +1002,8 @@ That buffer is current and empty when this hook is runs.
|
|||
|
||||
@cindex modifying existing transients
|
||||
|
||||
To an extent, transients can be customized interactively, see
|
||||
@ref{Enabling and Disabling Suffixes}. This section explains how existing
|
||||
To an extent, transients can be customized interactively,
|
||||
@xref{Enabling and Disabling Suffixes}. This section explains how existing
|
||||
transients can be further modified non-interactively. Let's begin
|
||||
with an example:
|
||||
|
||||
|
|
@ -1029,10 +1029,10 @@ which can be included in multiple prefixes. See TODO@.
|
|||
as expected by @code{transient-define-prefix}. Note that an infix is a
|
||||
special kind of suffix. Depending on context ``suffixes'' means
|
||||
``suffixes (including infixes)'' or ``non-infix suffixes''. Here it
|
||||
means the former. See @ref{Suffix Specifications}.
|
||||
means the former. @xref{Suffix Specifications}.
|
||||
|
||||
@var{SUFFIX} may also be a group in the same form as expected by
|
||||
@code{transient-define-prefix}. See @ref{Group Specifications}.
|
||||
@code{transient-define-prefix}. @xref{Group Specifications}.
|
||||
|
||||
@item
|
||||
@var{LOC} is a key description (a string as returned by @code{key-description}
|
||||
|
|
@ -1055,9 +1055,9 @@ the function @code{transient--get-layout}.
|
|||
|
||||
These functions operate on the information stored in the
|
||||
@code{transient--layout} property of the @var{PREFIX} symbol. Elements in that
|
||||
tree are not objects but have the form @code{(@var{CLASS} @var{PLIST}) for suffixes} and
|
||||
tree are not objects but have the form @code{(@var{CLASS} @var{PLIST})} for suffixes and
|
||||
@code{[CLASS PLIST CHILDREN]} for groups. At the root of the tree is an
|
||||
element @code{[N Nil CHILDREN]}, where @code{N} is the version of the layout format,
|
||||
element @code{[N nil CHILDREN]}, where @code{N} is the version of the layout format,
|
||||
currently and hopefully for a long time 2. While that element looks
|
||||
like a group vector, that element does not count when identifying a
|
||||
group using a coordinate vector, i.e., @code{[0]} is its first child, not the
|
||||
|
|
@ -1072,7 +1072,7 @@ or after @var{LOC}.
|
|||
Conceptually adding a binding to a transient prefix is similar to
|
||||
adding a binding to a keymap, but this is complicated by the fact
|
||||
that multiple suffix commands can be bound to the same key, provided
|
||||
they are never active at the same time, see @ref{Predicate Slots}.
|
||||
they are never active at the same time, @xref{Predicate Slots}.
|
||||
|
||||
Unfortunately both false-positives and false-negatives are possible.
|
||||
To deal with the former, use non-@code{nil} @var{KEEP-OTHER@.} The symbol @code{always}
|
||||
|
|
@ -1205,14 +1205,14 @@ enabled. One benefit of the Transient interface is that it remembers
|
|||
history not only on a global level (``this command was invoked using
|
||||
these arguments, and previously it was invoked using those other
|
||||
arguments''), but also remembers the values of individual arguments
|
||||
independently. See @ref{Using History}.
|
||||
independently. @xref{Using History}.
|
||||
|
||||
After a transient prefix command is invoked, @kbd{C-h @var{KEY}} can be used to
|
||||
show the documentation for the infix or suffix command that @kbd{@var{KEY}} is
|
||||
bound to (see @ref{Getting Help for Suffix Commands}), and infixes and
|
||||
bound to (@pxref{Getting Help for Suffix Commands}), and infixes and
|
||||
suffixes can be removed from the transient using @kbd{C-x l @var{KEY}}. Infixes
|
||||
and suffixes that are disabled by default can be enabled the same way.
|
||||
See @ref{Enabling and Disabling Suffixes}.
|
||||
@xref{Enabling and Disabling Suffixes}.
|
||||
|
||||
Transient ships with support for a few different types of specialized
|
||||
infix commands. A command that sets a command line option, for example,
|
||||
|
|
@ -1263,7 +1263,7 @@ explicitly.
|
|||
|
||||
@var{GROUP}s add key bindings for infix and suffix commands and specify
|
||||
how these bindings are presented in the menu buffer. At least one
|
||||
@var{GROUP} has to be specified. See @ref{Binding Suffix and Infix Commands}.
|
||||
@var{GROUP} has to be specified. @xref{Binding Suffix and Infix Commands}.
|
||||
|
||||
The @var{BODY} is optional. If it is omitted, then @var{ARGLIST} is ignored and
|
||||
the function definition becomes:
|
||||
|
|
@ -1314,11 +1314,13 @@ GROUPs have the same form as for @code{transient-define-prefix}.
|
|||
@section Binding Suffix and Infix Commands
|
||||
|
||||
The macro @code{transient-define-prefix} is used to define a transient.
|
||||
This defines the actual transient prefix command (see @ref{Defining Transients}) and adds the transient's infix and suffix bindings, as
|
||||
This defines the actual transient prefix command (@pxref{Defining
|
||||
Transients}) and adds the transient's infix and suffix bindings, as
|
||||
described below.
|
||||
|
||||
Users and third-party packages can add additional bindings using
|
||||
functions such as @code{transient-insert-suffix} (see @ref{Modifying Existing Transients}). These functions take a ``suffix specification'' as one of
|
||||
functions such as @code{transient-insert-suffix} (@pxref{Modifying Existing Transients}).
|
||||
These functions take a ``suffix specification'' as one of
|
||||
their arguments, which has the same form as the specifications used in
|
||||
@code{transient-define-prefix}.
|
||||
|
||||
|
|
@ -1334,7 +1336,7 @@ for a set of suffixes.
|
|||
|
||||
Several group classes exist, some of which organize suffixes in
|
||||
subgroups. In most cases the class does not have to be specified
|
||||
explicitly, but see @ref{Group Classes}.
|
||||
explicitly, but @xref{Group Classes}.
|
||||
|
||||
Groups are specified in the call to @code{transient-define-prefix}, using
|
||||
vectors. Because groups are represented using vectors, we cannot use
|
||||
|
|
@ -1344,10 +1346,13 @@ brackets to do the latter.
|
|||
Group specifications then have this form:
|
||||
|
||||
@lisp
|
||||
[@{LEVEL@} @{DESCRIPTION@} @{KEYWORD VALUE@}... ELEMENT...]
|
||||
[@{@var{LEVEL}@} @{@var{DESCRIPTION}@}
|
||||
@{@var{KEYWORD} @var{VALUE}@}...
|
||||
@var{ELEMENT}...]
|
||||
@end lisp
|
||||
|
||||
The @var{LEVEL} is optional and defaults to 4. See @ref{Enabling and Disabling Suffixes}.
|
||||
The @var{LEVEL} is optional and defaults to 4. @xref{Enabling and
|
||||
Disabling Suffixes}.
|
||||
|
||||
The @var{DESCRIPTION} is optional. If present, it is used as the heading of
|
||||
the group.
|
||||
|
|
@ -1378,7 +1383,7 @@ useful while rebase is already in progress; and another that uses
|
|||
initiate a rebase.
|
||||
|
||||
These predicates can also be used on individual suffixes and are
|
||||
only documented once, see @ref{Predicate Slots}.
|
||||
only documented once, @xref{Predicate Slots}.
|
||||
|
||||
@item
|
||||
The value of @code{:hide}, if non-@code{nil}, is a predicate that controls
|
||||
|
|
@ -1483,13 +1488,13 @@ The form of suffix specifications is documented in the next node.
|
|||
@cindex suffix specifications
|
||||
|
||||
A transient's suffix and infix commands are bound when the transient
|
||||
prefix command is defined using @code{transient-define-prefix}, see
|
||||
@ref{Defining Transients}. The commands are organized into groups, see
|
||||
@ref{Group Specifications}. Here we describe the form used to bind an
|
||||
prefix command is defined using @code{transient-define-prefix},
|
||||
@xref{Defining Transients}. The commands are organized into groups,
|
||||
@xref{Group Specifications}. Here we describe the form used to bind an
|
||||
individual suffix command.
|
||||
|
||||
The same form is also used when later binding additional commands
|
||||
using functions such as @code{transient-insert-suffix}, see @ref{Modifying Existing Transients}.
|
||||
using functions such as @code{transient-insert-suffix}, @xref{Modifying Existing Transients}.
|
||||
|
||||
Note that an infix is a special kind of suffix. Depending on context
|
||||
``suffixes'' means ``suffixes (including infixes)'' or ``non-infix
|
||||
|
|
@ -1498,7 +1503,9 @@ suffixes''. Here it means the former.
|
|||
Suffix specifications have this form:
|
||||
|
||||
@lisp
|
||||
([LEVEL] [KEY [DESCRIPTION]] COMMAND|ARGUMENT [KEYWORD VALUE]...)
|
||||
([@var{LEVEL}]
|
||||
[@var{KEY} [@var{DESCRIPTION}]]
|
||||
@var{COMMAND}|@var{ARGUMENT} [@var{KEYWORD} @var{VALUE}]...)
|
||||
@end lisp
|
||||
|
||||
@var{LEVEL}, @var{KEY} and @var{DESCRIPTION} can also be specified using the @var{KEYWORD}s
|
||||
|
|
@ -1509,8 +1516,8 @@ the object's values just for the binding inside this transient.
|
|||
|
||||
@itemize
|
||||
@item
|
||||
@var{LEVEL} is the suffix level, an integer between 1 and 7. See
|
||||
@ref{Enabling and Disabling Suffixes}.
|
||||
@var{LEVEL} is the suffix level, an integer between 1 and 7.
|
||||
@xref{Enabling and Disabling Suffixes}.
|
||||
|
||||
@item
|
||||
KEY is the key binding, a string in the format returned by
|
||||
|
|
@ -1584,7 +1591,7 @@ guessed based on the long argument. If the argument ends with @samp{=}
|
|||
|
||||
Finally, details can be specified using optional @var{KEYWORD}-@var{VALUE} pairs.
|
||||
Each keyword has to be a keyword symbol, either @code{:class} or a keyword
|
||||
argument supported by the constructor of that class. See @ref{Suffix Slots}.
|
||||
argument supported by the constructor of that class. @xref{Suffix Slots}.
|
||||
|
||||
If a keyword argument accepts a function as value, you an use a @code{lambda}
|
||||
expression. As a special case, the @code{##} macro (which returns a @code{lambda}
|
||||
|
|
@ -1702,7 +1709,7 @@ should be used.
|
|||
@end defun
|
||||
|
||||
@defun transient-get-value
|
||||
This function returns the value of the current prefix.
|
||||
This function returns the value of the extant prefix.
|
||||
|
||||
This function is intended to be used when setting up a menu and its
|
||||
suffixes. It is not intended to be used when a suffix command is
|
||||
|
|
@ -1934,8 +1941,8 @@ means that all outer prefixes are exited at once.
|
|||
@item
|
||||
The behavior for non-suffixes can be set for a particular prefix,
|
||||
by the prefix's @code{transient-non-suffix} slot to a boolean, a suitable
|
||||
pre-command function, or a shorthand for such a function. See
|
||||
@ref{Pre-commands for Non-Suffixes}.
|
||||
pre-command function, or a shorthand for such a function.
|
||||
@xref{Pre-commands for Non-Suffixes}.
|
||||
|
||||
@item
|
||||
The common behavior for the suffixes of a particular prefix can be
|
||||
|
|
@ -2260,7 +2267,7 @@ Transient itself provides a single class for prefix commands,
|
|||
@code{transient-prefix}, but package authors may wish to define specialized
|
||||
classes. Doing so makes it possible to change the behavior of the set
|
||||
of prefix commands that use that class, by implementing specialized
|
||||
methods for certain generic functions (see @ref{Prefix Methods}).
|
||||
methods for certain generic functions (@pxref{Prefix Methods}).
|
||||
|
||||
A transient prefix command's object is stored in the @code{transient--prefix}
|
||||
property of the command symbol. While a transient is active, a clone
|
||||
|
|
@ -2275,7 +2282,7 @@ object should not affect later invocations.
|
|||
@item
|
||||
All suffix and infix classes derive from @code{transient-suffix}, which in
|
||||
turn derives from @code{transient-child}, from which @code{transient-group} also
|
||||
derives (see @ref{Group Classes}).
|
||||
derives (@pxref{Group Classes}).
|
||||
|
||||
@item
|
||||
All infix classes derive from the abstract @code{transient-infix} class,
|
||||
|
|
@ -2283,13 +2290,13 @@ which in turn derives from the @code{transient-suffix} class.
|
|||
|
||||
Infixes are a special type of suffixes. The primary difference is
|
||||
that infixes always use the @code{transient--do-stay} pre-command, while
|
||||
non-infix suffixes use a variety of pre-commands (see @ref{Transient State}). Doing that is most easily achieved by using this class,
|
||||
non-infix suffixes use a variety of pre-commands (@pxref{Transient State}). Doing that is most easily achieved by using this class,
|
||||
though theoretically it would be possible to define an infix class
|
||||
that does not do so. If you do that then you get to implement many
|
||||
methods.
|
||||
|
||||
Also, infixes and non-infix suffixes are usually defined using
|
||||
different macros (see @ref{Defining Suffix and Infix Commands}).
|
||||
different macros (@pxref{Defining Suffix and Infix Commands}).
|
||||
|
||||
@item
|
||||
Classes used for infix commands that represent arguments should
|
||||
|
|
@ -2699,7 +2706,7 @@ secondary value, called a ``scope''. See @code{transient-define-prefix}.
|
|||
@code{transient-suffix}, @code{transient-non-suffix} and @code{transient-switch-frame}
|
||||
play a part when determining whether the currently active transient
|
||||
prefix command remains active/transient when a suffix or arbitrary
|
||||
non-suffix command is invoked. See @ref{Transient State}.
|
||||
non-suffix command is invoked. @xref{Transient State}.
|
||||
|
||||
@item
|
||||
@code{refresh-suffixes} Normally suffix objects and keymaps are only setup
|
||||
|
|
@ -2781,7 +2788,7 @@ of the same symbol.
|
|||
|
||||
@item
|
||||
@code{level} The level of the prefix commands. The suffix commands whose
|
||||
layer is equal or lower are displayed. See @ref{Enabling and Disabling Suffixes}.
|
||||
layer is equal or lower are displayed. @pxref{Enabling and Disabling Suffixes}.
|
||||
|
||||
@item
|
||||
@code{value} The likely outdated value of the prefix. Instead of accessing
|
||||
|
|
@ -2805,15 +2812,15 @@ Here we document most of the slots that are only available for suffix
|
|||
objects. Some slots are shared by suffix and group objects, they are
|
||||
documented in @ref{Predicate Slots}.
|
||||
|
||||
Also see @ref{Suffix Classes}.
|
||||
Also @xref{Suffix Classes}.
|
||||
|
||||
@anchor{Slots of @code{transient-child}}
|
||||
@subheading Slots of @code{transient-child}
|
||||
|
||||
This is the abstract superclass of @code{transient-suffix} and @code{transient-group}.
|
||||
This is where the shared @code{if*} and @code{inapt-if*} slots (see @ref{Predicate Slots}),
|
||||
the @code{level} slot (see @ref{Enabling and Disabling Suffixes}), and the @code{advice}
|
||||
and @code{advice*} slots (see @ref{Slots of @code{transient-suffix}}) are defined.
|
||||
This is where the shared @code{if*} and @code{inapt-if*} slots (@pxref{Predicate Slots}),
|
||||
the @code{level} slot (@pxref{Enabling and Disabling Suffixes}), and the @code{advice}
|
||||
and @code{advice*} slots (@pxref{Slots of @code{transient-suffix}}) are defined.
|
||||
|
||||
@itemize
|
||||
@item
|
||||
|
|
@ -2839,7 +2846,7 @@ which is useful for alignment purposes.
|
|||
@code{command} The command, a symbol.
|
||||
|
||||
@item
|
||||
@code{transient} Whether to stay transient. See @ref{Transient State}.
|
||||
@code{transient} Whether to stay transient. @xref{Transient State}.
|
||||
|
||||
@item
|
||||
@code{format} The format used to display the suffix in the menu buffer.
|
||||
|
|
@ -3063,14 +3070,14 @@ currently cannot be invoked.
|
|||
|
||||
By default these predicates run when the prefix command is invoked,
|
||||
but this can be changes, using the @code{refresh-suffixes} prefix slot.
|
||||
See @ref{Prefix Slots}.
|
||||
@xref{Prefix Slots}.
|
||||
|
||||
One more slot is shared between group and suffix classes, @code{level}. Like
|
||||
the slots documented above, it is a predicate, but it is used for a
|
||||
different purpose. The value has to be an integer between 1
|
||||
and 7. @code{level} controls whether a suffix or a group should be
|
||||
available depending on user preference.
|
||||
See @ref{Enabling and Disabling Suffixes}.
|
||||
@xref{Enabling and Disabling Suffixes}.
|
||||
|
||||
@node FAQ
|
||||
@appendix FAQ
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
;; Author: Jonas Bernoulli <jonas@bernoul.li>
|
||||
;; URL: https://github.com/magit/transient
|
||||
;; Keywords: extensions
|
||||
;; Version: 0.11.0
|
||||
;; Version: 0.12.0
|
||||
|
||||
;; SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
;;; Code:
|
||||
;;;; Frontmatter
|
||||
|
||||
(defconst transient-version "v0.11.0-10-g6637364e-builtin")
|
||||
(defconst transient-version "v0.12.0-15-gfe5214e6-builtin")
|
||||
|
||||
(require 'cl-lib)
|
||||
(require 'eieio)
|
||||
|
|
@ -669,15 +669,16 @@ See also option `transient-highlight-mismatched-keys'."
|
|||
(insert-file-contents file)
|
||||
(read (current-buffer))))))
|
||||
|
||||
(defun transient--pp-to-file (list file)
|
||||
(make-directory (file-name-directory file) t)
|
||||
(setq list (cl-sort (copy-sequence list) #'string< :key #'car))
|
||||
(with-temp-file file
|
||||
(let ((print-level nil)
|
||||
(print-length nil)
|
||||
(pp-default-function 'pp-28)
|
||||
(fill-column 999))
|
||||
(pp list (current-buffer)))))
|
||||
(defun transient--pp-to-file (value file)
|
||||
(when (or value (file-exists-p file))
|
||||
(make-directory (file-name-directory file) t)
|
||||
(setq value (cl-sort (copy-sequence value) #'string< :key #'car))
|
||||
(with-temp-file file
|
||||
(let ((print-level nil)
|
||||
(print-length nil)
|
||||
(pp-default-function 'pp-28)
|
||||
(fill-column 999))
|
||||
(pp value (current-buffer))))))
|
||||
|
||||
(defvar transient-values
|
||||
(transient--read-file-contents transient-values-file)
|
||||
|
|
@ -1215,15 +1216,15 @@ commands are aliases for."
|
|||
(while-let
|
||||
((arg (car args))
|
||||
(arg (cond
|
||||
;; Inline group definition.
|
||||
((vectorp arg)
|
||||
(pop args))
|
||||
;; Quoted include, as one would expect.
|
||||
((eq (car-safe arg) 'quote)
|
||||
(cadr (pop args)))
|
||||
;; Unquoted include, for compatibility.
|
||||
((and arg (symbolp arg))
|
||||
(pop args)))))
|
||||
;; Inline group definition.
|
||||
((vectorp arg)
|
||||
(pop args))
|
||||
;; Quoted include, as one would expect.
|
||||
((eq (car-safe arg) 'quote)
|
||||
(cadr (pop args)))
|
||||
;; Unquoted include, for compatibility.
|
||||
((and arg (symbolp arg))
|
||||
(pop args)))))
|
||||
(push arg suffixes))
|
||||
(when (eq (car-safe (car args)) 'declare)
|
||||
(setq declare (car args))
|
||||
|
|
@ -1234,11 +1235,11 @@ commands are aliases for."
|
|||
(unless (cdr declare)
|
||||
(setq declare nil)))
|
||||
(cond
|
||||
((not args))
|
||||
(nobody
|
||||
(error "%s: No function body allowed" form))
|
||||
((not (eq (car-safe (nth (if declare 1 0) args)) 'interactive))
|
||||
(error "%s: Interactive form missing" form)))
|
||||
((not args))
|
||||
(nobody
|
||||
(error "%s: No function body allowed" form))
|
||||
((not (eq (car-safe (nth (if declare 1 0) args)) 'interactive))
|
||||
(error "%s: Interactive form missing" form)))
|
||||
(list (if (eq (car-safe class) 'quote)
|
||||
(cadr class)
|
||||
class)
|
||||
|
|
@ -1502,40 +1503,40 @@ Intended for use in a group's `:setup-children' function."
|
|||
(symbol suffix)))
|
||||
(`(,elt ,group) (transient--locate-child prefix loc)))
|
||||
(cond
|
||||
((not elt)
|
||||
(funcall (if transient-error-on-insert-failure #'error #'message)
|
||||
"Cannot insert %S into %s; %s not found"
|
||||
suffix prefix loc))
|
||||
((or (and (vectorp suffix) (not (vectorp elt)))
|
||||
(and (listp suffix) (vectorp elt))
|
||||
(and (stringp suffix) (vectorp elt)))
|
||||
(funcall (if transient-error-on-insert-failure #'error #'message)
|
||||
"Cannot place %S into %s at %s; %s"
|
||||
suffix prefix loc
|
||||
"suffixes and groups cannot be siblings"))
|
||||
(t
|
||||
(when-let* ((_(not (eq keep-other 'always)))
|
||||
(bindingp (listp suf))
|
||||
(key (transient--suffix-key suf))
|
||||
(conflict (car (transient--locate-child prefix key)))
|
||||
(conflictp
|
||||
(and (not (and (eq action 'replace)
|
||||
(eq conflict elt)))
|
||||
(or (not keep-other)
|
||||
(eq (plist-get (transient--suffix-props suf)
|
||||
:command)
|
||||
(plist-get (transient--suffix-props conflict)
|
||||
:command)))
|
||||
(equal (transient--suffix-predicate suf)
|
||||
(transient--suffix-predicate conflict)))))
|
||||
(transient-remove-suffix prefix key)
|
||||
(pcase-setq `(,elt ,group) (transient--locate-child prefix loc)))
|
||||
(let ((mem (memq elt (aref group 2))))
|
||||
(pcase-exhaustive action
|
||||
('insert (setcdr mem (cons elt (cdr mem)))
|
||||
(setcar mem suf))
|
||||
('append (setcdr mem (cons suf (cdr mem))))
|
||||
('replace (setcar mem suf))))))))
|
||||
((not elt)
|
||||
(funcall (if transient-error-on-insert-failure #'error #'message)
|
||||
"Cannot insert %S into %s; %s not found"
|
||||
suffix prefix loc))
|
||||
((or (and (vectorp suffix) (not (vectorp elt)))
|
||||
(and (listp suffix) (vectorp elt))
|
||||
(and (stringp suffix) (vectorp elt)))
|
||||
(funcall (if transient-error-on-insert-failure #'error #'message)
|
||||
"Cannot place %S into %s at %s; %s"
|
||||
suffix prefix loc
|
||||
"suffixes and groups cannot be siblings"))
|
||||
(t
|
||||
(when-let* ((_(not (eq keep-other 'always)))
|
||||
(bindingp (listp suf))
|
||||
(key (transient--suffix-key suf))
|
||||
(conflict (car (transient--locate-child prefix key)))
|
||||
(conflictp
|
||||
(and (not (and (eq action 'replace)
|
||||
(eq conflict elt)))
|
||||
(or (not keep-other)
|
||||
(eq (plist-get (transient--suffix-props suf)
|
||||
:command)
|
||||
(plist-get (transient--suffix-props conflict)
|
||||
:command)))
|
||||
(equal (transient--suffix-predicate suf)
|
||||
(transient--suffix-predicate conflict)))))
|
||||
(transient-remove-suffix prefix key)
|
||||
(pcase-setq `(,elt ,group) (transient--locate-child prefix loc)))
|
||||
(let ((mem (memq elt (aref group 2))))
|
||||
(pcase-exhaustive action
|
||||
('insert (setcdr mem (cons elt (cdr mem)))
|
||||
(setcar mem suf))
|
||||
('append (setcdr mem (cons suf (cdr mem))))
|
||||
('replace (setcar mem suf))))))))
|
||||
|
||||
;;;###autoload
|
||||
(defun transient-insert-suffix (prefix loc suffix &optional keep-other)
|
||||
|
|
@ -1644,20 +1645,20 @@ See info node `(transient)Modifying Existing Transients'."
|
|||
(setq group (transient--get-layout group)))
|
||||
(when (vectorp loc)
|
||||
(setq loc (append loc nil)))
|
||||
(if (listp loc)
|
||||
(and-let* ((match (transient--nth (pop loc) (aref group 2))))
|
||||
(if loc
|
||||
(transient--locate-child
|
||||
match (cond ((or (stringp (car loc))
|
||||
(symbolp (car loc)))
|
||||
(car loc))
|
||||
((symbolp match)
|
||||
(vconcat (cons 0 loc)))
|
||||
((vconcat loc))))
|
||||
(list match group)))
|
||||
(seq-some (lambda (child)
|
||||
(transient--match-child group loc child))
|
||||
(aref group 2))))
|
||||
(cond*
|
||||
((atom loc)
|
||||
(seq-some (lambda (child)
|
||||
(transient--match-child group loc child))
|
||||
(aref group 2)))
|
||||
((bind-and* (match (transient--nth (pop loc) (aref group 2))))
|
||||
(cond (loc (transient--locate-child
|
||||
match (cond ((or (stringp (car loc))
|
||||
(symbolp (car loc)))
|
||||
(car loc))
|
||||
((symbolp match)
|
||||
(vconcat (cons 0 loc)))
|
||||
((vconcat loc)))))
|
||||
((list match group))))))
|
||||
|
||||
(defun transient--match-child (group loc child)
|
||||
(cl-etypecase child
|
||||
|
|
@ -1931,23 +1932,23 @@ probably use this instead:
|
|||
(or transient--suffixes
|
||||
transient-current-suffixes))))
|
||||
(cond
|
||||
((length= suffixes 1)
|
||||
(car suffixes))
|
||||
((cl-find-if (lambda (obj)
|
||||
(equal (listify-key-sequence (kbd (oref obj key)))
|
||||
(listify-key-sequence (this-command-keys))))
|
||||
suffixes))
|
||||
;; COMMAND is only provided if `this-command' is meaningless, in
|
||||
;; which case `this-command-keys' is also meaningless, making it
|
||||
;; impossible to disambiguate bindings for the same command.
|
||||
(command (car suffixes))
|
||||
;; If COMMAND is nil, then failure to disambiguate likely means
|
||||
;; that there is a bug somewhere.
|
||||
((length> suffixes 1)
|
||||
(error "BUG: Cannot unambiguously determine suffix object"))
|
||||
;; It is legitimate to use this function as a predicate of sorts.
|
||||
;; `transient--pre-command' and `transient-help' are examples.
|
||||
(t nil))))
|
||||
((length= suffixes 1)
|
||||
(car suffixes))
|
||||
((cl-find-if (lambda (obj)
|
||||
(equal (listify-key-sequence (kbd (oref obj key)))
|
||||
(listify-key-sequence (this-command-keys))))
|
||||
suffixes))
|
||||
;; COMMAND is only provided if `this-command' is meaningless, in
|
||||
;; which case `this-command-keys' is also meaningless, making it
|
||||
;; impossible to disambiguate bindings for the same command.
|
||||
(command (car suffixes))
|
||||
;; If COMMAND is nil, then failure to disambiguate likely means
|
||||
;; that there is a bug somewhere.
|
||||
((length> suffixes 1)
|
||||
(error "BUG: Cannot unambiguously determine suffix object"))
|
||||
;; It is legitimate to use this function as a predicate of sorts.
|
||||
;; `transient--pre-command' and `transient-help' are examples.
|
||||
(t nil))))
|
||||
((bind-and* (obj (transient--suffix-prototype (or command this-command)))
|
||||
(obj (clone obj)))
|
||||
(transient-init-scope obj)
|
||||
|
|
@ -2254,31 +2255,31 @@ of the corresponding object."
|
|||
((cl-typep obj 'transient-infix) 'infix)
|
||||
(t 'suffix)))
|
||||
(pre (cond
|
||||
((oref obj inactive) nil)
|
||||
((oref obj inapt) #'transient--do-warn-inapt)
|
||||
((slot-boundp obj 'transient)
|
||||
(pcase (list kind
|
||||
(transient--resolve-pre-command
|
||||
(oref obj transient) nil t)
|
||||
return)
|
||||
(`(prefix t ,_) #'transient--do-recurse)
|
||||
(`(prefix nil ,_) #'transient--do-stack)
|
||||
(`(infix t ,_) #'transient--do-stay)
|
||||
(`(suffix t ,_) #'transient--do-call)
|
||||
('(suffix nil t) #'transient--do-return)
|
||||
(`(,_ nil ,_) #'transient--do-exit)
|
||||
(`(,_ ,do ,_) do)))
|
||||
((not (lookup-key transient-predicate-map id))
|
||||
(pcase (list kind default return)
|
||||
(`(prefix ,(or 'transient--do-stay 'transient--do-call) ,_)
|
||||
#'transient--do-recurse)
|
||||
(`(prefix t ,_) #'transient--do-recurse)
|
||||
(`(prefix ,_ ,_) #'transient--do-stack)
|
||||
(`(infix ,_ ,_) #'transient--do-stay)
|
||||
(`(suffix t ,_) #'transient--do-call)
|
||||
('(suffix nil t) #'transient--do-return)
|
||||
(`(suffix nil nil) #'transient--do-exit)
|
||||
(`(suffix ,do ,_) do))))))
|
||||
((oref obj inactive) nil)
|
||||
((oref obj inapt) #'transient--do-warn-inapt)
|
||||
((slot-boundp obj 'transient)
|
||||
(pcase (list kind
|
||||
(transient--resolve-pre-command
|
||||
(oref obj transient) nil t)
|
||||
return)
|
||||
(`(prefix t ,_) #'transient--do-recurse)
|
||||
(`(prefix nil ,_) #'transient--do-stack)
|
||||
(`(infix t ,_) #'transient--do-stay)
|
||||
(`(suffix t ,_) #'transient--do-call)
|
||||
('(suffix nil t) #'transient--do-return)
|
||||
(`(,_ nil ,_) #'transient--do-exit)
|
||||
(`(,_ ,do ,_) do)))
|
||||
((not (lookup-key transient-predicate-map id))
|
||||
(pcase (list kind default return)
|
||||
(`(prefix ,(or 'transient--do-stay 'transient--do-call) ,_)
|
||||
#'transient--do-recurse)
|
||||
(`(prefix t ,_) #'transient--do-recurse)
|
||||
(`(prefix ,_ ,_) #'transient--do-stack)
|
||||
(`(infix ,_ ,_) #'transient--do-stay)
|
||||
(`(suffix t ,_) #'transient--do-call)
|
||||
('(suffix nil t) #'transient--do-return)
|
||||
(`(suffix nil nil) #'transient--do-exit)
|
||||
(`(suffix ,do ,_) do))))))
|
||||
(when pre
|
||||
(if-let* ((alt (lookup-key map id)))
|
||||
(unless (eq alt pre)
|
||||
|
|
@ -2336,24 +2337,24 @@ EDIT may be non-nil."
|
|||
(transient--debug 'setup)
|
||||
(transient--with-emergency-exit :setup
|
||||
(cond
|
||||
((not name)
|
||||
;; Switching between regular and edit mode.
|
||||
(transient--pop-keymap 'transient--transient-map)
|
||||
(transient--pop-keymap 'transient--redisplay-map)
|
||||
(setq name (oref transient--prefix command))
|
||||
(setq params (list :scope (oref transient--prefix scope))))
|
||||
(transient--prefix
|
||||
;; Invoked as a ":transient-non-suffix 'transient--do-{stay,call}"
|
||||
;; of an outer prefix. Unlike the usual `transient--do-stack',
|
||||
;; these predicates fail to clean up after the outer prefix.
|
||||
(transient--pop-keymap 'transient--transient-map)
|
||||
(transient--pop-keymap 'transient--redisplay-map))
|
||||
((not (or layout ; resuming parent/suspended prefix
|
||||
transient-current-command)) ; entering child prefix
|
||||
(transient--stack-zap)) ; replace suspended prefix, if any
|
||||
(edit
|
||||
;; Returning from help to edit.
|
||||
(setq transient--editp t)))
|
||||
((not name)
|
||||
;; Switching between regular and edit mode.
|
||||
(transient--pop-keymap 'transient--transient-map)
|
||||
(transient--pop-keymap 'transient--redisplay-map)
|
||||
(setq name (oref transient--prefix command))
|
||||
(setq params (list :scope (oref transient--prefix scope))))
|
||||
(transient--prefix
|
||||
;; Invoked as a ":transient-non-suffix 'transient--do-{stay,call}"
|
||||
;; of an outer prefix. Unlike the usual `transient--do-stack',
|
||||
;; these predicates fail to clean up after the outer prefix.
|
||||
(transient--pop-keymap 'transient--transient-map)
|
||||
(transient--pop-keymap 'transient--redisplay-map))
|
||||
((not (or layout ; resuming parent/suspended prefix
|
||||
transient-current-command)) ; entering child prefix
|
||||
(transient--stack-zap)) ; replace suspended prefix, if any
|
||||
(edit
|
||||
;; Returning from help to edit.
|
||||
(setq transient--editp t)))
|
||||
(transient--env-apply
|
||||
(lambda ()
|
||||
(transient--init-transient name layout params)
|
||||
|
|
@ -2570,25 +2571,25 @@ value. Otherwise return CHILDREN as is.")
|
|||
(if if-not if-nil if-non-nil if-mode if-not-mode if-derived if-not-derived
|
||||
default)
|
||||
(cond
|
||||
(if (funcall if))
|
||||
(if-not (not (funcall if-not)))
|
||||
(if-non-nil (symbol-value if-non-nil))
|
||||
(if-nil (not (symbol-value if-nil)))
|
||||
(if-mode (if (atom if-mode)
|
||||
(eq major-mode if-mode)
|
||||
(memq major-mode if-mode)))
|
||||
(if-not-mode (not (if (atom if-not-mode)
|
||||
(eq major-mode if-not-mode)
|
||||
(memq major-mode if-not-mode))))
|
||||
(if-derived (if (or (atom if-derived)
|
||||
(>= emacs-major-version 30))
|
||||
(derived-mode-p if-derived)
|
||||
(apply #'derived-mode-p if-derived)))
|
||||
(if-not-derived (not (if (or (atom if-not-derived)
|
||||
(>= emacs-major-version 30))
|
||||
(derived-mode-p if-not-derived)
|
||||
(apply #'derived-mode-p if-not-derived))))
|
||||
(default)))
|
||||
(if (funcall if))
|
||||
(if-not (not (funcall if-not)))
|
||||
(if-non-nil (symbol-value if-non-nil))
|
||||
(if-nil (not (symbol-value if-nil)))
|
||||
(if-mode (if (atom if-mode)
|
||||
(eq major-mode if-mode)
|
||||
(memq major-mode if-mode)))
|
||||
(if-not-mode (not (if (atom if-not-mode)
|
||||
(eq major-mode if-not-mode)
|
||||
(memq major-mode if-not-mode))))
|
||||
(if-derived (if (or (atom if-derived)
|
||||
(>= emacs-major-version 30))
|
||||
(derived-mode-p if-derived)
|
||||
(apply #'derived-mode-p if-derived)))
|
||||
(if-not-derived (not (if (or (atom if-not-derived)
|
||||
(>= emacs-major-version 30))
|
||||
(derived-mode-p if-not-derived)
|
||||
(apply #'derived-mode-p if-not-derived))))
|
||||
(default)))
|
||||
|
||||
(defun transient--suffix-predicate (spec)
|
||||
(let ((props (transient--suffix-props spec)))
|
||||
|
|
@ -2649,30 +2650,30 @@ value. Otherwise return CHILDREN as is.")
|
|||
(not (transient--get-pre-command this-command nil 'suffix)))
|
||||
(setq this-command this-original-command))
|
||||
(cond
|
||||
((memq this-command '(transient-update transient-quit-seq))
|
||||
(transient--pop-keymap 'transient--redisplay-map))
|
||||
((and transient--helpp
|
||||
(not (memq this-command transient--quit-commands)))
|
||||
(cond
|
||||
((transient-help)
|
||||
(transient--do-suspend)
|
||||
(setq this-command 'transient-suspend)
|
||||
(transient--pre-exit))
|
||||
((not (transient--edebug-command-p))
|
||||
(setq this-command 'transient-undefined))))
|
||||
((and transient--editp
|
||||
(transient-suffix-object)
|
||||
(not (memq this-command
|
||||
(cons 'transient-help transient--quit-commands))))
|
||||
(setq this-command 'transient-set-level)
|
||||
(transient--wrap-command))
|
||||
(t
|
||||
(setq transient--exitp nil)
|
||||
(let ((exitp (eq (transient--call-pre-command) transient--exit)))
|
||||
(transient--wrap-command)
|
||||
(when exitp
|
||||
(transient--maybe-set-value 'exit)
|
||||
(transient--pre-exit)))))))
|
||||
((memq this-command '(transient-update transient-quit-seq))
|
||||
(transient--pop-keymap 'transient--redisplay-map))
|
||||
((and transient--helpp
|
||||
(not (memq this-command transient--quit-commands)))
|
||||
(cond
|
||||
((transient-help)
|
||||
(transient--do-suspend)
|
||||
(setq this-command 'transient-suspend)
|
||||
(transient--pre-exit))
|
||||
((not (transient--edebug-command-p))
|
||||
(setq this-command 'transient-undefined))))
|
||||
((and transient--editp
|
||||
(transient-suffix-object)
|
||||
(not (memq this-command
|
||||
(cons 'transient-help transient--quit-commands))))
|
||||
(setq this-command 'transient-set-level)
|
||||
(transient--wrap-command))
|
||||
(t
|
||||
(setq transient--exitp nil)
|
||||
(let ((exitp (eq (transient--call-pre-command) transient--exit)))
|
||||
(transient--wrap-command)
|
||||
(when exitp
|
||||
(transient--maybe-set-value 'exit)
|
||||
(transient--pre-exit)))))))
|
||||
|
||||
(defun transient--pre-exit ()
|
||||
(transient--debug 'pre-exit)
|
||||
|
|
@ -2787,25 +2788,25 @@ value. Otherwise return CHILDREN as is.")
|
|||
(advice
|
||||
(lambda (fn &rest args)
|
||||
(interactive
|
||||
(lambda (spec)
|
||||
(let ((abort t))
|
||||
(unwind-protect
|
||||
(prog1 (let ((debugger #'transient--exit-and-debug))
|
||||
(if-let* ((obj suffix)
|
||||
(grp (oref obj parent))
|
||||
(adv (or (oref obj advice*)
|
||||
(oref grp advice*))))
|
||||
(funcall
|
||||
adv #'advice-eval-interactive-spec spec)
|
||||
(advice-eval-interactive-spec spec)))
|
||||
(setq abort nil))
|
||||
(when abort
|
||||
(when-let* ((unwind (oref prefix unwind-suffix)))
|
||||
(transient--debug 'unwind-interactive)
|
||||
(funcall unwind command))
|
||||
(when (symbolp command)
|
||||
(remove-function (symbol-function command) advice))
|
||||
(oset prefix unwind-suffix nil))))))
|
||||
(lambda (spec)
|
||||
(let ((abort t))
|
||||
(unwind-protect
|
||||
(prog1 (let ((debugger #'transient--exit-and-debug))
|
||||
(if-let* ((obj suffix)
|
||||
(grp (oref obj parent))
|
||||
(adv (or (oref obj advice*)
|
||||
(oref grp advice*))))
|
||||
(funcall
|
||||
adv #'advice-eval-interactive-spec spec)
|
||||
(advice-eval-interactive-spec spec)))
|
||||
(setq abort nil))
|
||||
(when abort
|
||||
(when-let* ((unwind (oref prefix unwind-suffix)))
|
||||
(transient--debug 'unwind-interactive)
|
||||
(funcall unwind command))
|
||||
(when (symbolp command)
|
||||
(remove-function (symbol-function command) advice))
|
||||
(oset prefix unwind-suffix nil))))))
|
||||
(unwind-protect
|
||||
(let ((debugger #'transient--exit-and-debug))
|
||||
(if-let* ((obj suffix)
|
||||
|
|
@ -3316,21 +3317,22 @@ transient is active."
|
|||
|
||||
;;;; Help
|
||||
|
||||
(defun transient-help (&optional interactive)
|
||||
(defun transient-help (&optional interactivep)
|
||||
"Show help for the active transient or one of its suffixes.
|
||||
\n(fn)"
|
||||
(interactive (list t))
|
||||
(if interactive
|
||||
(setq transient--helpp t)
|
||||
(with-demoted-errors "transient-help: %S"
|
||||
(when (lookup-key transient--transient-map
|
||||
(this-single-command-raw-keys))
|
||||
(setq transient--helpp nil)
|
||||
(transient--display-help #'transient-show-help
|
||||
(if (eq this-original-command 'transient-help)
|
||||
transient--prefix
|
||||
(or (transient-suffix-object)
|
||||
this-original-command)))))))
|
||||
(cond
|
||||
(interactivep
|
||||
(setq transient--helpp t))
|
||||
((lookup-key transient--transient-map
|
||||
(this-single-command-raw-keys))
|
||||
(setq transient--helpp nil)
|
||||
(with-demoted-errors "transient-help: %S"
|
||||
(transient--display-help #'transient-show-help
|
||||
(if (eq this-original-command 'transient-help)
|
||||
transient--prefix
|
||||
(or (transient-suffix-object)
|
||||
this-original-command)))))))
|
||||
|
||||
(transient-define-suffix transient-describe ()
|
||||
"From a transient menu, describe something in another buffer.
|
||||
|
|
@ -3358,55 +3360,55 @@ For example:
|
|||
(defun transient-set-level (&optional command level)
|
||||
"Set the level of the transient or one of its suffix commands."
|
||||
(interactive
|
||||
(let ((command this-original-command)
|
||||
(prefix (oref transient--prefix command)))
|
||||
(and (or (not (eq command 'transient-set-level))
|
||||
(and transient--editp
|
||||
(setq command prefix)))
|
||||
(list command
|
||||
(let ((keys (this-single-command-raw-keys)))
|
||||
(and (lookup-key transient--transient-map keys)
|
||||
(progn
|
||||
(transient--show)
|
||||
(string-to-number
|
||||
(transient--read-number-N
|
||||
(format "Set level for `%s': " command)
|
||||
nil nil (not (eq command prefix)))))))))))
|
||||
(let ((command this-original-command)
|
||||
(prefix (oref transient--prefix command)))
|
||||
(and (or (not (eq command 'transient-set-level))
|
||||
(and transient--editp
|
||||
(setq command prefix)))
|
||||
(list command
|
||||
(let ((keys (this-single-command-raw-keys)))
|
||||
(and (lookup-key transient--transient-map keys)
|
||||
(progn
|
||||
(transient--show)
|
||||
(string-to-number
|
||||
(transient--read-number-N
|
||||
(format "Set level for `%s': " command)
|
||||
nil nil (not (eq command prefix)))))))))))
|
||||
(cond
|
||||
((not command)
|
||||
(setq transient--editp t)
|
||||
(transient-setup))
|
||||
(level
|
||||
(let* ((prefix (oref transient--prefix command))
|
||||
(alist (alist-get prefix transient-levels))
|
||||
(akey command))
|
||||
(cond ((eq command prefix)
|
||||
(oset transient--prefix level level)
|
||||
(setq akey t))
|
||||
(t
|
||||
(oset (transient-suffix-object command) level level)
|
||||
(when (cdr (cl-remove-if-not (lambda (obj)
|
||||
(eq (oref obj command) command))
|
||||
transient--suffixes))
|
||||
(setq akey (cons command (this-command-keys))))))
|
||||
(setf (alist-get akey alist) level)
|
||||
(setf (alist-get prefix transient-levels) alist))
|
||||
(transient-save-levels)
|
||||
(transient--show))
|
||||
(t
|
||||
(transient-undefined))))
|
||||
((not command)
|
||||
(setq transient--editp t)
|
||||
(transient-setup))
|
||||
(level
|
||||
(let* ((prefix (oref transient--prefix command))
|
||||
(alist (alist-get prefix transient-levels))
|
||||
(akey command))
|
||||
(cond ((eq command prefix)
|
||||
(oset transient--prefix level level)
|
||||
(setq akey t))
|
||||
(t
|
||||
(oset (transient-suffix-object command) level level)
|
||||
(when (cdr (cl-remove-if-not (lambda (obj)
|
||||
(eq (oref obj command) command))
|
||||
transient--suffixes))
|
||||
(setq akey (cons command (this-command-keys))))))
|
||||
(setf (alist-get akey alist) level)
|
||||
(setf (alist-get prefix transient-levels) alist))
|
||||
(transient-save-levels)
|
||||
(transient--show))
|
||||
(t
|
||||
(transient-undefined))))
|
||||
|
||||
(transient-define-suffix transient-toggle-level-limit ()
|
||||
"Toggle whether to temporarily display suffixes on all levels."
|
||||
:description
|
||||
(lambda ()
|
||||
(cond
|
||||
(transient--all-levels-p
|
||||
(format "Hide suffix %s"
|
||||
(propertize
|
||||
(format "levels > %s" (oref (transient-prefix-object) level))
|
||||
'face 'transient-higher-level)))
|
||||
("Show all suffix levels")))
|
||||
(transient--all-levels-p
|
||||
(format "Hide suffix %s"
|
||||
(propertize
|
||||
(format "levels > %s" (oref (transient-prefix-object) level))
|
||||
'face 'transient-higher-level)))
|
||||
("Show all suffix levels")))
|
||||
:transient t
|
||||
(interactive)
|
||||
(setq transient--all-levels-p (not transient--all-levels-p))
|
||||
|
|
@ -3695,13 +3697,13 @@ it\", in which case it is pointless to preserve history.)"
|
|||
'transient--history))
|
||||
(value
|
||||
(cond
|
||||
(reader (funcall reader prompt initial-input history))
|
||||
(multi-value
|
||||
(completing-read-multiple prompt choices nil nil
|
||||
initial-input history))
|
||||
(choices
|
||||
(completing-read prompt choices nil t initial-input history))
|
||||
((read-string prompt initial-input history)))))
|
||||
(reader (funcall reader prompt initial-input history))
|
||||
(multi-value
|
||||
(completing-read-multiple prompt choices nil nil
|
||||
initial-input history))
|
||||
(choices
|
||||
(completing-read prompt choices nil t initial-input history))
|
||||
((read-string prompt initial-input history)))))
|
||||
(cond ((and (equal value "") (not allow-empty))
|
||||
(setq value nil))
|
||||
((and (equal value "\"\"") allow-empty)
|
||||
|
|
@ -4097,17 +4099,19 @@ a string, using the empty string for the empty value, or nil if
|
|||
the option does not appear in ARGS.
|
||||
|
||||
Append \"=\ to ARG to indicate that it is an option."
|
||||
(if (string-suffix-p "=" arg)
|
||||
(save-match-data
|
||||
(and-let* ((match (let ((case-fold-search nil)
|
||||
(re (format "\\`%s\\(?:=\\(.+\\)\\)?\\'"
|
||||
(substring arg 0 -1))))
|
||||
(cl-find-if (lambda (a)
|
||||
(and (stringp a)
|
||||
(string-match re a)))
|
||||
args))))
|
||||
(or (match-string 1 match) "")))
|
||||
(and (member arg args) t)))
|
||||
(save-match-data
|
||||
(cond*
|
||||
((member arg args) t)
|
||||
((bind-and*
|
||||
(_(string-suffix-p "=" arg))
|
||||
(match (let ((case-fold-search nil)
|
||||
(re (format "\\`%s\\(?:=\\(.+\\)\\)?\\'"
|
||||
(substring arg 0 -1))))
|
||||
(cl-find-if (lambda (a)
|
||||
(and (stringp a)
|
||||
(string-match re a)))
|
||||
args))))
|
||||
(match-string 1 match)))))
|
||||
|
||||
;;;; Return
|
||||
|
||||
|
|
@ -4177,21 +4181,23 @@ be non-nil. If either is non-nil, try the following in order:
|
|||
class definition or using its `transient-init-scope' method.
|
||||
|
||||
If no prefix matches, return nil."
|
||||
(if (or prefixes classes)
|
||||
(let ((prefixes (ensure-list prefixes))
|
||||
(type (if (symbolp classes) classes (cons 'or classes))))
|
||||
(if-let* ((obj (cl-flet ((match (obj)
|
||||
(and obj
|
||||
(or (memq (oref obj command) prefixes)
|
||||
(cl-typep obj type))
|
||||
obj)))
|
||||
(or (match transient-current-prefix)
|
||||
(match transient--prefix)))))
|
||||
(oref obj scope)
|
||||
(and (get (car prefixes) 'transient--prefix)
|
||||
(oref (transient--init-prefix (car prefixes)) scope))))
|
||||
(and-let* ((obj (transient-prefix-object)))
|
||||
(oref obj scope))))
|
||||
(cond*
|
||||
((or prefixes classes)
|
||||
(let* ((prefixes (ensure-list prefixes))
|
||||
(type (if (symbolp classes) classes (cons 'or classes)))
|
||||
(match (lambda (obj)
|
||||
(and obj
|
||||
(or (memq (oref obj command) prefixes)
|
||||
(cl-typep obj type))
|
||||
obj))))
|
||||
(cond*
|
||||
((bind-and* (obj (or (funcall match transient-current-prefix)
|
||||
(funcall match transient--prefix))))
|
||||
(oref obj scope))
|
||||
((get (car prefixes) 'transient--prefix)
|
||||
(oref (transient--init-prefix (car prefixes)) scope)))))
|
||||
((bind-and* (obj (transient-prefix-object)))
|
||||
(oref obj scope))))
|
||||
|
||||
;;;; History
|
||||
|
||||
|
|
@ -4309,15 +4315,15 @@ have a history of their own.")
|
|||
(and (minibuffer-selected-window)
|
||||
(selected-window))))
|
||||
(cond
|
||||
((eq (car (window-parameter win 'quit-restore)) 'other)
|
||||
;; Window used to display another buffer.
|
||||
(set-window-parameter win 'no-other-window
|
||||
(window-parameter win 'prev--no-other-window))
|
||||
(set-window-parameter win 'prev--no-other-window nil))
|
||||
((with-demoted-errors "Error while exiting transient: %S"
|
||||
(if (window-parent win)
|
||||
(delete-window win)
|
||||
(delete-frame (window-frame win) t)))))
|
||||
((eq (car (window-parameter win 'quit-restore)) 'other)
|
||||
;; Window used to display another buffer.
|
||||
(set-window-parameter win 'no-other-window
|
||||
(window-parameter win 'prev--no-other-window))
|
||||
(set-window-parameter win 'prev--no-other-window nil))
|
||||
((with-demoted-errors "Error while exiting transient: %S"
|
||||
(if (window-parent win)
|
||||
(delete-window win)
|
||||
(delete-frame (window-frame win) t)))))
|
||||
(when remain-in-minibuffer-window
|
||||
(select-window remain-in-minibuffer-window))))
|
||||
(when (buffer-live-p transient--buffer)
|
||||
|
|
@ -4576,49 +4582,49 @@ as a button."
|
|||
(let ((len (length transient--redisplay-key))
|
||||
(seq (cl-coerce (edmacro-parse-keys key t) 'list)))
|
||||
(cond
|
||||
((member (seq-take seq len)
|
||||
(list transient--redisplay-key
|
||||
(thread-last transient--redisplay-key
|
||||
(cl-substitute ?- 'kp-subtract)
|
||||
(cl-substitute ?= 'kp-equal)
|
||||
(cl-substitute ?+ 'kp-add))))
|
||||
(let ((pre (key-description (vconcat (seq-take seq len))))
|
||||
(suf (key-description (vconcat (seq-drop seq len)))))
|
||||
(setq pre (string-replace "RET" "C-m" pre))
|
||||
(setq pre (string-replace "TAB" "C-i" pre))
|
||||
(setq suf (string-replace "RET" "C-m" suf))
|
||||
(setq suf (string-replace "TAB" "C-i" suf))
|
||||
;; We use e.g., "-k" instead of the more correct "- k",
|
||||
;; because the former is prettier. If we did that in
|
||||
;; the definition, then we want to drop the space that
|
||||
;; is reinserted above. False-positives are possible
|
||||
;; for silly bindings like "-C-c C-c".
|
||||
(unless (string-search " " key)
|
||||
(setq pre (string-replace " " "" pre))
|
||||
(setq suf (string-replace " " "" suf)))
|
||||
(concat (propertize pre 'face 'transient-unreachable-key)
|
||||
(and (string-prefix-p (concat pre " ") key) " ")
|
||||
(propertize suf 'face (transient--key-face cmd key))
|
||||
(save-excursion
|
||||
(and (string-match " +\\'" key)
|
||||
(propertize (match-string 0 key)
|
||||
'face 'fixed-pitch))))))
|
||||
((transient--lookup-key transient-sticky-map (kbd key))
|
||||
(propertize key 'face (transient--key-face cmd key)))
|
||||
(t
|
||||
(propertize key 'face 'transient-unreachable-key))))
|
||||
((member (seq-take seq len)
|
||||
(list transient--redisplay-key
|
||||
(thread-last transient--redisplay-key
|
||||
(cl-substitute ?- 'kp-subtract)
|
||||
(cl-substitute ?= 'kp-equal)
|
||||
(cl-substitute ?+ 'kp-add))))
|
||||
(let ((pre (key-description (vconcat (seq-take seq len))))
|
||||
(suf (key-description (vconcat (seq-drop seq len)))))
|
||||
(setq pre (string-replace "RET" "C-m" pre))
|
||||
(setq pre (string-replace "TAB" "C-i" pre))
|
||||
(setq suf (string-replace "RET" "C-m" suf))
|
||||
(setq suf (string-replace "TAB" "C-i" suf))
|
||||
;; We use e.g., "-k" instead of the more correct "- k",
|
||||
;; because the former is prettier. If we did that in
|
||||
;; the definition, then we want to drop the space that
|
||||
;; is reinserted above. False-positives are possible
|
||||
;; for silly bindings like "-C-c C-c".
|
||||
(unless (string-search " " key)
|
||||
(setq pre (string-replace " " "" pre))
|
||||
(setq suf (string-replace " " "" suf)))
|
||||
(concat (propertize pre 'face 'transient-unreachable-key)
|
||||
(and (string-prefix-p (concat pre " ") key) " ")
|
||||
(propertize suf 'face (transient--key-face cmd key))
|
||||
(save-excursion
|
||||
(and (string-match " +\\'" key)
|
||||
(propertize (match-string 0 key)
|
||||
'face 'fixed-pitch))))))
|
||||
((transient--lookup-key transient-sticky-map (kbd key))
|
||||
(propertize key 'face (transient--key-face cmd key)))
|
||||
(t
|
||||
(propertize key 'face 'transient-unreachable-key))))
|
||||
(propertize key 'face (transient--key-face cmd key)))))
|
||||
|
||||
(cl-defmethod transient-format-key :around ((obj transient-argument))
|
||||
"Handle `transient-highlight-mismatched-keys'."
|
||||
(let ((key (cl-call-next-method obj)))
|
||||
(cond
|
||||
((not transient-highlight-mismatched-keys) key)
|
||||
((not (slot-boundp obj 'shortarg))
|
||||
(transient--add-face key 'transient-nonstandard-key))
|
||||
((not (string-equal key (oref obj shortarg)))
|
||||
(transient--add-face key 'transient-mismatched-key))
|
||||
(key))))
|
||||
((not transient-highlight-mismatched-keys) key)
|
||||
((not (slot-boundp obj 'shortarg))
|
||||
(transient--add-face key 'transient-nonstandard-key))
|
||||
((not (string-equal key (oref obj shortarg)))
|
||||
(transient--add-face key 'transient-mismatched-key))
|
||||
(key))))
|
||||
|
||||
(cl-defgeneric transient-format-description (obj)
|
||||
"Format OBJ's `description' for display and return the result.")
|
||||
|
|
@ -4631,7 +4637,7 @@ and its value is returned to the caller."
|
|||
|
||||
(cl-defmethod transient-format-description ((obj transient-value-preset))
|
||||
(pcase-let* (((eieio description key set) obj)
|
||||
((eieio value) transient--prefix)
|
||||
(value (transient--get-extended-value))
|
||||
(active (seq-set-equal-p set value)))
|
||||
(format
|
||||
"%s %s"
|
||||
|
|
@ -4752,23 +4758,24 @@ apply the face `transient-unreachable' to the complete string."
|
|||
(propertize "|" 'face 'transient-delimiter))))))
|
||||
|
||||
(cl-defmethod transient--get-description ((obj transient-child))
|
||||
(and-let* ((desc (oref obj description)))
|
||||
(if (functionp desc)
|
||||
(if (= (car (transient--func-arity desc)) 1)
|
||||
(funcall desc obj)
|
||||
(funcall desc))
|
||||
desc)))
|
||||
(cond*
|
||||
((bind* (desc (oref obj description))))
|
||||
((functionp desc)
|
||||
(condition-case nil
|
||||
(funcall desc obj)
|
||||
(wrong-number-of-arguments (funcall desc))))
|
||||
(desc)))
|
||||
|
||||
(cl-defmethod transient--get-face ((obj transient-suffix) slot)
|
||||
(and-let* ((_(slot-boundp obj slot))
|
||||
(face (slot-value obj slot)))
|
||||
(if (and (not (facep face))
|
||||
(functionp face))
|
||||
(let ((transient--pending-suffix obj))
|
||||
(if (= (car (transient--func-arity face)) 1)
|
||||
(funcall face obj)
|
||||
(funcall face)))
|
||||
face)))
|
||||
(cond*
|
||||
((not (slot-boundp obj slot)) nil)
|
||||
((bind* (face (slot-value obj slot))))
|
||||
((facep face) face)
|
||||
((functionp face)
|
||||
(let ((transient--pending-suffix obj))
|
||||
(condition-case nil
|
||||
(funcall face obj)
|
||||
(wrong-number-of-arguments (funcall face)))))))
|
||||
|
||||
(defun transient--add-face (string face &optional append beg end)
|
||||
(let ((str (copy-sequence string)))
|
||||
|
|
@ -4875,7 +4882,7 @@ prefix method."
|
|||
((eq this-command 'transient-help)
|
||||
(transient-show-help transient--prefix))
|
||||
((bind-and* (prefix (get (oref obj command) 'transient--prefix))
|
||||
(n/a (not (eq (oref transient--prefix command) this-command))))
|
||||
(_(not (eq (oref transient--prefix command) this-command))))
|
||||
(transient-show-help prefix))
|
||||
((bind-and* (show-help (oref obj show-help)))
|
||||
(funcall show-help obj))
|
||||
|
|
@ -5116,20 +5123,20 @@ See `forward-button' for information about N."
|
|||
|
||||
(defun transient--goto-button (command)
|
||||
(cond
|
||||
((stringp command)
|
||||
(when (re-search-forward (concat "^" (regexp-quote command)) nil t)
|
||||
(goto-char (match-beginning 0))))
|
||||
(command
|
||||
(cl-flet ((found ()
|
||||
(and-let* ((button (button-at (point))))
|
||||
(eq (button-get button 'command) command))))
|
||||
(while (and (ignore-errors (forward-button 1))
|
||||
(not (found))))
|
||||
(unless (found)
|
||||
(goto-char (point-min))
|
||||
(ignore-errors (forward-button 1))
|
||||
(unless (found)
|
||||
(goto-char (point-min))))))))
|
||||
((stringp command)
|
||||
(when (re-search-forward (concat "^" (regexp-quote command)) nil t)
|
||||
(goto-char (match-beginning 0))))
|
||||
(command
|
||||
(cl-flet ((found ()
|
||||
(and-let* ((button (button-at (point))))
|
||||
(eq (button-get button 'command) command))))
|
||||
(while (and (ignore-errors (forward-button 1))
|
||||
(not (found))))
|
||||
(unless (found)
|
||||
(goto-char (point-min))
|
||||
(ignore-errors (forward-button 1))
|
||||
(unless (found)
|
||||
(goto-char (point-min))))))))
|
||||
|
||||
(defun transient--heading-at-point ()
|
||||
(and (eq (get-text-property (point) 'face) 'transient-heading)
|
||||
|
|
@ -5253,7 +5260,7 @@ that binding back, then call this function in your init file like so:
|
|||
Individual transients may already bind \\`q' to something else
|
||||
and such a binding would shadow the quit binding. If that is the
|
||||
case then \\`Q' is bound to whatever \\`q' would have been bound
|
||||
to by setting `transient-substitute-key-function' to a function
|
||||
to, by setting `transient-substitute-key-function' to a function
|
||||
that does that. Of course \\`Q' may already be bound to something
|
||||
else, so that function binds \\`M-q' to that command instead.
|
||||
Of course \\`M-q' may already be bound to something else, but
|
||||
|
|
@ -5275,9 +5282,6 @@ we stop there."
|
|||
(face-remap-reset-base 'default)
|
||||
(face-remap-add-relative 'default 'fixed-pitch))
|
||||
|
||||
(defun transient--func-arity (fn)
|
||||
(func-arity (advice--cd*r (if (symbolp fn) (symbol-function fn) fn))))
|
||||
|
||||
(defun transient--seq-reductions-from (function sequence initial-value)
|
||||
(let ((acc (list initial-value)))
|
||||
(seq-doseq (elt sequence)
|
||||
|
|
@ -5373,7 +5377,11 @@ as stand-in for elements of exhausted lists."
|
|||
;;;; _
|
||||
(provide 'transient)
|
||||
;; Local Variables:
|
||||
;; indent-tabs-mode: nil
|
||||
;; checkdoc-symbol-words: ("command-line" "edit-mode" "help-mode")
|
||||
;; indent-tabs-mode: nil
|
||||
;; lisp-indent-local-overrides: (
|
||||
;; (cond . 0)
|
||||
;; (cond* . 0)
|
||||
;; (interactive . 0))
|
||||
;; End:
|
||||
;;; transient.el ends here
|
||||
|
|
|
|||
Loading…
Reference in a new issue