diff options
| author | Mountain Man <mmosmacs-dev@anu.tgwil.net> | 2023-04-08 15:45:27 -0400 |
|---|---|---|
| committer | Mountain Man <mmosmacs-dev@anu.tgwil.net> | 2023-04-08 15:45:27 -0400 |
| commit | 98ed8e7dedaf6a5d6844a18d1f9e72dfaf174701 (patch) | |
| tree | 4fabc673a7ad3d50104bdb959fd8f8869ba4622c | |
| parent | Create `CONTRIBUTING.md` (diff) | |
| download | mmosmacs-98ed8e7dedaf6a5d6844a18d1f9e72dfaf174701.tar.gz mmosmacs-98ed8e7dedaf6a5d6844a18d1f9e72dfaf174701.tar.bz2 mmosmacs-98ed8e7dedaf6a5d6844a18d1f9e72dfaf174701.zip | |
Create `STYLE_GUIDE.md`
A style guide is necessary to keep the contents of the repository
consistent. I've created an initial set of guidelines, based loosely on
the guide fount at https://github.com/bbatsov/emacs-lisp-style-guide.
| -rw-r--r-- | STYLE_GUIDE.md | 149 |
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 | |||
| 3 | Much 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 | |||
| 16 | Emacs Lisp files should begin with a header. The first line of the | ||
| 17 | header should include the filename, a very brief comment (2-5 words), | ||
| 18 | and the `-*- lexical-binding: t; -*-` thing. The next line(s) should be | ||
| 19 | a 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 | |||
| 30 | All Emacs Lisp files are organized into Sections and Subsections using | ||
| 31 | comment decorations. Section titles begin with `;;;`, are ALL CAPS, and | ||
| 32 | their decorations extend up to 72 chars. Subsections begin with `;;` | ||
| 33 | and their decorations extend up to 36 chars. Titles should be underlined | ||
| 34 | with dashes on the proceeding line. Explanatory comments go below the | ||
| 35 | title underline, and an additional 36-or-72-char line goes at the bottom | ||
| 36 | of the header. | ||
| 37 | |||
| 38 | Each subsection should have 2 blank lines between the top line of the | ||
| 39 | header and the bottom line of code from the previous subsection. Only | ||
| 40 | one line goes between the Section header and the first Subsection, as | ||
| 41 | well as between portions of code within the same subsection. 4 lines go | ||
| 42 | between 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 | ||
| 126 | language (e.g. "Verify" instead of "Verifies") | ||
| 127 | - When a function takes arguments, mention what the arguments do, | ||
| 128 | whether they are optional or required, etc. Describe the arguments in | ||
| 129 | UPPERCASE, 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 | ||
| 131 | code 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. | ||
| 137 | If called interactively, a numeric prefix argument specifies | ||
| 138 | LINE; without a numeric prefix argument, read LINE from the | ||
| 139 | minibuffer..." | ||
| 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 | ``` | ||