Fork me on GitHub
#cider
<
2023-10-23
>
respatialized19:10:36

What's the easiest way to interactively pass the result of a cider evaluation to an elisp function (as a string)?

vemv19:10:19

(cider-nrepl-sync-request:eval "(+ 1 2)")

1
mikerod22:10:43

I’ve ran into some trouble with “indentation inference” now too, as mentioned several times here now. It became a bit problematic in some codebases that I work in that macro forms started to indent at different levels than before. Adding alter-meta! to all of these cases is a fairly tedious and brittle task I’d say too. Perhaps I can move past that though, but one thing that still bothers me about it is that indentation works differently in a clj/cljs/cljc buffer if I have a REPL running vs not. I think this is quite confusing since the indentation will move around depending on this state. What if someone were to just want to format a file statically without running things? Lastly, I’ve noticed that the indentation inference doesn’t seem to happen in the actual REPL buffer running with cider-mode?. It only seems to affect the clj/cljs/cljc buffers that have clojure-mode. I thought that was quite odd/confusing when I first encountered since I’d think something “dynamic” coming from cider runtime state would be more likely to affect a cider buffer than not.

vemv06:10:20

> Adding alter-meta! to all of these cases is a fairly tedious and brittle task I’d say too. If it's your code, it should be declared as :style/indent - as we always have expected over the years! If not, alter-meta! is only suggested as a temp patch. The actual desired endgame is that libs get improved upstream for everyone (which not only includes CIDER users, but also clojure-lsp users since it also understands :style/indent). > indentation works differently in a clj/cljs/cljc buffer if I have a REPL running vs not. This has been the case with CIDER since, approximately. forever :) I get that it can be frustrating though, so I created https://github.com/clojure-emacs/cider/issues/3401 > Lastly, I’ve noticed that the indentation inference doesn’t seem to happen in the actual REPL buffer running with cider-mode?. I can take a look at it.

mikerod13:10:17

Thanks I appreciate the feedback and the follow-up issue looks good.

👍 1
mikerod13:10:56

And indeed my problems come from other libs so far. So just have to work with those for now.

vemv13:10:54

Does the inference look off for your case? Feel free to provide a screenshot + the macro in question Generally inference works well by now but I'd be interested in edge cases

mikerod19:10:43

In my case it just made the body of a macro go from indenting 1 space to 2 spaces. Aesthetically this isn’t a big deal. The issue is just that we wanted to avoid indentation changing/thrash across dev env’s on our large codebase that uses this macro often.

mikerod19:10:20

The macro in question that came up the most was a re-frame testing macro. It now does 2 indentations for the body since it’s signature is & body.

mikerod19:10:40

And as I’ve mentioned, when the repl is not connected, we get 1 indentation due to the inference not being on.

vemv19:10:31

But would you find the produced indentation wrong, when comparing it with similar macros? [& body] would sound like a 2-space indent macro to me. If you prefered no-churn diffs over idiomatic indentation, I'd kind of understand it but for us, producing the right result always comes first.

vemv19:10:16

The ideal result for the average team is that you'd add style/indents here, maybe a cljfmt config there, and have stuff look better than before

mikerod15:10:34

Fair enough. And yeah, I think that 2-space indent seemed to be what I saw happen most of the time anyways, so I wasn’t strongly against it becoming 2 spaces. I just didn’t like the churn and confusion it brought this time around. At least it is understood now and I think indeed a general solution is to use some sort of auto formatting in builds to make sure everyone remains consistent. And of course use :style/indent more often for cases we want adjustments for.

👍 1
mikerod15:10:41

Is it still possible to setup emacs elisp sort of rules to override indentation inference of certain macros?

mikerod15:10:59

via define-clojure-indent

vemv16:10:39

It's not possible, CIDER's rules always override clojure-mode's. There's no internal distinction between inferred and defined

😮 1
vemv16:10:22

As always, you can :style/indent your way into avoiding inference > At least it is understood now and I think indeed a general solution is to use some sort of auto formatting in builds to make sure everyone remains consistent. Yes, lein cljfmt check or so is a common sight in teams' CIs. If you run it through clojure-lsp's https://clojure-lsp.io/api/api/ / CLI, it will honor :style/indent

👍 1