diff options
Diffstat (limited to 'early-init.el')
-rw-r--r-- | early-init.el | 121 |
1 files changed, 59 insertions, 62 deletions
diff --git a/early-init.el b/early-init.el index 8004342..b841ea5 100644 --- a/early-init.el +++ b/early-init.el | |||
@@ -1,98 +1,95 @@ | |||
1 | ;;; early-init.el --- Emacs early init -*- lexical-binding: t; -*- | 1 | ;;; early-init.el --- Emacs early init -*- lexical-binding: t -*- |
2 | |||
2 | ;; by C. Duckworth <acdw@acdw.net> | 3 | ;; by C. Duckworth <acdw@acdw.net> |
3 | ;; Bankruptcy: 9 | ||
4 | 4 | ||
5 | ;;; Speed up init | 5 | ;; Bankruptcy: 9.3 |
6 | |||
7 | ;;; Debugging --- delete this when done bankrupting | ||
8 | (setf debug-on-error t | ||
9 | use-package-verbose t) | ||
10 | |||
11 | ;;; Speedy startup | ||
6 | 12 | ||
7 | ;; Restore things after init | ||
8 | (defvar +emacs--startup-restore-alist nil | 13 | (defvar +emacs--startup-restore-alist nil |
9 | "Variables and values to restore after init.") | 14 | "Variables to restore after startup.") |
10 | 15 | ||
11 | (add-hook 'emacs-startup-hook | 16 | (defun +emacs-startup@restore-variables () |
12 | (defun emacs-startup@restore-values () | 17 | "Restore variables set temporarily during startup." |
13 | "Restore values set during init. | 18 | (dolist (v +emacs--startup-restore-alist) |
14 | This applies values in `+emacs--startup-restore-alist'." | 19 | (set-default (car v) (cdr v)))) |
15 | (dolist (a +emacs--startup-restore-alist) | 20 | (add-hook 'after-init-hook #'+emacs-startup@restore-variables) |
16 | (set (car a) (cdr a))))) | ||
17 | 21 | ||
18 | (defun +set-during-startup (variable value &optional restore) | 22 | (defun +set-during-startup (variable value &optional restore) |
19 | "Set VARIABLE to VALUE during startup, but restore to RESTORE. | 23 | "Set VARIABLE to VALUE during startup. |
20 | If RESTORE is nil or not passed, save the original value and | 24 | If RESTORE is non-nil, restore the variable's value to it. |
21 | restore that." | 25 | Otherwise, save its original value and restore to that." |
22 | (unless after-init-time | 26 | (unless after-init-time |
23 | (setf (alist-get variable +emacs--startup-restore-alist) | 27 | (setf (alist-get variable +emacs--startup-restore-alist) |
24 | (or restore (symbol-value variable))) | 28 | (or restore (symbol-value variable))) |
25 | (set-default variable value))) | 29 | (set-default variable value))) |
26 | 30 | ||
27 | ;; Garbage collection | ||
28 | (+set-during-startup 'gc-cons-threshold most-positive-fixnum) | 31 | (+set-during-startup 'gc-cons-threshold most-positive-fixnum) |
29 | 32 | ||
30 | (add-hook 'minibuffer-setup-hook (defun garbage-collect@minibuffer-enter () | 33 | ;;; Distraction-free startup |
31 | (setf gc-cons-threshold most-positive-fixnum))) | ||
32 | (add-hook 'minibuffer-exit-hook (defun garbage-collect@minibuffer-exit () | ||
33 | (setf gc-cons-threshold 800000))) | ||
34 | 34 | ||
35 | ;; Don't prematurely re-display | ||
36 | (unless debug-on-error | 35 | (unless debug-on-error |
37 | (+set-during-startup 'inhibit-redisplay t) | 36 | (+set-during-startup 'inhibit-redisplay t) |
38 | (+set-during-startup 'inhibit-message t)) | 37 | (+set-during-startup 'inhibit-message t)) |
39 | 38 | ||
40 | ;; Debug during init | 39 | (setf warning-minimum-level :emergency) |
41 | (unless (eq debug-on-error 'startup) | 40 | (add-hook 'emacs-startup-hook |
42 | (+set-during-startup 'debug-on-error 'init)) | 41 | (defun +message-about-warnings () |
43 | 42 | (when-let ((warnings (get-buffer "*Warnings*"))) | |
44 | ;;; Default frame settings | 43 | (message "%s. %s." "There were init-time warnings" |
44 | "See the `*Warnings*' buffer.")))) | ||
45 | 45 | ||
46 | (setf default-frame-alist '((tool-bar-lines . 0) | 46 | (setf default-frame-alist '((tool-bar-lines . 0) |
47 | (menu-bar-lines . 0) | 47 | (menu-bar-lines . 0) |
48 | (vertical-scroll-bars) | 48 | (vertical-scroll-bars . nil) |
49 | (horizontal-scroll-bars)) | 49 | (horizontal-scroll-bars . nil)) |
50 | frame-inhibit-implied-resize t | 50 | frame-inhibit-implied-resize t |
51 | frame-resize-pixelwise t | 51 | frame-resize-pixelwise t |
52 | window-resize-pixelwise t | 52 | window-resize-pixelwise t |
53 | inhibit-x-resources t | 53 | inhibit-x-resources t |
54 | indicate-empty-lines nil | 54 | indicate-empty-lines nil |
55 | indicate-buffer-boundaries nil | 55 | indicate-buffer-boundaries nil) |
56 | ;; '((top . right) | 56 | |
57 | ;; (bottom . right)) | 57 | ;;; Packages |
58 | ) | ||
59 | 58 | ||
60 | ;;; Set up extra load paths and functionality | 59 | (require 'package) |
61 | 60 | ||
62 | (push (expand-file-name (locate-user-emacs-file "lisp")) load-path) | 61 | (dolist (archive |
63 | (require 'acdw) | 62 | '(("gnu-devel" . "https://elpa.gnu.org/devel/") |
63 | ("nongnu-devel" . "https://elpa.gnu.org/nongnu-devel/") | ||
64 | ("melpa" . "https://melpa.org/packages/"))) | ||
65 | (add-to-list 'package-archives archive :append)) | ||
64 | 66 | ||
65 | (+define-dir .etc (locate-user-emacs-file "etc") | 67 | (setf package-archive-priorities |
66 | "Directory for all of Emacs's various files. | 68 | '(("gnu-devel" . 2) |
67 | See `no-littering' for examples.") | 69 | ("nongnu-devel" . 1) |
70 | ("melpa" . 0) | ||
71 | ("gnu" . 0) | ||
72 | ("nongnu" . 0))) | ||
68 | 73 | ||
69 | (+define-dir sync/ (expand-file-name "~/Sync") | 74 | (package-initialize) |
70 | "My Syncthing directory.") | ||
71 | 75 | ||
72 | (+define-dir private/ (sync/ "emacs/private")) | 76 | (unless package-archive-contents |
73 | (add-to-list 'load-path private/) | 77 | (package-refresh-contents)) |
74 | 78 | ||
75 | ;;; Packages | 79 | ;; https://melpa.org/packages/archive-contents |
76 | 80 | ||
77 | (setf package-enable-at-startup nil | 81 | ;;; Use-package |
78 | package-quickstart nil) | ||
79 | 82 | ||
80 | (require 'yoke) | 83 | (setf use-package-enable-imenu-support t |
81 | (add-hook 'emacs-lisp-mode-hook #'yoke-imenu-insinuate) | 84 | use-package-hook-name-suffix nil) |
82 | 85 | ||
83 | (yoke (compat "https://git.sr.ht/~pkal/compat")) | 86 | (require 'use-package) |
84 | 87 | ||
85 | (yoke (no-littering "https://github.com/emacscollective/no-littering") | 88 | (setf use-package-compute-statistics debug-on-error) |
86 | (setf no-littering-etc-directory .etc | ||
87 | no-littering-var-directory .etc | ||
88 | custom-file (.etc "custom.el")) | ||
89 | (require 'no-littering) | ||
90 | (when (boundp 'native-comp-eln-load-path) | ||
91 | (setcar native-comp-eln-load-path (expand-file-name (.etc "eln-cache" t)))) | ||
92 | (when (boundp 'comp-eln-load-path) | ||
93 | (setcar comp-eln-load-path (expand-file-name (.etc "eln-cache" t)))) | ||
94 | (when (fboundp 'startup-redirect-eln-cache) | ||
95 | (startup-redirect-eln-cache (convert-standard-filename (.etc "eln-cache/"))))) | ||
96 | 89 | ||
97 | (provide 'early-init) | 90 | (use-package use-package-vc |
98 | ;;; early-init.el ends here | 91 | :load-path "~/src/emacs/use-package-vc.el" |
92 | :config | ||
93 | (define-advice package-vc-install (:around (orig &rest args) wtf) | ||
94 | (let ((package-archives nil)) | ||
95 | (apply orig args)))) | ||