                  (:host options "localhost"))]
     (nrepl/connect :host host :port port)))
 
-(defn adhoc-eval [client form]
+(defn adhoc-eval [client session form]
   (let [results (atom "nil")]
     (execute-with-client
       client
       {:value (partial reset! results)
        :out print
-       :err print}
+       :err print
+       :session session}
       (pr-str form))
     (read-string @results)))
 


(defn execute-with-client [client options form]
  (let [command-id (nrepl.misc/uuid)
        response-seq (nrepl/message client {:op "eval" :code form :id command-id :session @current-session})]
    (reset! current-command-id command-id)
    (doall (for [{:keys [ns value out err] :as res}
                   (take-while #(not (some #{"done" "interrupted" "error"} (:status %)))

          (let [input-result (.readLine *in*)]
            (nrepl/message client
              {:op "stdin" :stdin (str input-result "\n")
               :id (nrepl.misc/uuid) :session session})))
        (when value ((:value options print) value))
        (when out ((:out options print) out))
        (when err ((:err options print) err))
