Skip to content

Commit 4733e02

Browse files
vspinubbatsov
authored andcommitted
[#1875] In cljc files eval into both clj and cljs repls
1 parent 6066086 commit 4733e02

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
* [#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.
4949
* [#1707](https://github.com/clojure-emacs/cider/issues/1707): Allow to customize line truncating in CIDER's special buffers.
5050
* [#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`.
51-
* [#1875](https://github.com/clojure-emacs/cider/issues/1875): Ensure cljc buffers can load buffer into both clj and cljs repls.
51+
* [#1875](https://github.com/clojure-emacs/cider/issues/1875): Ensure that loading and evaluation in cljc buffers is performed in both clj and cljs repls.
5252
* [#1897](https://github.com/clojure-emacs/cider/issues/1897): Bind TAB in stacktrace buffers in the terminal.
5353
* [#1895](https://github.com/clojure-emacs/cider/issues/1895): Connect to the same host:port after `cider-restart` if the connection was established with `cider-connect`.
5454
* [#1881](https://github.com/clojure-emacs/cider/issues/1881): Add `cider-cljs-boot-repl` and `cider-cljs-gradle-repl` defcustom and hook `boot-cljs-repl`.

cider-client.el

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,12 +669,13 @@ Return the id of the sent message."
669669
(nrepl--mark-id-completed id))
670670
id))
671671

672-
(defun cider-nrepl-request:eval (input callback &optional ns line column additional-params)
672+
(defun cider-nrepl-request:eval (input callback &optional ns line column additional-params connection)
673673
"Send the request INPUT and register the CALLBACK as the response handler.
674674
If NS is non-nil, include it in the request. LINE and COLUMN, if non-nil,
675675
define the position of INPUT in its buffer. ADDITIONAL-PARAMS is a plist
676-
to be appended to the request message."
677-
(let ((connection (cider-current-connection)))
676+
to be appended to the request message. CONNECTION is the connection
677+
buffer, defaults to (cider-current-connection)."
678+
(let ((connection (or connection (cider-current-connection))))
678679
(nrepl-request:eval input
679680
(if cider-show-eval-spinner
680681
(cider-eval-spinner-handler connection callback)

cider-interaction.el

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,15 +1135,19 @@ arguments and only proceed with evaluation if it returns nil."
11351135
(funcall cider-interactive-eval-override form callback bounds))
11361136
(cider-map-connections #'ignore :any)
11371137
(cider--prep-interactive-eval form)
1138-
(cider-nrepl-request:eval
1139-
form
1140-
(or callback (cider-interactive-eval-handler nil bounds))
1141-
;; always eval ns forms in the user namespace
1142-
;; otherwise trying to eval ns form for the first time will produce an error
1143-
(if (cider-ns-form-p form) "user" (cider-current-ns))
1144-
(when start (line-number-at-pos start))
1145-
(when start (cider-column-number-at-pos start))
1146-
additional-params))))
1138+
(cider-map-connections
1139+
(lambda (connection)
1140+
(cider-nrepl-request:eval
1141+
form
1142+
(or callback (cider-interactive-eval-handler nil bounds))
1143+
;; always eval ns forms in the user namespace
1144+
;; otherwise trying to eval ns form for the first time will produce an error
1145+
(if (cider-ns-form-p form) "user" (cider-current-ns))
1146+
(when start (line-number-at-pos start))
1147+
(when start (cider-column-number-at-pos start))
1148+
additional-params
1149+
connection))
1150+
:both))))
11471151

11481152
(defun cider-eval-region (start end)
11491153
"Evaluate the region between START and END."

0 commit comments

Comments
 (0)