diff options
Diffstat (limited to 'early-init.el')
-rw-r--r-- | early-init.el | 229 |
1 files changed, 78 insertions, 151 deletions
diff --git a/early-init.el b/early-init.el index 64bf3cc..ccd1ff4 100644 --- a/early-init.el +++ b/early-init.el | |||
@@ -1,135 +1,76 @@ | |||
1 | ;;; early-init.el -*- lexical-binding: t; coding: utf-8-unix -*- | 1 | ;;; early-init.el -*- lexical-binding: t; coding: utf-8-unix -*- |
2 | ;; Author: Case Duckworth <(rot13-string "npqj@npqj.arg")> | 2 | |
3 | ;; Author: Case Duckworth <acdw@acdw.net> | ||
3 | ;; Created: Sometime during Covid-19, 2020 | 4 | ;; Created: Sometime during Covid-19, 2020 |
4 | ;; Keywords: configuration | 5 | ;; Keywords: configuration |
5 | ;; URL: https://tildegit.org/acdw/emacs | 6 | ;; URL: https://tildegit.org/acdw/emacs |
6 | 7 | ||
7 | ;; This file is NOT part of GNU Emacs. | ||
8 | |||
9 | ;;; License: | 8 | ;;; License: |
10 | ;; Everyone is permitted to do whatever with this software, without | 9 | |
11 | ;; limitation. This software comes without any warranty whatsoever, | 10 | ;; Everyone is permitted to do whatever they like with this software |
12 | ;; but with two pieces of advice: | 11 | ;; without limitation. This software comes without any warranty |
13 | ;; - Don't hurt yourself. | 12 | ;; whatsoever, but with two pieces of advice: |
13 | ;; - Be kind to yourself. | ||
14 | ;; - Make good choices. | 14 | ;; - Make good choices. |
15 | 15 | ||
16 | ;;; Comentary: | 16 | ;;; Commentary: |
17 | ;; Starting with Emacs 27.1, `early-init' is sourced before `package' | 17 | |
18 | ;; or any frames. So those are the settings I run in this file. | 18 | ;; Starting with Emacs 27.1, early-init.el is sourced before |
19 | ;; package.el and any graphical frames. In this file, I set up frame | ||
20 | ;; parameters and packaging infrastructure. | ||
19 | 21 | ||
20 | ;;; Code: | 22 | ;;; Code: |
21 | 23 | ||
22 | ;;; Add `acdw.el' | 24 | (push (locate-user-emacs-file "lisp") load-path) |
23 | (push (expand-file-name "lisp/" user-emacs-directory) | 25 | (add-to-list 'load-path (locate-user-emacs-file "lisp/compat") :append) |
24 | load-path) | 26 | |
25 | (require 'acdw) | 27 | (require 'acdw) |
26 | (require 'acdw-frame) | 28 | |
27 | 29 | (+define-dir .etc (locate-user-emacs-file ".etc") | |
28 | ;;; Frame settings | 30 | "Directory for all of Emacs's various files. |
29 | (when (acdw/system :home) | 31 | See `no-littering' for examples.") |
30 | (setq initial-frame-alist '((fullscreen . maximized)))) | 32 | |
31 | 33 | (+define-dir sync/ (expand-file-name "~/Sync") | |
32 | (setq default-frame-alist | 34 | "My Syncthing directory.") |
33 | `((tool-bar-lines . 0) | 35 | |
34 | (menu-bar-lines . 0) | 36 | ;;; Default frame settings |
35 | (vertical-scroll-bars . nil) | 37 | |
36 | (horizontal-scroll-bars . nil) | 38 | (setq default-frame-alist '((tool-bar-lines . 0) |
37 | ;; (width . 84) | 39 | (menu-bar-lines . 0) |
38 | ;; (height . 30) | 40 | (vertical-scroll-bars) |
39 | (left-fringe . 8) | 41 | (horizontal-scroll-bars)) |
40 | (right-fringe . 8) | ||
41 | (font . ,(acdw/system | ||
42 | (:home "DejaVu Sans Mono 10") | ||
43 | (:work "Consolas 12") | ||
44 | (:other "monospace 10")))) | ||
45 | frame-inhibit-implied-resize t | 42 | frame-inhibit-implied-resize t |
46 | frame-resize-pixelwise t | 43 | frame-resize-pixelwise t |
47 | inhibit-x-resources t) | 44 | window-resize-pixelwise t |
48 | 45 | inhibit-x-resources t | |
49 | (add-hook 'after-init-hook | 46 | indicate-empty-lines nil |
50 | (defun after-init@disable-ui-modes () | 47 | indicate-buffer-boundaries '((top . right) |
51 | "Disable UI modes after init. | 48 | (bottom . right))) |
52 | I already disable them from the `default-frame-alist' for speed | 49 | |
53 | and anti-flickering reasons, but this function allows running, | 50 | ;; Fonts |
54 | say, `tool-bar-mode' once to toggle the tool bar back on." | 51 | (let ((font-name "Go Mono") |
55 | (dolist (mode ;; each mode is of the form (MODE . FRAME-ALIST-VAR) | 52 | (font-size 105)) |
56 | '((tool-bar-mode . tool-bar-lines) | 53 | (set-face-attribute 'default nil :family font-name |
57 | (menu-bar-mode . menu-bar-lines) | 54 | :height font-size :weight 'book) |
58 | (scroll-bar-mode . vertical-scroll-bars) | 55 | (set-face-attribute 'italic nil :family font-name |
59 | (horizontal-scroll-bar-mode . horizontal-scroll-bars))) | 56 | :height font-size :slant 'italic)) |
60 | (let ((setting (alist-get (cdr mode) default-frame-alist))) | 57 | |
61 | (when (or (not setting) | 58 | ;;; Packages |
62 | (zerop setting)) | 59 | |
63 | (funcall (car mode) -1)))))) | ||
64 | |||
65 | (add-hook 'after-make-frame-functions | ||
66 | (defun after-make-frame@setup (&rest args) | ||
67 | (ignore args) | ||
68 | (let ((fixed-pitch-faces | ||
69 | '((:font "Fantasque Sans Mono" :height 115) | ||
70 | (:font "Go Mono" :height 110) | ||
71 | (:font "DejaVu Sans Mono" :height 110) | ||
72 | (:font "monospace" :height 100))) | ||
73 | (variable-pitch-faces | ||
74 | '((:font "Inter" :height 120) | ||
75 | (:font "Go" :height 120) | ||
76 | (:font "sans-serif" :height 100)))) | ||
77 | (acdw/set-first-face-attribute 'default | ||
78 | fixed-pitch-faces) | ||
79 | (acdw/set-first-face-attribute 'fixed-pitch | ||
80 | fixed-pitch-faces) | ||
81 | (acdw/set-first-face-attribute 'variable-pitch | ||
82 | variable-pitch-faces)) | ||
83 | (acdw/set-emoji-fonts "Noto Color Emoji" | ||
84 | "Noto Emoji" | ||
85 | "Segoe UI Emoji" | ||
86 | "Apple Color Emoji" | ||
87 | "FreeSans" | ||
88 | "FreeMono" | ||
89 | "FreeSerif" | ||
90 | "Unifont" | ||
91 | "Symbola") | ||
92 | (acdw/set-fringes '((left-curly-arrow [#b01100000 | ||
93 | #b00110000 | ||
94 | #b00011000 | ||
95 | #b00001100] | ||
96 | 4 8 center) | ||
97 | (right-curly-arrow [#b00000011 | ||
98 | #b00000110 | ||
99 | #b00001100 | ||
100 | #b00011000] | ||
101 | 4 8 center) | ||
102 | (left-arrow [#b01100000 | ||
103 | #b01010000] | ||
104 | 2 8 (top t)) | ||
105 | (right-arrow [#b00000011 | ||
106 | #b00000101] | ||
107 | 2 8 (top t)))) | ||
108 | (setq indicate-empty-lines nil | ||
109 | indicate-buffer-boundaries '((top . right) | ||
110 | (bottom . right))) | ||
111 | (custom-set-faces '(fringe ((t (:foreground "dim gray"))))))) | ||
112 | (add-hook 'server-after-make-frame-hook #'after-make-frame@setup) | ||
113 | |||
114 | ;; I have this here because ... the first frame doesn't ? run ? the hook ??? | ||
115 | (add-function :after after-focus-change-function | ||
116 | (defun after-focus-change@first-frame-setup (&rest args) | ||
117 | (ignore args) | ||
118 | (after-make-frame@setup) | ||
119 | (remove-function after-focus-change-function | ||
120 | #'after-focus-change@first-frame-setup))) | ||
121 | |||
122 | ;;; Bootstrap package manager (`straight.el') | ||
123 | |||
124 | ;; Set `package' and `straight' variables. | ||
125 | (setq package-enable-at-startup nil | 60 | (setq package-enable-at-startup nil |
126 | package-quickstart nil | 61 | package-quickstart nil |
127 | straight-host-usernames '((github . "duckwork") | 62 | straight-host-usernames '((github . "duckwork") |
128 | (gitlab . "acdw")) | 63 | (gitlab . "acdw")) |
129 | straight-base-dir (acdw/dir) | 64 | straight-check-for-modifications '(check-on-save |
130 | straight-check-for-modifications '(check-on-save find-when-checking)) | 65 | find-when-checking)) |
66 | |||
67 | (setq no-littering-etc-directory .etc | ||
68 | no-littering-var-directory .etc | ||
69 | straight-base-dir .etc) | ||
70 | |||
71 | ;; Bootstrap straight.el | ||
72 | ;; https://github.com/raxod502/straight.el | ||
131 | 73 | ||
132 | ;; Bootstrap `straight'. | ||
133 | (defvar bootstrap-version) | 74 | (defvar bootstrap-version) |
134 | (let ((bootstrap-file | 75 | (let ((bootstrap-file |
135 | (expand-file-name | 76 | (expand-file-name |
@@ -146,44 +87,30 @@ say, `tool-bar-mode' once to toggle the tool bar back on." | |||
146 | (eval-print-last-sexp))) | 87 | (eval-print-last-sexp))) |
147 | (load bootstrap-file nil 'nomessage)) | 88 | (load bootstrap-file nil 'nomessage)) |
148 | 89 | ||
149 | ;; Helper package, good commands here. | 90 | ;; Early-loaded packages -- those that, for some reason or another, |
91 | ;; need to be ensured to be loaded first. | ||
92 | |||
150 | (require 'straight-x) | 93 | (require 'straight-x) |
151 | 94 | ||
152 | ;; Appendix. Get rid of a dumb alias. | 95 | (dolist (pkg '(el-patch |
153 | ;; straight-ಠ_ಠ-mode really slows down all minibuffer completion functions. | 96 | no-littering |
154 | ;; Since it's a (rarely-used, even) alias anyway, I just define it back to nil. | 97 | setup)) |
155 | ;; By the way, the alias is `straight-package-neutering-mode'. | 98 | (straight-use-package pkg) |
156 | (defalias 'straight-ಠ_ಠ-mode nil) | 99 | (require pkg) |
100 | (require (intern (format "+%s" pkg)) nil :noerror)) | ||
157 | 101 | ||
158 | ;;; Message startup time for profiling | 102 | ;;; Appendix |
159 | ;; This just redefines the Emacs function | ||
160 | ;; `display-startup-echo-area-message', so no hooks needed. | ||
161 | (defun display-startup-echo-area-message () | ||
162 | "Show Emacs's startup time in the message buffer. For profiling." | ||
163 | (message "Emacs ready in %s with %d garbage collections." | ||
164 | (format "%.2f seconds" | ||
165 | (float-time (time-subtract after-init-time | ||
166 | before-init-time))) | ||
167 | gcs-done)) | ||
168 | |||
169 | ;;; Early-loaded packages | ||
170 | ;; These packages are here because they need to be loaded /before/ | ||
171 | ;; everything else in init.el. | ||
172 | |||
173 | (straight-use-package '(setup | ||
174 | :host nil | ||
175 | :repo "https://git.sr.ht/~pkal/setup")) | ||
176 | (require 'setup) | ||
177 | (require 'acdw-setup) | ||
178 | |||
179 | (setup (:straight no-littering) | ||
180 | (:option no-littering-etc-directory (acdw/dir) | ||
181 | no-littering-var-directory (acdw/dir)) | ||
182 | (require 'no-littering)) | ||
183 | |||
184 | (setup (:straight el-patch)) | ||
185 | |||
186 | ;; My private variables and stuff | ||
187 | (require 'private (acdw/sync-dir "private") :noerror) | ||
188 | 103 | ||
104 | ;; I've patched setup to look at `setup-ensure-function-inhibit' to decide | ||
105 | ;; whether to ensure functions or not with local macros. | ||
106 | (setq setup-ensure-function-inhibit t) | ||
107 | |||
108 | ;; Get rid of a dumb alias. straight-ಠ_ಠ-mode really slows down all | ||
109 | ;; minibuffer completion functions. Since it's a (rarely-used, even) | ||
110 | ;; alias anyway, I just define it back to nil. By the way, the alias | ||
111 | ;; is `straight-package-neutering-mode'. | ||
112 | (defalias 'straight-ಠ_ಠ-mode nil) | ||
113 | |||
114 | (provide 'early-init) | ||
189 | ;;; early-init.el ends here | 115 | ;;; early-init.el ends here |
116 | |||