-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathearly-init.el
98 lines (82 loc) · 3.53 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 --- early-init -*- lexical-binding: t -*-
;;;
;;; Commentary:
;;
;; Provides early initialization for Emacs.
;;
;;; Code:
;; Disable `package.el' early, as we use `straight.el'.
(setopt package-enable-at-startup nil)
;; Redirect native compilation cache if possible.
(when (fboundp 'startup-redirect-eln-cache)
(startup-redirect-eln-cache
(convert-standard-filename
(expand-file-name "var/eln-cache/" user-emacs-directory))))
(let ((minver "30.1"))
(when (version< emacs-version minver)
(error "The minimum Emacs version expected is %s" minver)))
(setopt ok-debug nil ; global switch for debugging
debug-on-error ok-debug
confirm-kill-processes t
inhibit-default-init nil
native-comp-async-query-on-exit t
pgtk-wait-for-event-timeout 0)
(setq debug-on-message nil ; set regexp to trigger debugger
byte-compile-warnings '(not obsolete)) ; set t for development
;; Reduce GC usage while initialization. 800 kb is the default (2021-08-01).
;; Note that the threshold while running is set by gcmh later in init and the
;; following temporary setting will be overridden. Use that for adjustment.
(setopt gc-cons-threshold most-positive-fixnum)
;; UI:
(setopt frame-inhibit-implied-resize t
inhibit-startup-screen t
initial-buffer-choice nil
native-comp-async-report-warnings-errors ok-debug
ring-bell-function 'ignore)
(setq native-comp-jit-compilation t
redisplay-skip-fontification-on-input t)
(dolist (it '((menu-bar-lines . 0)
(tool-bar-lines . 0)
;; (width . 120) ; default frame width
;; (height . 40) ; default frame height
(vertical-scroll-bars . nil)))
(push it default-frame-alist))
(fringe-mode '(12 . 12))
;; Misc. configurations
(setenv "LSP_USE_PLISTS" "true")
;; Ignore x session resources:
(advice-add 'x-apply-session-resources :override 'ignore)
;; Disable magic file name during `init.el'
(letrec ((saved-file-name-handler-alist file-name-handler-alist)
(restore-file-name-handler-alist
(lambda ()
"Restore `file-name-handler-alist'."
(setq file-name-handler-alist saved-file-name-handler-alist)
(remove-hook 'after-init-hook restore-file-name-handler-alist))))
(setq file-name-handler-alist nil)
(add-hook 'after-init-hook restore-file-name-handler-alist 97))
;; Profile `init.el'.
(when ok-debug
(letrec ((profile-init
(lambda ()
(message "Emacs (PID:%d) started in %s"
(emacs-pid) (emacs-init-time))
(profiler-report)
(profiler-stop)
(remove-hook 'after-init-hook profile-init))))
(profiler-start 'cpu+mem)
(add-hook 'after-init-hook profile-init 98)))
;; Compute the running time of all functions in `after-init-hook'.
;; `emacs-init-time' underestimates the total startup time, when
;; time-consuming operations are delayed to `after-init-hook'. Use
;; this metric to actually reduce the experienced startup time.
(letrec ((time-after-init-hook
(lambda ()
(message "after-init-hook took %f sec"
(float-time
(time-subtract (current-time) after-init-time)))
(remove-hook 'after-init-hook time-after-init-hook))))
(add-hook 'after-init-hook time-after-init-hook 99))
;; Configure package manager. (`init-straight.el' or `init-package.el')
(load (locate-user-emacs-file "lisp/init-straight.el"))
;;; early-init.el ends here