Re: pg_bsd_indent: implement -lps ("leave preprocessor space")

From: Antonin Houska <ah(at)cybertec(dot)at>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_bsd_indent: implement -lps ("leave preprocessor space")
Date: 2017-02-09 09:45:56
Message-ID: 7701.1486633556@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)anarazel(dot)de> wrote:

> On 2017-02-07 23:30:44 -0500, Tom Lane wrote:
> > Piotr Stefaniak <postgres(at)piotr-stefaniak(dot)me> writes:
> > > this is a patch that Andres asked me for. It makes pg_bsd_indent leave
> > > preprocessor space alone, as in this example:
> >
> > > #if 0
> > > # if 0
> > > # if 0
> > > # error
> > > # endif
> > > # endif
> > > #else
> > > # line 7
> > > #endif
>
> For context: I'd asked Piotr how dificult it'd be to add this.
>
> > Um ... but the point of pgindent is to standardize spacing, not to let
> > people invent their own style. If you wanted to have a discussion about
> > whether pgindent should force preprocessor directives to look like the
> > above, we could talk about that. But I do not want to be reading code that
> > looks like the above in one place and code that does not ten lines away.
>
> I don't think that's something easily done in an automatic
> manner. Because you'd e.g. obviously not want to indent everything
> within include guards. I don't really buy the danger of large
> divergances in code nearby - this seems mostly useful when writing a bit
> more complicated macros, and I don't think they'll be that frequently
> added in existing files.
>
> I do think this makes the nesting for #ifdefs a *lot* more readable, and
> we have plenty of cases where it's currently really hard to discern what
> "branch" one is currently reading. Allowing to opt-in into the "newer"
> formatting in places where it makes sense, seems reasonable to me.

As an alternative approach, the formatting can be implemented in elisp and
added to src/tools/editors/emacs.samples. In particular I mean one function to
make the code human readable and another one to turn it back to the concise
style. User would only call the function on text selection (region) as opposed
to the whole file.

--
Antonin Houska
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt
Web: http://www.postgresql-support.de, http://www.cybertec.at

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Christoph Berg 2017-02-09 10:12:00 Re: One-shot expanded output in psql using \gx
Previous Message Andres Freund 2017-02-09 08:05:49 Re: amcheck (B-Tree integrity checking tool)