Emacs vs pg_indent's weird indentation for function declarations

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Emacs vs pg_indent's weird indentation for function declarations
Date: 2019-01-27 22:10:33
Message-ID: CAEepm=0P3FeTXRcU5B2W3jv3PgRVZ-kGUXLGfd42FFhUROO3ug@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

Using either the .dir-locals.el settings or the "more complete"
src/tools/editors/emacs.samples, I have never convinced Emacs to
produce multi-line function declarations in .h files that satisfy
pg_indent.

For example, latch.c has the following definition:

int
WaitEventSetWait(WaitEventSet *set, long timeout,
WaitEvent *occurred_events, int nevents,
uint32 wait_event_info)

And now let's see the declaration in latch.h:

extern int WaitEventSetWait(WaitEventSet *set, long timeout,
WaitEvent *occurred_events, int nevents,
uint32 wait_event_info);

(I replaced all tabs with four space here; if you're reading in a
monospace font, you'll see that the first arguments off all lines
begin in the same column in the definition by not in the declaration.)

For a while I've been baffled by that: the first arguments of later
lines don't line up with that of the first line, but they're also not
in a constant column (it varies from function to function), and it's
also not caused by 8-space vs 4-space confusion. It was only when I
put those two things next to each other just now in this email that I
finally spotted the logic it's using: if you remove "extern int " then
the later lines line up with the first argument of the top line. This
works for other examples I looked at too. Huh.

That's ... annoying. I wish indent wouldn't do that, because it means
that my declarations get moved around every time I write code. But if
it's not possible to change that for whatever technical or political
reason, I wonder if it's possible to teach Emacs to understand that
weird rule...

--
Thomas Munro
http://www.enterprisedb.com

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2019-01-27 22:28:39 Re: FETCH FIRST clause PERCENT option
Previous Message John Naylor 2019-01-27 21:03:22 Re: WIP: Avoid creation of the free space map for small tables