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

From Andrew Dunstan
Subject Re: Add trim_trailing_whitespace to editorconfig file
Date
Msg-id cf2ef117-a284-4a77-989a-f82e9abf0482@dunslane.net
Whole thread Raw
In response to Re: Add trim_trailing_whitespace to editorconfig file  (Jelte Fennema-Nio <postgres@jeltef.nl>)
List pgsql-hackers


On 2024-08-07 We 4:42 PM, Jelte Fennema-Nio wrote:
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.


Ah, OK. Yeah, that makes sense.



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.


OK, good, thanks.



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


sounds good.

cheers

andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com

pgsql-hackers by date:

Previous
From: Shlok Kyal
Date:
Subject: Re: long-standing data loss bug in initial sync of logical replication
Next
From: Andrew Dunstan
Date:
Subject: Re: Windows default locale vs initdb