Skip to content

Commit

Permalink
Simplify cider-repl-set-ns
Browse files Browse the repository at this point in the history
There's no need to actually do an eval to change the namespace of the REPL -
we only have to change it's nrepl-buffer-ns, as it's attached to all eval
requests made from the REPL buffer.
  • Loading branch information
bbatsov committed Aug 29, 2014
1 parent 4dd1526 commit aeb125e
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions cider-repl.el
Original file line number Diff line number Diff line change
Expand Up @@ -659,17 +659,6 @@ text property `cider-old-input'."
(cider-eval-and-get-value
"(clojure.core/map clojure.core/str (clojure.core/all-ns))"))

(defun cider-repl-switch-ns-handler (buffer)
"Make a nREPL evaluation handler for the REPL ns switching."
(nrepl-make-response-handler buffer
(lambda (buffer value))
(lambda (buffer out)
(cider-repl-emit-output buffer out))
(lambda (buffer err)
(cider-repl-emit-err-output buffer err))
(lambda (buffer)
(cider-repl-emit-prompt buffer))))

(defun cider-repl-set-ns (ns)
"Switch the namespace of the REPL buffer to NS.
Expand All @@ -681,9 +670,8 @@ namespace to switch to."
(cider-current-ns))))
(if ns
(with-current-buffer (cider-current-repl-buffer)
(cider-eval
(format "(in-ns '%s)" ns)
(cider-repl-switch-ns-handler (current-buffer))))
(setq nrepl-buffer-ns ns)
(cider-repl-emit-prompt (current-buffer)))
(error "Cannot determine the current namespace")))


Expand Down

0 comments on commit aeb125e

Please sign in to comment.