;;; emacs early init -*- lexical-binding: t; -*- ;; by C. Duckworth (provide 'early-init) ;;; Speed up init ;; 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 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 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) (add-hook 'minibuffer-setup-hook (defun garbage-collect@minibuffer-enter () (setq gc-cons-threshold most-positive-fixnum))) (add-hook 'minibuffer-exit-hook (defun garbage-collect@minibuffer-exit () (setq gc-cons-threshold 800000))) ;; Don't prematurely re-display (unless debug-on-error (+set-during-startup 'inhibit-redisplay t) (+set-during-startup 'inhibit-message t)) ;; Debug during init (unless (eq debug-on-error 'startup) (+set-during-startup 'debug-on-error 'init)) ;;; Default frame settings (setq default-frame-alist '((tool-bar-lines . 0) (menu-bar-lines . 0) (vertical-scroll-bars) (horizontal-scroll-bars)) frame-inhibit-implied-resize t frame-resize-pixelwise t window-resize-pixelwise t inhibit-x-resources t indicate-empty-lines nil indicate-buffer-boundaries nil ;; '((top . right) ;; (bottom . right)) ) ;;; Set up extra load paths and functionality (push (locate-user-emacs-file "lisp") load-path) (require 'acdw) (+define-dir .etc (locate-user-emacs-file ".etc") "Directory for all of Emacs's various files. See `no-littering' for examples.") (+define-dir sync/ (expand-file-name "~/Sync") "My Syncthing directory.") ;;; Packages (setq package-enable-at-startup nil package-quickstart nil) (require 'yoke) (yoke compat "https://git.sr.ht/~pkal/compat") (yoke no-littering "https://github.com/emacscollective/no-littering" (require 'no-littering) (setq no-littering-etc-directory .etc no-littering-var-directory .etc custom-file (.etc "custom.el")) (when (boundp 'comp-eln-load-path) (setcar comp-eln-load-path (expand-file-name (.etc "eln-cache" t)))) (when (fboundp 'startup-redirect-eln-cache) (startup-redirect-eln-cache (convert-standard-filename (.etc "eln-cache/")))))