Permalink
Browse files

Pull ns-switching outside the let

def doesn't work as I expected inside a let or binding, regardless of
any ns/in-ns incantations I threw at it.
  • Loading branch information...
1 parent b75f5f1 commit c1398817e6861712f6824bb1cd55e78ee21524f6 @trptcolin committed Feb 10, 2013
Showing with 54 additions and 50 deletions.
  1. +54 −50 src/clj/reply/initialization.clj
View
104 src/clj/reply/initialization.clj
@@ -94,56 +94,60 @@
"Assumes cd-client will be on the classpath when this is evaluated."
[]
`(do
- (println "REPL-y" ~(version/get-version "reply" "reply"))
- (println "Clojure" (clojure-version))
-
- (use '[clojure.repl :only ~'[source apropos dir]])
- ; doc and find-doc live in clojure.core in 1.2
- (when (ns-resolve '~'clojure.repl '~'pst)
- (refer 'clojure.repl :only '~'[pst doc find-doc]))
-
- (use '[clojure.java.javadoc :only ~'[javadoc]])
- (use '[clojure.pprint :only ~'[pp pprint]])
-
- (let [original-ns# ~'*ns*]
- (ns reply.exports)
- ~(export-definition 'reply.initialization/intern-with-meta)
-
- (binding [*err* (java.io.StringWriter.)]
- ~(export-definition 'reply.initialization/repl-defn)
- (~'intern-with-meta '~'user '~'defn ~'#'repl-defn))
-
- ~(export-definition 'reply.initialization/help)
- (~'intern-with-meta '~'user '~'help ~'#'help)
-
- ~(export-definition 'reply.initialization/sourcery)
- (~'intern-with-meta '~'user '~'sourcery ~'#'sourcery)
-
- ~(export-definition 'reply.initialization/clojuredocs-available?)
- ~(export-definition 'reply.initialization/call-with-ns-and-name)
- ~(export-definition 'reply.initialization/handle-fns-etc)
- ~(export-definition 'reply.initialization/lazy-clojuredocs)
- (~'intern-with-meta '~'user '~'clojuredocs ~'#'lazy-clojuredocs)
- (~'intern-with-meta '~'user '~'cdoc ~'#'lazy-clojuredocs)
-
- (try
- (require '[complete.core])
- ; hack for 1.2 support until we release the next clojure-complete version
- ~(export-definition 'reply.initialization/resolve-class)
- (~'intern-with-meta '~'complete.core '~'resolve-class ~'#'resolve-class)
-
- (catch Exception e#
- (try
- (eval '~(formify-file
- (ClassLoader/getSystemResource "complete/core.clj")))
- (catch Exception f#
- (intern (create-ns '~'complete.core) '~'completions
- (fn [prefix# ns#] []))
- (println "Unable to initialize completions.")))))
-
- (in-ns (ns-name original-ns#)))
- (~'user/help)
- nil))
+ (println "REPL-y" ~(version/get-version "reply" "reply"))
+ (println "Clojure" (clojure-version))
+
+ (use '[clojure.repl :only ~'[source apropos dir]])
+ ; doc and find-doc live in clojure.core in 1.2
+ (when (ns-resolve '~'clojure.repl '~'pst)
+ (refer 'clojure.repl :only '~'[pst doc find-doc]))
+
+ (use '[clojure.java.javadoc :only ~'[javadoc]])
+ (use '[clojure.pprint :only ~'[pp pprint]])
+
+ (create-ns 'reply.exports)
+ (~'intern '~'reply.exports '~'original-ns ~'*ns*)
+ (in-ns '~'reply.exports)
+ (clojure.core/refer '~'clojure.core)
+
+ ~(export-definition 'reply.initialization/intern-with-meta)
+
+ (binding [*err* (java.io.StringWriter.)]
+ ~(export-definition 'reply.initialization/repl-defn)
+ (~'intern-with-meta '~'user '~'defn ~'#'repl-defn))
+
+ ~(export-definition 'reply.initialization/help)
+ (~'intern-with-meta '~'user '~'help ~'#'help)
+
+ ~(export-definition 'reply.initialization/sourcery)
+ (~'intern-with-meta '~'user '~'sourcery ~'#'sourcery)
+
+ ~(export-definition 'reply.initialization/clojuredocs-available?)
+ ~(export-definition 'reply.initialization/call-with-ns-and-name)
+ ~(export-definition 'reply.initialization/handle-fns-etc)
+ ~(export-definition 'reply.initialization/lazy-clojuredocs)
+ (~'intern-with-meta '~'user '~'clojuredocs ~'#'lazy-clojuredocs)
+ (~'intern-with-meta '~'user '~'cdoc ~'#'lazy-clojuredocs)
+
+ (try
+ (require '[complete.core])
+ ; hack for 1.2 support until we release the next clojure-complete version
+ ~(export-definition 'reply.initialization/resolve-class)
+ (~'intern-with-meta '~'complete.core '~'resolve-class ~'#'resolve-class)
+
+ (catch Exception e#
+ (try
+ (eval '~(formify-file
+ (ClassLoader/getSystemResource "complete/core.clj")))
+ (catch Exception f#
+ (intern (create-ns '~'complete.core) '~'completions
+ (fn [prefix# ns#] []))
+ (println "Unable to initialize completions.")))))
+
+ (in-ns (ns-name ~'original-ns))
+
+ (~'user/help)
+ nil))
(defn eval-in-user-ns [code]
(let [original-ns (symbol (str *ns*))]

0 comments on commit c139881

Please sign in to comment.