Fork me on GitHub
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?


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


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.


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?


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.


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

Jim Newton08:04:45

does the path interpreter understand “~/” ?


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


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


or using cider scratch buffer


maybe this third alternative is the simpler...

Jim Newton08:04:47

nice suggestions, all.


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


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


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.

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


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

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.


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

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


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


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.


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