summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2021-03-25 12:03:59 -0500
committerCase Duckworth2021-03-25 12:03:59 -0500
commit870d1595e4137b84481df678cf41871dfde1fbbd (patch)
tree41fcc488f3a420df018e3ab966571f264ea5813b
parentAdd `god-mode' (diff)
downloademacs-870d1595e4137b84481df678cf41871dfde1fbbd.tar.gz
emacs-870d1595e4137b84481df678cf41871dfde1fbbd.zip
White space
-rw-r--r--early-init.el78
-rw-r--r--lisp/acdw.el130
2 files changed, 104 insertions, 104 deletions
diff --git a/early-init.el b/early-init.el index d803c89..4037ef8 100644 --- a/early-init.el +++ b/early-init.el
@@ -47,7 +47,7 @@
47 "Reset `gc-cons-threshold', `gc-cons-percentage', and 47 "Reset `gc-cons-threshold', `gc-cons-percentage', and
48 `file-name-handler-alist' to their defaults after init." 48 `file-name-handler-alist' to their defaults after init."
49 (setq gc-cons-threshold gc-cons-threshold-basis 49 (setq gc-cons-threshold gc-cons-threshold-basis
50 gc-cons-percentage gc-cons-percentage-basis) 50 gc-cons-percentage gc-cons-percentage-basis)
51 (dolist (handler file-name-handler-alist) 51 (dolist (handler file-name-handler-alist)
52 (add-to-list 'orig-file-name-handler-alist handler)) 52 (add-to-list 'orig-file-name-handler-alist handler))
53 (setq file-name-handler-alist orig-file-name-handler-alist)) 53 (setq file-name-handler-alist orig-file-name-handler-alist))
@@ -58,33 +58,33 @@
58 58
59(setq default-frame-alist ; Remove most UI 59(setq default-frame-alist ; Remove most UI
60 `((tool-bar-lines . 0) ; No tool bar 60 `((tool-bar-lines . 0) ; No tool bar
61 (menu-bar-lines . 0) ; No menu bar 61 (menu-bar-lines . 0) ; No menu bar
62 (vertical-scroll-bars) ; No scroll bars 62 (vertical-scroll-bars) ; No scroll bars
63 (horizontal-scroll-bars) ; ... at all 63 (horizontal-scroll-bars) ; ... at all
64 (width . 84) ; A /little/ wider than 64 (width . 84) ; A /little/ wider than
65 ; `fill-column' (set later) 65 ; `fill-column' (set later)
66 (height . 30) 66 (height . 30)
67 (left-fringe . 8) ; Width of fringes 67 (left-fringe . 8) ; Width of fringes
68 (right-fringe . 8) ; (8 is default) 68 (right-fringe . 8) ; (8 is default)
69 (font . ,(pcase acdw/system 69 (font . ,(pcase acdw/system
70 (:home "DejaVu Sans Mono 10") 70 (:home "DejaVu Sans Mono 10")
71 (:work "Consolas 10")))) 71 (:work "Consolas 10"))))
72 frame-inhibit-implied-resize t ; Don't resize randomly 72 frame-inhibit-implied-resize t ; Don't resize randomly
73 frame-resize-pixelwise t ; Resize by pixels, not chars 73 frame-resize-pixelwise t ; Resize by pixels, not chars
74 ) 74 )
75 75
76(defun hook--disable-ui-modes () 76(defun hook--disable-ui-modes ()
77 "Disable frame UI using modes, for toggling later." 77 "Disable frame UI using modes, for toggling later."
78 (dolist (mode ;; each mode is of the form (MODE . FRAME-ALIST-VAR) 78 (dolist (mode ;; each mode is of the form (MODE . FRAME-ALIST-VAR)
79 '((tool-bar-mode . tool-bar-lines) 79 '((tool-bar-mode . tool-bar-lines)
80 (menu-bar-mode . menu-bar-lines) 80 (menu-bar-mode . menu-bar-lines)
81 (scroll-bar-mode . vertical-scroll-bars) 81 (scroll-bar-mode . vertical-scroll-bars)
82 (horizontal-scroll-bar-mode . horizontal-scroll-bars) 82 (horizontal-scroll-bar-mode . horizontal-scroll-bars)
83 )) 83 ))
84 (let ((setting (alist-get (cdr mode) default-frame-alist))) 84 (let ((setting (alist-get (cdr mode) default-frame-alist)))
85 (when (or (not setting) 85 (when (or (not setting)
86 (= 0 setting)) 86 (= 0 setting))
87 (funcall (car mode) -1))))) 87 (funcall (car mode) -1)))))
88 88
89(add-hook 'after-init-hook #'hook--disable-ui-modes) 89(add-hook 'after-init-hook #'hook--disable-ui-modes)
90 90
@@ -92,11 +92,11 @@
92 92
93;; 1. Update `exec-path'. 93;; 1. Update `exec-path'.
94(dolist (path (list (expand-file-name "bin" user-emacs-directory) 94(dolist (path (list (expand-file-name "bin" user-emacs-directory)
95 (expand-file-name "~/bin") 95 (expand-file-name "~/bin")
96 (expand-file-name "~/.local/bin") 96 (expand-file-name "~/.local/bin")
97 (expand-file-name "~/usr/bin") 97 (expand-file-name "~/usr/bin")
98 (expand-file-name "~/cmd") 98 (expand-file-name "~/cmd")
99 (expand-file-name "~/mingw64/bin"))) 99 (expand-file-name "~/mingw64/bin")))
100 (when (file-exists-p path) 100 (when (file-exists-p path)
101 (add-to-list 'exec-path path :append))) 101 (add-to-list 'exec-path path :append)))
102 102
@@ -105,10 +105,10 @@
105 105
106;; 2. Set `package' and `straight' variables. 106;; 2. Set `package' and `straight' variables.
107(setq package-enable-at-startup nil ; not sure if strictly 107(setq package-enable-at-startup nil ; not sure if strictly
108 ; necessary 108 ; necessary
109 package-quickstart nil ; ditto 109 package-quickstart nil ; ditto
110 straight-host-usernames '((github . "duckwork") 110 straight-host-usernames '((github . "duckwork")
111 (gitlab . "acdw")) 111 (gitlab . "acdw"))
112 straight-base-dir acdw/dir ; don't clutter ~/.emacs.d 112 straight-base-dir acdw/dir ; don't clutter ~/.emacs.d
113 ) 113 )
114 114
@@ -116,15 +116,15 @@
116(defvar bootstrap-version) 116(defvar bootstrap-version)
117(let ((bootstrap-file 117(let ((bootstrap-file
118 (expand-file-name 118 (expand-file-name
119 "straight/repos/straight.el/bootstrap.el" 119 "straight/repos/straight.el/bootstrap.el"
120 straight-base-dir)) 120 straight-base-dir))
121 (bootstrap-version 5)) 121 (bootstrap-version 5))
122 (unless (file-exists-p bootstrap-file) 122 (unless (file-exists-p bootstrap-file)
123 (with-current-buffer 123 (with-current-buffer
124 (url-retrieve-synchronously 124 (url-retrieve-synchronously
125 (concat "https://raw.githubusercontent.com/" 125 (concat "https://raw.githubusercontent.com/"
126 "raxod502/straight.el/develop/install.el") 126 "raxod502/straight.el/develop/install.el")
127 'silent 'inhibit-cookies) 127 'silent 'inhibit-cookies)
128 (goto-char (point-max)) 128 (goto-char (point-max))
129 (eval-print-last-sexp))) 129 (eval-print-last-sexp)))
130 (load bootstrap-file nil 'nomessage)) 130 (load bootstrap-file nil 'nomessage))
@@ -134,10 +134,10 @@
134(defun hook--message-startup-time () 134(defun hook--message-startup-time ()
135 "Show Emacs's startup time in the message buffer. For profiling." 135 "Show Emacs's startup time in the message buffer. For profiling."
136 (message "Emacs ready in %s with %d garbage collections." 136 (message "Emacs ready in %s with %d garbage collections."
137 (format "%.2f seconds" 137 (format "%.2f seconds"
138 (float-time (time-subtract after-init-time 138 (float-time (time-subtract after-init-time
139 before-init-time))) 139 before-init-time)))
140 gcs-done)) 140 gcs-done))
141 141
142(add-hook 'emacs-startup-hook #'hook--message-startup-time) 142(add-hook 'emacs-startup-hook #'hook--message-startup-time)
143 143
diff --git a/lisp/acdw.el b/lisp/acdw.el index 4493275..bd6c02a 100644 --- a/lisp/acdw.el +++ b/lisp/acdw.el
@@ -37,20 +37,20 @@ Ready for use with `after-focus-change-function'."
37(defun acdw/sunrise-sunset (sunrise-command sunset-command) 37(defun acdw/sunrise-sunset (sunrise-command sunset-command)
38 "Run commands at sunrise and sunset." 38 "Run commands at sunrise and sunset."
39 (let* ((times-regex (rx (* nonl) 39 (let* ((times-regex (rx (* nonl)
40 (: (any ?s ?S) "unrise") " " 40 (: (any ?s ?S) "unrise") " "
41 (group (repeat 1 2 digit) ":" 41 (group (repeat 1 2 digit) ":"
42 (repeat 1 2 digit) 42 (repeat 1 2 digit)
43 (: (any ?a ?A ?p ?P) (any ?m ?M))) 43 (: (any ?a ?A ?p ?P) (any ?m ?M)))
44 (* nonl) 44 (* nonl)
45 (: (any ?s ?S) "unset") " " 45 (: (any ?s ?S) "unset") " "
46 (group (repeat 1 2 digit) ":" 46 (group (repeat 1 2 digit) ":"
47 (repeat 1 2 digit) 47 (repeat 1 2 digit)
48 (: (any ?a ?A ?p ?P) (any ?m ?M))) 48 (: (any ?a ?A ?p ?P) (any ?m ?M)))
49 (* nonl))) 49 (* nonl)))
50 (ss (sunrise-sunset)) 50 (ss (sunrise-sunset))
51 (_m (string-match times-regex ss)) 51 (_m (string-match times-regex ss))
52 (sunrise-time (match-string 1 ss)) 52 (sunrise-time (match-string 1 ss))
53 (sunset-time (match-string 2 ss))) 53 (sunset-time (match-string 2 ss)))
54 (run-at-time sunrise-time (* 60 60 24) sunrise-command) 54 (run-at-time sunrise-time (* 60 60 24) sunrise-command)
55 (run-at-time sunset-time (* 60 60 24) sunset-command) 55 (run-at-time sunset-time (* 60 60 24) sunset-command)
56 (run-at-time "12:00am" (* 60 60 24) sunset-command))) 56 (run-at-time "12:00am" (* 60 60 24) sunset-command)))
@@ -58,15 +58,15 @@ Ready for use with `after-focus-change-function'."
58;;; Directories (think `no-littering') 58;;; Directories (think `no-littering')
59 59
60(defvar acdw/dir (expand-file-name 60(defvar acdw/dir (expand-file-name
61 (convert-standard-filename "var/") 61 (convert-standard-filename "var/")
62 user-emacs-directory) 62 user-emacs-directory)
63 "A directory to hold extra configuration and emacs data.") 63 "A directory to hold extra configuration and emacs data.")
64 64
65(defun acdw/in-dir (file &optional make-directory) 65(defun acdw/in-dir (file &optional make-directory)
66 "Expand FILE relative to `acdw/dir', optionally creating its 66 "Expand FILE relative to `acdw/dir', optionally creating its
67directory." 67directory."
68 (let ((f (expand-file-name (convert-standard-filename file) 68 (let ((f (expand-file-name (convert-standard-filename file)
69 acdw/dir))) 69 acdw/dir)))
70 (when make-directory 70 (when make-directory
71 (make-directory (file-name-directory f) 'parents)) 71 (make-directory (file-name-directory f) 'parents))
72 f)) 72 f))
@@ -81,11 +81,11 @@ ASSIGNMENTS is a list where each element is of the form
81 (let (setting) ; for return value 81 (let (setting) ; for return value
82 (dolist (assignment assignments setting) 82 (dolist (assignment assignments setting)
83 (customize-set-variable (car assignment) 83 (customize-set-variable (car assignment)
84 (cadr assignment) 84 (cadr assignment)
85 (if (and (caddr assignment) 85 (if (and (caddr assignment)
86 (stringp (caddr assignment))) 86 (stringp (caddr assignment)))
87 (caddr assignment) 87 (caddr assignment)
88 "Customized by `acdw/set'.")) 88 "Customized by `acdw/set'."))
89 (setq setting (car assignment))))) 89 (setq setting (car assignment)))))
90 90
91;;; Faces 91;;; Faces
@@ -118,19 +118,19 @@ ARGS accept the following keywords:
118 118
119:after FEATURE .. `autoload' all functions after FEATURE." 119:after FEATURE .. `autoload' all functions after FEATURE."
120 (let ((after (plist-get args :after)) 120 (let ((after (plist-get args :after))
121 (command-list)) 121 (command-list))
122 (dolist (spec hook-specs) 122 (dolist (spec hook-specs)
123 (let* ((hooks (car spec)) 123 (let* ((hooks (car spec))
124 (funcs (cadr spec)) 124 (funcs (cadr spec))
125 (depth (or (caddr spec) 0)) 125 (depth (or (caddr spec) 0))
126 (local (cadddr spec))) 126 (local (cadddr spec)))
127 (when (not (listp hooks)) (setq hooks (list hooks))) 127 (when (not (listp hooks)) (setq hooks (list hooks)))
128 (when (not (listp funcs)) (setq funcs (list funcs))) 128 (when (not (listp funcs)) (setq funcs (list funcs)))
129 (dolist (hook hooks) 129 (dolist (hook hooks)
130 (dolist (func funcs) 130 (dolist (func funcs)
131 (push `(add-hook ',hook #',func ,depth ,local) command-list) 131 (push `(add-hook ',hook #',func ,depth ,local) command-list)
132 (when after 132 (when after
133 (push `(autoload #',func ,after) command-list)))))) 133 (push `(autoload #',func ,after) command-list))))))
134 `(progn 134 `(progn
135 ,@command-list))) 135 ,@command-list)))
136 136
@@ -161,25 +161,25 @@ The following keywords are recognized:
161 defined in a different file than the command it binds (looking 161 defined in a different file than the command it binds (looking
162 at you, `org-mode')." 162 at you, `org-mode')."
163 (let ((after (when-let (sym (plist-get args :after)) 163 (let ((after (when-let (sym (plist-get args :after))
164 (if (not (listp sym)) 164 (if (not (listp sym))
165 (list sym) 165 (list sym)
166 sym))) 166 sym)))
167 (map-after (plist-get args :map-after)) 167 (map-after (plist-get args :map-after))
168 (keymap (or (plist-get args :map) acdw/bind-default-map)) 168 (keymap (or (plist-get args :map) acdw/bind-default-map))
169 (keycode (if (vectorp key) key (kbd key))) 169 (keycode (if (vectorp key) key (kbd key)))
170 (command-list)) 170 (command-list))
171 (let ((define-key-command `(define-key ,keymap ,keycode ',command))) 171 (let ((define-key-command `(define-key ,keymap ,keycode ',command)))
172 (if map-after 172 (if map-after
173 (push `(with-eval-after-load ,map-after 173 (push `(with-eval-after-load ,map-after
174 ,define-key-command) 174 ,define-key-command)
175 command-list) 175 command-list)
176 (push define-key-command command-list))) 176 (push define-key-command command-list)))
177 (when after 177 (when after
178 (unless (fboundp command) 178 (unless (fboundp command)
179 (push `(autoload ',command ,@after) command-list)) 179 (push `(autoload ',command ,@after) command-list))
180 (unless (or map-after 180 (unless (or map-after
181 (eq keymap acdw/bind-default-map)) 181 (eq keymap acdw/bind-default-map))
182 (push `(autoload ',keymap ,(car after) nil nil 'keymap) command-list))) 182 (push `(autoload ',keymap ,(car after) nil nil 'keymap) command-list)))
183 `(progn 183 `(progn
184 ,@command-list))) 184 ,@command-list)))
185 185
@@ -197,9 +197,9 @@ The following keywords are recognized:
197KEYMAP can be nil." 197KEYMAP can be nil."
198 (declare (indent 2)) 198 (declare (indent 2))
199 (let ((bind-list) 199 (let ((bind-list)
200 (extra-args (if keymap 200 (extra-args (if keymap
201 `(:after ,file :map ,keymap) 201 `(:after ,file :map ,keymap)
202 `(:after ,file)))) 202 `(:after ,file))))
203 (dolist (binding bindings) 203 (dolist (binding bindings)
204 (push `(acdw/bind ,@binding ,@extra-args) bind-list)) 204 (push `(acdw/bind ,@binding ,@extra-args) bind-list))
205 `(progn 205 `(progn
@@ -213,34 +213,34 @@ KEYMAP can be nil."
213ARGS can include the following keywords: 213ARGS can include the following keywords:
214 214
215:local BOOL .. if BOOL is non-nil, don't run `straight-use-package' on 215:local BOOL .. if BOOL is non-nil, don't run `straight-use-package' on
216 PACKAGE. Good for using `acdw/pkg' on local features. 216 PACKAGE. Good for using `acdw/pkg' on local features.
217:require BOOL .. if BOOL is non-nil, run `require' on PACKAGE before anything. 217:require BOOL .. if BOOL is non-nil, run `require' on PACKAGE before anything.
218:now FORMS .. run FORMS immediately. 218:now FORMS .. run FORMS immediately.
219:then FORMS .. run FORMS after loading PACKAGE, using `with-eval-after-load'. 219:then FORMS .. run FORMS after loading PACKAGE, using `with-eval-after-load'.
220:set SETTINGS .. pass SETTINGS to `acdw/set', right after `:now' forms. 220:set SETTINGS .. pass SETTINGS to `acdw/set', right after `:now' forms.
221 SETTINGS should be properly quoted, just like they'd be passed 221 SETTINGS should be properly quoted, just like they'd be passed
222 to the function. 222 to the function.
223:binds BINDS .. run `acdw/bind-after-map' on BINDS. 223:binds BINDS .. run `acdw/bind-after-map' on BINDS.
224:hooks HOOKS .. run `acdw/hooks' on HOOKS." 224:hooks HOOKS .. run `acdw/hooks' on HOOKS."
225 (declare (indent 1)) 225 (declare (indent 1))
226 (let ((local-pkg (plist-get args :local)) 226 (let ((local-pkg (plist-get args :local))
227 (require-pkg (plist-get args :require)) 227 (require-pkg (plist-get args :require))
228 (now-forms (plist-get args :now)) 228 (now-forms (plist-get args :now))
229 (settings (plist-get args :set)) 229 (settings (plist-get args :set))
230 (binds (plist-get args :binds)) 230 (binds (plist-get args :binds))
231 (hooks (plist-get args :hooks)) 231 (hooks (plist-get args :hooks))
232 (then-forms (plist-get args :then)) 232 (then-forms (plist-get args :then))
233 (requirement (if (listp package) 233 (requirement (if (listp package)
234 (car package) 234 (car package)
235 package)) 235 package))
236 (final-form)) 236 (final-form))
237 (when then-forms 237 (when then-forms
238 (push `(with-eval-after-load ',requirement ,@then-forms) final-form)) 238 (push `(with-eval-after-load ',requirement ,@then-forms) final-form))
239 (when hooks 239 (when hooks
240 (push `(acdw/hooks ,hooks :after ,(symbol-name requirement)) final-form)) 240 (push `(acdw/hooks ,hooks :after ,(symbol-name requirement)) final-form))
241 (when binds 241 (when binds
242 (push `(acdw/bind-after-map ,(symbol-name requirement) nil ,binds) 242 (push `(acdw/bind-after-map ,(symbol-name requirement) nil ,binds)
243 final-form)) 243 final-form))
244 (when settings 244 (when settings
245 (push `(acdw/set ,settings) final-form)) 245 (push `(acdw/set ,settings) final-form))
246 (when now-forms 246 (when now-forms
@@ -273,7 +273,7 @@ ARGS can include the following keywords:
273;; Set up a leader key for `acdw/mode' 273;; Set up a leader key for `acdw/mode'
274(defvar acdw/leader 274(defvar acdw/leader
275 (let ((map (make-sparse-keymap)) 275 (let ((map (make-sparse-keymap))
276 (c-z (global-key-binding "\C-z"))) 276 (c-z (global-key-binding "\C-z")))
277 (define-key acdw/map "\C-z" map) 277 (define-key acdw/map "\C-z" map)
278 (define-key map "\C-z" c-z) 278 (define-key map "\C-z" c-z)
279 map)) 279 map))