Replies: 3 comments 3 replies
-
The code you are quoting was an experiment by someone else. I am not sure to what extend it was expected to work back then. If some part of it doesn't work now, it probably also didn't work then. It would be easier for me to help, if you described what you are trying to achieve. Depending on what you want to do, maybe this is all you need: (transient-define-prefix demo ()
[("-a" "Arg" "--arg")
("-b" "Bar" "--bar")
("s" "Submenu" demo-sub)
(transient-echo-arguments)])
(transient-define-prefix demo-sub ()
[("-a" "Arg" "--arg")
("-b" "Bar" "--bar")
(transient-echo-arguments)]
(interactive)
(transient-setup 'demo-sub nil nil :value (transient-args 'demo))) Note that once you have called Here we deal with that by calling |
Beta Was this translation helpful? Give feedback.
-
We can (ab?)use the "scope" of the sub-prefix to inherit the value of the parent prefix. The scope is a kind of "secondary value" used by, e.g., (transient-define-prefix demo ()
[("-a" "Arg" "--arg")
("-b" "Bar" "--bar")
("s" "Submenu" demo-sub)
(transient-echo-arguments)])
(transient-define-prefix demo-sub ()
[("-l" "local arg" "--local")
("a" "target a" demo-suffix)]
(interactive)
(transient-setup 'demo-sub nil nil :scope (transient-args 'demo)))
(defun demo-args ()
(append (transient-args 'demo-sub)
(and transient-current-prefix
(transient-scope))))
(defun demo-suffix (args)
(interactive (list (demo-args)))
(message "arguments: %S" args)) I'll probably soon make (defun demo-args ()
(append (transient-args 'demo-sub)
(transient-scope 'demo-sub))) |
Beta Was this translation helpful? Give feedback.
-
Some further experiments on the (transient-define-prefix demo ()
[("-a" "Arg" "--arg")
("-b" "Bar" "--bar")
("s" "Submenu" demo-sub)
(transient-echo-arguments)])
(defclass demo-sub-prefix (transient-prefix) ())
(cl-defmethod transient-init-scope ((obj demo-sub-prefix))
(oset obj scope (transient-args 'demo)))
(cl-defmethod transient-prefix-value ((obj demo-sub-prefix))
(append (cl-call-next-method)
(transient-scope 'demo-sub)))
(transient-define-prefix demo-sub ()
:class 'demo-sub-prefix
[("-l" "local arg" "--local")
("a" "target a" demo-suffix)
;; Note how that now echos *all* enabled arguments too.
("b" "target b" transient-echo-arguments)]
;; Note how we no longer need a body; the default will do.
)
(defun demo-suffix (args)
;; Note how we can just use `transient-args' as usual.
(interactive (list (transient-args 'demo-sub)))
(message "arguments: %S" args)) Note that the arguments of |
Beta Was this translation helpful? Give feedback.
-
I'm currently working with transient version 0.7.7 (fc03c0b) and looking to access the infix values from a parent prefix within a sub-prefix without saving the parent prefix first. I've read this relevant issue, but it seems the behavior discussed there has changed.
Here’s a revised example based on the original post:
When pressing
a
within the sub-prefix, I expectedtransient-toys--msg-parent-args
to print the infix values set in the parent prefix when the switch option is enabled, which happened according to the original post. However, it doesn’t print the expected values when I tried it. After some investigation, I noticed in the documentation fortransient-args
that it mentions the following:This leads me to believe that the observed behavior may be expected due to the change in how transient-args works since the original post.
I then modified
transient-toys--msg-parent-args
to usetransient-current-command
instead of'transient-toys-wave-parent
directly and added some debug messages:In this case, since
transient-toys--msg-parent-args
is invoked withtransient--do-stay
, I expectedtransient--export
not executed, sotransient-current-command
would still be the parent. However, it appears that callingtransient-toys--msg-parent-args
resetstransient-current-command
tonil
in the sub-prefix rather than preserving the initial command context.Questions:
transient-args
?transient-args
doesn't seem to work. Is there an approach to pass infix values from a parent prefix to a sub-prefix, allowing access to them in the sub-prefix without saving the parent prefix?Thank you for any insights or clarifications regarding this behavior!
Beta Was this translation helpful? Give feedback.
All reactions