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
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
and I’ve opened a file.clj file.
but the .clj file seems to not be connected
so commands such as C-M-x have no effect
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 ?
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.
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
how do I do that?
what kind of project are you using ? lein or clj tools ?
lein
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
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"]
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
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
that’s reasonable, right?
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...
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
1. for literate programming, does the file need to be in the project?
2. how can I go the scratch buffer direction? I know about the elisp scratch buffer
#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.
cider scratch is cool
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
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.and now it is.
huh, maybe when i hit the command i wasn't in the cljs buffer?
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.
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
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.