This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-13
Channels
- # ai (5)
- # announcements (4)
- # babashka (34)
- # beginners (78)
- # biff (6)
- # calva (41)
- # cider (47)
- # clerk (1)
- # clj-commons (3)
- # clj-http (1)
- # clojure (72)
- # clojure-europe (51)
- # clojure-nl (1)
- # clojure-norway (87)
- # clojure-romania (1)
- # clojure-uk (5)
- # clojuredesign-podcast (2)
- # community-development (1)
- # conjure (2)
- # cursive (11)
- # datomic (6)
- # docker (4)
- # emacs (13)
- # exercism (20)
- # hyperfiddle (56)
- # matrix (6)
- # membrane (4)
- # nbb (11)
- # off-topic (88)
- # pathom (7)
- # pedestal (1)
- # polylith (20)
- # portal (16)
- # practicalli (1)
- # re-frame (13)
- # reagent (4)
- # reitit (2)
- # remote-jobs (7)
- # shadow-cljs (49)
- # sql (4)
My indentation for rum/defc
and rum/defcs
forms broke today and I'm pulling my hair out trying to find out why. I did a MELPA upgrade of clojure-mode to 5.17.1 today, I think I was on 5.17.0 before, but I can't find anything that could cause this. My forms are indented correctly until I load them in CIDER, at which point they get plenty of extra indentation.
Hey! It's https://docs.cider.mx/cider/indent_spec.html#indentation-inference Could you please point at the defc source? Most likely it's missing style/indent metadata (which is what we always expected to be declared)
And it's something tied to CIDER, because the moment I cider-quit
, I am back to normal (e.g. what worked for the last 8 years).
Well, this is the source: https://github.com/tonsky/rum/blob/45ca02046aa9e0b13eca6db7ec4e3fc7dcc9f95d/src/rum/core.clj#L71 — but I don't think I can expect all libs to be changed. Also, I'm confused about why this worked for the last 8 years and suddenly changed now. This is what I consider "correct":
(rum/defcs form-component < rum/static (mixins/local-nofirstrender {})
;; Are we sure that :rum/local exists at this point in :init? Yes, we are, because we do not use rum/local,
;; but our own mixin, which does its work in the :init phase.
{:init (fn [{local-state :rum/local
[initial-model-data xforms _ initial-metadata _ options] :rum/args
:as state}]
And this is what I get after I cider-connect
:
(rum/defcs form-component < rum/static (mixins/local-nofirstrender {})
;; Are we sure that :rum/local exists at this point in :init? Yes, we are, because we do not use rum/local,
;; but our own mixin, which does its work in the :init phase.
{:init (fn [{local-state :rum/local
[initial-model-data xforms _ initial-metadata _ options] :rum/args
:as state}]
Well, slack mangles indentation beyond recognition. So, in pictures: this is correct
We introduced a feature (https://docs.cider.mx/cider/indent_spec.html#indentation-inference) based on our observations and what we'd like things to be like. Note that not only CIDER honors style/indent metadata, but also clojure-lsp so it's a pretty big win in terms of standardization!
If you feel frustrated I'd understand that btw, note that adding the metadata (with alter-var-meta, until a commit is added upstream) should take you a few minutes. I'll be happy to help.
Hey, I'm all for standardization, but at the moment I have this code base of 10k lines (my SaaS) that I need to work on to pay the bills, so I'm looking to quickly find out which recent change caused this and revert it.
Please add (alter-var-meta #'rum/defc assoc :style/indent <some value that works>)
in user.clj, it doesn't take more than a few mins
Sorry if this comes across as harsh, it's just my reality at the moment: I really can't afford to spend time on this right now.
(to begin with, there is no good place to put this in a huge app that is being compiled in various ways and that I cider-connect to)
But I wonder why this happened today, the only thing I upgraded today was clojure-mode from MELPA.
dev/user.clj
, it's pretty standard to have a dev profile that doesn't impact other compilation targets
> But I wonder why this happened today, the only thing I upgraded today was clojure-mode from MELPA. Most likely it's cider-nrepl
As a side note, I did set :style/indent
on my own macros for quite some time now. And it worked. But something changed the formatting of Rum macros recently.
Ok, I give up. I'm trying, but I have no idea whether my alter-meta! works at all, the behavior doesn't seem to change. I also have no idea what the "right" settings are, and I can't spend much time on this… I think I'll just have to cider-quit
every time before final formatting and committing.
You could always run cljfmt or such right before committing as it would be a less dramatic measure Anyway, feel free to get back at this thread anytime. Personally I can't work with the "has to work right now" constraint, I also have stuff to do Have a great one!
Oh, to be clear, I'm not "demanding" this to be fixed immediately 🙂 (although I've been a noticeable CIDER sponsor for many years now). Just looking realistically at what my options are.
What could be a data point is that none of my attempts at setting :style/indent
for rum macros work, but also :style/indent
from my other macros stopped working. Something that worked for a while now.
So it's not just about rum macros not having indent information, something else must have changed.
> but also :style/indent from my other macros stopped working. That would be a severe problem, feel free to create a detailed issue, including an example of the macro.
Ok, I've spent some time on this and I'm totally confused and I think I have to give up. Here's what I'm seeing:
• Start with fresh Emacs, indentation is OK for rum macros, but wrong for my macros.
• cider-connect
and indentation for rum macros breaks, but my macros are now indented correctly.
• do (alter-meta! #'rum.core/defcs assoc :style/indent :defn)
in the REPL and rum/defcs macros are now indented correctly, rum/defc macros are not
• do (alter-meta! #'rum.core/defc assoc :style/indent :defn)
in the REPL and rum/defc macros are still not indented correctly, e.g. no change in behavior for rum/defc; rum/defcs is still OK.
• cider-quit
and cider-connect
again and both rum/defc and rum/defcs macros are indented correctly
It almost seems like there is some sort of per-namespace caching going on. I don't understand this, and I can't spend any more time on it. Just wanted to point out that something must have changed recently that caused all this. For the last 8 years I've been looking at correctly indented Rum macros, and I upgrade CIDER, cider-nrepl and clojure-mode regularly. This broke today, and the only thing I upgraded today was clojure-mode to 5.17.1.
I know that something has changed, because we changed it, with code review and tests. There's indeed per-ns caching, as there's always been. tbh I don't want to further spend time in this thread. It's frustrating to see intermittent interest in having this truly solved - either you have "given up" or not. Hypotheses and partial info are not useful to me. However I'll be happy to provide support via our primary means, namely Github, which ensures that we have all the context we need.
in the REPL I suggested to do this in user.clj which has the special semantic of being executed before anything else.
In user
, require rum, perform the alter-meta! and caching will be irrelevant
Restart your JVM just this time, to discard any current caching.
(I'll try to add this to our docs)
I'm sorry if my interest came across as "intermittent". It very much isn't. I live in CIDER. I spend most of my working hours in it and thanks to it I can make a living. I just have to juggle priorities, so sometimes I have to report something and just hope for the best. And the latest releases fixed all of my issues beautifully: no more indentation issues!
Congrats to the whole CIDER team for their new release and thank you for your efforts! CIDER is an awesome development environment that I enjoy using both for professional and personal projects.
I noticed that with enrich-classpath repl takes much longer to start. Does it have any effect on performance even when it is turned on?
No, it has zero effect, since it only adds stuff to the classpath, there's no runtime effect
Note that enrich has a built-in layer of caching. One can use further caching by using the cider-connect
-friendly https://github.com/clojure-emacs/enrich-classpath#any-lein-or-toolsdeps-project.
In a future we'll automate this caching for cider-jack-in
too.
If you've experienced issues with enrich-classpath or indentation inference, please make sure to use CIDER latest (master / 1.8.0 stable / <tel:202310131425|20231013.1425> snapshot).
Those (and others) have been improved very frequently based on your gracious feedback
Is there a way in Cider to "copy/paste" the command which would be use by CIDER for cider-jack-in
? This could be very useful in "sending" jack-in commands into an remote shell opened in Emacs
what I’ve done before is C-u M-x -jac
, which gives me the ability to edit the jack-in command. but, in your case, rather than edit the command, you’d just select it all while in the mini-buffer
there’s a https://clojurians.slack.com/archives/C0617A8PQ/p1688529209320339 above with some solutions. I don’t think anyone made an issue so you should
it’s not hard (i don’t think). just needs to be issue-ed so it gets done. I think it’s a great feature
I opened issue for it: https://github.com/clojure-emacs/cider/issues/3519
After being called, the jack-in command is also sent to the *messages*
buffer from where it can be seen, a useful way to check if custom configuration from .dir-locals.el
, e.g. including Clojure CLI aliases