2021-03-08 04:14:38 +00:00
|
|
|
|
;;; early-init.el -*- lexical-binding: t; coding: utf-8-unix -*-
|
2021-02-26 17:31:50 +00:00
|
|
|
|
;; 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
|
|
|
|
;; This file is NOT part of GNU Emacs.
|
2021-03-16 16:16:21 +00:00
|
|
|
|
|
2021-03-01 05:58:57 +00:00
|
|
|
|
;;; 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.
|
2021-03-16 16:16:21 +00:00
|
|
|
|
|
2021-03-01 05:58:57 +00:00
|
|
|
|
;;; 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.
|
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
|
|
|
|
|
2021-03-25 17:02:28 +00:00
|
|
|
|
;;; Add `acdw.el'
|
|
|
|
|
(push (expand-file-name "lisp/" user-emacs-directory)
|
|
|
|
|
load-path)
|
|
|
|
|
(require 'acdw)
|
2021-03-01 05:58:57 +00:00
|
|
|
|
|
2021-04-06 22:59:45 +00:00
|
|
|
|
|
2021-03-08 04:14:38 +00:00
|
|
|
|
;;; Speed up init
|
|
|
|
|
;; see doom-emacs, et al.
|
2021-03-01 05:58:57 +00:00
|
|
|
|
|
2021-04-06 23:30:49 +00:00
|
|
|
|
(setq load-prefer-newer noninteractive
|
|
|
|
|
orig-file-name-handler-alist file-name-handler-alist
|
2021-04-19 05:21:12 +00:00
|
|
|
|
file-name-handler-alist nil
|
|
|
|
|
inhibit-x-resources t)
|
2021-04-06 22:59:45 +00:00
|
|
|
|
(acdw/gc-disable)
|
2021-03-08 04:14:38 +00:00
|
|
|
|
|
2021-05-21 15:48:05 +00:00
|
|
|
|
(add-hook 'after-init-hook
|
|
|
|
|
(defun after-init@reset ()
|
|
|
|
|
(acdw/gc-enable)
|
|
|
|
|
(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)))
|
2021-04-06 22:59:45 +00:00
|
|
|
|
|
2021-03-11 18:04:18 +00:00
|
|
|
|
;;; Frame settings
|
2021-03-30 22:23:10 +00:00
|
|
|
|
(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
|
2021-03-29 22:52:23 +00:00
|
|
|
|
; `fill-column' (set later)
|
|
|
|
|
(height . 30)
|
2021-03-30 22:23:10 +00:00
|
|
|
|
(left-fringe . 8) ; Width of fringes
|
|
|
|
|
(right-fringe . 8) ; (8 is default)
|
2021-05-11 14:44:04 +00:00
|
|
|
|
(font . ,(acdw/system
|
|
|
|
|
(:home "DejaVu Sans Mono 10")
|
2021-07-23 02:13:08 +00:00
|
|
|
|
(:work "Consolas 12")
|
2021-05-11 14:44:04 +00:00
|
|
|
|
(:other "monospace 10"))))
|
2021-03-29 22:52:23 +00:00
|
|
|
|
frame-inhibit-implied-resize t ; Don't resize randomly
|
2021-03-30 22:23:10 +00:00
|
|
|
|
frame-resize-pixelwise t ; Resize by pixels, not chars
|
2021-04-30 01:21:31 +00:00
|
|
|
|
inhibit-x-resources t ; Don't load ~/.Xresources
|
2021-03-29 22:52:23 +00:00
|
|
|
|
)
|
2021-03-01 05:58:57 +00:00
|
|
|
|
|
2021-05-21 15:48:05 +00:00
|
|
|
|
(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))))))
|
|
|
|
|
|
2021-05-21 15:58:30 +00:00
|
|
|
|
(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")
|
2021-07-23 02:13:08 +00:00
|
|
|
|
(_ "monospace"))
|
|
|
|
|
acdw-fonts/monospace-size (acdw/system
|
|
|
|
|
(:work 12)
|
|
|
|
|
(_ 10))
|
2021-05-21 15:58:30 +00:00
|
|
|
|
acdw-fonts/variable (acdw/system
|
2021-08-12 01:24:54 +00:00
|
|
|
|
(:home "Inter")
|
2021-08-16 22:11:22 +00:00
|
|
|
|
(:work "Inter")
|
2021-07-23 02:13:08 +00:00
|
|
|
|
(_ "sans-serif"))
|
|
|
|
|
acdw-fonts/variable-size (acdw/system
|
|
|
|
|
(:work 14)
|
|
|
|
|
(_ 12)))
|
2021-05-21 15:58:30 +00:00
|
|
|
|
(acdw-fonts/set)
|
|
|
|
|
(acdw-fonts/setup-emoji-fonts "Segoe UI Emoji"
|
|
|
|
|
"Noto Color Emoji"
|
|
|
|
|
"Apple Color Emoji"
|
|
|
|
|
"Symbola")
|
|
|
|
|
;; fringes
|
|
|
|
|
(acdw/setup-fringes)))
|
2021-04-06 22:59:45 +00:00
|
|
|
|
|
2021-05-27 22:36:39 +00:00
|
|
|
|
;; I have this here because ... the first frame doesn't ? run ? the hook ???
|
2021-05-30 04:17:57 +00:00
|
|
|
|
(add-function :after after-focus-change-function
|
|
|
|
|
(defun acdw/first-frame-setup (&rest args)
|
|
|
|
|
(ignore args)
|
|
|
|
|
(acdw/frame-setup)
|
|
|
|
|
(remove-function after-focus-change-function
|
|
|
|
|
#'acdw/first-frame-setup)))
|
2021-05-27 22:36:39 +00:00
|
|
|
|
|
2021-04-06 22:59:45 +00:00
|
|
|
|
|
2021-03-08 04:14:38 +00:00
|
|
|
|
;;; Bootstrap package manager (`straight.el')
|
2021-02-26 17:31:50 +00:00
|
|
|
|
|
2021-03-08 04:14:38 +00:00
|
|
|
|
;; 1. Update `exec-path'.
|
2021-03-24 16:22:39 +00:00
|
|
|
|
(dolist (path (list (expand-file-name "bin" user-emacs-directory)
|
2021-03-29 22:52:23 +00:00
|
|
|
|
(expand-file-name "~/bin")
|
|
|
|
|
(expand-file-name "~/.local/bin")
|
|
|
|
|
(expand-file-name "~/usr/bin")
|
|
|
|
|
(expand-file-name "~/cmd")
|
2021-04-09 17:50:11 +00:00
|
|
|
|
(expand-file-name "~/mingw64/bin")
|
2021-04-09 17:58:45 +00:00
|
|
|
|
(expand-file-name "~/clisp-2.49"))
|
2021-04-09 17:50:11 +00:00
|
|
|
|
exec-path)
|
2021-03-24 16:22:39 +00:00
|
|
|
|
(when (file-exists-p path)
|
|
|
|
|
(add-to-list 'exec-path path :append)))
|
|
|
|
|
|
2021-03-08 04:14:38 +00:00
|
|
|
|
;; 1.5. Update $PATH to reflect changes.
|
2021-02-26 17:31:50 +00:00
|
|
|
|
(setenv "PATH" (mapconcat #'identity exec-path path-separator))
|
2021-03-01 05:58:57 +00:00
|
|
|
|
|
2021-03-08 04:14:38 +00:00
|
|
|
|
;; 2. Set `package' and `straight' variables.
|
2021-03-29 22:52:23 +00:00
|
|
|
|
(setq package-enable-at-startup nil
|
|
|
|
|
package-quickstart nil
|
2021-03-08 04:14:38 +00:00
|
|
|
|
straight-host-usernames '((github . "duckwork")
|
2021-03-29 22:52:23 +00:00
|
|
|
|
(gitlab . "acdw"))
|
2021-04-19 05:21:12 +00:00
|
|
|
|
straight-base-dir (acdw/dir)
|
|
|
|
|
straight-check-for-modifications '(check-on-save find-when-checking))
|
2021-03-01 05:58:57 +00:00
|
|
|
|
|
2021-03-08 04:14:38 +00:00
|
|
|
|
;; 3. Bootstrap `straight'.
|
2021-03-01 18:12:48 +00:00
|
|
|
|
(defvar bootstrap-version)
|
|
|
|
|
(let ((bootstrap-file
|
|
|
|
|
(expand-file-name
|
2021-03-29 22:52:23 +00:00
|
|
|
|
"straight/repos/straight.el/bootstrap.el"
|
|
|
|
|
straight-base-dir))
|
2021-03-01 18:12:48 +00:00
|
|
|
|
(bootstrap-version 5))
|
|
|
|
|
(unless (file-exists-p bootstrap-file)
|
|
|
|
|
(with-current-buffer
|
2021-03-29 22:52:23 +00:00
|
|
|
|
(url-retrieve-synchronously
|
|
|
|
|
(concat "https://raw.githubusercontent.com/"
|
|
|
|
|
"raxod502/straight.el/develop/install.el")
|
|
|
|
|
'silent 'inhibit-cookies)
|
2021-03-01 18:12:48 +00:00
|
|
|
|
(goto-char (point-max))
|
|
|
|
|
(eval-print-last-sexp)))
|
|
|
|
|
(load bootstrap-file nil 'nomessage))
|
2021-04-09 22:51:10 +00:00
|
|
|
|
|
2021-08-07 02:26:02 +00:00
|
|
|
|
;; Helper package, good commands here.
|
|
|
|
|
(require 'straight-x)
|
|
|
|
|
|
2021-04-22 22:58:43 +00:00
|
|
|
|
;; 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)
|
|
|
|
|
|
2021-04-06 22:59:45 +00:00
|
|
|
|
|
2021-03-08 04:14:38 +00:00
|
|
|
|
;;; Message startup time for profiling
|
2021-04-06 22:59:45 +00:00
|
|
|
|
;; This just redefines the Emacs function
|
|
|
|
|
;; `display-startup-echo-area-message', so no hooks needed.
|
2021-04-01 22:02:22 +00:00
|
|
|
|
(defun display-startup-echo-area-message ()
|
2021-03-08 04:14:38 +00:00
|
|
|
|
"Show Emacs's startup time in the message buffer. For profiling."
|
2021-03-01 05:58:57 +00:00
|
|
|
|
(message "Emacs ready in %s with %d garbage collections."
|
2021-03-29 22:52:23 +00:00
|
|
|
|
(format "%.2f seconds"
|
|
|
|
|
(float-time (time-subtract after-init-time
|
|
|
|
|
before-init-time)))
|
|
|
|
|
gcs-done))
|