Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Extract a fn

  • Loading branch information...
commit b56d7285e14878de7c75aa603b6f0f83ace93f88 1 parent 9299338
@trptcolin authored
Showing with 14 additions and 13 deletions.
  1. +14 −13 src/clj/reply/eval_modes/nrepl.clj
View
27 src/clj/reply/eval_modes/nrepl.clj
@@ -66,11 +66,11 @@
(let [concatted-text (if text-so-far
(str text-so-far \newline next-text)
next-text)
- parse-tree (sjacket.parser/parser concatted-text)
- completed? #(not= :net.cgrand.parsley/unfinished (:tag %))]
+ parse-tree (sjacket.parser/parser concatted-text)]
(if (empty? (:content parse-tree))
(list "")
- (let [complete-forms (take-while completed? (:content parse-tree))
+ (let [completed? #(not= :net.cgrand.parsley/unfinished (:tag %))
+ complete-forms (take-while completed? (:content parse-tree))
remainder (drop-while completed? (:content parse-tree))
form-strings (map sjacket/str-pt
(remove #(contains? #{:whitespace :comment :discard}
@@ -137,6 +137,15 @@
(pr-str `(binding [*ns* (symbol ~(deref current-ns))] ~form)))
(read-string @results)))
+(defn poll-for-responses [connection]
+ (when-let [{:keys [out err] :as resp} (nrepl.transport/recv connection 100)]
+ (when err (print err))
+ (when out (print out))
+ (when-not (or err out)
+ (.offer (@response-queues (:session resp)) resp))
+ (flush))
+ (recur connection))
+
(defn main
"Mostly ripped from nREPL's cmdline namespace."
[options]
@@ -155,16 +164,8 @@
options (if (:color options)
(merge options nrepl.cmdline/colored-output)
options)]
- (.start (Thread.
- (fn []
- (when-let [{:keys [out err] :as resp}
- (nrepl.transport/recv connection 100)]
- (when err (print err))
- (when out (print out))
- (when-not (or err out)
- (.offer (@response-queues (:session resp)) resp))
- (flush))
- (recur))))
+
+ (.start (Thread. (partial poll-for-responses connection)))
(execute-with-client
client
(assoc options :value (constantly nil))
Please sign in to comment.
Something went wrong with that request. Please try again.