diff options
| author | Jonas Bernoulli <jonas@bernoul.li> | 2025-08-16 14:07:21 +0200 |
|---|---|---|
| committer | Jonas Bernoulli <jonas@bernoul.li> | 2025-08-16 14:07:21 +0200 |
| commit | 6322fc7445799a30fdf36a1e3705a1673080869b (patch) | |
| tree | 77509496d7468473d7aa501979ebdc0679397447 | |
| parent | b4edb633488fc251df0883b69b1eb350cb2e94ec (diff) | |
Incrementally populate transient--suffixes
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.
| -rw-r--r-- | lisp/transient.el | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lisp/transient.el b/lisp/transient.el index 51dd29f..168bcff 100644 --- a/lisp/transient.el +++ b/lisp/transient.el @@ -2456,9 +2456,13 @@ value. Otherwise return CHILDREN as is.") (setq transient--prefix (transient--init-prefix name params)) (setq name (oref transient--prefix command))) (setq transient--refreshp (oref transient--prefix refresh-suffixes)) - (setq transient--layout (or (and (not transient--refreshp) layout) - (transient--init-suffixes name))) - (setq transient--suffixes (transient--flatten-suffixes transient--layout))) + (cond ((and (not transient--refreshp) layout) + (setq transient--layout layout) + (setq transient--suffixes (transient--flatten-suffixes layout))) + (t + (setq transient--suffixes nil) + (setq transient--layout (transient--init-suffixes name)) + (setq transient--suffixes (nreverse transient--suffixes))))) (defun transient--init-prefix (name &optional params) (let ((obj (let ((proto (get name 'transient--prefix))) @@ -2553,6 +2557,8 @@ value. Otherwise return CHILDREN as is.") (oset obj inapt t) (transient-init-scope obj) (transient-init-value obj)) + (unless (cl-typep def 'transient-information) + (push obj transient--suffixes)) (list obj)))))) (cl-defmethod transient--init-suffix-key ((obj transient-suffix)) |
