Skip to content

Commit

Permalink
Support cider.clj-reload/reload ops
Browse files Browse the repository at this point in the history
  • Loading branch information
filipesilva committed Mar 2, 2024
1 parent dc58ed1 commit 2b67373
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions cider-ns.el
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ namespace-qualified function of zero arity."
:group 'cider
:package-version '(cider . "0.10.0"))

(defcustom cider-ns-use-clj-reload nil
"Whether to use clj-reload instead of tools.namespace for reloading."
:type 'boolean
:group 'cider
:package-version '(cider . "1.13.1"))

(defun cider-ns-refresh--handle-response (response log-buffer)
"Refresh LOG-BUFFER with RESPONSE."
(nrepl-dbind-response response (out err reloading status error error-ns after before)
Expand Down Expand Up @@ -186,6 +192,16 @@ Its behavior is controlled by `cider-ns-save-files-on-refresh' and
(file-in-directory-p buffer-file-name dir))
dirs)))))))

(defun cider-ns-refresh--refresh-op (op-name)
"Return the refresh operation to use.
Based on OP-NAME and the value of cider-ns-use-clj-reload defcustom."
(list "op"
(if (not cider-ns-use-clj-reload)
op-name
(cond ((string= op-name "refresh") "cider.clj-reload/reload")
((string= op-name "refresh-all") "cider.clj-reload/reload-all")
((string= op-name "refresh-all") "cider.clj-reload/reload-clear")))))

;;;###autoload
(defun cider-ns-reload (&optional prompt)
"Send a (require 'ns :reload) to the REPL.
Expand Down Expand Up @@ -237,6 +253,7 @@ refresh functions (defined in `cider-ns-refresh-before-fn' and
(interactive "p")
(cider-ensure-connected)
(cider-ensure-op-supported "refresh")
(cider-ensure-op-supported "cider.clj-reload/reload")
(cider-ns-refresh--save-modified-buffers)
(let ((clear? (member mode '(clear 16)))
(refresh-all? (member mode '(refresh-all 4)))
Expand All @@ -254,11 +271,11 @@ refresh functions (defined in `cider-ns-refresh-before-fn' and
nil
t))
(when clear?
(cider-nrepl-send-sync-request '("op" "refresh-clear") conn))
(cider-nrepl-send-sync-request (cider-ns-refresh--refresh-op "refresh-clear") conn))
(cider-nrepl-send-request
(thread-last
(map-merge 'list
`(("op" ,(if refresh-all? "refresh-all" "refresh")))
(list (cider-ns-refresh--refresh-op (if refresh-all? "refresh-all" "refresh")))
(cider--nrepl-print-request-map fill-column)
(when (and (not inhibit-refresh-fns) cider-ns-refresh-before-fn)
`(("before" ,cider-ns-refresh-before-fn)))
Expand Down

0 comments on commit 2b67373

Please sign in to comment.