cider

A channel dedicated to the Clojure Interactive Development Environment that Rocks (aka CIDER). :cider:
macrobartfast 2021-04-18T00:42:52.315600Z

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

macrobartfast 2021-04-18T00:52:41.318600Z

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

macrobartfast 2021-04-18T00:59:00.319600Z

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

macrobartfast 2021-04-18T01:01:33.320400Z

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.

bozhidar 2021-04-18T19:11:19.330600Z

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.

macrobartfast 2021-04-18T01:03:38.322100Z

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.

dpsutton 2021-04-18T01:43:15.322400Z

I would guess it’s a namespace thing

macrobartfast 2021-04-18T01:54:39.322900Z

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

dpsutton 2021-04-18T03:58:54.324100Z

Eval “ns” and see what it reports

macrobartfast 2021-04-19T00:38:46.330800Z

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

macrobartfast 2021-04-19T00:45:42.331200Z

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

macrobartfast 2021-04-19T00:52:47.331400Z

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

macrobartfast 2021-04-19T00:53:00.331600Z

my cljs.user> prompt, that is.

dpsutton 2021-04-18T04:23:26.324900Z

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

macrobartfast 2021-04-19T00:40:02.331Z

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.

2021-04-18T10:48:21.326600Z

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?

bozhidar 2021-04-18T18:25:20.327200Z

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

jumar 2021-04-18T18:26:55.329Z

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

bozhidar 2021-04-18T18:28:58.329400Z

Try C-u C-c C-p.

2021-04-18T18:58:12.329900Z

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

👍 1
2021-04-18T18:59:53.330400Z

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