Skip to content

Commit

Permalink
Auto-require namespace from :repl-options :caught.
Browse files Browse the repository at this point in the history
  • Loading branch information
technomancy committed Jun 5, 2014
1 parent d41fe8d commit 3addf52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion sample.project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@
:init (println "here we are in" *ns*)
;; Print stack traces on exceptions (highly recommended, but
;; currently overwrites *1, *2, etc).
:caught clojure.repl/pst
:caught clj-stacktrace.repl/pst+
;; Skip's the default requires and printed help message.
:skip-default-init false
;; Customize the socket the repl task listens on and
Expand Down
12 changes: 7 additions & 5 deletions src/leiningen/repl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,16 @@
`(clojure.tools.nrepl.server/default-handler
~@(map #(if (symbol? %) (list 'var %) %) nrepl-middleware)))))

(defn- init-requires [{{:keys [nrepl-middleware nrepl-handler]} :repl-options
:as project} & nses]
(defn- init-requires [{{:keys [nrepl-middleware nrepl-handler caught]}
:repl-options :as project} & nses]
(let [defaults '[clojure.tools.nrepl.server complete.core]
nrepl-syms (->> (cons nrepl-handler nrepl-middleware)
(filter symbol?)
(map namespace)
(remove nil?)
(map symbol))]
(for [n (concat defaults nrepl-syms nses)]
(map symbol))
caught (and caught (namespace caught) [(symbol (namespace caught))])]
(for [n (concat defaults nrepl-syms nses caught)]
(list 'quote n))))

(defn- server-forms [project cfg ack-port start-msg?]
Expand All @@ -139,7 +140,8 @@
legacy-repl-port# (if (.exists (io/file ~(:target-path project)))
(io/file ~(:target-path project) "repl-port"))]
(when ~start-msg?
(println "nREPL server started on port" port# "on host" ~(:host cfg) (str "- nrepl://" ~(:host cfg) ":" port#)))
(println "nREPL server started on port" port# "on host" ~(:host cfg)
(str "- nrepl://" ~(:host cfg) ":" port#)))
(spit (doto repl-port-file# .deleteOnExit) port#)
(when legacy-repl-port#
(spit (doto legacy-repl-port# .deleteOnExit) port#))
Expand Down

0 comments on commit 3addf52

Please sign in to comment.