Fork me on GitHub
#cider
<
2023-10-13
>
jrychter09:10:58

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.

vemv09:10:23

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)

jrychter09:10:47

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

jrychter09:10:28

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}]

jrychter09:10:39

Well, slack mangles indentation beyond recognition. So, in pictures: this is correct

jrychter09:10:54

And this is what I get after cider-connect:

jrychter09:10:23

I can't figure out what recent change caused this behavior.

vemv09:10:41

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!

vemv09:10:44

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.

jrychter09:10:15

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.

vemv09:10:46

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

jrychter09:10:26

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.

jrychter09:10:34

Do you mean alter-meta! ?

vemv09:10:20

If you want to revert, use CIDER 1.7.0 and cider-nrepl 0.30.0 (as bundled with 1.7.0)

jrychter09:10:09

I think I'll revert. This is quite a bit more involved than it seems.

jrychter09:10:52

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

jrychter09:10:17

But I wonder why this happened today, the only thing I upgraded today was clojure-mode from MELPA.

vemv09:10:38

dev/user.clj, it's pretty standard to have a dev profile that doesn't impact other compilation targets

vemv09:10:51

> But I wonder why this happened today, the only thing I upgraded today was clojure-mode from MELPA. Most likely it's cider-nrepl

jrychter09:10:21

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.

jrychter09:10:40

I did not upgrade cider-nrepl today. Nor cider, for that matter. Only clojure-mode.

jrychter09:10:26

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.

vemv09:10:46

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!

jrychter09:10:17

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.

👍 1
vemv09:10:57

There are options. We can continue later (or over GH)

jrychter09:10:41

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.

jrychter09:10:19

So it's not just about rum macros not having indent information, something else must have changed.

vemv09:10:37

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

jrychter10:10:53

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.

vemv10:10:23

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.

vemv10:10:22

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)

jrychter08:10:33

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!

vemv18:10:36

Today's a great day 🍎🍏

🎉 11
gratitude 6
cider 5
César Olea19:10:38

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.

vemv19:10:43

Gracias, César 🤝

nivekuil20:10:58

@U45T93RA6 thanks for the massive amount of work you've done for us 🙂

❤️ 1
Akiz07:10:38

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?

vemv11:10:47

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.

👍 1
vemv18:10:42

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 cider

Carsten Behring19:10:25

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

Evan Bernard19:10:12

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

3
dpsutton19:10:24

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

2
dpsutton19:10:02

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

practicalli-johnny13:10:49

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

dpsutton15:10:53

It prints it at the top of the repl too. To remove “the magic”. You can see it’s just a startup command