Skip to content

Instantly share code, notes, and snippets.

@devth
Created November 30, 2011 05:48
Show Gist options
  • Save devth/1408201 to your computer and use it in GitHub Desktop.
Save devth/1408201 to your computer and use it in GitHub Desktop.
(defmacro cmd-hook [prefix & exprs]
`(rh/add-hook
#'core/handle-command
(fn [~'callback ~'cmd ~'args]
(if (re-find ~prefix (s/lower-case ~'cmd))
(cond-let [~'p]
~@(map (fn [i#]
(if (instance? java.util.regex.Pattern i#)
`(re-find ~i# ~'args)
`~i#))
exprs)
`:else (~'callback ~'cmd ~'args))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment