Skip to content

Commit f6dda2d

Browse files
plexusbbatsov
authored andcommitted
Don't call fundamental-mode if we already are in fundamental-mode
If the `" *nrepl-decoding*"` buffer already exists then it is likely already in the right mode. Not re-initializing the mode means we don't re-trigger hooks, which in this case in particular prevents an unfortunate interaction with evil-mode, where the cursor color gets updated even though it shouldn't. Fixes #3068
1 parent 2b8bde3 commit f6dda2d

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* [#3044](https://github.com/clojure-emacs/cider/pull/3044): Dynamically upgrade nREPL connection
2222
* [#3047](https://github.com/clojure-emacs/cider/pull/3047): Fix info/lookup fallback: response has an extra level
2323
* [#2746](https://github.com/clojure-emacs/cider/issues/2746): Handle gracefully Clojure versions with non-standard qualifiers (e.g. `1.11.0-master-SNAPSHOT`).
24+
* [#3069](https://github.com/clojure-emacs/cider/pull/3069): Fix cursor color changing when it shouldn't in evil-mode
2425

2526
## 1.1.1 (2021-05-24)
2627

nrepl-client.el

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,11 @@ STACK is as in `nrepl--bdecode-1'. Return a cons (INFO . STACK)."
362362
stack (cdr istack)))
363363
istack))
364364

365+
(defun nrepl--ensure-fundamental-mode ()
366+
"Enable `fundamental-mode' if it is not enabled already."
367+
(when (not (eq 'fundamental-mode major-mode))
368+
(fundamental-mode)))
369+
365370
(defun nrepl-bdecode (string-q &optional response-q)
366371
"Decode STRING-Q and place the results into RESPONSE-Q.
367372
STRING-Q is either a queue of strings or a string. RESPONSE-Q is a queue of
@@ -374,7 +379,10 @@ decoded. RESPONSE-Q is the original queue with successfully decoded messages
374379
enqueued and with slot STUB containing a nested stack of an incompletely
375380
decoded message or nil if the strings were completely decoded."
376381
(with-current-buffer (get-buffer-create " *nrepl-decoding*")
377-
(fundamental-mode)
382+
;; Don't needlessly call `fundamental-mode', to prevent needlessly firing
383+
;; hooks. This fixes an issue with evil-mode where the cursor loses its
384+
;; correct color.
385+
(nrepl--ensure-fundamental-mode)
378386
(erase-buffer)
379387
(if (queue-p string-q)
380388
(while (queue-head string-q)
@@ -1352,7 +1360,7 @@ The default buffer name is *nrepl-error*."
13521360
(let ((buffer (get-buffer-create nrepl-error-buffer-name)))
13531361
(with-current-buffer buffer
13541362
(buffer-disable-undo)
1355-
(fundamental-mode)
1363+
(nrepl--ensure-fundamental-mode)
13561364
buffer))))
13571365

13581366
(defun nrepl-log-error (msg)

0 commit comments

Comments
 (0)