-
Notifications
You must be signed in to change notification settings - Fork 0
/
early-init.el
71 lines (57 loc) · 2.49 KB
/
early-init.el
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
;;; Emacs 27 introduced early-init.el, that runs before anything else | -*- lexical-binding: t; -*-
;; If .el file has .elc (or other) counterpart then load the newer one
(setq load-prefer-newer t)
;; Set GC Threshold to 4GiB initially (100MiB later)
(setq gc-cons-threshold (* 4 1024 1024 1024)
gc-cons-percentage 0.6)
;; For inhibiting the while flash at startup (colors: doom-one)
(unless (daemonp)
(set-face-attribute 'default nil :background "#282c34" :foreground "#bbc2cf"))
;; Reduce startup time due to fonts which are larger than system-font.
(setq frame-inhibit-implied-resize t
frame-resize-pixelwise t)
;; Reduce startup time due to file-handler matching
(defvar default-file-name-handler-alist file-name-handler-alist)
(setq file-name-handler-alist nil)
;; Set a few post-run handlers
(defun +gc-after-focus-change ()
"Run GC when frame loses focus."
(run-with-idle-timer
5 nil
(lambda () (unless (frame-focus-state) (garbage-collect)))))
(defun +reset-init-values ()
(run-with-idle-timer
1 nil
(lambda ()
(setq file-name-handler-alist default-file-name-handler-alist
gc-cons-percentage 0.1
gc-cons-threshold (* 100 1024 1024))
(message "Set gc-cons-threshold = 100M & file-name-handler-alist restored")
(when (boundp 'after-focus-change-function)
(add-function :after after-focus-change-function #'+gc-after-focus-change)))))
(defun +profiling ()
(message "Emacs loaded in %s with %d garbage collections."
(format "%.2f seconds"
(float-time (time-subtract (current-time) before-init-time)))
gcs-done))
(with-eval-after-load 'elpaca
(add-hook 'elpaca-after-init-hook #'+profiling)
(add-hook 'elpaca-after-init-hook #'+reset-init-values))
;; Disable the default & generally ugly UI elements
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(setq inhibit-startup-buffer-menu t ; When opening multiple-files with CLI
inhibit-splash-screen t ; Startup Screen
ring-bell-function #'ignore ; Silence :^)
use-file-dialog nil ; GUI File Dialog
use-dialog-box nil ; GUI Yes/No Prompt
server-client-instructions nil) ; Instructions for closing session (daemon mode)
;; Debugging
(setq debug-on-error t)
;; Ref: elpaca package-manager
(setq package-enable-at-startup nil)
(setq native-comp-async-report-warnings-errors nil)
;; Ignore Xresources (not sure if useful)
;; (advice-add #'x-apply-session-resources :override #'ignore)
(provide 'early-init)