Andres Freund <and...@anarazel.de> wrote: > On 2017-02-07 23:30:44 -0500, Tom Lane wrote: > > Piotr Stefaniak <postg...@piotr-stefaniak.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 -- Sent via pgsql-hackers mailing list (email@example.com) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers