-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathearly-init.el
98 lines (69 loc) · 3.13 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
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 -*-
;; Copyright (C) 2022-2023 Tommaso Rossi
;; Author: Tommaso Rossi <[email protected]>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Emacs early init file, that gets evaluated before init.el and even before the GUI is loaded.
;; The focus is on optimizing startup time and perform basic UI cleanups.
;;; Code:
;;;; Optimize garbage collections
(defconst +gc-cons-standard-threshold-mb 1024
"Number of MB of consing between garbage collection during normal operativity.")
(defconst +gc-cons-startup-threshold-mb 2048
"Number of MB of consing between garbage collection during startup.")
(defun +restore-garbage-collection ()
"Restore GC consing threshold to `+gc-cons-standard-threshold-mb'."
(setq gc-cons-threshold (* +gc-cons-standard-threshold-mb 1024 1024)))
;; set high garbage collection consing threshold during startup
(setq gc-cons-threshold (* +gc-cons-startup-threshold-mb 1024 1024))
;; restore garbage collection after init
(add-hook 'emacs-startup-hook '+restore-garbage-collection)
;; garbage collect when idle
(run-with-idle-timer 2 t 'garbage-collect)
;;;; Put native comp cache elsewhere
(when (boundp 'native-comp-eln-load-path)
(startup-redirect-eln-cache
(expand-file-name ".cache/eln-cache" user-emacs-directory)))
;;;; Temporary disable file handler at startup
(defvar default-file-name-handler-alist file-name-handler-alist)
(setq file-name-handler-alist nil)
(defun +reset-file-name-handler-alist ()
"Reset filename handlers to default value."
(setq file-name-handler-alist default-file-name-handler-alist))
(add-hook 'emacs-startup-hook '+reset-file-name-handler-alist)
;;;; Disable package.el at startup
(setq package-enable-at-startup nil)
;;;; Early UI cleanups
;; frame resize seems to be very expensive, disable it
(setq frame-inhibit-implied-resize t)
(setq inhibit-default-init t)
(setq inhibit-startup-buffer-menu t)
(setq inhibit-startup-screen t)
(setq initial-scratch-message nil)
;; initial frame settings
(setq default-frame-alist
`(
;; start fullscreen without window bar
;; (undecorated . t)
;; start fullscreen
(fullscreen . maximized)
;; avoid blinding white on startup
(background-color . "#000000")))
(set-face-attribute 'default nil :foreground "#ffffff")
(when (not (getenv "CI"))
;; disable unwanted ui components
(menu-bar-mode -1)
(toggle-scroll-bar -1)
(scroll-bar-mode -1)
(tool-bar-mode -1)
(setq inhibit-startup-screen t))
;;; early-init.el ends here