Re: Script to format the functions in a C header?

Can someone tell me what is wrong with using the indent program?
man indent for details
 The indent program can be used to make code easier to read.  It can also convert from one style of writing C to another.

       indent understands a substantial amount about the syntax of C, but it also attempts to cope with  incomplete  and  misformed

       In version 1.2 and more recent versions, the GNU style of indenting is the default.


Leslie Satenstein
Montréal Québec, Canada

From: Sébastien Wilmet <swilmet gnome org>
To: desktop-devel-list gnome org
Sent: Wednesday, November 23, 2016 8:03 AM
Subject: Re: Script to format the functions in a C header?

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:

Cool, added to:

> 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

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


desktop-devel-list mailing list
desktop-devel-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]