Fork me on GitHub
#cider
<
2021-04-29
>
Jim Newton07:04:57

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 Newton07:04:11

and I’ve opened a file.clj file.

Jim Newton07:04:56

but the .clj file seems to not be connected

Jim Newton07:04:09

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

Jim Newton07:04:21

can someone explain what I’m doing wrong?

yuhan08:04:39

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

gon08:04:24

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

Jim Newton08:04:58

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 Newton08:04:34

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.

gon08:04:02

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 Newton08:04:37

how do I do that?

gon08:04:16

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

Jim Newton08:04:59

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 Newton08:04:23

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

gon08:04:00

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

Jim Newton08:04:45

does the path interpreter understand “~/” ?

gon08:04:54

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 Newton08:04:44

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 Newton08:04:59

that’s reasonable, right?

Jim Newton08:04:50

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

gon08:04:35

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....

gon08:04:11

or using cider scratch buffer

gon08:04:36

maybe this third alternative is the simpler...

Jim Newton08:04:47

nice suggestions, all.

gon08:04:49

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 Newton08:04:00

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

Jim Newton08:04:45

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

Jim Newton08:04:12

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

gon08:04:00

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

gon08:04:05

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.

3
Jim Newton08:04:58

cider scratch is cool

Jim Newton08:04:30

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

yuhan08:04:14

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

3
Drew Verlee17:04:22

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.

Drew Verlee19:04:13

and now it is.

Drew Verlee19:04:14

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

Drew Verlee20:04:45

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.

Drew Verlee20:04:39

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

dpsutton20:04:13

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

👍 3
hugod21:04:35

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

bozhidar09:04:51

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

bozhidar09:04:31

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.

hugod09:04:50

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