On Tue, Nov 22, 2016 at 07:03:02PM +0100, Daiki Ueno wrote:
> For what it's worth, I wrote such elisp some time ago:
>
http://elpa.gnu.org/packages/gnome-c-style.htmlCool, added to:
https://wiki.gnome.org/Newcomers/Tools-C-language> If anyone is trying to implement the feature somewhere, I would suggest
> to provide two separate scripts or commands to do the job: (1) guess the
> alignment rule somehow, e.g. from the existing C code, and (2) do the
> actual formatting. That would be helpful to avoid unnecessary
> formatting changes when creating a patch for existing projects.
Why two separate scripts? A single script can have two passes.
I think I'll write a new script like I did for lineup-parameters, so
that it can be integrated in Vim or Emacs or other text editors (it just
reads stdin and write to stdout, or optionally takes file arguments).
For the script, the first pass - to determine the columns where to do
the alignment - could have two modes: "re-align everything" and "minimal
perturbation". For the minimal perturbation, it would look which columns
are used the most, and fix the functions that are not aligned to those
columns.
Also, in the GNOME convention there is something that I don't like and
that I would prefer not to do: aligning all the parameter names on the
same column (the third column). I prefer aligning the parameter names
for each function separately, IMHO it's more readable. Because
otherwise, for some functions, there can be a big empty space between
parameter types and their names, which doesn't help readability (caused
by a long type in another function).
--
Sébastien