Created
April 28, 2010 08:26
-
-
Save Raynes/381870 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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] | |
`(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