-
-
Save cgrand/381898 to your computer and use it in GitHub Desktop.
This file contains 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
;; 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