Fork me on GitHub
#cursive
<
2022-07-17
>
Ernesto Garcia20:07:40

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

imre08:07:24

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

Ernesto Garcia08:07:23

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.

imre08:07:29

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?

Ernesto Garcia08:07:32

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.

Ernesto Garcia08:07:33

I don't rely on automatic formatting of Clojure code. Indentation is part of the way I express code.

imre08:07:40

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

Ernesto Garcia09:07:28

That would depend on the expectations. From my pov, one wouldn't expect barf and slurp to change the format of existing nested forms.

isak14:07:05

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.

Ernesto Garcia15:07:45

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

octahedrion06:07:53

I wish Cursive didn't reformat my code after structural editing too