Files
dotfiles/config/emacs/early-init.el
T

45 lines
1.8 KiB
EmacsLisp

;;; early-init.el --- Pre-init: GC ceiling and frame chrome -*- lexical-binding: t; -*-
;;; Commentary:
;; Runs before package.el initialises and before the first frame is drawn, so
;; it is the only place two things can take effect:
;; 1. Raising the GC ceiling, so the whole startup (package load + init.el)
;; runs without garbage-collection pauses.
;; 2. Removing the menu/tool/scroll bars via `default-frame-alist', so they
;; are never drawn — toggling the minor modes in init.el instead draws
;; them and then removes them, a visible flicker on launch.
;;
;; Nothing here may depend on a package: none are loaded yet.
;;
;; IMPORTANT: the GC bump below is only half the pair. Restore a working value
;; once startup is done by adding this to init.el:
;;
;; (add-hook 'emacs-startup-hook
;; (lambda () (setq gc-cons-threshold (* 16 1024 1024))))
;;
;; Without it, GC never runs again and Emacs slowly eats memory.
;;; Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Garbage Collection
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Hold GC off for the whole startup; init.el lowers it back on
;; `emacs-startup-hook' (see the Commentary above).
(setq gc-cons-threshold most-positive-fixnum)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Frame Chrome (no flicker)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Disable the bars before the first frame exists.
(push '(menu-bar-lines . 0) default-frame-alist)
(push '(tool-bar-lines . 0) default-frame-alist)
(push '(vertical-scroll-bars) default-frame-alist)
;; Don't resize the frame when the UI/fonts change during startup.
(setq frame-inhibit-implied-resize t)
;;; early-init.el ends here