This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-23
Channels
- # aws-lambda (2)
- # beginners (40)
- # calva (9)
- # cider (17)
- # clojure (84)
- # clojure-europe (13)
- # clojure-nl (1)
- # clojure-norway (77)
- # clojure-uk (26)
- # conjure (1)
- # cursive (7)
- # datomic (7)
- # events (1)
- # exercism (1)
- # gratitude (2)
- # hyperfiddle (4)
- # improve-getting-started (10)
- # jobs-discuss (12)
- # malli (4)
- # missionary (12)
- # off-topic (22)
- # other-languages (4)
- # pedestal (3)
- # portal (6)
- # reagent (6)
- # reitit (1)
- # releases (1)
- # ring (4)
- # shadow-cljs (2)
- # thejaloniki (2)
- # tools-build (27)
- # tools-deps (4)
- # vim (6)
What's the easiest way to interactively pass the result of a cider
evaluation to an elisp function (as a string)?
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.
> 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.
And indeed my problems come from other libs so far. So just have to work with those for now.
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
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.
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
.
And as I’ve mentioned, when the repl is not connected, we get 1 indentation due to the inference not being on.
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.
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
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.
Is it still possible to setup emacs elisp sort of rules to override indentation inference of certain macros?
It's not possible, CIDER's rules always override clojure-mode's. There's no internal distinction between inferred and defined
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