Fork me on GitHub
#cider
<
2023-11-16
>
jf14:11:21

Apologies if I’m not getting the terminology right here (I’m new to this), but does anybody know how (assuming there is a “how”) to reset the context in a CIDER nREPL session? for example, I’ve defined some vars previously in my buffer and did C-c C-k. After removing the defs, and doing C-c C-k again, I’m expecting the vars to no longer be there. But they still are.

nivekuil14:11:01

cider-ns-refresh, but in general look up "reloaded workflow"

nivekuil14:11:00

(ns-unmap) if you want to surgically undef stuff

vemv14:11:43

We have cider-undef-all as well https://docs.cider.mx/cider/usage/cider_mode.html#key-reference You can mix and match approaches (see above) depending on your preferences :)

Roma14:11:33

I usually eval buffer using C-u C-c C-k, which first undef all vars.

jf14:11:10

thank you everybody! @U797MAJ8M I assume you mean like a search engine lookup? using the search box at https://docs.cider.mx/cider/usage/cider_mode.html doesnt really give me anything @U01320BR6US thank you. I’m not seeing this at https://docs.cider.mx/cider/usage/cider_mode.html#key-reference. Is this documented somewhere else?

Roma14:11:22

Yes, if you check the doc in emacs (`C-h k C-c C-k`):

C-c C-k runs the command cider-load-buffer (found in cider-mode-map),
which is an interactive native-compiled Lisp function in
‘cider-eval.el’.

It is bound to C-c C-k.

(cider-load-buffer &optional BUFFER CALLBACK UNDEF-ALL)

Load (eval) BUFFER’s file in nREPL.
If no buffer is provided the command acts on the current buffer.  If the
buffer is for a cljc file, and both a Clojure and ClojureScript REPL exists
for the project, it is evaluated in both REPLs.
Optional argument CALLBACK will override the default ‘cider-load-file-handler’.
When UNDEF-ALL is non-nil or called with C-u, removes
all ns aliases and var mappings from the namespace before reloading it.

jf14:11:46

I see. Got it; thank you!

practicalli-johnny14:11:11

I've use cider-undef very successfully to remove a specific var (a def or defn), usually before renaming a test or function name. If you have deftype, defrecord then they can be harder to manage Using clojure.tools.namespace.repl/refresh should remove all def and defn vars https://practical.li/clojure/clojure-cli/repl-reloaded/#reload-namespaces

👌 1
vemv19:11:55

Curious, does sesman-restart work for y'all on a cider-connect ed repl? I've never used it much tbh, so I can't make a complete asessment. I've seen it working on cider-jack-in sessions, but not cider-connect ones (which ironically sounds like an easier use case)

vemv19:11:39

Clarification, I mean restart after the server was shut down and started again over the same port

vemv20:11:31

oh I'm now making sense of things... duckie Servers often restart over a new random port, so sesman-restart cannot magically know about it. It may be worthwhile to prompt for ports if the current one can't be connected to. But there's the alternative of cider-connect ing again and reuse the dead repl. 🌀

👍 1