about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--early-init.el18
-rw-r--r--init.el24
-rw-r--r--lisp/system.el8
-rw-r--r--lisp/titlecase.el197
-rw-r--r--machines/bob.el (renamed from systems/bob.el)4
-rw-r--r--machines/gnu-linux.el (renamed from systems/gnu-linux.el)2
-rw-r--r--machines/windows-nt.el (renamed from systems/windows-nt.el)8
7 files changed, 37 insertions, 224 deletions
diff --git a/early-init.el b/early-init.el index 068770c..40edbe5 100644 --- a/early-init.el +++ b/early-init.el
@@ -55,10 +55,10 @@ See `no-littering' for examples.")
55 "My Syncthing directory.") 55 "My Syncthing directory.")
56 56
57;; Load system-specific changes. 57;; Load system-specific changes.
58(progn (require 'system) 58;; (progn (require 'system)
59 (setq system-default-font "DejaVu Sans Mono" 59;; (setq system-default-font "DejaVu Sans Mono"
60 system-variable-pitch-font "DejaVu Sans") 60;; system-variable-pitch-font "DejaVu Sans")
61 (system-settings-load)) 61;; (system-settings-load))
62 62
63;;; Default frame settings 63;;; Default frame settings
64 64
@@ -78,11 +78,11 @@ See `no-littering' for examples.")
78(+with-ensure-after-init 78(+with-ensure-after-init
79 ;; Set default faces 79 ;; Set default faces
80 (+with-message "Setting default faces" 80 (+with-message "Setting default faces"
81 (let ((font-name system-default-font) 81 (let ((font-name machine-default-font)
82 (font-size system-default-height) 82 (font-size machine-default-height)
83 (variable-font-name system-variable-pitch-font) 83 (variable-font-name machine-variable-pitch-font)
84 (variable-font-size system-variable-pitch-height)) 84 (variable-font-size machine-variable-pitch-height))
85 (set-face-attribute 'default nil :family system-default-font 85 (set-face-attribute 'default nil :family font-name
86 :height font-size :weight 'book) 86 :height font-size :weight 'book)
87 (set-face-attribute 'italic nil :family font-name 87 (set-face-attribute 'italic nil :family font-name
88 :height font-size :slant 'italic) 88 :height font-size :slant 'italic)
diff --git a/init.el b/init.el index 53a8a81..93c5c1d 100644 --- a/init.el +++ b/init.el
@@ -262,10 +262,10 @@
262 #'hl-line-mode) 262 #'hl-line-mode)
263 (:+key "C-x C-j" #'dired-jump) 263 (:+key "C-x C-j" #'dired-jump)
264 (with-eval-after-load 'dired 264 (with-eval-after-load 'dired
265 (pcase system-system 265 (cl-case system-type
266 ('windows 266 ((windows-nt ms-dos)
267 (:straight w32-browser)) 267 (:straight w32-browser))
268 ('linux 268 (gnu/linux
269 (:straight dired-open) 269 (:straight dired-open)
270 (:option dired-listing-switches 270 (:option dired-listing-switches
271 (concat dired-listing-switches " -F"))))) 271 (concat dired-listing-switches " -F")))))
@@ -402,12 +402,6 @@
402 (+kmacro-recording-indicator-mode +1) 402 (+kmacro-recording-indicator-mode +1)
403 (+kmacro-block-undo-mode +1))) 403 (+kmacro-block-undo-mode +1)))
404 404
405(setup magit
406 ;; This setup is weird because of dependency issues
407 (:straight (transient :host github :repo "magit/transient" :branch "master")
408 (magit :host github :repo "magit/magit")
409 (git-modes :host github :repo "magit/git-modes")))
410
411(setup minibuffer 405(setup minibuffer
412 (:require +minibuffer) 406 (:require +minibuffer)
413 (:with-map minibuffer-local-map 407 (:with-map minibuffer-local-map
@@ -1237,6 +1231,10 @@ See also `crux-reopen-as-root-mode'."
1237 (:file-match (rx ".rkt" eos) 1231 (:file-match (rx ".rkt" eos)
1238 (rx ".scm" eos))) 1232 (rx ".scm" eos)))
1239 1233
1234(setup (:straight (git-modes
1235 :host github :repo "magit/git-modes"))
1236 (:require git-modes))
1237
1240;; (setup (:straight god-mode) 1238;; (setup (:straight god-mode)
1241;; (setq god-mode-enable-function-key-translation nil) 1239;; (setq god-mode-enable-function-key-translation nil)
1242;; (:require god-mode 1240;; (:require god-mode
@@ -1335,6 +1333,8 @@ See also `crux-reopen-as-root-mode'."
1335 (:with-mode emacs-lisp-mode 1333 (:with-mode emacs-lisp-mode
1336 (:bind "C-c e" #'macrostep-expand))) 1334 (:bind "C-c e" #'macrostep-expand)))
1337 1335
1336(setup (:straight (magit :host github :repo "magit/magit")))
1337
1338(setup (:straight marginalia) 1338(setup (:straight marginalia)
1339 (marginalia-mode +1)) 1339 (marginalia-mode +1))
1340 1340
@@ -1745,3 +1745,9 @@ See also `crux-reopen-as-root-mode'."
1745 (:require +zzz-to-char) 1745 (:require +zzz-to-char)
1746 (:option zzz-to-char-reach (+bytes 1 :kib)) 1746 (:option zzz-to-char-reach (+bytes 1 :kib))
1747 (:global "M-z" #'+zzz-to-char)) 1747 (:global "M-z" #'+zzz-to-char))
1748
1749(setup (:straight (machine
1750 :host github :repo "duckwork/machine.el"))
1751 (:option machine-default-font "DejaVu Sans Mono"
1752 machine-variable-pitch-font "DejaVu Sans")
1753 (machine-settings-load))
diff --git a/lisp/system.el b/lisp/system.el index 0c1e457..73cd80b 100644 --- a/lisp/system.el +++ b/lisp/system.el
@@ -6,6 +6,12 @@
6;; different definitions. This library is built to assist in working with 6;; different definitions. This library is built to assist in working with
7;; different system configurations for Emacs. 7;; different system configurations for Emacs.
8 8
9;;; TODO:
10
11;; machine.el
12;; machine-case to switch on machine
13;;
14
9;;; Code: 15;;; Code:
10 16
11(require 'cl-lib) 17(require 'cl-lib)
@@ -171,5 +177,3 @@ NOMESSAGE is passed directly to `load'."
171 177
172(provide 'system) 178(provide 'system)
173;;; system.el ends here 179;;; system.el ends here
174
175
diff --git a/lisp/titlecase.el b/lisp/titlecase.el deleted file mode 100644 index c79f558..0000000 --- a/lisp/titlecase.el +++ /dev/null
@@ -1,197 +0,0 @@
1;;; titlecase.el --- title-case phrases -*- lexical-binding: t; -*-
2
3;;; Commentary:
4
5;; adapted from https://hungyi.net/posts/programmers-way-to-title-case/
6
7;;; Code:
8
9(require 'seq)
10
11(defgroup titlecase nil
12 "Customizations for titlecasing phrases."
13 :prefix "titlecase-"
14 :group 'text)
15
16;;; Lists of words /never/ to capitalize
17
18(defvar titlecase-prepositions
19 '("'thout" "'tween" "aboard" "about" "above"
20 "abreast" "absent" "abt." "across" "after" "against" "ago" "aloft" "along"
21 "alongside" "amid" "amidst" "among" "amongst" "anti" "apart" "apropos"
22 "around" "as" "aside" "aslant" "astride" "at" "atop" "away" "before"
23 "behind" "below" "beneath" "beside" "besides" "between" "beyond" "but" "by"
24 "c." "ca." "circa" "come" "concerning" "contra" "counting" "cum" "despite"
25 "down" "during" "effective" "ere" "except" "excepting" "excluding" "failing"
26 "following" "for" "from" "hence" "in" "including" "inside" "into" "less"
27 "like" "mid" "midst" "minus" "mod" "modulo" "near" "nearer" "nearest"
28 "neath" "next" "notwithstanding" "o'" "o'er" "of" "off" "offshore" "on"
29 "onto" "ontop" "opposite" "out" "outside" "over" "pace" "past" "pending"
30 "per" "plus" "post" "pre" "pro" "qua" "re" "regarding" "respecting" "round"
31 "sans" "save" "saving" "short" "since" "sub" "t'" "than" "through"
32 "throughout" "thru" "thruout" "till" "times" "to" "toward" "towards" "under"
33 "underneath" "unlike" "until" "unto" "up" "upon" "v." "versus" "via"
34 "vis-à-vis" "vs." "w." "w/" "w/i" "w/o" "wanting" "with" "within"
35 "without")
36 "List of prepositions in English.
37This list is, by necessity, incomplete, even though prepositions
38are a closed lexical group in the English language. This list
39was pulled and culled from
40https://en.wikipedia.org/wiki/List_of_English_prepositions.")
41
42(defvar titlecase-articles '("a" "an" "the")
43 "List of articles in English.")
44
45(defvar titlecase-coordinating-conjunctions '("for" "and" "nor" "but" "or"
46 "yet" "so")
47 "List of coordinating conjunctions in English.")
48
49(defvar titlecase-lowercase-chicago (append titlecase-articles
50 titlecase-prepositions
51 titlecase-coordinating-conjunctions)
52 "Words to lowercase in Chicago Style.
53Include: articles, coordinating conjunctions, prepositions, and
54\"to\" in an infinitive (though that's caught as a preposition).")
55
56(defvar titlecase-lowercase-apa (append titlecase-articles
57 (seq-filter (lambda (p)
58 (< (length p) 4))
59 titlecase-prepositions))
60 "Words to lowercase in APA Style.")
61
62(defvar titlecase-lowercase-mla (append titlecase-articles
63 titlecase-prepositions
64 titlecase-coordinating-conjunctions)
65 "Words to lowercase in MLA Style.")
66
67(defvar titlecase-lowercase-ap (append titlecase-articles
68 (seq-filter (lambda (p)
69 (< (length p) 4))
70 titlecase-prepositions)
71 (seq-filter
72 (lambda (p)
73 (< (length p) 4))
74 titlecase-coordinating-conjunctions))
75 "Words to lowercase in AP Style.")
76
77(defvar titlecase-lowercase-bluebook (append titlecase-articles
78 titlecase-coordinating-conjunctions
79 (seq-filter
80 (lambda (p)
81 (< (length p) 4))
82 titlecase-prepositions))
83 "Words to lowercase in Bluebook Style.")
84
85(defvar titlecase-lowercase-ama (append titlecase-articles
86 titlecase-coordinating-conjunctions
87 (seq-filter (lambda (p)
88 (< (length p) 4))
89 titlecase-prepositions))
90 "Words to lowercase in AMA Style.")
91
92(defvar titlecase-lowercase-nyt (append titlecase-articles
93 titlecase-prepositions
94 titlecase-coordinating-conjunctions)
95 "Words to lowercase in New York Times Style.")
96
97(defvar titlecase-lowercase-wikipedia
98 (append titlecase-articles
99 (seq-filter (lambda (p) (< (length p) 5)) titlecase-prepositions)
100 titlecase-coordinating-conjunctions)
101 "Words to lowercase in Wikipedia Style.")
102
103(defcustom titlecase-style 'chicago
104 "Which style to use when titlecasing."
105 :type '(choice (const :tag "Chicago Style" chicago)
106 (const :tag "APA Style" apa)
107 (const :tag "MLA Style" mla)
108 (const :tag "AP Style" ap)
109 (const :tag "Bluebook Style" bluebook)
110 (const :tag "AMA Style" ama)
111 (const :tag "New York Times Style" nyt)
112 (const :tag "Wikipedia Style" wikipedia)))
113
114(defun titlecase--normalize (begin end)
115 "Normalize region from BEGIN to END."
116 (goto-char begin)
117 (unless (re-search-forward "[a-z]" end :noerror)
118 (downcase-region begin end)))
119
120(defun titlecase--capitalize-first-word (begin end)
121 "Capitalize the first word of region from BEGIN to END."
122 (goto-char begin)
123 (capitalize-word 1))
124
125(defun titlecase--capitalize-last-word (begin end)
126 "Capitalize the last word of region from BEGIN to END."
127 (goto-char end)
128 (backward-word 1)
129 (when (and (>= (point) begin))
130 (capitalize-word 1)))
131
132
133
134
135(defun titlecase-region-with-style (begin end style)
136 "Titlecase the region of English text from BEGIN to END, using STYLE."
137 (interactive "*r")
138 (save-excursion
139 (goto-char begin)
140 ;; If the region is in ALL-CAPS, normalize it first
141 (unless (re-search-forward "[a-z]" end :noerror)
142 (downcase-region begin end))
143 (goto-char begin) ; gotta go back to the beginning
144 (let (;; Constants during this function's runtime
145 (case-fold-search nil)
146 (downcase-word-list (symbol-value
147 (intern (format "titlecase-lowercase-%s"
148 style))))
149 ;; State variables
150 (this-word (current-word))
151 (force-capitalize t))
152 ;; And loop over the rest
153 (while (< (point) end)
154 (setq this-word (current-word))
155 (cond
156 ;; Skip ALL-CAPS words
157 ((string-match "^[A-Z]+$" this-word) (forward-word 1))
158 ;; Force capitalization if `force-capitalize' is t
159 (force-capitalize (progn (capitalize-word 1)
160 (setq force-capitalize nil)))
161 ;; Special rules for different styles
162 ((and (memq style '(ap))
163 (> (length this-word) 3))
164 (capitalize-word 1))
165 ;; Downcase words that should be
166 ((member (downcase this-word) downcase-word-list)
167 (downcase-word 1))
168 ;; Otherwise, capitalize the word
169 (t (capitalize-word 1)))
170 ;; If the word ends with a :, ., ?, newline, or carriage-return, force
171 ;; the next word to be capitalized.
172 (when (looking-at "[:.?;\n\r]")
173 (setq force-capitalize t))
174 (skip-syntax-forward "^w" end))
175 ;; Capitalize the last word, only in some styles
176 (when (memq style '(chicago ap bluebook ama nyt wikipedia))
177 (backward-word 1)
178 (when (and (>= (point) begin))
179 (capitalize-word 1))))))
180
181;;;###autoload
182(defun titlecase-region (begin end)
183 "Titlecase the region of English text from BEGIN to END.
184Uses the style provided in `titlecase-style'."
185 (interactive "*r")
186 (titlecase-region-with-style begin end titlecase-style))
187
188;;;###autoload
189(defun titlecase-dwim ()
190 "Titlecase either the region, if active, or the current line."
191 (interactive)
192 (if (region-active-p)
193 (titlecase-region (region-beginning) (region-end))
194 (titlecase-region (point-at-bol) (point-at-eol))))
195
196(provide 'titlecase)
197;;; titlecase.el ends here
diff --git a/systems/bob.el b/machines/bob.el index 427f38a..e9b444c 100644 --- a/systems/bob.el +++ b/machines/bob.el
@@ -4,7 +4,7 @@
4 4
5;;; Code: 5;;; Code:
6 6
7(setq system-default-font "DejaVu Sans Mono" 7(setq machine-default-font "DejaVu Sans Mono"
8 system-default-height 105) 8 machine-default-height 105)
9 9
10;;; bob.el ends here 10;;; bob.el ends here
diff --git a/systems/gnu-linux.el b/machines/gnu-linux.el index 333f15a..309ca34 100644 --- a/systems/gnu-linux.el +++ b/machines/gnu-linux.el
@@ -1,5 +1,5 @@
1;;; linux.el -*- lexical-binding: t; -*- 1;;; linux.el -*- lexical-binding: t; -*-
2 2
3(setq system-default-height 105) 3(setq machine-default-height 105)
4 4
5;;; linux.el ends here 5;;; linux.el ends here
diff --git a/systems/windows-nt.el b/machines/windows-nt.el index 3a0deee..a95754e 100644 --- a/systems/windows-nt.el +++ b/machines/windows-nt.el
@@ -7,10 +7,10 @@
7 7
8;; Fonts 8;; Fonts
9 9
10(setq system-default-font "Cascadia Mono" 10(setq machine-default-font "Cascadia Mono"
11 system-default-height 90 11 machine-default-height 90
12 system-variable-pitch-font "Carlito" 12 machine-variable-pitch-font "Carlito"
13 system-variable-pitch-height 1.2) 13 machine-variable-pitch-height 1.2)
14 14
15;; Add C:\Program Files\* and C:\Program Files (x86)\* to exec-path 15;; Add C:\Program Files\* and C:\Program Files (x86)\* to exec-path
16(dolist (path (append (file-expand-wildcards "C:/Program Files/*") 16(dolist (path (append (file-expand-wildcards "C:/Program Files/*")