Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gnzTO-0005SW-3m for pgsql-hackers@arkaria.postgresql.org; Mon, 28 Jan 2019 05:28:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gnzTL-00017A-Fp for pgsql-hackers@arkaria.postgresql.org; Mon, 28 Jan 2019 05:28:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gnzTL-00015N-7K for pgsql-hackers@lists.postgresql.org; Mon, 28 Jan 2019 05:28:39 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gnzTI-0001EL-JR for pgsql-hackers@postgresql.org; Mon, 28 Jan 2019 05:28:38 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x0S5SUue007660; Mon, 28 Jan 2019 00:28:30 -0500 From: Tom Lane To: Thomas Munro cc: Pg Hackers Subject: Re: Emacs vs pg_indent's weird indentation for function declarations In-reply-to: References: Comments: In-reply-to Thomas Munro message dated "Mon, 28 Jan 2019 11:10:33 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <7658.1548653310.1@sss.pgh.pa.us> Date: Mon, 28 Jan 2019 00:28:30 -0500 Message-ID: <7659.1548653310@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thomas Munro writes: > 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. Yeah. I suspect that the underlying cause is that pgindent doesn't really distinguish function declarations from definitions, at least not when it comes time to indent the lines after the first one. > That's ... annoying. I wish indent wouldn't do that, because it means > that my declarations get moved around every time I write code. If you can fix it, I'd vote for accepting the patch. I don't personally have the desire to dig into the indent code that much ... regards, tom lane