emacs/early-init.el

174 lines
5.7 KiB
EmacsLisp
Raw Normal View History

2021-03-08 04:14:38 +00:00
;;; early-init.el -*- lexical-binding: t; coding: utf-8-unix -*-
;; Author: Case Duckworth <acdw@acdw.net>
2021-03-01 05:58:57 +00:00
;; Created: Sometime during Covid-19, 2020
2021-02-26 17:31:50 +00:00
;; Keywords: configuration
2021-03-08 04:14:38 +00:00
;; URL: https://tildegit.org/acdw/emacs
2021-03-16 16:16:21 +00:00
2021-03-01 05:58:57 +00:00
;;; License:
;; Everyone is permitted to do whatever they like with this software
;; without limitation. This software comes without any warranty
;; whatsoever, but with two pieces of advice:
;; - Be kind to yourself.
2021-03-01 05:58:57 +00:00
;; - Make good choices.
2021-03-16 16:16:21 +00:00
;;; Commentary:
;; Starting with Emacs 27.1, early-init.el is sourced before
;; package.el and any graphical frames. In this file, I set up frame
;; parameters and packaging infrastructure.
2021-03-16 16:16:21 +00:00
2021-03-01 05:58:57 +00:00
;;; Code:
2021-02-26 17:31:50 +00:00
;;(setq debug-on-error t)
(message "Loading early-init.el...")
2022-01-18 23:18:06 +00:00
(define-advice load (:before (feature &rest _))
"Message the user when loading a library."
(with-temp-message (format "Now loading: '%s'" feature)))
2021-12-31 05:08:10 +00:00
;;; Speed up init
2022-01-18 23:18:06 +00:00
(setq gc-cons-threshold most-positive-fixnum)
2021-12-31 05:08:10 +00:00
(add-hook 'emacs-startup-hook
(defun emacs-startup@restore-values ()
"Restore values set during early-init for speed."
(setq gc-cons-threshold 134217728 ; 128mb
;; I don't do the common `file-name-handler-alist' thing here
;; because of a weirdness where my Emacs doesn't know how to
;; load bookmark.el.gz when initializing.
)))
;;; Set up extra load paths and functionality
2021-12-29 04:14:21 +00:00
(push (locate-user-emacs-file "lisp") load-path)
2021-03-25 17:02:28 +00:00
(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.")
2022-01-04 20:42:26 +00:00
;; Load system-specific changes.
(progn (require 'system)
(setq system-default-font "DejaVu Sans Mono"
system-variable-pitch-font "DejaVu Sans")
2022-01-17 19:45:32 +00:00
(system-settings-load))
2022-01-04 20:42:26 +00:00
;;; Default frame settings
(setq default-frame-alist '((tool-bar-lines . 0)
2022-01-04 20:42:26 +00:00
(menu-bar-lines . 0)
(vertical-scroll-bars)
(horizontal-scroll-bars))
2021-09-25 18:16:09 +00:00
frame-inhibit-implied-resize t
frame-resize-pixelwise t
window-resize-pixelwise t
inhibit-x-resources t
indicate-empty-lines nil
indicate-buffer-boundaries '((top . right)
2022-01-04 20:42:26 +00:00
(bottom . right)))
;;; Fonts
2022-01-17 19:45:32 +00:00
(+with-ensure-after-init
2022-01-12 23:40:43 +00:00
;; Set default faces
(+with-message "Setting default faces"
(let ((font-name system-default-font)
(font-size system-default-height)
(variable-font-name system-variable-pitch-font)
(variable-font-size system-variable-pitch-height))
(set-face-attribute 'default nil :family system-default-font
:height font-size :weight 'book)
(set-face-attribute 'italic nil :family font-name
:height font-size :slant 'italic)
(set-face-attribute 'variable-pitch nil :family variable-font-name
:height variable-font-size)))
;; Emoji fonts
2022-01-17 19:45:32 +00:00
(+with-message "Adding 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)
(message "Found font: %s" font)
(set-fontset-font t 'symbol
(font-spec :family font) nil :append))))))
2022-01-04 20:42:26 +00:00
;;; Packages
(setq package-enable-at-startup nil
package-quickstart nil
2021-03-08 04:14:38 +00:00
straight-host-usernames '((github . "duckwork")
2022-01-04 20:42:26 +00:00
(gitlab . "acdw"))
straight-check-for-modifications '(check-on-save
2022-01-04 20:42:26 +00:00
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
2021-03-01 05:58:57 +00:00
2022-01-12 23:40:43 +00:00
(+with-message "Bootstrapping straight"
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name
"straight/repos/straight.el/bootstrap.el"
straight-base-dir))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
(concat "https://raw.githubusercontent.com/"
"raxod502/straight.el/develop/install.el")
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage)))
2021-04-09 22:51:10 +00:00
;; Early-loaded packages -- those that, for some reason or another,
;; need to be ensured to be loaded first.
2021-08-07 02:26:02 +00:00
(require 'straight-x)
(dolist (pkg '(el-patch
2022-01-04 20:42:26 +00:00
no-littering
2022-01-20 14:28:37 +00:00
setup
straight)) ; already installed, but what the hell
(straight-use-package pkg)
(require pkg)
(require (intern (format "+%s" pkg)) nil :noerror))
;; Setup `setup'
(add-to-list 'setup-modifier-list 'setup-wrap-to-demote-errors)
2022-01-06 00:20:40 +00:00
;; (advice-add 'setup :before (defun +setup-before (&rest args)
;; (message "Setup: %S" args)))
;; (advice-add 'setup :after (defun +setup-after (&rest args)
;; (message "Setup: %S...Done." args)))
;;; Appendix
;; Get rid of a dumb alias. straight-ಠ_ಠ-mode really slows down all
;; minibuffer completion functions. Since it's a (rarely-used, even)
;; alias anyway, I just define it back to nil. By the way, the alias
;; is `straight-package-neutering-mode'.
(defalias 'straight-ಠ_ಠ-mode nil)
(message "Loading early-init.el...Done.")
(provide 'early-init)
2021-08-21 14:10:01 +00:00
;;; early-init.el ends here