Skip to content

Commit e082ec6

Browse files
committed
Create EditorConfig
This will help me maintain a consistent style across all of my repos. In a future commit, I’m going to enable a pre-commit hook that will validate that files follow the EditorConfig’s rules. I removed the note about indentation from the README. From this point onwards, you’ll need to look at the EditorConfig file to figure out the indentation width. This makes it so that the indentation width is both human-readable and machine-readable.
1 parent 4f1e797 commit e082ec6

File tree

2 files changed

+176
-1
lines changed

2 files changed

+176
-1
lines changed

.editorconfig

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
# SPDX-License-Identifier: CC0-1.0
2+
# SPDX-FileCopyrightText: 2023 Jason Yundt <jason@jasonyundt.email>
3+
root = true
4+
5+
[**]
6+
# I personally prefer tabs for a few reasons:
7+
#
8+
# 1. One tab character is smaller than two or more space characters.
9+
# 2. A tab character clearly means “indentation”. A space character
10+
# could mean “indentation” or it could mean “space”.
11+
indent_style = tab
12+
13+
# I accept patches using git-send-email [1]. When sending a patch using
14+
# git-send-email, the diff is embedded in the body of the message [2].
15+
# According to the standard for the format of email messages [3]: “There
16+
# are two limits that this specification places on the number of
17+
# characters in a line. Each line of characters MUST be no more than
18+
# 998 characters, and SHOULD be no more than 78 characters, excluding
19+
# the CRLF.”
20+
#
21+
# I want to try and avoid having people send messages with lines that
22+
# are longer than 78 characters. Here’s the problem: in an email, how
23+
# wide are tab characters? If a line is indented one time, how many more
24+
# characters am I allowed to type before I hit the 78 character
25+
# threshold? What if the line is indented twice?
26+
#
27+
# Unfortunately, there isn’t one right answer for those questions. As
28+
# far as I know, there’s no standard that defines how long a tab
29+
# character is in an email.
30+
#
31+
# Additionally, I couldn’t find anything in the Unicode Standard or any
32+
# of its annexes about the width of a tab character. In Unicode, U+0009
33+
# CHARACTER TABULATION is a control code. The Unicode Standard says “The
34+
# Unicode Standard provides for the intact interchange of these code
35+
# points, neither adding to nor subtracting from their semantics. The
36+
# semantics of the control codes are generally determined by the
37+
# application with which they are used. However, in the absence of
38+
# specific application uses, they may be interpreted according to the
39+
# control function semantics specified in ISO/IEC 6429:1992” [4].
40+
#
41+
# OK, so what does ISO/IEC 6429:1992 have to say about character
42+
# tabulations? Unfortunately, that standard costs over two hundred
43+
# dollars [5]. Luckily, you can read a free sample of the standard on
44+
# the ISO’s Web site [6]. The Introduction says “International Standard
45+
# ISO/IEC 6429 was prepared by the European Computer Manufacturers
46+
# Association (as Standard ECMA-48) and was adopted, under a special
47+
# "fast-track procedure", by Joint Technical Committee ISO/IEC JTC1,
48+
# Information technology, in parallel with its approval by national
49+
# bodies of ISO and IEC.”
50+
#
51+
# OK, so if I’m not willing to pay for ISO/IEC 6429:1992, then the next
52+
# best thing would be to look at ECMA-48 which is available for free on
53+
# ECMA’s Web site [7]. That standard explains character tabulations in
54+
# terms of fields. A character tabulation causes text to appear in the
55+
# next field [8][9]. I wasn’t able to find anything in the standard that
56+
# says how wide fields are.
57+
#
58+
# After all that searching, I was unable to find any applicable
59+
# standards that defined the width of a tab character in an email. As a
60+
# result, the width of a tab character in an email is implementation
61+
# defined. In other words: it could be anything.
62+
#
63+
# In practice, the maximum width I’ve seen for tab characters is eight.
64+
# I’ve seen people make them less than eight characters wide, but I’ve
65+
# never seen anyone make them more than eight characters wide. By
66+
# setting indent_size to 8, we’re significantly decreasing the chances
67+
# that lines go over the 78 character threshold. If a line doesn’t
68+
# surpass that threshold with tabs that eight characters wide, then it
69+
# won’t surpass that threshold with tabs that are smaller.
70+
#
71+
# [1]: <https://jasonyundt.website/submitting-patches.html#send>
72+
# [2]: <https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project#_project_over_email>
73+
# [3]: <https://www.rfc-editor.org/rfc/rfc5322.html#section-2.1.1>
74+
# [4]: <https://www.unicode.org/versions/Unicode15.0.0/ch23.pdf#G20365>
75+
# [5]: <https://www.iso.org/standard/12782.html>
76+
# [6]: <https://www.iso.org/obp/ui/en/#iso:std:12782:en>
77+
# [7]: <https://ecma-international.org/publications-and-standards/standards/ecma-48/>
78+
# [8]: <https://ecma-international.org/wp-content/uploads/ECMA-48_5th_edition_june_1991.pdf#page=34>
79+
# [9]: <https://ecma-international.org/wp-content/uploads/ECMA-48_5th_edition_june_1991.pdf#page=59>
80+
indent_size = 8
81+
82+
# Ideally, I would use U+2028 LINE SEPARATOR. Unlike other options,
83+
# U+2028 is platform-neutral. Platform neutrality is very important to
84+
# me. I find it very frustrating when software doesn’t do the right
85+
# thing on my machine because someone did something platform specific.
86+
# Additionally, the Unicode Standard recommends the use of U+2028 LINE
87+
# SEPARATOR [1].
88+
#
89+
# Unfortunately, the EditorConfig Specification doesn’t support U+2028
90+
# [2]. Even if it did, I tried using U+2028 a while ago and (if I
91+
# remember correctly) all of the common text editors that I tried didn’t
92+
# support it. I’m guessing that a lot of compliers, interpreters or
93+
# other tools also don’t support using U+2028 for newlines.
94+
#
95+
# This leaves me with three options: LF, CR or CRLF.
96+
#
97+
# I know that CR is used by Classic Mac OS [3], but I’m not aware of any
98+
# other platforms that use it. As far as I know, there are no modern
99+
# platforms that use CRs for newlines.
100+
#
101+
# I personally prefer using LF instead of CRLF. LFs take up less space,
102+
# and are used more often on FOSS platforms. Additionally, Git seems to
103+
# prefer it when you use LFs.
104+
#
105+
# [1]: <https://www.unicode.org/versions/Unicode15.0.0/ch05.pdf#G29990>
106+
# [2]: <https://spec.editorconfig.org/#supported-pairs>
107+
# [3]: <https://superuser.com/a/439443/954602>
108+
end_of_line = lf
109+
110+
# The EditorConfig specification gives me five options for charset:
111+
# latin1, utf-8, utf-8-bom, utf-16be or utf-16le [1].
112+
#
113+
# I definitely want to use Unicode, so latin1 is off the table. I like
114+
# being able to use a lot of the weird symbols that Unicode provides. I
115+
# also add quotes that include emojis from time to time.
116+
#
117+
# Using UTF-16 is also unappealing. Most of the text in my repos is
118+
# probably going to either be written in English or in a programming
119+
# language that uses English keywords. As a result, my files will almost
120+
# certainly always be smaller if they’re encoded in UTF-8 [2].
121+
# Additionally, UTF-8 is much more popular than UTF-16 [3][4].
122+
#
123+
# That leaves us with two options: UTF-8 with a BOM or UTF-8 without a
124+
# BOM. According to the Unicode Standard, byte order marks can be used
125+
# for two different purposes [5]:
126+
#
127+
# 1. to clarify whether the file is little-endian or big-endian or
128+
# 2. to clarify what character set the file uses.
129+
#
130+
# Number 1 doesn’t apply to UTF-8 files. The Unicode Standard says so:
131+
# “For UTF-8, the encoding scheme consists merely of the UTF-8 code
132+
# units (= bytes) in sequence. Hence, there is no issue of big- versus
133+
# little-endian byte order for data represented in UTF-8” [6].
134+
#
135+
# Number 2 also doesn’t apply. We already know that all plain text files
136+
# will use UTF-8 because this EditorConfig file says that they will use
137+
# UTF-8. Including extra clarification that files are UTF-8 is
138+
# redundant.
139+
#
140+
# Additionally, including a BOM will break shebangs [7].
141+
#
142+
# Finally, the Unicode Standard recommends against using a BOM with
143+
# UTF-8: “Use of a BOM is neither required nor recommended for UTF-8,
144+
# but may be encountered in contexts where UTF-8 data is converted from
145+
# other encoding forms that use a BOM or where the BOM is used as a
146+
# UTF-8 signature” [6].
147+
#
148+
# For all those previous reasons, I chose to set charset to utf-8.
149+
#
150+
# [1]: <https://spec.editorconfig.org/#supported-pairs>
151+
# [2]: <https://utf8everywhere.org/#asian>
152+
# [3]: <https://w3techs.com/technologies/cross/character_encoding/ranking>
153+
# [4]: <https://w3techs.com/technologies/details/en-utf16>
154+
# [5]: <https://www.unicode.org/versions/Unicode15.0.0/ch23.pdf#G25817>
155+
# [6]: <https://www.unicode.org/versions/Unicode15.0.0/ch02.pdf#G19273>
156+
# [7]: <https://unicode.org/faq/utf_bom.html#bom5>
157+
charset = utf-8
158+
159+
# Trailing whitespace makes files larger, and I don’t know of any
160+
# benefits to including it.
161+
trim_trailing_whitespace = true
162+
163+
# I found the answers to this question [1] to be compelling. Also, I
164+
# don’t like it when I cat [2] a file and it puts my prompt on the same
165+
# line as the last part of the file.
166+
#
167+
# [1]: <https://stackoverflow.com/q/729692/7593853>
168+
# [2]: <https://www.gnu.org/software/coreutils/manual/html_node/cat-invocation.html#cat-invocation>
169+
insert_final_newline = true
170+
171+
[**.yaml]
172+
# YAML requires spaces for indentation:
173+
# <https://yaml.org/spec/1.2.2/#61-indentation-spaces>.
174+
indent_style = space
175+
indent_size = 4

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ REUSE-IgnoreStart
88

99
## Hints for Contributors
1010

11-
- Use four spaces for indentation.
1211
- You can use [pre-commit](https://pre-commit.com/) to automatically check your
1312
contributions. Follow [these instructions](https://pre-commit.com/#quick-start)
1413
to get started. Skip [the part about creating a pre-commit
1514
configuration](https://pre-commit.com/#2-add-a-pre-commit-configuration).
15+
- This repo uses an [EditorConfig](https://editorconfig.org) file.
1616

1717
## Copying
1818

0 commit comments

Comments
 (0)