Permalink
Browse files

Attempt to keep REPL namespace even if it gets reloaded

  • Loading branch information...
1 parent 8a359a4 commit 7ff4f9658c5579e7d3539134ec92a9726f620c37 @stuartsierra stuartsierra committed Aug 3, 2012
Showing with 8 additions and 6 deletions.
  1. +8 −6 src/main/clojure/clojure/tools/namespace/repl.clj
@@ -25,6 +25,12 @@
e)
:ok))
+(defn- do-refresh [f]
+ (let [current-ns (ns-name *ns*)]
+ (alter-var-root #'refresh-tracker f)
+ (print-and-return refresh-tracker)
+ (in-ns current-ns)))
+
(defn refresh
"Scans source code directories for files which have changed (since
the last time this function was run) and reloads them in dependency
@@ -34,9 +40,7 @@
The directories to be scanned are controlled by 'set-refresh-dirs';
defaults to all directories on the Java classpath."
[]
- (alter-var-root #'refresh-tracker
- #(-> % dir/scan reload/track-reload))
- (print-and-return refresh-tracker))
+ (do-refresh #(-> % dir/scan reload/track-reload)))
(defn refresh-all
"Scans source code directories for all Clojure source files and
@@ -45,9 +49,7 @@
The directories to be scanned are controlled by 'set-refresh-dirs';
defaults to all directories on the Java classpath."
[]
- (alter-var-root #'refresh-tracker
- #(-> % dir/scan-all reload/track-reload))
- (print-and-return refresh-tracker))
+ (do-refresh #(-> % dir/scan-all reload/track-reload)))
(defn set-refresh-dirs
"Sets the directories which are scanned by 'refresh'. Supports the

0 comments on commit 7ff4f96

Please sign in to comment.