Re: Run pgindent now? - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: Run pgindent now?
Date
Msg-id 5565EDD2.4050304@dunslane.net
Whole thread Raw
In response to Re: Run pgindent now?  (Bruce Momjian <bruce@momjian.us>)
List pgsql-hackers
On 05/27/2015 11:53 AM, Bruce Momjian wrote:
> On Wed, May 27, 2015 at 02:31:07AM +0200, Andres Freund wrote:
>> But really, the typedef list is the minor part what annoys me about
>> pgindent. That it completely butchers so many constructs (e.g. function
>> pointer typedefs, inline asm as extreme examples) is much worse. It's
>> also neigh on impossible to predict/keep the indentation pgindent will
>> use in many cases.  Having to try to write code in a way that doesn't
>> break the re-indentation tool, even if it'd otherwise be fine, is just
>> absurd.
> What does "break" mean here?  Considering we are indenting 1.4M lines of
> code, skipping ASM files seems pretty minor.
>


That's not a bad bit of perspective.

One thing that might ease some pain would a facility to tell pgindent to 
leave a block of code alone. That wouldn't be terribly hard to create. 
The perl code could save those blocks out in the pre_indent function, 
which would return them along with the source. they would then be passed 
to the post_indent function which would restore them. All we would need 
would be a pair or markers to delimit such blocks. Something like:

/* PGINDENT_PRESERVE */
and
/* PGINDENT_END_PRESERVE */

should do the trick.

I imagine we could probably do this in 50 lines of perl or less.

Worth the trouble?

cheers

andrew




pgsql-hackers by date:

Previous
From: Alexander Korotkov
Date:
Subject: Re: PGCon hacker lounge
Next
From: Robert Haas
Date:
Subject: Re: [COMMITTERS] pgsql: Add pg_audit, an auditing extension