0

I'm trying to add a very simple transient thus:

(transient-define-prefix simple-transient ()
       "A simple transient"
       ["Arguments"
        ("-a" "Address (default 127.0.0.1)" "--addresss=")
        ("-p" "Port (default 554)" "--port=")
        ("-v" "Use verbose logging" "--verbose")
       ["Actions"
        ("r" "Run" run-command)])

All I want to do is have say "verbose" on by default, or set port to something else, but I can't fathom the docs - is there a simple way of doing this?

0

1 Answer 1

0

I have since found a way to do this, by using:

:value '("--verbose" "--port="1234")

Which is hopefully the recommended way of doing things.

In case it helps anyone else, this is the first time I'd tried to use transient and found the documentation fairly heavy going. I just wanted to launch a command via transient and have some default values plugged in. So here's what I did.

First, create the command to launch the process:

(defun run-command (&optional args)
  (interactive
   (list (transient-args 'simple-transient)))
  (let ((input-file (read-file-name "Run with input: " "C:/Path/Somewhere" nil t)))
    (apply #'start-process "command" "*command*" "command" (cons input-file args))))

Then define the transient:

(transient-define-prefix simple-transient ()
       "A simple transient"
       :value '("--verbose") ; default to verbose on
       ["Arguments"
        ("-a" "Address (default 127.0.0.1)" "--addresss=")
        ("-p" "Port (default 554)" "--port=")
        ("-v" "Use verbose logging" "--verbose")
       ["Actions"
        ("r" "Run" run-command)])

And finally, you can then bind this to a key:

(global-set-key [f8] 'simple-transient)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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