emacs/early-init.el

185 lines
7.5 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 <(rot13-string "npqj@npqj.arg")>
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-08-22 20:04:39 +00:00
(require 'acdw-frame)
2021-08-21 14:10:01 +00:00
2021-03-11 18:04:18 +00:00
;;; Frame settings
2021-10-06 01:18:03 +00:00
(setq initial-frame-alist '((fullscreen . maximized))
2021-10-06 01:05:22 +00:00
default-frame-alist
2021-09-25 18:16:09 +00:00
`((tool-bar-lines . 0)
(menu-bar-lines . 0)
(vertical-scroll-bars . nil)
(horizontal-scroll-bars . nil)
(width . 84)
(height . 30)
2021-09-25 18:16:09 +00:00
(left-fringe . 8)
(right-fringe . 8)
(font . ,(acdw/system
(:home "DejaVu Sans Mono 10")
2021-07-23 02:13:08 +00:00
(:work "Consolas 12")
(:other "monospace 10"))))
2021-09-25 18:16:09 +00:00
frame-inhibit-implied-resize t
frame-resize-pixelwise t
inhibit-x-resources t)
2021-03-01 05:58:57 +00:00
(add-hook 'after-init-hook
(defun after-init@disable-ui-modes ()
2021-08-21 14:10:01 +00:00
"Disable UI modes after init.
I already disable them from the `default-frame-alist' for speed
and anti-flickering reasons, but this function allows running,
say, `tool-bar-mode' once to toggle the tool bar back on."
(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)
2021-08-21 14:10:01 +00:00
(horizontal-scroll-bar-mode . horizontal-scroll-bars)))
(let ((setting (alist-get (cdr mode) default-frame-alist)))
(when (or (not setting)
2021-08-21 14:10:01 +00:00
(zerop setting))
(funcall (car mode) -1))))))
(add-hook 'after-make-frame-functions
2021-08-21 14:10:01 +00:00
(defun after-make-frame@setup (&rest args)
(ignore args)
2021-09-25 18:16:09 +00:00
(let ((fixed-pitch-faces
2021-10-06 01:05:22 +00:00
'((:font "Fantasque Sans Mono" :height 115)
2021-10-02 00:05:26 +00:00
(:font "Go Mono" :height 110)
2021-09-23 22:10:56 +00:00
(:font "DejaVu Sans Mono" :height 110)
2021-09-25 18:16:09 +00:00
(:font "monospace" :height 100)))
(variable-pitch-faces
2021-10-02 00:05:26 +00:00
'((:font "Inter" :height 120)
2021-09-25 18:16:09 +00:00
(:font "Go" :height 120)
2021-10-06 01:05:22 +00:00
(:font "sans-serif" :height 100))))
2021-09-25 18:16:09 +00:00
(acdw/set-first-face-attribute 'default
fixed-pitch-faces)
(acdw/set-first-face-attribute 'fixed-pitch
fixed-pitch-faces)
2021-08-21 14:10:01 +00:00
(acdw/set-first-face-attribute 'variable-pitch
2021-09-25 18:16:09 +00:00
variable-pitch-faces))
2021-09-23 22:10:56 +00:00
(acdw/set-emoji-fonts "Noto Color Emoji"
"Noto Emoji"
"Segoe UI Emoji"
2021-08-21 14:10:01 +00:00
"Apple Color Emoji"
2021-09-23 22:10:56 +00:00
"FreeSans"
"FreeMono"
"FreeSerif"
"Unifont"
2021-08-21 14:10:01 +00:00
"Symbola")
(acdw/set-fringes '((left-curly-arrow [#b01100000
#b00110000
#b00011000
#b00001100]
4 8 center)
(right-curly-arrow [#b00000011
#b00000110
#b00001100
#b00011000]
4 8 center)
(left-arrow [#b01100000
#b01010000]
2 8 (top t))
(right-arrow [#b00000011
#b00000101]
2 8 (top t))))
(setq indicate-empty-lines nil
indicate-buffer-boundaries '((top . right)
(bottom . right)))
(custom-set-faces '(fringe ((t (:foreground "dim gray")))))))
(add-hook 'server-after-make-frame-hook #'after-make-frame@setup)
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 ???
(add-function :after after-focus-change-function
2021-08-21 14:10:01 +00:00
(defun after-focus-change@first-frame-setup (&rest args)
(ignore args)
2021-08-21 14:10:01 +00:00
(after-make-frame@setup)
(remove-function after-focus-change-function
2021-08-21 14:10:01 +00:00
#'after-focus-change@first-frame-setup)))
2021-05-27 22:36:39 +00:00
2021-03-08 04:14:38 +00:00
;;; Bootstrap package manager (`straight.el')
2021-02-26 17:31:50 +00:00
2021-09-25 18:16:09 +00:00
;; Set `package' and `straight' variables.
(setq package-enable-at-startup nil
package-quickstart nil
2021-03-08 04:14:38 +00:00
straight-host-usernames '((github . "duckwork")
(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-09-25 18:16:09 +00:00
;; Bootstrap `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
2021-08-07 02:26:02 +00:00
;; Helper package, good commands here.
(require 'straight-x)
;; 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-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.
(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."
(format "%.2f seconds"
(float-time (time-subtract after-init-time
before-init-time)))
gcs-done))
2021-08-21 14:10:01 +00:00
2021-09-16 13:38:24 +00:00
;;; Early-loaded packages
;; These packages are here because they need to be loaded /before/
;; everything else in init.el.
2021-09-25 18:16:09 +00:00
(straight-use-package '(setup
:host nil
:repo "https://git.sr.ht/~pkal/setup"))
(require 'setup)
2021-09-04 03:50:58 +00:00
(require 'acdw-setup)
(setup (:straight no-littering)
(:option no-littering-etc-directory (acdw/dir)
no-littering-var-directory (acdw/dir))
(require 'no-littering))
2021-09-16 13:38:24 +00:00
(setup (:straight el-patch))
2021-08-21 14:10:01 +00:00
;;; early-init.el ends here