summary refs log tree commit diff stats
path: root/early-init.el
diff options
context:
space:
mode:
authorCase Duckworth2021-04-06 17:59:45 -0500
committerCase Duckworth2021-04-06 17:59:45 -0500
commitc05d1ba2c8e28f2f55f9e11bcf8e42b1ed43e539 (patch)
treed0faa720fd0c957c2597aa1d3956054d0112395f /early-init.el
parentRemove acdw/map (diff)
downloademacs-c05d1ba2c8e28f2f55f9e11bcf8e42b1ed43e539.tar.gz
emacs-c05d1ba2c8e28f2f55f9e11bcf8e42b1ed43e539.zip
7
Diffstat (limited to 'early-init.el')
-rw-r--r--early-init.el75
1 files changed, 34 insertions, 41 deletions
diff --git a/early-init.el b/early-init.el index fac0705..b8f652e 100644 --- a/early-init.el +++ b/early-init.el
@@ -24,37 +24,21 @@
24 load-path) 24 load-path)
25(require 'acdw) 25(require 'acdw)
26 26
27;;; Refresh Emacs easily 27
28(defun refresh-emacs ()
29 "Reload Emacs's configuration files."
30 (interactive)
31 (dolist (file (list (locate-user-emacs-file "early-init.el")
32 (locate-user-emacs-file "init.el" ".emacs")))
33 (when (file-exists-p file)
34 (load-file file))))
35
36;;; Speed up init 28;;; Speed up init
37;; see doom-emacs, et al. 29;; see doom-emacs, et al.
38 30
39(defvar orig-file-name-handler-alist file-name-handler-alist 31(setq orig-file-name-handler-alist file-name-handler-alist
40 "The original value of `file-name-handler-alist' will be restored 32 file-name-handler-alist nil)
41 after init.") 33(acdw/gc-disable)
42
43(setq file-name-handler-alist nil)
44(setq gc-cons-threshold (* 800 1024 1024)
45 gc-cons-percentage 0.6)
46
47(add-hook 'after-init-hook
48 (defun hook--post-init-reset ()
49 "Reset `gc-cons-threshold', `gc-cons-percentage', and
50 `file-name-handler-alist' to their defaults after init."
51 (acdw/gc-enable)
52 (dolist (handler file-name-handler-alist)
53 (add-to-list 'orig-file-name-handler-alist handler))
54 (setq file-name-handler-alist orig-file-name-handler-alist)))
55 34
35(hook-defun post-init-reset after-init-hook
36 (acdw/gc-enable)
37 (dolist (handler file-name-handler-alist)
38 (add-to-list 'orig-file-name-handler-alist handler))
39 (setq file-name-handler-alist orig-file-name-handler-alist))
40
56;;; Frame settings 41;;; Frame settings
57
58(setq default-frame-alist ; Remove most UI 42(setq default-frame-alist ; Remove most UI
59 `((tool-bar-lines . 0) ; No tool bar 43 `((tool-bar-lines . 0) ; No tool bar
60 (menu-bar-lines . 0) ; No menu bar 44 (menu-bar-lines . 0) ; No menu bar
@@ -73,8 +57,7 @@
73 frame-resize-pixelwise t ; Resize by pixels, not chars 57 frame-resize-pixelwise t ; Resize by pixels, not chars
74 ) 58 )
75 59
76(defun hook--disable-ui-modes () 60(hook-defun disable-ui-modes after-init-hook
77 "Disable frame UI using modes, for toggling later."
78 (dolist (mode ;; each mode is of the form (MODE . FRAME-ALIST-VAR) 61 (dolist (mode ;; each mode is of the form (MODE . FRAME-ALIST-VAR)
79 '((tool-bar-mode . tool-bar-lines) 62 '((tool-bar-mode . tool-bar-lines)
80 (menu-bar-mode . menu-bar-lines) 63 (menu-bar-mode . menu-bar-lines)
@@ -86,8 +69,25 @@
86 (= 0 setting)) 69 (= 0 setting))
87 (funcall (car mode) -1))))) 70 (funcall (car mode) -1)))))
88 71
89(add-hook 'after-init-hook #'hook--disable-ui-modes) 72(add-function :after after-focus-change-function
90 73 (defun hook--setup-fonts ()
74 (dolist (face '(default fixed-pitch))
75 ;; `default' and `fixed-pitch' should be the same.
76 (set-face-attribute face nil
77 :font (pcase acdw/system
78 (:home "DejaVu Sans Mono-10")
79 (:work "Consolas-10")
80 (:other "monospace-10"))))
81 ;; `variable-pitch' is, of course, different.
82 (set-face-attribute 'variable-pitch nil
83 :font (pcase acdw/system
84 (:home "DejaVu Sans")
85 (:work "Calibri-11")
86 (:other "sans-serif")))
87 (remove-function after-focus-change-function
88 'hook--setup-fonts)))
89
90
91;;; Bootstrap package manager (`straight.el') 91;;; Bootstrap package manager (`straight.el')
92 92
93;; 1. Update `exec-path'. 93;; 1. Update `exec-path'.
@@ -108,7 +108,7 @@
108 package-quickstart nil 108 package-quickstart nil
109 straight-host-usernames '((github . "duckwork") 109 straight-host-usernames '((github . "duckwork")
110 (gitlab . "acdw")) 110 (gitlab . "acdw"))
111 straight-base-dir acdw/dir) 111 straight-base-dir (acdw/dir))
112 112
113;; 3. Bootstrap `straight'. 113;; 3. Bootstrap `straight'.
114(defvar bootstrap-version) 114(defvar bootstrap-version)
@@ -126,9 +126,10 @@
126 (goto-char (point-max)) 126 (goto-char (point-max))
127 (eval-print-last-sexp))) 127 (eval-print-last-sexp)))
128 (load bootstrap-file nil 'nomessage)) 128 (load bootstrap-file nil 'nomessage))
129 129
130;;; Message startup time for profiling 130;;; Message startup time for profiling
131 131;; This just redefines the Emacs function
132;; `display-startup-echo-area-message', so no hooks needed.
132(defun display-startup-echo-area-message () 133(defun display-startup-echo-area-message ()
133 "Show Emacs's startup time in the message buffer. For profiling." 134 "Show Emacs's startup time in the message buffer. For profiling."
134 (message "Emacs ready in %s with %d garbage collections." 135 (message "Emacs ready in %s with %d garbage collections."
@@ -136,11 +137,3 @@
136 (float-time (time-subtract after-init-time 137 (float-time (time-subtract after-init-time
137 before-init-time))) 138 before-init-time)))
138 gcs-done)) 139 gcs-done))
139
140;;; Install `no-littering', pointing both directories at `acdw/dir'. This will
141;;; take care of the packages I don't care about configuring.
142
143(straight-use-package 'no-littering)
144(setq no-littering-etc-directory acdw/dir
145 no-littering-var-directory acdw/dir)
146(require 'no-littering)