Skip to content

Commit fa162fb

Browse files
committed
Add support for refresh middleware
1 parent 973f115 commit fa162fb

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

cider-interaction.el

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ if the candidate is not namespace-qualified."
214214
(defvar cider-required-nrepl-ops
215215
'("apropos" "classpath" "complete" "eldoc" "format-code" "format-edn" "info"
216216
"inspect-pop" "inspect-push" "inspect-refresh"
217-
"macroexpand" "ns-list" "ns-vars"
217+
"macroexpand" "ns-list" "ns-vars" "refresh"
218218
"resource" "stacktrace" "toggle-trace-var" "toggle-trace-ns" "undef")
219219
"A list of nREPL ops required by CIDER to function properly.
220220
@@ -1947,12 +1947,27 @@ opposite of what that option dictates."
19471947
"symbol" sym)
19481948
(cider-interactive-eval-handler (current-buffer))))))
19491949

1950-
(defun cider-refresh ()
1951-
"Refresh loaded code."
1952-
(interactive)
1953-
(cider-tooling-eval
1954-
"(clojure.core/require 'clojure.tools.namespace.repl) (clojure.tools.namespace.repl/refresh)"
1955-
(cider-interactive-eval-handler (current-buffer))))
1950+
(defun cider-refresh--handle-response (response)
1951+
(nrepl-dbind-response response (reloading status error error-ns)
1952+
(cond (reloading
1953+
(message "Reloading: %s" reloading))
1954+
((member "ok" status)
1955+
(message "Reloading successful"))
1956+
((member "error" status)
1957+
(progn (message "Error reloading %s" error-ns)
1958+
(cider--render-stacktrace-causes error))))))
1959+
1960+
(defun cider-refresh (&optional arg)
1961+
"Reload modified and unloaded namespaces on the classpath.
1962+
1963+
With a non-nil prefix ARG, reload all namespaces on the classpath
1964+
unconditionally."
1965+
(interactive "P")
1966+
(cider-ensure-op-supported "refresh")
1967+
(nrepl-send-request (list "op" (if arg "refresh-all" "refresh")
1968+
"print-length" cider-stacktrace-print-length
1969+
"print-level" cider-stacktrace-print-level)
1970+
#'cider-refresh--handle-response))
19561971

19571972
(defun cider-file-string (file)
19581973
"Read the contents of a FILE and return as a string."

0 commit comments

Comments
 (0)