Skip to content

Instantly share code, notes, and snippets.

@cgrand
Forked from Raynes/respond.clj
Created April 28, 2010 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cgrand/381898 to your computer and use it in GitHub Desktop.
Save cgrand/381898 to your computer and use it in GitHub Desktop.
;; something like that should be closer to what you want
(defmacro defplugin [& body]
(let [cmd-list (into {} (for [[docs words cmdkey] body word words] [word {:cmd cmdkey :doc docs}]))]
`(do
~@(for [[docs words cmdkey & method-stuff] body]
`(defmethod respond ~cmdkey ~@method-stuff))
(dosync
(let [m-name# (keyword (last (.split (str *ns*) "\\.")))]
(alter modules assoc m-name#
{:load #(dosync (alter commands assoc m-name# ~cmd-list))
:unload #(dosync (alter commands dissoc m-name#))}))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment