Repository navigation
<
8000
/div>
Expand file tree
/
Copy pathearly-init.el
More file actions
125 lines (98 loc) · 4.51 KB
/
Copy pathearly-init.el
File metadata and controls
125 lines (98 loc) · 4.51 KB
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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
;;; early-init.el --- Emacs Solo (no external packages) Configuration --- Early Init -*- lexical-binding: t; -*-
;;
;; Author: Rahul Martim Juliato
;; URL: https://github.com/LionyxML/emacs-solo
;; Package-Requires: ((emacs "30.1"))
;; Keywords: config
;; SPDX-License-Identifier: GPL-3.0-or-later
;;
;;; Commentary:
;; Early init configuration for Emacs Solo
;;
;;; Code:
;; Load customizations as early as possible so user settings
;; (e.g. emacs-solo-avoid-flash-options) take effect before they are used.
(setq custom-file (locate-user-emacs-file "custom-vars.el"))
(load custom-file 'noerror 'nomessage)
(defcustom emacs-solo-avoid-flash-options
'((enabled . t)
(background . "#292D3E") ;; Catppuccin "#1e1e2e" / Crafters "#292D3E" / GITS #050810
(foreground . "#292D3E")
(reset-background . "#292D3E")
(reset-foreground . "#EEFFFF")) ;; Catppuccin "#cdd6f4" / Crafters "#EEFFFF" / GITS #68b8cc
"Options to avoid flash of light on Emacs startup.
- `enabled`: Whether to apply the workaround.
- `background`, `foreground`: Initial colors to use.
- `reset-background`, `reset-foreground`: Optional explicit colors to restore after startup.
NOTE: The default values here presented are set for the default
`emacs-solo' custom theme. If you'd like to turn this ON with another
theme, change the background/foreground variables.
If reset values are nil, nothing is reset."
:type '(alist :key-type symbol :value-type (choice (const nil) string))
:group 'emacs-solo)
;;; -------------------- PERFORMANCE & HACKS
;; HACK: inscrease startup speed
;; Delay garbage collection while Emacs is booting
(setq gc-cons-threshold most-positive-fixnum
gc-cons-percentage 0.6)
;; Schedule garbage collection sensible defaults for after booting
(add-hook 'after-init-hook
(lambda ()
(setq gc-cons-threshold (* 100 1024 1024)
gc-cons-percentage 0.1)))
;; HACK: Skip the file-name-handler regexp matching on every file load
;; while booting, then restore it afterwards
(defvar emacs-solo--file-name-handler-alist file-name-handler-alist)
(setq file-name-handler-alist nil)
(add-hook 'after-init-hook
(lambda ()
(setq file-name-handler-alist emacs-solo--file-name-handler-alist)))
;; Single VC backend inscreases booting speed
(setq vc-handled-backends '(Git))
;; Do not native compile if on battery power
(setopt native-comp-async-on-battery-power nil) ; EMACS-31
;; HACK: avoid being flashbanged
(defun emacs-solo/avoid-initial-flash-of-light ()
"Avoid flash of light when starting Emacs, based on `emacs-solo-avoid-flash-options`."
(when (alist-get 'enabled emacs-solo-avoid-flash-options)
(setq mode-line-format nil)
(set-face-attribute 'default nil
:background (alist-get 'background emacs-solo-avoid-flash-options)
:foreground (alist-get 'foreground emacs-solo-avoid-flash-options))))
(defun emacs-solo/reset-default-colors ()
"Reset any explicitly defined reset values in `emacs-solo-avoid-flash-options`."
(when (alist-get 'enabled emacs-solo-avoid-flash-options)
(let ((bg (alist-get 'reset-background emacs-solo-avoid-flash-options))
(fg (alist-get 'reset-foreground emacs-solo-avoid-flash-options)))
(when bg
(set-face-attribute 'default nil :background bg))
(when fg
(set-face-attribute 'default nil :foreground fg)))))
(emacs-solo/avoid-initial-flash-of-light)
(add-hook 'after-init-hook #'emacs-solo/reset-default-colors)
;; Always start Emacs and new frames maximized
(add-to-list 'default-frame-alist '(fullscreen . maximized)
4E55
)
;; Better Window Management handling
(setq frame-resize-pixelwise t
frame-inhibit-implied-resize t
frame-title-format
'(:eval
(let ((project (project-current)))
(if project
(concat "Emacs - [p] " (project-name project))
(concat "Emacs - " (buffer-name))))))
(when (eq system-type 'darwin)
(setq ns-use-proxy-icon nil))
(setq inhibit-compacting-font-caches t)
;; Disables unused UI Elements
(if (fboundp 'menu-bar-mode) (menu-bar-mode -1))
(if (fboundp 'scroll-bar-mode) (scroll-bar-mode -1))
(if (fboundp 'tool-bar-mode) (tool-bar-mode -1))
(if (fboundp 'tooltip-mode) (tooltip-mode -1))
(if (fboundp 'fringe-mode) (fringe-mode -1))
;; Avoid raising the *Messages* buffer if anything is still without
;; lexical bindings
(setq warning-minimum-level :error)
(setq warning-suppress-types '((lexical-binding)))
(provide 'early-init)
;;; early-init.el ends here