fortran-lang / fprettify

auto-formatter for modern fortran source code
https://pypi.python.org/pypi/fprettify
Other
370 stars 76 forks source link

Enabling indentation prevalence over line-length #95

Closed bclmary closed 3 years ago

bclmary commented 3 years ago

Hy, This is a proposition of enhancement related to line length control. If the following is already available with another option, please just let me know.

There is some cases where a very long line is not easily splittable (by easely, I mean with an easy to read result). In my case, it is long strings used for outputs. The current behavior of fprettify in such case is to sacrifice indentation to preserve the line-length directive. I would like to obtain the reverse : preserve indentation by sacrificing the line-length limitation. I tried the --strict-indent option, but it seems it was introduce for other purpose.

My proposition is to add line-length prevalence for non splittable lines in the --strict-indent option.

pseewald commented 3 years ago

This can be controlled with the option (see fprettify -h)

  -l LINE_LENGTH, --line-length LINE_LENGTH
                        column after which a line should end, viz. -ffree-
                        line-length-n for GCC (default: 132)

Unlimited line length can be achieved with ./fprettify.py -l 0.

bclmary commented 3 years ago

I should have pointed out that I already use the line length control option -l. The request concerns the behavior of this option. For now, when a line is too long and the line length is specified, the indentation is sacrificed to keep the line length. I ask for a way to preserve indentation in such cases (prevalence of indentation over line length)

pseewald commented 3 years ago

Prevalence of indentation over line length is equivalent to unlimited line length for how fprettify is working. Imposing line length affects nothing else but indentation. For instance, lines that are too long (irrespective of indentation) are not split by fprettify. Therefore I do think -l 0 is exactly what you need.

bclmary commented 3 years ago

Ok, I thought fprettify was cutting at least some lines too long. My bad.