Skip to content

Latest commit

 

History

History
62 lines (59 loc) · 2.26 KB

early-init.org

File metadata and controls

62 lines (59 loc) · 2.26 KB

Emacs’s early-init Configuration File

Background

Emacs HEAD (27+) introduces early-init.el, which is run before init.el, before package.el and the first graphical frame is initialized.

Header

;;; early-init.el -*- lexical-binding: t; -*-

Garbage collection

The GC can easily double startup time, so we suppress it at startup by turning up gc-cons-threshold and gc-cons-percentage temporarily. However, it is important to reset it eventually, to prevent GC freeze during long-term interactive use, and gc-cons-threshold that is too small cause stuttering.

(defvar init-gc-cons-threshold gc-cons-threshold)
(defvar init-gc-cons-percentage gc-cons-percentage)

(setq gc-cons-threshold most-positive-fixnum
  gc-cons-percentage 0.6)

(add-hook 'emacs-startup-hook
          (lambda ()
            (setq init-gc-cons-threshold
                  init-gc-cons-percentage)))

Package initialization

Packages are made available before reading the init file (but after reading the early init file). we must prevent Emacs from doing it early!

(setq package-enable-at-startup nil)
(advice-add #'package--ensure-init-file :override #'ignore)

GUI

(push '(menu-bar-lines . 0) default-frame-alist)
(push '(tool-bar-lines . 0) default-frame-alist)
(push '(vertical-scroll-bars) default-frame-alist)

Resizing the Emacs frame

Whether frames should be resized implicitly. If this option is nil, setting font, menu bar, tool bar, tab bar, internal borders, fringes or scroll bars of a specific frame may resize the frame in order to preserve the number of columns or lines it displays. If this option is t, no such resizing is done.

(setq frame-inhibit-implied-resize t)

Ignore X resources

its settings would be redundant with the other settingsin this file and can conflict with later config (particularly where the cursor color is concerned).

(advice-add #'x-apply-session-resources :override #'ignore)

Load init.el

(load
 (expand-file-name "init.el" user-emacs-directory) nil 'nomessage 'nosuffix)