-
-
Save noisesmith/3448f0494a81bbb0adebb66b57f5e9e0 to your computer and use it in GitHub Desktop.
use all non-macros from target ns in local scope
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
phoenix.core=> (user/with-use user (+ 1 1)) | |
2 | |
phoenix.core=> (macroexpand-1 '(user/with-use user (+ 1 1))) | |
(clojure.core/let [help user/help find-name user/find-name non-macros user/non-macros src-dir user/src-dir exercise-coverage user/exercise-coverage apropos-better user/apropos-better] (+ 1 1)) |
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
(defn non-macros | |
[target-ns] | |
(map key | |
(remove #(:macro (meta (val %))) | |
(ns-publics target-ns)))) | |
(defmacro with-use | |
[target-ns & body] | |
`(let ~(into [] | |
(mapcat (juxt identity (fn [s] (symbol (name target-ns) (name s)))) | |
(non-macros target-ns))) | |
~@body)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment