blob: c75d963aeadcfc411801368b40712321a1e28c41 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
;;; early-init.el --- Emacs early init -*- lexical-binding: t; -*-
;; by C. Duckworth <acdw@acdw.net>
;; Bankruptcy: 9
;;; Speed up init
;; Restore things after init
(defvar +emacs--startup-restore-alist nil
"Variables and values to restore after init.")
(add-hook 'emacs-startup-hook
(defun emacs-startup@restore-values ()
"Restore values set during init.
This applies values in `+emacs--startup-restore-alist'."
(dolist (a +emacs--startup-restore-alist)
(set (car a) (cdr a)))))
(defun +set-during-startup (variable value &optional restore)
"Set VARIABLE to VALUE during startup, but restore to RESTORE.
If RESTORE is nil or not passed, save the original value and
restore that."
(unless after-init-time
(setf (alist-get variable +emacs--startup-restore-alist)
(or restore (symbol-value variable)))
(set-default variable value)))
;; Garbage collection
(+set-during-startup 'gc-cons-threshold most-positive-fixnum)
(add-hook 'minibuffer-setup-hook (defun garbage-collect@minibuffer-enter ()
(setf gc-cons-threshold most-positive-fixnum)))
(add-hook 'minibuffer-exit-hook (defun garbage-collect@minibuffer-exit ()
(setf gc-cons-threshold 800000)))
;; Don't prematurely re-display
(unless debug-on-error
(+set-during-startup 'inhibit-redisplay t)
(+set-during-startup 'inhibit-message t))
;; Debug during init
(unless (eq debug-on-error 'startup)
(+set-during-startup 'debug-on-error 'init))
;;; Default frame settings
(setf default-frame-alist '((tool-bar-lines . 0)
(menu-bar-lines . 0)
(vertical-scroll-bars)
(horizontal-scroll-bars))
frame-inhibit-implied-resize t
frame-resize-pixelwise t
window-resize-pixelwise t
inhibit-x-resources t
indicate-empty-lines nil
indicate-buffer-boundaries nil
;; '((top . right)
;; (bottom . right))
)
;;; Set up extra load paths and functionality
(push (locate-user-emacs-file "lisp") load-path)
(require 'acdw)
(+define-dir .etc (locate-user-emacs-file "etc")
"Directory for all of Emacs's various files.
See `no-littering' for examples.")
(+define-dir sync/ (expand-file-name "~/Sync")
"My Syncthing directory.")
(+define-dir private/ (sync/ "emacs/private"))
(add-to-list 'load-path private/)
;;; Packages
(setf package-enable-at-startup nil
package-quickstart nil)
(require 'yoke)
(add-hook 'emacs-lisp-mode-hook #'yoke-imenu-insinuate)
(yoke (compat "https://git.sr.ht/~pkal/compat"))
(yoke (no-littering "https://github.com/emacscollective/no-littering")
(setf no-littering-etc-directory .etc
no-littering-var-directory .etc
custom-file (.etc "custom.el"))
(require 'no-littering)
(when (boundp 'native-comp-eln-load-path)
(setcar native-comp-eln-load-path (expand-file-name (.etc "eln-cache" t))))
(when (boundp 'comp-eln-load-path)
(setcar comp-eln-load-path (expand-file-name (.etc "eln-cache" t))))
(when (fboundp 'startup-redirect-eln-cache)
(startup-redirect-eln-cache (convert-standard-filename (.etc "eln-cache/")))))
(provide 'early-init)
;;; early-init.el ends here
|