Trouble defining a macro in Common Lisp/StumpWM

65 views Asked by At

I am trying to define a macro that creates commands. So far I have the following:

    (defmacro create-command (command name)
      `(defcommand ,name ()
       (run-shell-command ,command)
        ))

    (create-command "firefox" firefox)

Basically, I want to create a command that called "firefox", that simply launches "firefox". When I try to run the command I get the following error:

Bad Argument Type: RUN-SHELL-COMMAND.

Any idea on what is happening? Thank you!

1

There are 1 answers

1
coredump On BEST ANSWER

defcommand has two argument lists, not once; the second list defines how arguents in the first list are read interactively. In your case there is no arguments, but you missed one empty list:

(defmacro create-command (command name)
  `(defcommand ,name () ()
      (run-shell-command ,command)))


STUMPWM-USER> (create-command "firefox" firefox)
#S(STUMPWM::COMMAND :NAME FIREFOX :CLASS T :ARGS NIL)