How can I pass a list of parameters to start-process
's 4th argument (PROGRAMS-ARGS)
:
(start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS)
for example:
(start-process "program-name" nil "program-name" "-p1" "-p2" "-p3" "program-name")
I want to do the same thing by collecting parameters in a list and passing the list variable to functions argument, but it doesn't work:
(setq program-args (list "-p1" "-p2" "-p3"))
(start-process "program-name" nil "program-name" program-args "program-name")
You should use apply
in this case:
apply calls function with arguments, just like funcall but with one difference: the last of arguments is a list of objects, which are passed to function as separate arguments, rather than a single list.
I.e., in your case the correct code is:
(apply 'start-process
(append (list "program-name" nil "program-name")
program-args
(list "program-name")))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With