You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

167 lines
6.5 KiB

;;; early-init.el -*- lexical-binding: t; coding: utf-8-unix -*-
;; Author: Case Duckworth <>
;; Created: Sometime during Covid-19, 2020
;; Keywords: configuration
;; URL:
;; This file is NOT part of GNU Emacs.
;;; License:
;; Everyone is permitted to do whatever with this software, without
;; limitation. This software comes without any warranty whatsoever,
;; but with two pieces of advice:
;; - Don't hurt yourself.
;; - Make good choices.
;;; Comentary:
;; Starting with Emacs 27.1, `early-init' is sourced before `package'
;; or any frames. So those are the settings I run in this file.
;;; Code:
;;; Add `acdw.el'
(push (expand-file-name "lisp/" user-emacs-directory)
(require 'acdw)
;;; Speed up init
;; see doom-emacs, et al.
(setq load-prefer-newer noninteractive
orig-file-name-handler-alist file-name-handler-alist
file-name-handler-alist nil
inhibit-x-resources t)
(add-hook 'after-init-hook
(defun after-init@reset ()
(dolist (handler file-name-handler-alist)
(add-to-list 'orig-file-name-handler-alist handler))
(setq file-name-handler-alist orig-file-name-handler-alist)))
;;; Frame settings
(setq default-frame-alist ; Remove most UI
`((tool-bar-lines . 0) ; No tool bar
(menu-bar-lines . 0) ; No menu bar
(vertical-scroll-bars) ; No scroll bars
(horizontal-scroll-bars) ; ... at all
(width . 84) ; A /little/ wider than
; `fill-column' (set later)
(height . 30)
(left-fringe . 8) ; Width of fringes
(right-fringe . 8) ; (8 is default)
(font . ,(acdw/system
(:home "DejaVu Sans Mono 10")
(:work "Consolas 10")
(:other "monospace 10"))))
frame-inhibit-implied-resize t ; Don't resize randomly
frame-resize-pixelwise t ; Resize by pixels, not chars
inhibit-x-resources t ; Don't load ~/.Xresources
(add-hook 'after-init-hook
(defun after-init@disable-ui-modes ()
(dolist (mode ;; each mode is of the form (MODE . FRAME-ALIST-VAR)
'((tool-bar-mode . tool-bar-lines)
(menu-bar-mode . menu-bar-lines)
(scroll-bar-mode . vertical-scroll-bars)
(horizontal-scroll-bar-mode . horizontal-scroll-bars)
(let ((setting (alist-get (cdr mode) default-frame-alist)))
(when (or (not setting)
(= 0 setting))
(funcall (car mode) -1))))))
(add-hook 'after-make-frame-functions
(defun acdw/frame-setup (&rest args)
(ignore args)
;; fonts
(require 'acdw-fonts)
(setq acdw-fonts/monospace (acdw/system
(:home "DejaVu Sans Mono")
(:work "Consolas")
(:other "monospace"))
acdw-fonts/monospace-size 10
acdw-fonts/variable (acdw/system
(:home "DejaVu Sans")
(:work "Calibri")
(:other "sans-serif"))
acdw-fonts/variable-size 12)
(acdw-fonts/setup-emoji-fonts "Segoe UI Emoji"
"Noto Color Emoji"
"Apple Color Emoji"
;; fringes
;; I have this here because ... the first frame doesn't ? run ? the hook ???
(add-function :after after-focus-change-function
(defun acdw/first-frame-setup (&rest args)
(ignore args)
(remove-function after-focus-change-function
;;; Bootstrap package manager (`straight.el')
;; 1. Update `exec-path'.
(dolist (path (list (expand-file-name "bin" user-emacs-directory)
(expand-file-name "~/bin")
(expand-file-name "~/.local/bin")
(expand-file-name "~/usr/bin")
(expand-file-name "~/cmd")
(expand-file-name "~/mingw64/bin")
(expand-file-name "~/clisp-2.49"))
(when (file-exists-p path)
(add-to-list 'exec-path path :append)))
;; 1.5. Update $PATH to reflect changes.
(setenv "PATH" (mapconcat #'identity exec-path path-separator))
;; 2. Set `package' and `straight' variables.
(setq package-enable-at-startup nil
package-quickstart nil
straight-host-usernames '((github . "duckwork")
(gitlab . "acdw"))
straight-base-dir (acdw/dir)
straight-check-for-modifications '(check-on-save find-when-checking))
;; 3. Bootstrap `straight'.
(defvar bootstrap-version)
(let ((bootstrap-file
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(concat ""
'silent 'inhibit-cookies)
(goto-char (point-max))
(load bootstrap-file nil 'nomessage))
;; 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 startup time for profiling
;; This just redefines the Emacs function
;; `display-startup-echo-area-message', so no hooks needed.
(defun display-startup-echo-area-message ()
"Show Emacs's startup time in the message buffer. For profiling."
(message "Emacs ready in %s with %d garbage collections."
(format "%.2f seconds"
(float-time (time-subtract after-init-time