cider

A channel dedicated to the Clojure Interactive Development Environment that Rocks (aka CIDER). :cider:
bozhidar 2021-04-16T05:33:23.303900Z

I don’t think we need more help with this particular issue, but there are always other issues one can tackle. 😄

jmckitrick 2021-04-16T14:55:09.304400Z

I really need to do that. Let me see what I can find.

macrobartfast 2021-04-16T19:58:03.305200Z

what is the cider command that lets me evaluate a function under the point in the minibuffer, supplying arguments?

macrobartfast 2021-04-16T19:58:14.305500Z

or an equivalent.

macrobartfast 2021-04-16T19:58:42.306100Z

I’m constantly typing out functions in my buffer with arguments so I can evaluate them then deleting them. So, if I made

(defn foobar [x]
  (* 2 x))
I would then write
(foobar 8)
below it and run a cider eval on it, then delete it. Alternately I suppose I could copy paste it into the repl, but that would take as much time.

macrobartfast 2021-04-16T20:01:59.306300Z

aha, found it: cider-read-and-eval-defun-at-point

macrobartfast 2021-04-16T20:02:28.307Z

I remember now. I also remember I was getting errors and that’s why I had stopped using it and thus forgotten it.

macrobartfast 2021-04-16T20:03:49.307300Z

I’ll put the error in a thread…

macrobartfast 2021-04-19T02:29:03.331800Z

@qythium thanks!

macrobartfast 2021-04-16T20:07:59.307400Z

when running cider-read-and-eval-defun-at-point on

(defn foobar [x]
  (* 2 x))
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 past/someproject:localhost:3333(clj)* at (1:1)
   #:clojure.error{:phase :compile-syntax-check,
                   :line 1,
                   :column 1,
                   :source
                   "*cider-repl past/someproject: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-16T20:08:36.307600Z

cider-eval-defun-at-point works fine, however.

macrobartfast 2021-04-16T20:08:51.307800Z

to define the function in the buffer, that is.

macrobartfast 2021-04-16T20:09:31.308Z

This is a cljs file in a Reagent project, by the way, running in a browser.

macrobartfast 2021-04-16T20:15:37.309Z

I then delete it.

macrobartfast 2021-04-16T20:24:19.310100Z

I do this with most functions I define, so dozens of times a day. Probably my doing this is the result of a bad approach… not sure.