   (message "Hi, " x " from Arcadia!")
   )
 
+(defn do-thing [] (message "do-thing"))
+(make-delegate [] [] do-thing)
+(register-command "do-thing-cmd" [] [] 'do-thing {})
+(register-command "say-hello2-cmd" [String] '[name] 'say-hello2 {:signature "(defn say-hello2 (^String name) ...)"
+                  :parameter-names ["name"]})
 (defcmd say-hello3
   "Say hello to x. Return a number."
   [] ;; works

       (map #(remove #{'&} %))
       (map count)))

(defmacro defcmd
    "Define a Minibuffer command and function. The docstring is required.
  The typeargs define what C# types the function accepts and optionally what it

  prompt for a string. Functions with a String output will be `message`'d
  automatically. Functions with a IEnumerator output will be run as coroutines."
  [fn-name docstring typeargs args & body]
  `(do (defn ~fn-name
         ~docstring
         ~args ;; add type annotation?
         ~@body)
       (with-minibuffer ~'m
                        (.RegisterCommand ~'m (doto (Command. ~(name fn-name))
                                                    (.set_description ~docstring))
                                          (make-delegate ~typeargs ~args ~fn-name)))
     #'~fn-name))

(defn register-command
  [cmd-name typeargs args f attrs]
  (with-minibuffer m
                   (.RegisterCommand m
                                     (doto (Command. cmd-name)
                                           (.set_description (:description attrs nil))
                                           (.set_keySequence (:keysequence attrs nil))
                                           (.set_signature   (:signature attrs nil))
                                           (.set_parameterNames
                                            (if (:parameter-names attrs nil)
                                                (into-array String (into ["closure"] (:parameter-names attrs nil)))
                                              nil)))
                                     (eval `(make-delegate ~typeargs ~args ~f)))))


(defn message
  "Print a message to the echo area."
