From 59a1f58695d09ab29ddf992b2c0711c94a4039ea Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 3 Jan 2023 23:03:03 -0600 Subject: Switch to use-package --- early-init.el | 121 ++++++++++++++++++++++++++++------------------------------ 1 file changed, 59 insertions(+), 62 deletions(-) (limited to 'early-init.el') diff --git a/early-init.el b/early-init.el index 8004342..b841ea5 100644 --- a/early-init.el +++ b/early-init.el @@ -1,98 +1,95 @@ -;;; early-init.el --- Emacs early init -*- lexical-binding: t; -*- +;;; early-init.el --- Emacs early init -*- lexical-binding: t -*- + ;; by C. Duckworth -;; Bankruptcy: 9 -;;; Speed up init +;; Bankruptcy: 9.3 + +;;; Debugging --- delete this when done bankrupting +(setf debug-on-error t + use-package-verbose t) + +;;; Speedy startup -;; Restore things after init (defvar +emacs--startup-restore-alist nil - "Variables and values to restore after init.") + "Variables to restore after startup.") -(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 +emacs-startup@restore-variables () + "Restore variables set temporarily during startup." + (dolist (v +emacs--startup-restore-alist) + (set-default (car v) (cdr v)))) +(add-hook 'after-init-hook #'+emacs-startup@restore-variables) (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." + "Set VARIABLE to VALUE during startup. +If RESTORE is non-nil, restore the variable's value to it. +Otherwise, save its original value and restore to that." (unless after-init-time (setf (alist-get variable +emacs--startup-restore-alist) - (or restore (symbol-value variable))) + (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 () - (setf gc-cons-threshold most-positive-fixnum))) -(add-hook 'minibuffer-exit-hook (defun garbage-collect@minibuffer-exit () - (setf gc-cons-threshold 800000))) +;;; Distraction-free startup -;; 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 +(setf warning-minimum-level :emergency) +(add-hook 'emacs-startup-hook + (defun +message-about-warnings () + (when-let ((warnings (get-buffer "*Warnings*"))) + (message "%s. %s." "There were init-time warnings" + "See the `*Warnings*' buffer.")))) (setf default-frame-alist '((tool-bar-lines . 0) - (menu-bar-lines . 0) - (vertical-scroll-bars) - (horizontal-scroll-bars)) + (menu-bar-lines . 0) + (vertical-scroll-bars . nil) + (horizontal-scroll-bars . nil)) 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)) - ) + indicate-buffer-boundaries nil) + +;;; Packages -;;; Set up extra load paths and functionality +(require 'package) -(push (expand-file-name (locate-user-emacs-file "lisp")) load-path) -(require 'acdw) +(dolist (archive + '(("gnu-devel" . "https://elpa.gnu.org/devel/") + ("nongnu-devel" . "https://elpa.gnu.org/nongnu-devel/") + ("melpa" . "https://melpa.org/packages/"))) + (add-to-list 'package-archives archive :append)) -(+define-dir .etc (locate-user-emacs-file "etc") - "Directory for all of Emacs's various files. -See `no-littering' for examples.") +(setf package-archive-priorities + '(("gnu-devel" . 2) + ("nongnu-devel" . 1) + ("melpa" . 0) + ("gnu" . 0) + ("nongnu" . 0))) -(+define-dir sync/ (expand-file-name "~/Sync") - "My Syncthing directory.") +(package-initialize) -(+define-dir private/ (sync/ "emacs/private")) -(add-to-list 'load-path private/) +(unless package-archive-contents + (package-refresh-contents)) -;;; Packages +;; https://melpa.org/packages/archive-contents -(setf package-enable-at-startup nil - package-quickstart nil) +;;; Use-package -(require 'yoke) -(add-hook 'emacs-lisp-mode-hook #'yoke-imenu-insinuate) +(setf use-package-enable-imenu-support t + use-package-hook-name-suffix nil) -(yoke (compat "https://git.sr.ht/~pkal/compat")) +(require 'use-package) -(yoke (no-littering "https://github.com/emacscollective/no-littering") - (setf no-littering-etc-directory .etc - no-littering-var-directory .etc - custom-file (.etc "custom.el")) - (require 'no-littering) - (when (boundp 'native-comp-eln-load-path) - (setcar native-comp-eln-load-path (expand-file-name (.etc "eln-cache" t)))) - (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/"))))) +(setf use-package-compute-statistics debug-on-error) -(provide 'early-init) -;;; early-init.el ends here +(use-package use-package-vc + :load-path "~/src/emacs/use-package-vc.el" + :config + (define-advice package-vc-install (:around (orig &rest args) wtf) + (let ((package-archives nil)) + (apply orig args)))) -- cgit 1.4.1-21-gabe81