I've just come across dizzee, an Emacs package for managing subprocesses; it lets you create functions that stop, start or restart shell commands. For example:
(dz-defservice foo "script.sh" :cd ("/path/to/foo"))
This macro, dz-defservice
, will create the functions foo-start
, foo-stop
and foo-restart
that will run/kill "somecommand.sh" in the directory
"/path/to/foo", and collect its output in a buffer.
This is perfect for a project I'm working on, where I want to run a bunch of commands in separate directories all at once. The commands all have the same name, but do different things depending on the directory they're in.
One way of doing this would be to write separate entries for each service like so:
(dz-defservice foo "script.sh" :cd ("/path/to/foo"))
(dz-defservice bar "script.sh" :cd ("/path/to/bar"))
(dz-defservice baz "script.sh" :cd ("/path/to/baz"))
But of course, this seems perfect for a list (particularly as I'll be
adding more components in the future). So what I want to do is have a
list be input to dz-defservice
, which in turn seems like it's perfect for dolist
:
(setq my--project-components '(foo bar baz))
(dolist (i my--project-components)
(dz-defservice i "shell.sh" :cd (format "/path/to/%s" i)))
That was my first attempt; it only ended up redefining the functions
i-start
, i-stop
and i-restart
over and over again. Next I tried using
quotes in dolist
, since it's a macro too:
(dolist (i my--project-components)
`(dz-defservice ,i "shell.sh" :cd (format "/root/%s/" element)))
but that gives me this error:
Compiler-macro error for cl--block-wrapper: (wrong-type-argument symbolp (\, i))
I'm obviously misunderstanding something here, so can anyone tell me how to use a list to create these different service entries?