Fork me on GitHub
#cider
<
2020-11-20
>
niveauverleih07:11:21

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 ?

niveauverleih12:11:46

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

bozhidar13:11:10

This will require you to have a running nREPL server.

bozhidar13:11:01

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

bozhidar13:11:43

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

niveauverleih13:11:56

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

bozhidar13:11:11

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

niveauverleih13:11:28

I get an error "wrong number of arguments".

bozhidar13:11:56

cider-connect-clj is an autoloaded interactive Lisp function in
‘cider.el’.

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

bozhidar13:11:31

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

niveauverleih13:11:39

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.

niveauverleih14:11:17

@lkottmann @bozhidar @jr0cket 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!

👍 3
bozhidar11:11:11

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

niveauverleih11:11:15

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

niveauverleih12:11:57

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

niveauverleih13:11:33

@jr0cket @bozhidar @lkottmann 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.

erwinrooijakkers13:11:59

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

hkjels14:11:06

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.

erwinrooijakkers13:11:44

[:button.bg-blue.hover:bg-blue-dark.text-white.font-bold.py-2 px-4.rounded "Button"]

niveauverleih14:11:17

@lkottmann @bozhidar @jr0cket 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!

👍 3
jjttjj15:11:07

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

jjttjj16:11:00

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

jjttjj16:11:43

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

practicalli-johnny17:11:54

@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 https://practicalli.github.io/spacemacs/evaluating-clojure/inspect.html

st3fan19:11:54

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?

bozhidar11:11:12

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 https://github.com/clojure-emacs/cider/pull/2920

st3fan13:11:08

Thanks I will take a look

borkdude20:11:46

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

borkdude20:11:35

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

practicalli-johnny23:11:01

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.

borkdude20:11:39

aha, hs-minor-mode