Skip to content

Commit 2f3a802

Browse files
committed
Add support for refresh-clear middleware op
1 parent 070f547 commit 2f3a802

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* [#1219](https://github.com/clojure-emacs/cider/pull/1219): The output of `cider-refresh` is now sent to a dedicated `*cider-refresh-log*` buffer.
2626
* [#1219](https://github.com/clojure-emacs/cider/pull/1219): New custom variables `cider-refresh-before-fn` and `cider-refresh-after-fn`.
2727
* [#1220](https://github.com/clojure-emacs/cider/issues/1220): Treat keywords as symbols in lookup commands like `cider-find-var`.
28+
* [](): Passing a double prefix argument to `cider-refresh` will now clear the state of the namespace tracker used by the refresh middleware. This is useful for recovering from errors that a normal reload would not otherwise recover from, but may cause stale code in any deleted files to not be completely unloaded.
2829

2930
### Changes
3031

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,8 +820,7 @@ Keyboard shortcut | Description
820820
<kbd>C-c M-o</kbd> | Clear the entire REPL buffer, leaving only a prompt. Useful if you're running the REPL buffer in a side by side buffer.
821821
<kbd>C-c C-k</kbd> | Load (eval) the current buffer.
822822
<kbd>C-c C-l</kbd> | Load (eval) a Clojure file.
823-
<kbd>C-c C-x</kbd> | Reload all modified files on the classpath.
824-
<kbd>C-u C-c C-x</kbd> | Reload all files on the classpath.
823+
<kbd>C-c C-x</kbd> | 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.
825824
<kbd>C-c C-d d</kbd> | Display doc string for the symbol at point. If invoked with a prefix argument, or no symbol is found at point, prompt for a symbol.
826825
<kbd>C-c C-d j</kbd> | Display JavaDoc (in your default browser) for the symbol at point. If invoked with a prefix argument, or no symbol is found at point, prompt for a symbol.
827826
<kbd>C-c M-i</kbd> | Inspect expression. Will act on expression at point if present.

cider-interaction.el

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,13 +2086,22 @@ opposite of what that option dictates."
20862086
(defun cider-refresh (&optional arg)
20872087
"Reload modified and unloaded namespaces on the classpath.
20882088
2089-
With a non-nil prefix ARG, reload all namespaces on the classpath
2090-
unconditionally."
2091-
(interactive "P")
2089+
With a single prefix argument ARG, reload all namespaces on the classpath
2090+
unconditionally.
2091+
2092+
With a double prefix argument ARG, clear the state of the namespace tracker
2093+
before reloading. This is useful for recovering from some classes of
2094+
error (for example, those caused by circular dependencies) that a normal
2095+
reload would not otherwise recover from. The trade-off of clearing is that
2096+
stale code from any deleted files may not be completely unloaded."
2097+
(interactive "p")
20922098
(cider-ensure-op-supported "refresh")
20932099
(let ((log-buffer (cider-popup-buffer-display (or (get-buffer cider-refresh-log-buffer)
2094-
(cider-make-popup-buffer cider-refresh-log-buffer)))))
2095-
(nrepl-send-request (append (list "op" (if arg "refresh-all" "refresh")
2100+
(cider-make-popup-buffer cider-refresh-log-buffer))))
2101+
(clear? (>= arg 16))
2102+
(refresh-all? (>= arg 4)))
2103+
(when clear? (nrepl-send-request-sync (list "op" "refresh-clear")))
2104+
(nrepl-send-request (append (list "op" (if refresh-all? "refresh-all" "refresh")
20962105
"print-length" cider-stacktrace-print-length
20972106
"print-level" cider-stacktrace-print-level)
20982107
(when cider-refresh-before-fn (list "before" cider-refresh-before-fn))

0 commit comments

Comments
 (0)