From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
Cc: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Michael Paquier <michael(at)paquier(dot)xyz> |
Subject: | Re: Emacs vs pg_indent's weird indentation for function declarations |
Date: | 2019-05-15 21:17:01 |
Message-ID: | 9170.1557955021@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I wrote:
> I experimented with fixing this. I was able to get pg_bsd_indent to
> distinguish multi-line function declarations from definitions, but it
> turns out that it doesn't help your concern about the lines being too
> long after re-indenting. Contrary to what you imagine above, it seems
> pg_bsd_indent will not reflow argument lists, regardless of whether it
> thinks there needs to be more or less leading whitespace.
Actually, now that I think about it, pgindent seldom revisits line-break
decisions in code anyway; it's only aggressive about reflowing comments.
So maybe we shouldn't be expecting it to fix this.
Also, looking at sample results (attached), it seems like we don't have
such a large problem as one might guess. It looks like people have
mostly formatted declarations to work with this indentation already,
either because their editors did it automatically, or because they were
thinking that this might get fixed someday. (I know I've often had that
in the back of my mind.) There are some places in the attached diff
that I might take the trouble to clean up manually, but not that many.
I found out that my initial draft of a multi-line lookahead function was
not nearly smart enough to survive contact with the PG source corpus,
but after rejiggering it to cope with comments and attributes, it seems
to do quite well.
A small problem with the "rejiggering" is that it now makes the wrong
choice for K&R-style function definitions, causing them to be weirdly
indented. For our purposes, that's a non-problem so I'm not excited
about trying to make it smart enough to recognize those. We do have
a couple of amazingly old and crufty K&R-style functions in src/port/,
though, so probably we'd wish to fix those.
Attached is working draft of pg_bsd_indent changes (still sans comments)
as well as a patch showing the difference between current pgindent
results on HEAD and the results of this version. I think there's no
question that this is an improvement.
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
bsdindent.patch | text/x-diff | 5.9 KB |
indent-delta-results.patch.gz | application/x-gzip | 245.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Munro | 2019-05-15 21:26:47 | Re: Emacs vs pg_indent's weird indentation for function declarations |
Previous Message | Tomas Vondra | 2019-05-15 19:58:01 | Re: Replace hashtable growEnable flag |