Re: Emacs vs pg_indent's weird indentation for function declarations
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>,
Michael Paquier <michael@paquier.xyz>
Date: 2019-05-15T04:43:10Z
Lists: pgsql-hackers
Attachments
- wip-handle-multiline-function-declarations.patch (text/x-diff) patch
Thomas Munro <thomas.munro@gmail.com> writes: > I tried teaching pgindent's post_indent subroutine to unmangle the > multi-line declarations it mangles. That produces correct > indentation! But can also produce lines that exceed the column limit > we would normally wrap at (of course, because pg_bsd_indent had less > whitespace on the left when it made wrapping decisions). Doh. > Attached for posterity, but it's useless. > So I think pg_bsd_indent itself needs to be fixed. I think I know > where the problem is. lexi.c isn't looking far ahead enough to > recognise multi-line function declarations: 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. I'm a bit surprised that -bc doesn't cause that to happen, but it doesn't (and I'm not sure we'd really want to force one-parameter-per-line, anyway). Anyway, the attached hasty-and-undercommented change to pg_bsd_indent allows removal of the "Move prototype names to the same line as return type" hack in pgindent, and we then get prototypes with properly lined-up arguments, but we'll have a lot of places with over-length lines needing manual fixing. Unless somebody wants to find where to fix that in pg_bsd_indent, but I've had my fill of looking at that spaghetti code for today. regards, tom lane
Commits
-
Phase 2 pgindent run for v12.
- 8255c7a5eeba 12.0 landed
-
ANSI-ify a few straggler K&R-style function definitions.
- da71f98efba9 12.0 landed