Skip to content

Commit

Permalink
[Fix #909] Don't rely on eval's response for REPL ns tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
bbatsov committed Jan 11, 2015
1 parent 8f248a8 commit 37667a7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
### Bugs fixed

* [#921](https://github.com/clojure-emacs/cider/issues/921): Fixed
non-functioning `cider-test-jump` from test reports.
non-functioning `cider-test-jump` from test reports.
* [#909](https://github.com/clojure-emacs/cider/issues/909): Fixed
`cider-repl-set-ns`'s behavior for ClojureScript.

## 0.8.2 / 2014-12-21

Expand Down
20 changes: 15 additions & 5 deletions cider-repl.el
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,17 @@ text property `cider-old-input'."
(insert
(propertize ";;; output cleared" 'font-lock-face 'font-lock-comment-face)))))))

(defun cider-repl-switch-ns-handler (buffer)
"Make a nREPL evaluation handler for the REPL BUFFER's 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 @@ -690,11 +701,10 @@ namespace to switch to."
(completing-read "Switch to namespace: "
(cider-sync-request:ns-list))
(cider-current-ns))))
(if ns
(with-current-buffer (cider-current-repl-buffer)
(setq cider-buffer-ns ns)
(cider-repl-emit-prompt (current-buffer)))
(error "Cannot determine the current namespace")))
(if (and ns (not (equal ns "")))
(cider-eval (format "(in-ns '%s)" ns)
(cider-repl-switch-ns-handler (cider-current-repl-buffer)))
(error "No namespace selected")))


;;;;; History
Expand Down

0 comments on commit 37667a7

Please sign in to comment.