I am converting some of my Hydras to Transient. One of them includes a command with shrinks or enlarges one of my split windows, so I hit it repeatedly until I like my size. How to do this in Transient? The documentation makes it clear that it's possible, but I can't find a place where it explains how. It appears to be related to the :transient-suffix 'transient--do-stay, but I can't figure out where to place this to make some of my commands repeatable. Further, it would be nice to set this per-command or per-group, not just on the whole transient. Here is what I'm working with:

(transient-define-prefix tsa/transient-window ()
  ;; the following :transient-suffix causes the whole thing to fail at command invocation:
  ;;; command-execute: Wrong type argument: commandp, tsa/transient-window
  ;;     :transient-suffix 'transient--do-stay
  "Window navigation transient"
    ("q" "X←" tsa/move-splitter-left)    
    ("w" "X↓" tsa/move-splitter-down)    
    ("e" "X↑" tsa/move-splitter-up)    
    ("r" "X→" tsa/move-splitter-right)]])
  • 1
    Your example seems to work for me, though you need :transient-suffix after the doc string and not before.
    – glucas
    Apr 27 at 18:14
  • Ah! yes, silly me. That does it! But it doesn't seem to work for select groups/columns of a transient, such as "only the Resize group". Is that possible? Apr 28 at 11:36

transient provide a transient-variable abstract class. Inspired by magit magit--git-variable which store variables in git config file, I tried to use global elisp variable.

(setq-default my-variable "default")

(defclass my-transient-variable (transient-variable) ())

(cl-defmethod transient-init-value ((obj my-transient-variable))
  (oset obj value (symbol-value (oref obj variable))))

(cl-defmethod transient-format-value ((obj my-transient-variable))
  (let ((v (oref obj value)))
    (if v
        (propertize v 'face 'transient-value)
      (propertize "unset" 'face 'transient-inactive-value))))

(cl-defmethod transient-infix-set ((obj my-transient-variable) user-value)
  (oset obj value user-value)
  (set (oref obj variable) user-value))

(transient-define-argument my-option-argument ()
  :description "My Option"
  :class 'my-transient-variable
  :key "d"
  :variable 'my-variable
  :prompt "My option: "

(transient-define-prefix my-command-transiant ()
   ("c" "run"     my-command-run)
   ("q" "Quit"    transient-quit-one)])

(defun my-command-run (&optional args)
  (interactive (transient-args 'my-command-transiant))
  (message (format "My option value: %s" my-variable)))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.