genemichaels
genemichaels copied to clipboard
Preserve block-level newlines
As an option, on by default, per https://github.com/andrewbaxter/genemichaels/issues/29#issuecomment-1364574276
So I've been thinking a bit more on this and someone suggested another way this could be handled is enforcing block-level newlines (code paragraphing) rules in a specific way rather than letting the user put them anywhere.
For example:
- Newline before and after every closure
- Newline after every 3rd let binding
- Newline after every multi-line let binding
- Newline before every return value
Yeah, rules like that would work! Right now I already have (I think) two rules:
- Blank lines around
struct{}/enum{}/union{}definitions - Blank lines around groups of
usestatements
which are pretty uncontroversial. Would you specifically use any of your examples?
TBH I'm still thinking about this... I think preservation could work, but I'd probably have it off by default since it would reduce determinism. It would be better than hundreds of rules with one user each, if I can't identify any common rules.
Those two rules you listed are must-haves imo but they don't really relate to code paragraphing, which is most noticeable within function/closure/general code block bodies.
Those 4 I listed were mainly thinking out loud although I do think 1, 3, and 4 are pretty common for my workflows.
Oh hey, I think I actually did implement this at some point: keep_max_blank_lines in the readme. If not I can investigate further, but closing for now.