Fork me on GitHub
#cider
<
2019-02-25
>
dominicm12:02:53

the clojurescript.md docs suggest https://github.com/clojure-emacs/cider/blob/62134b4ffa109ddfd143303db929af4760182470/doc/clojurescript.md#L102-L109 but those aren't vars marked as safe, so doing this presents the user with a warning when they open files in the directory. Is it worth changing them to be marked as safe? I don't think they're actually unsafe, as they don't affect anything until you jack-in, which is inherently an unsafe operation, as I can run arbitrary code on your machine at that point.

dominicm12:02:19

I would assume unsafe is for things like "opening this file could run rm -rf /"

dpsutton12:02:41

I brought this up a bit ago and I think @bozhidar agreed. And yeah it's super annoying

dominicm12:02:15

this is about to become the default in edge (https://github.com/juxt/edge/issues/62)

dominicm12:02:36

in the past I have made PRs for this, but I don't use emacs, so I don't run the code or anything before doing so.

dominicm12:02:48

controversial question: I want to include something like: (define-key clojure-mode-map (kbd "M-r") (cider-interactive-eval "(dev-extras/reset)")) in the emacs guide, so, what is a good key, and how do I do this properly?

cichli13:02:40

well IMO the current keybinds situation is a bit of an untenable mess and there aren’t any good ones left… maybe it would fit in cider-ns-map if it’s conceptually similar to cider-ns-refresh

cichli13:02:47

cider-ns-map is prefixed C-c M-n by default

cichli13:02:41

You could also recommend customising cider-ns-refresh-before-fn or cider-ns-refresh-after-fn if it makes sense to run reset before/after a tools.namespace reload

dpsutton13:02:16

i wonder if we could do a pass where we remove lots of keybindings and open up something for users to have a place to assign stuff. I know that I only use like 10 or so keybindings.

dominicm14:02:37

@cichli thanks for the tip, I'm going to add that as a default to the .dir-locals in edge 🙂

dominicm14:02:17

controversial: I don't think there should be a keybinding for cider-jack-in-clj&cljs. You do it once a day at most 😛

cichli14:02:20

Or a single keybinding for something like cider-jack-in-command, which could be configurable to use either CLJ, CLJS, or both

dominicm14:02:20

yeah, that's a good point

dominicm14:02:32

there's no reason edge users should have to think about which

dominicm14:02:54

I would like to see a common .dev.edn though, as I have the same problem when launching clj and rebel and vim, etc.

dominicm14:02:04

maybe something for orchard to discuss

cichli16:02:40

It’s an interesting idea, and we can parse edn in emacs lisp now (not sure about vim though)

cichli16:02:40

I had a look at your Edge PR: one other option you could mention or include a default for is cider-repl-init-code. This is a list of strings of code to execute at REPL init – for example you could do:

(add-to-list 'cider-repl-init-code "(dev)")

cichli16:02:09

Or just set it to '("(dev)")

dominicm16:02:58

A default is good. Will do that.

dominicm16:02:12

How does init code play with cljs jack in?

cichli17:02:22

Should run in the Clojure session before the CLJS REPL is started

dominicm21:02:02

I can't seem to do add-to-list in .dir-locals.el

dominicm21:02:16

well, I could do it with eval, but that will never be marked safe 🙂

dominicm21:02:45

the repl-init-code isn't working for me 😕

cichli22:02:00

Ah, there’s a bug, in-ns has no effect in cider-repl-init-code! We ignore ns in the response when we eval it

cichli22:02:29

and yeah, I think eval is the only way to do that 😕

dominicm22:02:25

Are you on the bug or shall I report it? :)

cichli22:02:42

At least if you mark it as safe, it only marks the exact form as safe, not eval generally

cichli22:02:51

I’m taking a look, thanks though 🙂

dominicm22:02:09

Okay great :)

dominicm22:02:39

My colleague has been bothering me about this forever, so it will be nice to resolve it

cichli22:02:41

You can parse that markdown manually 😛

dominicm06:02:20

here's the interesting thing: the cljs repl runs the init code too 🙂 I put the emacs cljs repl function in user, that's okay though 🙂

dominicm06:02:57

the fix is working though, thanks! 🙂 making that part of edge now

cichli10:02:36

Probably best to fully qualify the cljs repl function anyway

cichli10:02:47

Since there’s also :init-ns in Leiningen’s :repl-options

cichli10:02:12

So we can’t be sure the initial namespace is user generally

dominicm10:02:00

hmm, I'm noticing a bit of a race condition between cider-repl-init-code and cider-cljs-repl-types I think.

dominicm10:02:13

probably because both repls are running (require 'dev) simultaneously.

dominicm10:02:09

(locking o (require 'dev))

cichli10:02:07

There is a fn in core for that in 1.10

cichli10:02:49

I’ll see if we can make sure that waits for init to be done first

dominicm10:02:13

I think it's actually that init is called in the clj and pending-cljs repl simultaneously.

dominicm10:02:41

yeah, they made it private. For our needs though having our own locking is fine.

cichli10:02:09

Yeah you’ll need the locking either way, because of the two simultaneous REPLs

cichli10:02:49

But I’m testing a change that lets the evaluation of cider-repl-init-code finish before proceeding with the rest of connection init

dominicm10:02:34

That's cool, thanks 🙂

dominicm14:02:22

or even cider-quit.

dpsutton14:02:25

i think cider-quit is a bit too strong and can sometimes take other existing connections out of cider-mode

cichli14:02:07

I haven’t really looked at how clj/cljs sessions are managed since it was moved into a separate library. It’s not an easy problem

richiardiandrea18:02:03

is there a way to output all the messages in nrepl if I start it from the terminal? I have seen that there is a PR for verbose logging but I wonder if we have something already in there I am missing

cichli18:02:22

Messages as in nrepl requests/responses? In CIDER you can set nrepl-log-messages, but there’s nothing in nrepl itself for that atm

richiardiandrea19:02:36

@cichli ok thanks!