genemichaels icon indicating copy to clipboard operation
genemichaels copied to clipboard

Preserve block-level newlines

Open andrewbaxter opened this issue 2 years ago • 3 comments

As an option, on by default, per https://github.com/andrewbaxter/genemichaels/issues/29#issuecomment-1364574276

andrewbaxter avatar Dec 30 '22 09:12 andrewbaxter

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

Billy-Sheppard avatar Feb 03 '23 03:02 Billy-Sheppard

Yeah, rules like that would work! Right now I already have (I think) two rules:

  1. Blank lines around struct{}/enum{}/union{} definitions
  2. Blank lines around groups of use statements

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.

andrewbaxter avatar Feb 03 '23 06:02 andrewbaxter

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.

Billy-Sheppard avatar Feb 05 '23 22:02 Billy-Sheppard

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.

andrewbaxter avatar Oct 01 '24 00:10 andrewbaxter