Skip to content

Commit f7f1256

Browse files
committed
Fix a regression related to requiring REPL util on REPL start
In f40014b an optimization was attempted which combined two requests into one. However, it switched the order of requiring the utils and setting the initial namespace, thus ending up not requiring the utils in the initial namespace.
1 parent da9c38b commit f7f1256

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

cider-repl.el

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ ENDPOINT is a plist as returned by `nrepl-connect'."
256256
(current-buffer))))
257257

258258
(declare-function cider-set-buffer-ns "cider-mode")
259-
(defun cider-repl-require-repl-utils-and-set-ns (buffer)
259+
(defun cider-repl-set-initial-ns (buffer)
260260
"Require standard REPL util functions and set the ns of the REPL's BUFFER.
261261
Namespace is \"user\" by default, but can be overridden in apps like
262262
lein (:init-ns). Both of these operations need to be done as a sync
@@ -265,17 +265,25 @@ efficiency."
265265
;; we don't want to get a timeout during init
266266
(let ((nrepl-sync-request-timeout nil))
267267
(with-current-buffer buffer
268-
(let* ((command "(do (when (clojure.core/resolve 'clojure.main/repl-requires)
269-
(clojure.core/map clojure.core/require clojure.main/repl-requires))
270-
(str *ns*))")
271-
(response (nrepl-send-sync-request
272-
(lax-plist-put (nrepl--eval-request command)
268+
(let* ((response (nrepl-send-sync-request
269+
(lax-plist-put (nrepl--eval-request "(str *ns*))")
273270
"inhibit-cider-middleware" "true")
274271
(cider-current-connection)))
275272
(initial-ns (or (read (nrepl-dict-get response "value"))
276273
"user")))
277274
(cider-set-buffer-ns initial-ns)))))
278275

276+
(defun cider-repl-require-repl-utils ()
277+
"Require standard REPL util functions into the current REPL."
278+
(interactive)
279+
(nrepl-send-sync-request
280+
(lax-plist-put
281+
(nrepl--eval-request
282+
"(when (clojure.core/resolve 'clojure.main/repl-requires)
283+
(clojure.core/map clojure.core/require clojure.main/repl-requires))")
284+
"inhibit-cider-middleware" "true")
285+
(cider-current-connection)))
286+
279287
(defvar cider-current-clojure-buffer nil
280288
"This variable holds current buffer temporarily when connecting to a REPL.
281289
It is set to current buffer when `cider' or `cider-jack-in' is called.
@@ -293,7 +301,8 @@ client process connection. Unless NO-BANNER is non-nil, insert a banner."
293301
(pcase cider-repl-pop-to-buffer-on-connect
294302
(`display-only (display-buffer buffer))
295303
((pred identity) (pop-to-buffer buffer)))
296-
(cider-repl-require-repl-utils-and-set-ns buffer)
304+
(cider-repl-set-initial-ns buffer)
305+
(cider-repl-require-repl-utils)
297306
(unless no-banner
298307
(cider-repl--insert-banner-and-prompt buffer))
299308
(cider-remember-clojure-buffer cider-current-clojure-buffer)

0 commit comments

Comments
 (0)