summary refs log tree commit diff stats
path: root/early-init.el
diff options
context:
space:
mode:
Diffstat (limited to 'early-init.el')
-rw-r--r--early-init.el111
1 files changed, 49 insertions, 62 deletions
diff --git a/early-init.el b/early-init.el index 4037ef8..adc876a 100644 --- a/early-init.el +++ b/early-init.el
@@ -27,64 +27,53 @@
27;;; Speed up init 27;;; Speed up init
28;; see doom-emacs, et al. 28;; see doom-emacs, et al.
29 29
30(defconst gc-cons-threshold-basis (* 800 1000)
31 "The basis value for `gc-cons-threshold' to return to after a jump.
32800 KB is Emacs's default `gc-cons-threshold'.")
33
34(defconst gc-cons-percentage-basis 0.1
35 "The basis value for `gc-cons-percentage' to return to after init.
360.1 is Emacs's default `gc-cons-percentage'.")
37
38(defvar orig-file-name-handler-alist file-name-handler-alist 30(defvar orig-file-name-handler-alist file-name-handler-alist
39 "The original value of `file-name-handler-alist' will be restored 31 "The original value of `file-name-handler-alist' will be restored
40 after init.") 32 after init.")
41 33
42(setq gc-cons-threshold most-positive-fixnum 34(setq file-name-handler-alist nil)
43 gc-cons-percentage 0.6 35(acdw/gc-disable)
44 file-name-handler-alist nil)
45 36
46(defun hook--post-init-reset () 37(add-hook 'after-init-hook
47 "Reset `gc-cons-threshold', `gc-cons-percentage', and 38 (defun hook--post-init-reset ()
39 "Reset `gc-cons-threshold', `gc-cons-percentage', and
48 `file-name-handler-alist' to their defaults after init." 40 `file-name-handler-alist' to their defaults after init."
49 (setq gc-cons-threshold gc-cons-threshold-basis 41 (acdw/gc-enable)
50 gc-cons-percentage gc-cons-percentage-basis) 42 (dolist (handler file-name-handler-alist)
51 (dolist (handler file-name-handler-alist) 43 (add-to-list 'orig-file-name-handler-alist handler))
52 (add-to-list 'orig-file-name-handler-alist handler)) 44 (setq file-name-handler-alist orig-file-name-handler-alist)))
53 (setq file-name-handler-alist orig-file-name-handler-alist))
54
55(add-hook 'after-init-hook #'hook--post-init-reset)
56 45
57;;; Frame settings 46;;; Frame settings
58 47
59(setq default-frame-alist ; Remove most UI 48(setq default-frame-alist ; Remove most UI
60 `((tool-bar-lines . 0) ; No tool bar 49 `((tool-bar-lines . 0) ; No tool bar
61 (menu-bar-lines . 0) ; No menu bar 50 (menu-bar-lines . 0) ; No menu bar
62 (vertical-scroll-bars) ; No scroll bars 51 (vertical-scroll-bars) ; No scroll bars
63 (horizontal-scroll-bars) ; ... at all 52 (horizontal-scroll-bars) ; ... at all
64 (width . 84) ; A /little/ wider than 53 (width . 84) ; A /little/ wider than
65 ; `fill-column' (set later) 54 ; `fill-column' (set later)
66 (height . 30) 55 (height . 30)
67 (left-fringe . 8) ; Width of fringes 56 (left-fringe . 8) ; Width of fringes
68 (right-fringe . 8) ; (8 is default) 57 (right-fringe . 8) ; (8 is default)
69 (font . ,(pcase acdw/system 58 (font . ,(pcase acdw/system
70 (:home "DejaVu Sans Mono 10") 59 (:home "DejaVu Sans Mono 10")
71 (:work "Consolas 10")))) 60 (:work "Consolas 10"))))
72 frame-inhibit-implied-resize t ; Don't resize randomly 61 frame-inhibit-implied-resize t ; Don't resize randomly
73 frame-resize-pixelwise t ; Resize by pixels, not chars 62 frame-resize-pixelwise t ; Resize by pixels, not chars
74 ) 63 )
75 64
76(defun hook--disable-ui-modes () 65(defun hook--disable-ui-modes ()
77 "Disable frame UI using modes, for toggling later." 66 "Disable frame UI using modes, for toggling later."
78 (dolist (mode ;; each mode is of the form (MODE . FRAME-ALIST-VAR) 67 (dolist (mode ;; each mode is of the form (MODE . FRAME-ALIST-VAR)
79 '((tool-bar-mode . tool-bar-lines) 68 '((tool-bar-mode . tool-bar-lines)
80 (menu-bar-mode . menu-bar-lines) 69 (menu-bar-mode . menu-bar-lines)
81 (scroll-bar-mode . vertical-scroll-bars) 70 (scroll-bar-mode . vertical-scroll-bars)
82 (horizontal-scroll-bar-mode . horizontal-scroll-bars) 71 (horizontal-scroll-bar-mode . horizontal-scroll-bars)
83 )) 72 ))
84 (let ((setting (alist-get (cdr mode) default-frame-alist))) 73 (let ((setting (alist-get (cdr mode) default-frame-alist)))
85 (when (or (not setting) 74 (when (or (not setting)
86 (= 0 setting)) 75 (= 0 setting))
87 (funcall (car mode) -1))))) 76 (funcall (car mode) -1)))))
88 77
89(add-hook 'after-init-hook #'hook--disable-ui-modes) 78(add-hook 'after-init-hook #'hook--disable-ui-modes)
90 79
@@ -92,11 +81,11 @@
92 81
93;; 1. Update `exec-path'. 82;; 1. Update `exec-path'.
94(dolist (path (list (expand-file-name "bin" user-emacs-directory) 83(dolist (path (list (expand-file-name "bin" user-emacs-directory)
95 (expand-file-name "~/bin") 84 (expand-file-name "~/bin")
96 (expand-file-name "~/.local/bin") 85 (expand-file-name "~/.local/bin")
97 (expand-file-name "~/usr/bin") 86 (expand-file-name "~/usr/bin")
98 (expand-file-name "~/cmd") 87 (expand-file-name "~/cmd")
99 (expand-file-name "~/mingw64/bin"))) 88 (expand-file-name "~/mingw64/bin")))
100 (when (file-exists-p path) 89 (when (file-exists-p path)
101 (add-to-list 'exec-path path :append))) 90 (add-to-list 'exec-path path :append)))
102 91
@@ -104,27 +93,25 @@
104(setenv "PATH" (mapconcat #'identity exec-path path-separator)) 93(setenv "PATH" (mapconcat #'identity exec-path path-separator))
105 94
106;; 2. Set `package' and `straight' variables. 95;; 2. Set `package' and `straight' variables.
107(setq package-enable-at-startup nil ; not sure if strictly 96(setq package-enable-at-startup nil
108 ; necessary 97 package-quickstart nil
109 package-quickstart nil ; ditto
110 straight-host-usernames '((github . "duckwork") 98 straight-host-usernames '((github . "duckwork")
111 (gitlab . "acdw")) 99 (gitlab . "acdw"))
112 straight-base-dir acdw/dir ; don't clutter ~/.emacs.d 100 straight-base-dir acdw/dir)
113 )
114 101
115;; 3. Bootstrap `straight'. 102;; 3. Bootstrap `straight'.
116(defvar bootstrap-version) 103(defvar bootstrap-version)
117(let ((bootstrap-file 104(let ((bootstrap-file
118 (expand-file-name 105 (expand-file-name
119 "straight/repos/straight.el/bootstrap.el" 106 "straight/repos/straight.el/bootstrap.el"
120 straight-base-dir)) 107 straight-base-dir))
121 (bootstrap-version 5)) 108 (bootstrap-version 5))
122 (unless (file-exists-p bootstrap-file) 109 (unless (file-exists-p bootstrap-file)
123 (with-current-buffer 110 (with-current-buffer
124 (url-retrieve-synchronously 111 (url-retrieve-synchronously
125 (concat "https://raw.githubusercontent.com/" 112 (concat "https://raw.githubusercontent.com/"
126 "raxod502/straight.el/develop/install.el") 113 "raxod502/straight.el/develop/install.el")
127 'silent 'inhibit-cookies) 114 'silent 'inhibit-cookies)
128 (goto-char (point-max)) 115 (goto-char (point-max))
129 (eval-print-last-sexp))) 116 (eval-print-last-sexp)))
130 (load bootstrap-file nil 'nomessage)) 117 (load bootstrap-file nil 'nomessage))
@@ -134,10 +121,10 @@
134(defun hook--message-startup-time () 121(defun hook--message-startup-time ()
135 "Show Emacs's startup time in the message buffer. For profiling." 122 "Show Emacs's startup time in the message buffer. For profiling."
136 (message "Emacs ready in %s with %d garbage collections." 123 (message "Emacs ready in %s with %d garbage collections."
137 (format "%.2f seconds" 124 (format "%.2f seconds"
138 (float-time (time-subtract after-init-time 125 (float-time (time-subtract after-init-time
139 before-init-time))) 126 before-init-time)))
140 gcs-done)) 127 gcs-done))
141 128
142(add-hook 'emacs-startup-hook #'hook--message-startup-time) 129(add-hook 'emacs-startup-hook #'hook--message-startup-time)
143 130