Skip to content

Latest commit

 

History

History
110 lines (75 loc) · 4.11 KB

early-init.org

File metadata and controls

110 lines (75 loc) · 4.11 KB

Emacs Early Init


This file contains Emacs Lisp code that will run before the Emacs init.el file.

This file was written using Emacs Org Mode. This makes navigating and modifying my Emacs configuration much simpler as I can place different elements of my configuration under separate headings. The code in this file is placed in source code blocks that are tangled to the early-init.el file that Emacs will look for upon starting. When this file is saved, the source code blocks that are marked for tangling will write their contents to early-init.el.

Header

The following code block will add a header to the early-init.el file when it is generated on saving.

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

;; Author: Thomas Freeman
;; Maintainer: Thomas Freeman
;; Created: 09 Jan 2022

;; URL: https://github.com/tfree87/.emacs.d

;; This file is an early-init file for Emacs. It will be executed before
;; init.el when emacs is loaded.

;; This file IS NOT intended to be edited! It was generated by init.org.

;;; Commentary:

;; For documentation and for editing this file, see the init.org in the
;; github repository tfree87/.emacs.d
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Code:

Decrease Garbage Collection Frequency

Emacs collects garbage very fequently slowing down the startup process. Emacs normally does a garbage collection every 800 kB. Since I always have the RAM for it, I have set the garbage collection to only happen after 500 MB. Increasing the number above this does not provide any significant gains in startup time as of yet. This idea came from https://blog.d46.us/advanced-emacs-startup/#/.emacs.d/init.el.

(setq gc-cons-threshold 500000000)

Prevent Unwanted Runtime Compilation

Prevent extra unnecessary runtime compilation for gccemacs. This idea came from the Doom Emacs early-init.el file.

(setq native-comp-deferred-compilation nil)

Disable Emacs Package Manager

In order to prevent conflicts between straight.el and the Emacs package manager, package-enable-at-startup should be set to nil. This came from the straight.el installation instructions.

(setq package-enable-at-startup nil)

Reduce Redisplay

To reduce slowdowns caused by early redisplays when loading, the following code will reduce the amount of times Emacs redisplays when setting up windows. This idea came from the Doom Emacs early-init.el file.

(setq-default inhibit-redisplay t
              inhibit-message t)

(add-hook 'window-setup-hook
          (lambda ()
            (setq-default inhibit-redisplay nil
                          inhibit-message nil)
            (redisplay)))

Set Environment to UTF-8

Set the default coding system to UTF-8.This idea came from the Doom Emacs early-init.el file.

(set-language-environment "UTF-8")
(setq default-input-method nil)

End

Tell Emacs what feature this file provides.

(provide 'early-init)

;;; early-init.el ends here