Skip to content

Commit

Permalink
[Fix #1947] Inhibit enlighten-mode during repl initialization
Browse files Browse the repository at this point in the history
When initializing the repl, we ask what namespace we are in by evaling code,
eg (eval "(str *ns*)"). However, enlighten mode hijacks eval messages in the
middleware and uses the debugger which causes an error if the debugger is not
yet initialized, ie, in `cider-repl-init`.

So we inhibit this feature. The reason I am doing this let binding rather than
just reordering is that reordering is brittle and doesn't convey that this order
is very important. While its kinda gross that we are dynamically altering this
variable several call stacks up, this is a very special case right at startup
and not complicated logic during the principal use of CIDER.
  • Loading branch information
Dan Sutton authored and bbatsov committed Mar 8, 2017
1 parent 2283d18 commit 27374da
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

### Bugs Fixed

* [#1947](https://github.com/clojure-emacs/cider/issues/1947): Fix error on `cider-jack-in` when `enlighten-mode` is enabled.
* [#1588](https://github.com/clojure-emacs/cider/issues/1588): Redirect `*err*`, `java.lang.System/out`, and `java.lang.System/err` to REPL buffer on all attached sessions.
* [#1707](https://github.com/clojure-emacs/cider/issues/1707): Allow to customize line truncating in CIDER's special buffers.
* [#1876](https://github.com/clojure-emacs/cider/issues/1876): Set pretty-printing width with `cider-repl-pretty-print-width`. If this variable is not set, fall back to `fill-column`.
Expand Down
24 changes: 14 additions & 10 deletions cider.el
Original file line number Diff line number Diff line change
Expand Up @@ -857,16 +857,20 @@ message in the REPL area."
This function is appended to `nrepl-connected-hook' in the client process
buffer."
;; `nrepl-connected-hook' is run in the connection buffer
(cider-make-connection-default (current-buffer))
(cider-repl-init (current-buffer))
(cider--check-required-nrepl-version)
(cider--check-clojure-version-supported)
(cider--check-middleware-compatibility)
(cider--debug-init-connection)
(cider--subscribe-repl-to-server-out)
(when cider-auto-mode
(cider-enable-on-existing-clojure-buffers))
(run-hooks 'cider-connected-hook))

;; `cider-enlighten-mode' changes eval to include the debugger, so we inhibit
;; it here as the debugger isn't necessarily initialized yet
(let ((cider-enlighten-mode nil))
(cider-make-connection-default (current-buffer))
(cider-repl-init (current-buffer))
(cider--check-required-nrepl-version)
(cider--check-clojure-version-supported)
(cider--check-middleware-compatibility)
(cider--debug-init-connection)
(cider--subscribe-repl-to-server-out)
(when cider-auto-mode
(cider-enable-on-existing-clojure-buffers))
(run-hooks 'cider-connected-hook)))

(defun cider--disconnected-handler ()
"Cleanup after nREPL connection has been lost or closed.
Expand Down

0 comments on commit 27374da

Please sign in to comment.