Skip to content

Instantly share code, notes, and snippets.

@Raynes
Created April 28, 2010 08:21
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 Raynes/381865 to your computer and use it in GitHub Desktop.
Save Raynes/381865 to your computer and use it in GitHub Desktop.
(defmacro defcommand [docs words cmdkey & method-stuff]
`(do (dosync (doseq [word# ~words] (assoc ~'cmd-list word# {:cmd ~cmdkey :doc ~docs})))
(defmethod respond ~cmdkey ~@method-stuff)))
(defmacro defplugin [& body]
`(do
(let [~'cmd-list (ref {})]
'~@body
(dosync
(let [m-name# (keyword (last (.split (str *ns*) "\\.")))]
(alter modules merge
{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