Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Call url-connect instead of just connect.

Accept URLs on --attach rather than just host/port.
  • Loading branch information...
commit 7181ec832fe4ba8ea2ed524d7d877c11b88312f9 1 parent dd2080a
@technomancy authored
Showing with 14 additions and 13 deletions.
  1. +14 −13 src/clj/reply/eval_modes/nrepl.clj
27 src/clj/reply/eval_modes/nrepl.clj
@@ -66,19 +66,20 @@
(binding [*print-meta* true]
(pr-str read-result))))))))))
-(defn get-connection [options]
- (let [attach (:attach options)
- [attach-port attach-host] (and attach
- (reverse (.split attach ":")))
- port (if attach-port
- (Integer/parseInt attach-port)
- (-> (nrepl.server/start-server :port (Integer/parseInt (or (:port options) "0")))
- deref
- :ss
- .getLocalPort))
- host (or attach-host
- (:host options "localhost"))]
- (nrepl/connect :host host :port port)))
+;; TODO: this could be less convoluted if we could break backwards-compat
+(defn- url-for [attach host port]
+ (if (and attach (re-find #"^\w+://" attach))
+ attach
+ (let [[port host] (if attach
+ (reverse (.split attach ":"))
+ [port host])]
+ (format "nrepl://%s:%s" (or host "localhost") port))))
+(defn get-connection [{:keys [attach host port]}]
+ (let [port (if-not attach
+ (-> (nrepl.server/start-server :port (Integer. (or port 0)))
+ deref :ss .getLocalPort))]
+ (nrepl/url-connect (url-for attach host port))))
(defn adhoc-eval [client session form]
(let [results (atom "nil")]
Please sign in to comment.
Something went wrong with that request. Please try again.