Skip to content

Commit 6d723a1

Browse files
committed
Change cider-ns-refresh to always use clj-repl
1 parent af63db1 commit 6d723a1

File tree

3 files changed

+36
-31
lines changed

3 files changed

+36
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
- Bump the injected `nrepl` to [1.4.0](https://github.com/nrepl/nrepl/blob/master/CHANGELOG.md#140-2025-09-02).
1010
- Bump the injected `piggieback` to [0.6.1](https://github.com/nrepl/piggieback/blob/master/CHANGES.md#061-2025-12-31).
11+
- [#3834](https://github.com/clojure-emacs/cider/issues/3834): Change cider-ns-refresh to always use Clojure REPL
1112

1213
### Bugs fixed
1314

cider-ns.el

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -297,36 +297,40 @@ refresh functions (defined in `cider-ns-refresh-before-fn' and
297297
`cider-ns-refresh-after-fn') from being invoked."
298298
(interactive "p")
299299
(cider-ensure-connected)
300-
(cider-ensure-op-supported "refresh")
301-
(cider-ensure-op-supported "cider.clj-reload/reload")
302-
(cider-ns-refresh--save-modified-buffers)
303-
(let ((clear? (member mode '(clear 16)))
304-
(all? (member mode '(refresh-all 4)))
305-
(inhibit-refresh-fns (member mode '(inhibit-fns -1))))
306-
(cider-map-repls :clj
307-
(lambda (conn)
308-
;; Inside the lambda, so the buffer is not created if we error out.
309-
(let ((log-buffer (or (get-buffer cider-ns-refresh-log-buffer)
310-
(cider-make-popup-buffer cider-ns-refresh-log-buffer))))
311-
(when cider-ns-refresh-show-log-buffer
312-
(cider-popup-buffer-display log-buffer))
313-
(when inhibit-refresh-fns
314-
(cider-emit-into-popup-buffer log-buffer
315-
"inhibiting refresh functions\n"
316-
nil
317-
t))
318-
(when clear?
319-
(cider-nrepl-send-sync-request `("op" ,(cider-ns--reload-op "reload-clear")) conn))
320-
(cider-nrepl-send-request
321-
`("op" ,(cider-ns--reload-op (if all? "reload-all" "reload"))
322-
,@(cider--nrepl-print-request-plist fill-column)
323-
,@(when (and (not inhibit-refresh-fns) cider-ns-refresh-before-fn)
324-
`("before" ,cider-ns-refresh-before-fn))
325-
,@(when (and (not inhibit-refresh-fns) cider-ns-refresh-after-fn)
326-
`("after" ,cider-ns-refresh-after-fn)))
327-
(lambda (response)
328-
(cider-ns-refresh--handle-response response log-buffer))
329-
conn))))))
300+
(if-let ((clj-connection (cider-current-repl 'clj)))
301+
(with-current-buffer clj-connection
302+
(cider-ensure-op-supported "refresh")
303+
(cider-ensure-op-supported "cider.clj-reload/reload")
304+
(cider-ns-refresh--save-modified-buffers)
305+
(let ((clear? (member mode '(clear 16)))
306+
(all? (member mode '(refresh-all 4)))
307+
(inhibit-refresh-fns (member mode '(inhibit-fns -1))))
308+
(funcall
309+
(lambda (conn)
310+
;; Inside the lambda, so the buffer is not created if we error out.
311+
(let ((log-buffer (or (get-buffer cider-ns-refresh-log-buffer)
312+
(cider-make-popup-buffer cider-ns-refresh-log-buffer))))
313+
(when cider-ns-refresh-show-log-buffer
314+
(cider-popup-buffer-display log-buffer))
315+
(when inhibit-refresh-fns
316+
(cider-emit-into-popup-buffer log-buffer
317+
"inhibiting refresh functions\n"
318+
nil
319+
t))
320+
(when clear?
321+
(cider-nrepl-send-sync-request `("op" ,(cider-ns--reload-op "reload-clear")) conn))
322+
(cider-nrepl-send-request
323+
`("op" ,(cider-ns--reload-op (if all? "reload-all" "reload"))
324+
,@(cider--nrepl-print-request-plist fill-column)
325+
,@(when (and (not inhibit-refresh-fns) cider-ns-refresh-before-fn)
326+
`("before" ,cider-ns-refresh-before-fn))
327+
,@(when (and (not inhibit-refresh-fns) cider-ns-refresh-after-fn)
328+
`("after" ,cider-ns-refresh-after-fn)))
329+
(lambda (response)
330+
(cider-ns-refresh--handle-response response log-buffer))
331+
conn)))
332+
clj-connection)))
333+
(cider--no-repls-user-error 'clj)))
330334

331335
(provide 'cider-ns)
332336
;;; cider-ns.el ends here

doc/modules/ROOT/pages/usage/cider_mode.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ kbd:[C-u C-c C-c]
175175

176176
| `cider-ns-refresh`
177177
| kbd:[C-c M-n (M-)r]
178-
| Reload all modified files on the classpath. If invoked with a prefix argument, reload all files on the classpath. If invoked with a double prefix argument, clear the state of the namespace tracker before reloading.
178+
| Reload all modified files on the classpath. If invoked with a prefix argument, reload all files on the classpath. If invoked with a double prefix argument, clear the state of the namespace tracker before reloading. Uses a clojure REPL whenever one exists.
179179

180180
| `cider-doc`
181181
| kbd:[C-c C-d d] +

0 commit comments

Comments
 (0)