From 9cf098bfb78ad4e3d696dbed1457886188f65e67 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Sun, 6 Feb 2022 22:15:41 -0600 Subject: [PATCH] Update early-init --- early-init.el | 70 ++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/early-init.el b/early-init.el index e2080a1..aca65d2 100644 --- a/early-init.el +++ b/early-init.el @@ -23,22 +23,35 @@ ;;; Speed up init -;; Garbage collection -(setq gc-cons-threshold most-positive-fixnum) +;; Restore things after init +(defvar +emacs--startup-restore-alist nil + "Variables and values to restore after init.") + (add-hook 'emacs-startup-hook (defun emacs-startup@restore-values () - "Restore values set during early-init for speed." - (setq gc-cons-threshold 134217728 ; 128mb - ))) + "Restore values set during init. +This applies values in `+emacs--startup-restore-alist'." + (dolist (a +emacs--startup-restore-alist) + (set (car a) (cdr a))))) + +(defun +set-during-startup (variable value &optional restore) + "Set VARIABLE to VALUE during startup, but restore to RESTORE. +If RESTORE is nil or not passed, save the original value and +restore that." + (unless nil ;after-init-time + (setf (alist-get variable +emacs--startup-restore-alist) + (or restore (symbol-value variable))) + (set-default variable value))) + +;; Garbage collection +(+set-during-startup 'gc-cons-threshold most-positive-fixnum (* 128 1024 1024)) ;; Don't prematurely re-display -(setq-default inhibit-redisplay t - inhibit-message t) -(add-hook 'window-setup-hook - (defun window-setup@restore-values () - "Restore values set during early-init for visuals." - (setq-default inhibit-redisplay nil - inhibit-message nil))) +(+set-during-startup 'inhibit-redisplay t) +(+set-during-startup 'inhibit-message t) + +;; Debug during init +(+set-during-startup 'debug-on-error t) ;;; Set up extra load paths and functionality @@ -67,22 +80,17 @@ See `no-littering' for examples.") indicate-buffer-boundaries '((top . right) (bottom . right))) -;;; Fonts -(+with-ensure-after-init - ;; Emoji fonts - (let ((ffl (font-family-list))) - (dolist (font '("Noto Color Emoji" - "Noto Emoji" - "Segoe UI Emoji" - "Apple Color Emoji" - "FreeSans" - "FreeMono" - "FreeSerif" - "Unifont" - "Symbola")) - (when (member font ffl) - (set-fontset-font t 'symbol - (font-spec :family font) nil :append))))) +;;; No littering! +;; We install `no-littering' package below, but we can set the variables now. + +(setq no-littering-etc-directory .etc + no-littering-var-directory .etc + straight-base-dir .etc) + +;; https://github.com/emacscollective/no-littering/wiki/Setting-gccemacs'-eln-cache + +(when (boundp 'comp-eln-load-path) + (setcar comp-eln-load-path (expand-file-name (.etc "eln-cache" t)))) ;;; Packages @@ -93,10 +101,6 @@ See `no-littering' for examples.") straight-check-for-modifications '(check-on-save find-when-checking)) -(setq no-littering-etc-directory .etc - no-littering-var-directory .etc - straight-base-dir .etc) - ;; Bootstrap straight.el ;; https://github.com/raxod502/straight.el @@ -147,7 +151,5 @@ See `no-littering' for examples.") ;; is `straight-package-neutering-mode'. (defalias 'straight-ಠ_ಠ-mode nil) -(message "Loading early-init.el...Done.") - (provide 'early-init) ;;; early-init.el ends here