Fork me on GitHub
#cider
<
2021-04-18
>
macrobartfast00:04:52

Do you mean by first evaluating it with cider-eval-defun-at-point ?

macrobartfast00:04:41

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

macrobartfast00:04:00

I got really addicted to evaluating forms in this way so it’s hard to live without, now, lol.

macrobartfast01:04:33

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.

bozhidar19:04:19

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.

macrobartfast01:04:38

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.

dpsutton01:04:15

I would guess it’s a namespace thing

macrobartfast01:04:39

That’s what it looks like to me. Unfortunately, I don’t know how to figure how to resolve it.

dpsutton03:04:54

Eval “ns” and see what it reports

macrobartfast00:04:46

do I (ns) int the cljs reple, or?

macrobartfast00:04:42

the cljs repl prompt is cljs.user> if that’s useful.

macrobartfast00:04:47

I was able to switch my prompt to the namespace foobar is defined in and type it in with an argument and that worked.

macrobartfast00:04:00

my cljs.user> prompt, that is.

dpsutton04:04:26

That got bolded trying to type the asterisks in +ns+ not meant to shout :)

macrobartfast00:04:02

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.

otfrom10:04:21

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?

bozhidar18:04:20

I think there's no variable for this, but there's another command to insert the result as a comment.

jumar18:04:55

Exactly, that’s what I use all the time - There’s a variant with pretty print too

bozhidar18:04:58

Try C-u C-c C-p.

otfrom18:04:12

@bozhidar @jumar thx! That gets what I want via another means 🙂

👍 1
otfrom18:04:53

that does a good job of keeping lsp and kondo from working too hard