Skip to content

Commit

Permalink
Attempt to keep REPL namespace even if it gets reloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuart Sierra committed Aug 3, 2012
1 parent 8a359a4 commit 7ff4f96
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main/clojure/clojure/tools/namespace/repl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 7ff4f96

Please sign in to comment.