This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
Is there a way to prevent that nested forms change indentation when barfed in, or slurped out? Like in:
(if (neg? i)
())
(cons (get s i)
(rec s (dec i)))
After barfing at the if
form:
(if (neg? i)
()
(cons (get s i)
(rec s (dec i)))) ; <-- re-indented
I think that’s because Cursive reformats modified code after the slurp. If the above one is your preferred formatting for cons, you can set its indentation to “Function” I believe to keep it after reformats
I choose the proper indentation based on the function used, or on the context sometimes. I would want Cursive to respect the existing indentation. There is no reason to change it.
What would you expect to happen in this case when you ask idea/cursive to reformat the file? Or would you just avoid using that action altogether?
Thank for your suggestion though. That might help me most of the time, if I configure the functions for which I typically use aligned parameters.
I don't rely on automatic formatting of Clojure code. Indentation is part of the way I express code.
Just asking as this sounds like a feature request and it would be great to get most of it right on the first try in case it’s implemented
That would depend on the expectations. From my pov, one wouldn't expect barf and slurp to change the format of existing nested forms.
You are going against the grain here, I wouldn't expect this to change. Paredit isn't really about artistic code freedom, it is more like the opposite.
I think it is quite valuable for these structural editing operations to preserve existing code layout as much as they can, both for the case of intentional deviations from the formatting rules currently set at the IDE, and for the maintenance of existing code for which we don't want to introduce collateral formatting changes. This doesn't go against applying automatic reindents when needed. Those may be done explicitly anytime. (In my experience this is an extremely rare operation. Basically, I never need to do it when using Clojure).
I wish Cursive didn't reformat my code after structural editing too
I opened https://github.com/cursive-ide/cursive/issues/2716. You may want to support it.