Here's what I use to pull symbols from Enlive into FW/1: (def ^:private enlive-symbols ['append 'at 'clone-for 'content 'do-> 'html-content 'prepend 'remove-class 'set-attr 'substitute])
(defmacro enlive-alias ^:private [sym] `(let [enlive-sym# (resolve (symbol (str "html/" ~sym)))] (intern *ns* (with-meta ~sym (meta enlive-sym#)) (deref enlive-sym#)))) This pulls in both functions and macros. It hard-codes the alias for Enlive (html, for net.cgrand.enlive-html) but otherwise should serve your needs. FW/1 uses it like this: (doseq [sym enlive-symbols] (enlive-alias sym)) Sean On Sun, Jan 6, 2013 at 12:19 PM, the80srobot <a...@ingenious.cz> wrote: > I have come up with a solution to a problem I don't think exists outside of > my mind, but since I can't for the life of me figure out how Clojure 'wants' > me to do this, I thought I would bounce this off the Google Group. > > The scenario: I am trying to collect a bunch of functions and macros from > all the different namespaces in my library into a single namespace; let's > call the namespace adams-lib.api. The idea is that the consumer of the > library will only have to include that one API namespace, and not all of the > little namespaces with parts of the functionality. > > The problem: Obviously, calling (use) doesn't cut it, because the aliased > vars are not immigrated by subsequent calls to the (use) of the namespace > that (used) them. You know what I mean. > > The "solution": For functions this is simpler, but macros pose some > additional challenges, which is why I'm including my "solution" for > immigrating macros. Hold on to your hats, this one is ugly: > > (defmacro immigrate-macro > [ns-sym macro-sym] > `(let [ nspublics# (ns-publics '~ns-sym) > macro-var# (nspublics# '~macro-sym) > macro-fn# @macro-var# > macro-meta# (meta macro-var#)] > (def ~macro-sym macro-fn#) > (. (var ~macro-sym) (setMacro)) > (reset-meta! (var ~macro-sym) macro-meta#)) > nil) > > > And using it: > > (immigrate-macro adams-lib.some-other-ns some-macro) > > > There has got to be a simpler/better/less insane way of doing this. Would > anyone care to weigh in? For the record, I fully realize that my solution is > not OK. > > -Adam > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with your > first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ "Perfection is the enemy of the good." -- Gustave Flaubert, French realist novelist (1821-1880) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en