cider

A channel dedicated to the Clojure Interactive Development Environment that Rocks (aka CIDER). :cider:
2021-04-29T05:39:34.405Z

Normally I just cider-jack-in-clj&cljs and everything “just works”. I need to navigate my browser to the app for the cljs repl to become responsive though

Jim Newton 2021-04-29T07:35:57.406200Z

I’m not a cider expert, but I’m trying to use it. I have a repl running in the repl buffer and I can type expressions and evaluate them

Jim Newton 2021-04-29T07:36:11.406500Z

and I’ve opened a file.clj file.

Jim Newton 2021-04-29T07:36:56.406900Z

but the .clj file seems to not be connected

Jim Newton 2021-04-29T07:37:09.407500Z

so commands such as C-M-x have no effect

Jim Newton 2021-04-29T07:37:21.407800Z

can someone explain what I’m doing wrong?

yuhan 2021-04-29T08:00:39.408Z

Is your clj file in the same folder as the project that you started the repl?

gon 2021-04-29T08:01:24.408700Z

is the file in the project class-path where you have started the cider repl ?

Jim Newton 2021-04-29T08:09:58.408900Z

no, it’s in a different directory. It is in a directory of files where I’m preparing a presentation. The presentation slides are not inside the clojure project.

Jim Newton 2021-04-29T08:11:34.409900Z

BTW, how do I know what directory the repl was started from? I didn’t directly start the repl, rather I used M-x cider-jack-in, but then that’s a completely different off-topic question.

gon 2021-04-29T08:15:02.412300Z

well, that's is the reason, clj files must be on the class-path, just extend the classpath over it and restart the repl

Jim Newton 2021-04-29T08:15:37.412500Z

how do I do that?

gon 2021-04-29T08:16:16.413200Z

what kind of project are you using ? lein or clj tools ?

Jim Newton 2021-04-29T08:16:23.413400Z

lein

Jim Newton 2021-04-29T08:17:59.414300Z

isn’t there a way just evaluate code from a file without incorporating a file into my project. I don’t really want the file in my project. the project does not depend on the file, rather the file depends on the project

Jim Newton 2021-04-29T08:18:23.414800Z

of course I could fork the project just for the presentation, and remember never to merge the branch.

gon 2021-04-29T08:21:00.415700Z

in project.clj editing this key should do the trick :resource-paths ["your-path-here"]

Jim Newton 2021-04-29T08:22:45.417300Z

does the path interpreter understand “~/” ?

gon 2021-04-29T08:23:54.418Z

to evaluate code in a sparse file I think you could achieve it loading the file and evaluating it, not that is just your shell that expands it

Jim Newton 2021-04-29T08:25:44.419300Z

the flow of my presentation is that I’ll cursor through the file, evaluating each top level form, looking at the printed result and talking to the audience about what happened or why certain errors occurred. the file is not loadable, as it contains intentional errors for pedagogical reasons

Jim Newton 2021-04-29T08:25:59.419500Z

that’s reasonable, right?

Jim Newton 2021-04-29T08:26:50.420100Z

I was considering just copy-pasting into the repl, but that makes for ugly indentation….

gon 2021-04-29T08:31:35.422100Z

One solution could be just comment the intentional errors so as the reader does not parse them, another one could be using Emacs literate programming... that seems to fit neatly to you needs....

gon 2021-04-29T08:32:11.422500Z

or using cider scratch buffer

gon 2021-04-29T08:32:36.422900Z

maybe this third alternative is the simpler...

Jim Newton 2021-04-29T08:35:47.424600Z

nice suggestions, all.

gon 2021-04-29T08:35:49.424700Z

in the cider scratch buffer you should be able to paste code and evaluate it and pretty print results either on the repl or following the code declaration... easy to follow for an audience

Jim Newton 2021-04-29T08:36:00.425Z

1. for literate programming, does the file need to be in the project?

Jim Newton 2021-04-29T08:36:45.425700Z

2. how can I go the scratch buffer direction? I know about the elisp scratch buffer

Jim Newton 2021-04-29T08:37:12.426200Z

#2 is probably the easiest solution for my needs, as you said

gon 2021-04-29T08:39:00.426900Z

maybe scratch buffer is the easiest, literate programming involve more stuff...

gon 2021-04-29T08:39:05.427100Z

Using a Scratchpad CIDER provides a simple way to create a Clojure scratchpad via the M-x `cider-scratch` command. This is a great way to play around with some code without having to create source files or pollute the REPL buffer and is very similar to Emacs’s own `*scratch*` buffer.

1
Jim Newton 2021-04-29T08:43:58.427600Z

cider scratch is cool

Jim Newton 2021-04-29T08:45:30.428500Z

C-M-x prints the result ephemerally with a => result which vanishes when I move the cursor. thats EXCELLENT

yuhan 2021-04-29T08:51:14.428700Z

@jimka.issy you could also use sesman-link-* commands to tell cider to connect buffers which aren't in the project directory

1
2021-04-29T17:24:22.431400Z

Given a deps file with the aliases:

{:fig {:extra-deps
                  {com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}
                   com.bhauman/figwheel-main {:mvn/version "0.2.11"}}
                 :extra-paths ["target" "test"]}...
and a dir-locals.el file (and a clean restart): ((clojurescript-mode . ((cider-clojure-cli-aliases . "-A:fig")))) when i run 'cider-jack-in-cljs` i expect figwheel -main to be available, but it isn't.

2021-04-29T19:55:13.431700Z

and now it is.

2021-04-29T19:55:14.431900Z

huh, maybe when i hit the command i wasn't in the cljs buffer?

2021-04-29T20:05:45.433800Z

ok fantastic, maybe all my woes are because i wasn't running cljs jack in the right right. I had considered the specific file mattered. That or something else wasn't aligned the way it is now.

2021-04-29T20:06:39.434300Z

Though i suppose this differs from the main project in that there is no server code to speak of.

dpsutton 2021-04-29T20:07:13.435400Z

You put the alias under clojurescript mode. So the mode of the file matters when jacking in. I’d change it to just nil so it’s always available

👍 1
2021-04-29T21:53:35.436900Z

Is it possible to disable the tracking in the cider-nrepl middleware?

bozhidar 2021-04-30T09:23:51.439500Z

Currently it's not, unless you regenerate the middleware vector manually.

bozhidar 2021-04-30T09:24:31.439700Z

I've been planning for a while to make it "opt-in"/"opt-out", which is just a matter of adding one more flag, but I never got to doing so.

2021-04-30T09:55:50.442700Z

Thanks. The tracking gets very slow on large projects, I think mainly due to the size of the nrepl messages it generates.