Re: Add trim_trailing_whitespace to editorconfig file - Mailing list pgsql-hackers

From Jelte Fennema-Nio
Subject Re: Add trim_trailing_whitespace to editorconfig file
Date
Msg-id CAGECzQS9oosFZNpUVAR0D+LLZa_mW-33YfSKRAHsmG3p564hYQ@mail.gmail.com
Whole thread Raw
In response to Re: Add trim_trailing_whitespace to editorconfig file  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: Add trim_trailing_whitespace to editorconfig file
Re: Add trim_trailing_whitespace to editorconfig file
List pgsql-hackers
On Wed, 7 Aug 2024 at 21:09, Andrew Dunstan <andrew@dunslane.net> wrote:
> You're not meant to use our pg_bsd_indent on its own without the
> appropriate flags, namely (from src/tools/pgindent/pgindent):

Ah sorry, I wasn't clear in what I meant then. I meant that if you
look at the sources of pg_bsd_indent (such as
src/tools/pg_bsd_indent/io.c) then you'll realize that comments are
alligned using tabs of width 8, not tabs of width 4. And right now
.editorconfig configures editors to show all .c files with a tab_width
of 4, because we use that for Postgres source files. The bottom
.gitattributes line now results in an editorconfig rule that sets a
tab_width of 8 for just the c and h files in src/tools/pg_bsd_indent
directory.

> Also, why are you proposing to undet indent-style for .pl and .pm files?
> That's not in accordance with our perltidy settings
> (src/tools/pgindent/perltidyrc), unless I'm misunderstanding.

All the way at the bottom of the .editorconfig file those "ident_style
= unset" lines are overridden to be "tab" for .pl and .pm files.
There's a comment there explaining why it's done that way.

# We want editors to use tabs for indenting Perl files, but we cannot add it
# such a rule to .gitattributes, because certain lines are still indented with
# spaces (e.g. SYNOPSIS blocks).
[*.{pl,pm}]
indent_style = tab

But now thinking about this again after your comment, I realize it's
just as easy and effective to change the script slightly to hardcode
the indent_style for "*.pl" and "*.pm" so that the resulting
.editorconfig looks less confusing. Attached is a patch that does
that.

I also added a .gitattributes rule for .py files, and changed the
default tab_width to unset. Because I realized the resulting
.editorconfig was using tab_width 8 for python files when editing
src/tools/generate_editorconfig.py

Attachment

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Add new protocol message to change GUCs for usage with future protocol-only GUCs
Next
From: Peter Eisentraut
Date:
Subject: Re: tiny step toward threading: reduce dependence on setlocale()