Fork me on GitHub

Is there a way to launch emacs so that it opens a given clojure file and automatically does the cider Jack-in? Sometimes I want to quickly try out some clojure command. I have a project "fiddle" with "fiddle.clj" under src. I want to place a shortcut on my desktop that launches spacemacs, opens fiddle.clj, starts a cider REPL and connects to it. I could run "emacs fiddle/stc/fiddle.clj" and "cd fiddle: lein repl"in parallel but that doesn't link my spacemacs session to the REPL.yet.

Louis Kottmann10:11:49

maybe with emacs --eval (cider-connect ...) fiddle.clj ?


Thank you! What should I put as arguments to cider-connect? Is there documentation?


This will require you to have a running nREPL server.


I think it'd be better to just add to your init.el visiting the file in question and running cider-jack-in.


(assuming you always want to do the same thing when starting emacs)


Yes. I first start up the nrepl, then emacs like this: ... set oldwd $PWD cd ~/cloj-projects/fiddle/src/fiddle tmux new-session -d -s lein-repl lein repl &> out.log echo ",scj" | emacs fiddle.clj tmux kill-session -t lein-repl cd $oldwd ...


emacs --eval (cider-jack-in-clj) fiddle.clj will probably work as well.


I get an error "wrong number of arguments".


cider-connect-clj is an autoloaded interactive Lisp function in

(cider-connect-clj &optional PARAMS)

Initialize a Clojure connection to an nREPL server.
PARAMS is a plist optionally containing :host, :port and :project-dir.  On
prefix argument, prompt for all the parameters.


So basically you can do something like (cider-connect-clj '(:host "localhost" :port 1234)).


Sorry I meant ... set oldwd $PWD cd ~/cloj-projects/fiddle/src/fiddle tmux new-session -d -s lein-repl lein repl &> out.log emacs fiddle.clj tmux kill-session -t lein-repl cd $oldwd ... I will try your suggestion.


@U01CVNTDF34 @U051BLM8F @U05254DQM So this works: This starts a lein-repl in a separate session, then spacemacs with fiddle.clj and has cider connect to the repl. ... set oldwd $PWD cd ~/cloj-projects/fiddle/src/fiddle tmux new-session -d -s lein-repl lein repl :start :port 40000 &> out.log emacs --eval "(progn (sleep-for 15) (cider-connect-clj '(:host \"localhost\" :port 40000)))" fiddle.clj tmux kill-session -t lein-repl cd $oldwd ... I also tried this: emacs --eval "(cider-jack-in-clj '(:host \"localhost\" :port 40000)))" ~/cloj-projects/fiddle/src/fiddle/fiddle.clj ...but: - first it asks for confirmation "do you really want to run cider-Jack-in-clj?" - then I get an error "error in process sentinel: Could not start nREPL server:" Anyway, I'm happy. Thanks for your help!

👍 1

Only cider-connect-* accept host/port params. cider-jack-in starts a server and connects to it automatically.


In theory yes, in practice I get an error "wrong number of arguments" if I don't provide any argument.


Ok found it . I need to provide 'nil' as argument


@U05254DQM @U051BLM8F @U01CVNTDF34 So here is my updated version ... set oldwd $PWD cd ~/cloj-projects/fiddle/src/fiddle emacs --eval "(cider-jack-in-clj nil)" fiddle.clj cd $oldwd ... Somehow you need to first cd into the directory of the file, otherwise the cider-jack-in-clj asks for confirmation.


Is there a way to have CSS autocomplete in Emacs, and specifically for Tailwindcss used in Hiccup?


If you don’t find a company-backend on melpa; it’s relatively easy to write one yourself if you have a good list of everything you’d like to complete.


[ px-4.rounded "Button"]


When I print a large data structure in the cider repl, it is printed but then instantly disappears. What's the setting to configure this? I think I set it to do this at some point but can't remember what the setting was


it seems to print a large thing out once or twice the first times I try but subsequently will revert to clearing the full repl after printing


AH nevermind, it's cider-repl-buffer-size-limit


@jjttjj cider-inspect allows you to navigate and page through results. It will even follow your normal evaluations in the source code buffer. For example screenshots


How about a cider-yank-last-result ? I keep having trouble easily copying for example a string result from something I evaluated. Or is there a trick for that?


There's nothing currently built-in, but it'd be easy to do implement something. There's also a PR proposing something similar in progress


Thanks I will take a look


Is there a way to collapse a rich comment form? I want to do this for a presentation


mind you, I'm not using spacemacs, but I do find some examples of that. I hope they translate to emacs / prelude as well?


I started using vimish-fold which can do very specific folding, but think that only works with Evil, so I don't think that helps, sorry. I found folding a bit basic otherwise.


aha, hs-minor-mode