Do you mean by first evaluating it with cider-eval-defun-at-point
?
I do run that to define it right after writing it… that’s a habit; cider-eval-defun-at-point
on
(defn foobar [x]
(* x 2))
I can then evaluate it with
(foobar 2)
in my buffer once I’ve typed it out. But when I run it with cider-read-and-eval-defun-at-point
I get
Show: Project-Only All
Hide: Clojure Java REPL Tooling Duplicates (24 frames hidden)
2. Unhandled clojure.lang.Compiler$CompilerException
Error compiling *cider-repl scratch/project:localhost:3333(clj)* at (1:1)
#:clojure.error{:phase :compile-syntax-check,
:line 1,
:column 1,
:source "*cider-repl scratch/project:localhost:3333(clj)*"}
1. Caused by java.lang.RuntimeException
Unable to resolve symbol: foobar in this context
Util.java: 221 clojure.lang.Util/runtimeException
core.clj: 3214 clojure.core/eval
core.clj: 3210 clojure.core/eval
main.clj: 437 clojure.main/repl/read-eval-print/fn
main.clj: 458 clojure.main/repl/fn
main.clj: 368 clojure.main/repl
RestFn.java: 1523 clojure.lang.RestFn/invoke
AFn.java: 22 clojure.lang.AFn/run
AFn.java: 22 clojure.lang.AFn/run
Thread.java: 748 java.lang.Thread/run
I got really addicted to evaluating forms in this way so it’s hard to live without, now, lol.
Another clue to whatever I’m doing wrong: if I run cider-read-and-eval
and type out (foobar 2) in the minibuffer at the prompt, I get the same error.
You might open some ticket about this, as when I try both commands they work for me, so I assume you're not using them exactly as I do.
It’s all partly because I’m learning a lot so I have to check almost every function in isolation; I spend at least 30% of my coding time typing out these functions, running them in isolation with fake arguments, then deleting them or commenting them out.
I would guess it’s a namespace thing
That’s what it looks like to me. Unfortunately, I don’t know how to figure how to resolve it.
Eval “ns” and see what it reports
do I (ns)
int the cljs reple, or?
the cljs repl prompt is cljs.user>
if that’s useful.
I was able to switch my prompt to the namespace foobar is defined in and type it in with an argument and that worked.
my cljs.user> prompt, that is.
That got bolded trying to type the asterisks in +ns+ not meant to shout :)
haha, didn’t think you were shouting… but, for the record, any of you can shout at me all day long… you all are angels so you can do no wrong.
Hi. I have the following set for cider
cider-repl-result-prefix ";; "
cider-eval-result-prefix ";; "
and when I do C-x C-e I get the ;;
in the overlay, but when I do C-u C-x C-e the results in my buffer aren't commented out. Can anyone recommend what variable I need to set to get this?I think there's no variable for this, but there's another command to insert the result as a comment.
Exactly, that’s what I use all the time - There’s a variant with pretty print too
Try C-u C-c C-p
.
that does a good job of keeping lsp and kondo from working too hard