-
With ![]() The technique I've been using for this, which works both before and after "export" of (defmacro with-transient-args (func)
"Call FUNC with transient args."
(let ((argsvar (make-symbol "arg")))
`(let ((,argsvar
(or (and transient-current-command (transient-args transient-current-command))
;; not yet exported, simulate
(let* ((transient-current-command (oref transient--prefix command))
(transient-current-suffixes transient--suffixes))
(transient-args transient-current-command)))))
(funcall #',func ,argsvar)))) I do not like the use of the internal I'm not sure why but I conjecture that the suffixes are being re-built from scratch, which calls a suffix's Is there a simpler/better/more future-proof way to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
I would like to see the branch where you use that macro. Also please create a prefix whose sole purpose is to demonstrate the issue at hand. Update: Is that what you are looking for?: (transient-define-prefix demo ()
:refresh-suffixes t
[:description
(lambda () (format "Active arguments: %S" (transient-get-value)))
("-a" "a" "-a")
("-b" "b" "-b")
(transient-echo-arguments)]) |
Beta Was this translation helpful? Give feedback.
-
Update: I just tried (defun my/one-val ()
(let ((args (transient-get-value)))
(when-let ((val (transient-arg-value "--oneval=" args)))
(string-to-number val)))) But honestly I'm not sure I understand it. Is it returning the same thing ++++ You can see GPTEL's recent commit which incorporated this technique here. Here's a highly contrived example, using the value of one infix to live-update various descriptions, an
|
Beta Was this translation helpful? Give feedback.
-
OK, thanks for the explanation. I have read the code but the confusion among prefix/prefix command/infix/suffix makes it hard for me to reason about. We've talked about that over the years.
For a single prefix, I claim it is more powerful than [1] Which I think you call suffix values... confusing because "proper" suffixes, the kind that exit the prefix, have no value... |
Beta Was this translation helpful? Give feedback.
As the docstring mentions, it does not include the values of "unsavable" suffixes. That's because it was original intended to be used when saving values. If and once someone needs those unsavable values too, then I can add an argument to not strip those.
When a prefix created, the individual values of its suffixes are set based on its value. This is the only time the "live" value of the prefix is sure to be up-to-date. When the user changes the value of a suffix, this does not change the value of the prefix. When a suffix reques…