| Age | Commit message (Collapse) | Author |
|
|
|
|
|
|
|
When we created `transient--get-savable-value' in [1: b4edb633], we
(intentionally) stopped falling back to `transient-current-suffixes'.
The value is saved to history before `transient--suffixes' is unset
and our commands that explicitly set the value do not exit the menu.
However, a third-party may add a command that sets the value and
also exits the menu. I realized that when I made the above change,
but figured I would hear about it, if anybody actually did that.
That just happened with #410, so use `transient-current-suffixes'
again.
Closes #410.
1: 2025-08-16 b4edb633488fc251df0883b69b1eb350cb2e94ec
transient-get-value: Replace with three functions
|
|
Correct IMO, obviously.
|
|
|
|
|
|
|
|
Closes #287.
|
|
This lists commands that quit a menu. I.e., not `transient-quit-seq'.
|
|
If this is enabled then even suffixes on level 0 are displayed.
This is something that possibly should be changed, but until we
do, it makes no sense to make this suffix inapt when on level 7.
|
|
|
|
Each suffix is used to track its value. If we drop an inactive
suffix and it later becomes active, then its value is lost, so
stop doing that. The consequence is that we now have to account
for `inactive' suffixes in several places, just like we already
had to do for `inapt' suffixes.
A suffix may be inactive for two reason. It may have an `:if*'
predicate, which currently returns nil. Or it may be on a level
that is currently not being used.
Closes #316.
Closes #364.
Closes #407.
|
|
|
|
|
|
|
|
Instead filter out their values in `transient-prefix-value' and
`transient-get-value'. (In the latter case we started doing that
a few commits ago.)
Re #407.
|
|
Initializing a prefix sets its `value' slot. Initializing the `value'
slots of its suffixes involves accessing the value stored in that slot.
After that the values of the suffixes' `value' slot collectively specify
the prefix's value. The value of the prefix's `value' slot may or may
not be identical at this point. (For example a suffix's `init-value'
slot may set pick a value different from the value in the prefix's
`value' slot.)
To prevent access to the potentially outdated value of the prefix's
`value' slot, make it unbound after initializing the suffixes.
|
|
Usually the value stored in the prefix's `value' slot is still the
same at this time, but that is not guaranteed. In particular if a
suffix has a non-nil `init-value' slot, it likely is not.
|
|
This allows suffixes to access the up-to-date values of earlier
suffixes. Doing so was already possible by instead using the value of
the prefix's `value' slot, which at this time often isn't outdated yet.
And yet, the prefix's `value' is not certain not to be outdated, e.g.,
when a suffix has a non-nil `init-value'. So it is often better to get
the up-to-date value using `transient-get-value', which thanks to this
commit is now possible even during the initial setup of the menu.
But suffixes do have to be processed in some order, and we obviously
cannot use the result of an operation that hasn't taken place yet.
So to use `transient-get-value' at this time, suffixes have to be
ordered so that the value of suffixes whose values are used by other
suffixes are processes earlier. They are processed earlier if they
appear earlier (further up and more to the left) in the menu.
In some rare cases that may not be possible or desirable. In such
cases it may still make sense to use the value of the prefix's `value'
slot.
Re #316.
|
|
`transient-get-value' was added in [1: d33fe5ab]. At this time it was
only used by commands that save the value. We didn't make a distinction
between `transient--suffixes' and `transient-current-suffixes' at this
time.
In [2: 1b9929ec] the `unsavable' suffix slot was added and this function
started to drop the values of unsavable suffixes.
In [3: 8db5f0fd] we started to also use it to preserve the value across
refreshes. That made it necessary to use `transient--suffixes'. It
would have made sense to only use that variable. Instead we started
to use it, if non-nil, and fall back to `transient-current-suffixes'
otherwise (which previously was used exclusively).
Sometime along the way, package authors started to need the value of
the prefix or of another suffix while setting up the menu and its
suffixes. `transient-args' is not intended for that purpose and I
started to tell them to use `transient-get-value'.
So now `transient-get-value' is being used for at least three distinct
purposes. They have in common that they deal with the value of the
extant prefix (so `transient-args' is not appropriate); but they need
different subsets of that value.
We could deal with that by adding arguments to `transient-get-value'.
Instead we use three different functions, and give them names that
make these differences obvious.
- New `transient--get-savable-value' obviously filters out the non-
savable parts of the value and is obviously used when saving the
value.
- New `transient--get-extended-value' returns the full value. This
includes the parts that are currently inactive, but have to be
preserved because they may become active again. This is used to
preserve the value across refreshes. This also includes unsavable
parts of the value, since we still want to use those parts.
- `transient-get-value' now returns the "effective" value. This
includes the "unsavable" (but "intend for use") parts. It does
not include the "inactive" parts. Keep the current name of this
function because that is being used in third-party package.
Note that while this now filters out the value of suffixes whose
`inapt' slot is non-nil, that doesn't make a difference just yet.
Such suffixes are not being added to `transient--suffixes' yet,
but we will start doing that in a few commits.
In other words, there effectively is no change in how this deals
with inapt parts of the value.
However, the behavior changes with regards to unsavable parts of
the value. Those are no longer dropped. That is a bugfix.
1: 2019-08-12 d33fe5abaf5d0de2a8e80e7e52555d725ebdc6e5
Split new transient-get-value from transient-args
2: 2020-10-20 1b9929eca9b1076fb04794b6736d42a1d394fadb
Add new `unsavable' infix slot
3: 2024-06-22 8db5f0fd4469f3b2af34e07a283372ca273fa685
transient--refresh-transient: Preserve value
|
|
|
|
Most callers already determine the value themselves because they need
to do other things with it, beside adding it to the history using this
function. Pass along the value to avoid having to calculate it twice.
|
|
|
|
|
|
This was not done until now because doing so resulted in a warning
because the macro expansion did not actually leave any variables
unused. This was fixed in Emacs 30.1 and the previous commit
backports that for older releases.
Without consistently using `_' one would always have to count parens
to be sure whether a member of the varlist does or does not bind a
variable. It is very easy to make mistake when writing or reading
such forms if `_' is not consistently used in the non-binding cases.
|
|
The macro expansions did not leave a variable `_' unused; this
triggered an irritating compiler warning.
Backport fix for https://debbugs.gnu.org/cgi/bugreport.cgi?bug=69108,
from Emacs commit e680827e814e155cf79175d87ff7c6ee3a08b69a.
|
|
|
|
When the suffix being inserted is already part of the menu, we
remove the existing entry and then insert a new entry. In some
cases we could avoid these two steps and just do nothing, but it
would likely be more expensive and certainly more complicated to
determine whether we can skip the two steps than it is to just
do them.
When the same suffix is added twice at the same coordinates (e.g.,
because the same form ends up being evaluated twice), this resulted
in an error because the entry that is removed in this case also is
the pointer to the insertion location, and removing it invalidates
it. So we have to lookup the coordinates again, after the removal.
Closes #400.
Closes #401.
(We cannot use `pcase-setq' because that wasn't added until Emacs
28.1 and Compat does not backport it. Also, it turns out this is
the exception to my rule to never set more than one variable using
a single `setq' form.)
Co-authored-by: Evgeny Boykov <artscan@list.ru>
|
|
|
|
|
|
It is unnecessary to call `transient--show' here because it will
later happen anyway when `transient--post-command' calls either
`transient--refresh-transient' or `transient--redisplay'.
Calling `transient--show' here also meant that it could not take any
state changes into account that the invoked command made, which is
relevant if `refresh-suffixes' is non-nil and those changes effect
the result of, e.g., suffix predicates.
Closes #397.
|
|
This could happen, for example, if a menu only has a single suffix and
invoking that suffix causes it to be removed from the menu. That is a
rather contrived use-case, but see #397.
|
|
Emacs commit 60c10b40d5b addresses this issued. That hasn't landed
on master yet (and so the hash is likely to change), so let's copy
the message here:
> Make C-g in command loops consistently invoke quit keybinding
>
> C-g in command loops could unpredictably either signal an error or
> invoke the quit_char keybinding, depending on the relative timing
> of input and redisplay. This change ensures C-g always runs the
> quit_char keybinding by wrapping read_char to check for quit_flag
> after reading input.
For older Emacs versions we have to work around the issue using this
new advice, approximately as suggested by Daniel Colascione at
https://github.com/magit/transient/commit/45fbefdc5b112f0a15cd93657.
The `unreadp' variable is an additional safety net, which should not
be necessary. It would kick in if the unread C-g again causesd quit
to be signaled, or if somehow our transient keymap got disabled,
without this advice also getting disabled.
Also see #388.
|
|
|
|
|
|
|
|
For class constructors and `clone', if a keyword argument is specified
multiple times, the latter instance wins, which in our case was the
outdated one.
As a result, it was impossible to change the level of a suffix if that
was set inline, in the prefix definition.
Fixes [1: bcc0bf83].
1: 2025-05-16 bcc0bf836808e156262d9ff631be7d91a0ec201d
Improve format of layout and handling of included groups
|
|
|
|
We only started this validation in [1: 45de8e46] and the justification
boiled down to "we might as well".
However these functions are being called by `transient--get-layout',
*before* that had a chance to upgrade from the old to the new format,
and here we perform the validation by calling `transient--get-layout',
which together resulted in an infinite loop, and this errors being
repeated many times:
Not a legacy group definition: PREFIX: \
(error "Not a transient prefix command or group definition: PREFIX")
1: 2025-05-16 45de8e46f066eab3160f62cbcc76859022c9c1cc
transient-parse-suffix: Accept object as prefix
|
|
We already call `transient--post-exit', which also takes care of this,
but to be absolutely sure, also reset here and unconditionally (i.e.,
even if `transient--prefix' is nil or `transient--exitp' is `replace').
Before the emergency exit was added, unexpected bugs could look up
Emacs. That does not happen anymore, and we can also rely on it
to guarantee quitting is enabled again.
|
|
|
|
Re #388.
|
|
Like the somewhat similar but much less complex `read-key-sequence',
for example, Transient menus should inhibit quitting, otherwise C-g
might, for example, kill some subprocess, when the user intended to
exit the menu.
Due to how Transient is implemented, there is nothing around which we
could let-bind `inhibit-quit', like that is usually done. Instead we
have to set the global value and make sure we reset that when exiting
the menu.
The resetting has to happen on `post-command-hook' but at that time
a let-binding for `inhibit-quit' is in effect, so we have to use
`set-default-toplevel-value', instead of `setq'.
Closes #388.
|
|
Positional LEVEL is semi-deprecated.
|
|
Command-line switches can be defined inline in a prefix definition
like so:
("-s" "My switch" "--switch")
("-o" "My option" "--option=")
Support something similar for `transient-cons-option':
("c" "My option" :cons option)
("o" :cons other-option)
("r" :cons number-option :reader read-number)
|
|
The existing `transient-option' class is suitable for options passed to
commands. A suffix that uses that class may represent an argument such
as "--option". In the list returned by `transient-args', that argument
and its value, "value", is represented as one element "--option=value".
For "options" that are not passed to a command that is not appropriate.
A caller that wants to extract the value of such an option would have
to parse that string. `transient-arg-value' can help with that, but it
always returns a string (or nil).
The new `transient-cons-option' class provides a more direct way to deal
with "non-command-line options", by representing the key value pair
using a cons-cell (ARGUMENT . VALUE), not just internally, but in
particular when handing it of to a caller. VALUE can have any printable
type and ARGUMENT can have any printable type, expect string.
We cannot use the term "key" because that is already used to the key
binding for the command. Also avoid using "property" because that
implies a property list, while the value returned by `transient-args'
is an alist when all infixes use the `transient-cons-options' class.
Sticking to "argument" also has the advantage, that we don't have to
implement or generalize a dozen methods.
|
|
|
|
|
|
|