cursive

danm 2025-05-08T14:33:39.453209Z

Quick q, I'm probably just being a muppet - When I am evaluating commands in a REPL, something I often want to do is first allocate a function response to a var so that I can perform other transforms or whatever on it later, and then see the contents of that var. So if I was directly in the REPL I would do:

(def tmp-test-1 (function-call "foo" "bar"))
tmp-test-1
;;further transforms on tmp-test-1

danm 2025-05-08T14:34:43.717619Z

With the assumption being that the calls to fetch that data are comparatively slow (remote API or whatever), and I'm not sure of the shape of it until I fetch it

danm 2025-05-08T14:35:50.640129Z

If I try that with 'evaluate form under caret in REPL', it doesn't work, because a bare tmp-test-1 is not a 'form', so is not evaluated. I have to switch to the REPL window itself to do that. Is there any better way to do it that (identity tmp-test-1) to not have to switch windows?

2025-05-08T14:47:57.652959Z

I'm not sure what you mean by 'evaluate form under caret in REPL', but 'Send form before caret to REPL' works fine for me for what you are trying to achieve. The caret needs to be right after tmp-test-1 .

cfleming 2025-05-08T17:33:43.390899Z

I do exactly as you describe, I do (def my-var (call-my-api)), then to see the result I just select my-var and send to REPL - all the send commands will send the selection if there is one rather than what they would normally send.

danm 2025-05-08T18:29:57.989209Z

Hmm. So I most-normally use cmd-shift-p, which is my binding (I forget if it's the default one) for "Send top form to REPL" rather than "Send form before caret to the REPL" (cmd-ctrl-p). Often I edit something in the middle of the form and then want to reevaluate the whole thing, so it's the one I have best muscle-memory for and tend to use 'by default'. "Send form before caret to the REPL" works to send 'bare' words like tmp-test-1 on a line on its own, as well as just selecting that var from within another form, i.e. if I have the caret as

(def x (long-running-thing))
(function-call x| y z)
                ^
it'll evaluate and return x rather than the result of function-call (though I will have to remember that trying the same after the x in the (def x ... reevaluates the function used to create the var... Oops) But "Send top form to REPL" doesn't evaluate bare vars as a form. So doing cmd-shift-p either within or immediately (on the same line) after
tmp-test-1
on a line on its own doesn't work. It's considered a 'form' by "Send form before caret", but not "Send top form". It doesn't send anything to the REPL in that case. I just need to try and retrain my muscle memory, but it is a bit odd that the 2 functions have different ideas of what classifies as a form.