Function: cider-ns-refresh

cider-ns-refresh is an autoloaded, interactive and byte-compiled function defined in cider-ns.el.

Signature

(cider-ns-refresh &optional MODE)

Documentation

Reload modified and unloaded namespaces, using the Reloaded Workflow.

Uses the configured refresh dirs (defaults to the classpath dirs).

With a single prefix argument, or if MODE is refresh-all, reload all namespaces on the classpath dirs unconditionally.

With a double prefix argument, or if MODE is clear, clear the state of the namespace tracker before reloading. This is useful for recovering from some classes of error (for example, those caused by circular dependencies) that a normal reload would not otherwise recover from. The trade-off of clearing is that stale code from any deleted files may not be completely unloaded.

With a negative prefix argument, or if MODE is inhibit-fns, prevent any refresh functions (defined in cider-ns-refresh-before-fn and cider-ns-refresh-after-fn) from being invoked.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/cider-20260414.1619/cider-ns.el
;;;###autoload
(defun cider-ns-refresh (&optional mode)
  "Reload modified and unloaded namespaces, using the Reloaded Workflow.
Uses the configured refresh dirs \(defaults to the classpath dirs).

With a single prefix argument, or if MODE is `refresh-all', reload all
namespaces on the classpath dirs unconditionally.

With a double prefix argument, or if MODE is `clear', clear the state of
the namespace tracker before reloading.  This is useful for recovering from
some classes of error (for example, those caused by circular dependencies)
that a normal reload would not otherwise recover from.  The trade-off of
clearing is that stale code from any deleted files may not be completely
unloaded.

With a negative prefix argument, or if MODE is `inhibit-fns', prevent any
refresh functions (defined in `cider-ns-refresh-before-fn' and
`cider-ns-refresh-after-fn') from being invoked."
  (interactive "p")
  (cider-ensure-connected)
  (let ((clear? (member mode '(clear 16)))
        (all? (member mode '(refresh-all 4)))
        (inhibit-refresh-fns (member mode '(inhibit-fns -1))))
    (cider-map-repls '(:clj "refresh" "cider.clj-reload/reload")
      (lambda (conn)
        (cider-ns-refresh--save-modified-buffers conn)
        ;; Inside the lambda, so the buffer is not created if we error out.
        (let ((log-buffer (or (get-buffer cider-ns-refresh-log-buffer)
                              (cider-make-popup-buffer cider-ns-refresh-log-buffer))))
          (when cider-ns-refresh-show-log-buffer
            (cider-popup-buffer-display log-buffer))
          (when inhibit-refresh-fns
            (cider-emit-into-popup-buffer log-buffer
                                          "inhibiting refresh functions\n"
                                          nil
                                          t))
          (when clear?
            (cider-nrepl-send-sync-request `("op" ,(cider-ns--reload-op "reload-clear")) conn))
          (cider-nrepl-send-request
           `("op" ,(cider-ns--reload-op (if all? "reload-all" "reload"))
             ,@(cider--nrepl-print-request-plist fill-column)
             ,@(when (and (not inhibit-refresh-fns) cider-ns-refresh-before-fn)
                 `("before" ,cider-ns-refresh-before-fn))
             ,@(when (and (not inhibit-refresh-fns) cider-ns-refresh-after-fn)
                 `("after" ,cider-ns-refresh-after-fn)))
           (lambda (response)
             (cider-ns-refresh--handle-response response log-buffer))
           conn))))))