aboutsummaryrefslogtreecommitdiff
path: root/STYLE_GUIDE.md
diff options
context:
space:
mode:
authorMountain Man <43313373+MountainMan1312@users.noreply.github.com>2023-04-08 20:07:22 -0400
committerGitHub <noreply@github.com>2023-04-08 20:07:22 -0400
commite274a5f8cbc3cdf6d953e8b37a6c8d79f62266a9 (patch)
tree4fabc673a7ad3d50104bdb959fd8f8869ba4622c /STYLE_GUIDE.md
parentInitial commit (diff)
parentCreate `STYLE_GUIDE.md` (diff)
downloadmmosmacs-e274a5f8cbc3cdf6d953e8b37a6c8d79f62266a9.tar.gz
mmosmacs-e274a5f8cbc3cdf6d953e8b37a6c8d79f62266a9.tar.bz2
mmosmacs-e274a5f8cbc3cdf6d953e8b37a6c8d79f62266a9.zip
Merge `initial-plans-docs` branch to `stable` branch
Diffstat (limited to 'STYLE_GUIDE.md')
-rw-r--r--STYLE_GUIDE.md149
1 files changed, 149 insertions, 0 deletions
diff --git a/STYLE_GUIDE.md b/STYLE_GUIDE.md
new file mode 100644
index 0000000..d1e4e6b
--- /dev/null
+++ b/STYLE_GUIDE.md
@@ -0,0 +1,149 @@
1# STYLE_GUIDE for MMOSMacs
2
3Much of this Style Guide was taken from
4[bbatsov/emacs-lisp-style-guide](https://github.com/bbatsov/emacs-lisp-style-guide).
5
6
7# General guidelines
8
9- Use spaces for indentation. Do not use tabs anywhere.
10- Where feasible, avoid making lines longer than 72 chars.
11- Avoid trailing whitespace.
12
13
14## Organization
15
16Emacs Lisp files should begin with a header. The first line of the
17header should include the filename, a very brief comment (2-5 words),
18and the `-*- lexical-binding: t; -*-` thing. The next line(s) should be
19a more detailed description of the file and it's purpose.
20
21```elisp
22;;; -*- lexical-binding: t; -*-
23;;; init.el
24;;
25;; Main config file for MMOSMacs; the glue that binds the modules
26;; together. Provides package management, performance tweaks, and
27;; integrates all the other MMOSMacs modules.
28```
29
30All Emacs Lisp files are organized into Sections and Subsections using
31comment decorations. Section titles begin with `;;;`, are ALL CAPS, and
32their decorations extend up to 72 chars. Subsections begin with `;;`
33and their decorations extend up to 36 chars. Titles should be underlined
34with dashes on the proceeding line. Explanatory comments go below the
35title underline, and an additional 36-or-72-char line goes at the bottom
36of the header.
37
38Each subsection should have 2 blank lines between the top line of the
39header and the bottom line of code from the previous subsection. Only
40one line goes between the Section header and the first Subsection, as
41well as between portions of code within the same subsection. 4 lines go
42between a new Section header and the previous bit of code.
43
44```elisp
45;; integrates all the other MMOSMacs modules.
46
47
48;; ---------------------------------------------------------------------
49;;; FIRST SECTION TITLE
50;; --------------------
51;; Comments about the purpose of the section go here.
52;; It should be concise. Don't go into too much detail.
53;; ---------------------------------------------------------------------
54
55;; ---------------------------------
56;; Subsection Title
57;; ----------------
58;; Subsection explanatory text goes
59;; here. Limit the line length to 36
60;; chars to maintain the visual
61;; "togetherness" of the header.
62;;
63;; Notice only 1 space between the
64;; Section header and the top of the
65;; first Subsection header.
66;; ---------------------------------
67
68;; `something` is a package I bet
69(use-package something
70 :straight t
71 :init
72 (setq some-crap nil))
73
74;; `something-else` is a little less
75;; likely to be a package
76(use-package something-else
77 :straight t)
78
79
80;; ---------------------------------
81;; Subsection Title
82;; ----------------
83;; Notice the 2 lines separating
84;; each Subsection.
85;; ---------------------------------
86
87;; I really don't know what to write
88;; in these example comments.
89(use-package some-other-thing
90 :straight
91 :init
92 (other-thing-mode))
93
94
95
96
97;; ---------------------------------------------------------------------
98;;; SECOND SECTION TITLE
99;; ---------------------
100;; Notice the 4 empty lines above this section.
101;; This provides visual separation; easier on the eyes.
102;; ---------------------------------------------------------------------
103```
104
105
106## Comments & Annotations
107
108- Write heading comments with 3 semicolons, and regular comments with 2.
109- Write margin comments with 1 semicolon.
110- Leave 1 space between the semicolons and the comment text.
111- Comments longer than 1 word are capitalized and use punctuation.
112
113```elisp
114;;; This is a heading comment
115;; This is a regular comment with more words and stuff.
116;; Something something something.
117(defun foo (bar)
118 (something something
119 something-else)) ; for some other reason
120```
121
122
123## Docstrings
124
125- Begin docstrings with a terse, complete sentence. Use imperative
126language (e.g. "Verify" instead of "Verifies")
127- When a function takes arguments, mention what the arguments do,
128whether they are optional or required, etc. Describe the arguments in
129UPPERCASE, and describe them in the order they are used in the function.
130- Do not indent subsequent lines of a docstring. It looks nice in source
131code but looks bizarre when viewed in Emacs.
132
133```elisp
134;; good
135(defun goto-line (line &optional buffer)
136 "Go to LINE, counting from line 1 at beginning of buffer.
137If called interactively, a numeric prefix argument specifies
138LINE; without a numeric prefix argument, read LINE from the
139minibuffer..."
140...)
141
142;; bad
143(defun goto-line (line &optional buffer)
144 "Go to LINE, counting from line 1 at beginning of buffer.
145 If called interactively, a numeric prefix argument specifies
146 LINE; without a numeric prefix argument, read LINE from the
147 minibuffer..."
148...)
149```