summary refs log tree commit diff
path: root/emacs
diff options
context:
space:
mode:
authornoa2024-11-15 02:37:00 +0800
committernoa2024-11-15 02:37:00 +0800
commit0d1ae2883cefc19f08c7b81c5d44858a569964eb (patch)
treea1ab68f8475d345e4fe44040d1f9d886ef03fa7b /emacs
parent6536c9b5d6a6cd5cc4a7afaa7650959a2311702b (diff)
Add early init file for emacs
Diffstat (limited to 'emacs')
-rw-r--r--emacs/early-init.el47
1 files changed, 47 insertions, 0 deletions
diff --git a/emacs/early-init.el b/emacs/early-init.el
new file mode 100644
index 0000000..fc1027d
--- /dev/null
+++ b/emacs/early-init.el
@@ -0,0 +1,47 @@
+;;; early-init.el -*- lexical-binding: t; -*-
+
+;; Emacs 27+ introduces early-init.el, which is run before init.el,
+;; before package and UI initialization happens.
+
+;; In noninteractive sessions, prioritize non-byte-compiled source files to prevent the use of stale byte-code. Otherwise, it saves us a little IO time to skip the mtime checks on every *.elc file.
+(setopt load-prefer-newer 'noninteractive
+        native-comp-jit-compilation nil)
+
+;; is this a bad idea?
+;; (setopt site-run-file nil
+;;         inhibit-default-init t)
+(setopt inhibit-x-resources t)
+
+;; In Emacs 27+, package initialization occurs before `user-init-file' is loaded, but after `early-init-file', so we can disable this here.
+;; (setopt package-enable-at-startup nil)
+
+;; Gui changes are expensive
+(setopt frame-inhibit-implied-resize t
+        default-frame-alist '((fullscreen . maximized)
+                              (font . "Noto Serif-12")))
+
+(push '(menu-bar-lines . 0) default-frame-alist)
+(push '(tool-bar-lines . 0) default-frame-alist)
+(push '(horizontal-scroll-bars) default-frame-alist)
+(when (bound-and-true-p tooltip-mode)
+  (tooltip-mode -1))
+(setq use-file-dialog nil)
+(setq use-dialog-box nil)
+
+;; Override the tool-bar-setup function to prevent it from running during the initial stages of startup
+;; h/t https://github.com/jamescherti/minimal-emacs.d/
+(when (fboundp 'tool-bar-setup)
+  (advice-add #'tool-bar-setup :override #'ignore))
+
+;; (setopt default-frame-alist '(
+;;                               (menu-bar-lines . 0)
+;;                               (tool-bar-lines . 0)))
+
+;; setup package
+(setopt package-archives
+        '(("gnu" . "https://elpa.gnu.org/packages/")
+          ("nongnu" . "https://elpa.nongnu.org/nongnu/")
+          ("melpa" . "https://melpa.org/packages/")))
+
+;; Ignore X resources; its settings would be redundant with the other settings in this file and can conflict with later config (particularly where the cursor color is concerned).
+(advice-add #'x-apply-session-resources :override #'ignore)