From aeb125e78d9053b42696e9ec00bdebaf60b2221b Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Fri, 29 Aug 2014 21:42:37 +0300 Subject: [PATCH] Simplify cider-repl-set-ns 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. --- cider-repl.el | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/cider-repl.el b/cider-repl.el index 286c56181..1c4cedacb 100644 --- a/cider-repl.el +++ b/cider-repl.el @@ -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. @@ -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")))