summary refs log tree commit diff stats
path: root/early-init.el
blob: b841ea5a7a34c1ef38ccf868a0856100a5b8c83e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
;;; early-init.el --- Emacs early init -*- lexical-binding: t -*-

;; by C. Duckworth <acdw@acdw.net>

;; Bankruptcy: 9.3

;;; Debugging --- delete this when done bankrupting
(setf debug-on-error t
      use-package-verbose t)

;;; Speedy startup

(defvar +emacs--startup-restore-alist nil
  "Variables to restore after startup.")

(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.
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)))
    (set-default variable value)))

(+set-during-startup 'gc-cons-threshold most-positive-fixnum)

;;; Distraction-free startup

(unless debug-on-error
  (+set-during-startup 'inhibit-redisplay t)
  (+set-during-startup 'inhibit-message t))

(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 . 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)

;;; Packages

(require 'package)

(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))

(setf package-archive-priorities
      '(("gnu-devel" . 2)
	("nongnu-devel" . 1)
        ("melpa" . 0)
        ("gnu" . 0)
        ("nongnu" . 0)))

(package-initialize)

(unless package-archive-contents
  (package-refresh-contents))

;; https://melpa.org/packages/archive-contents

;;; Use-package

(setf use-package-enable-imenu-support t
      use-package-hook-name-suffix nil)

(require 'use-package)

(setf use-package-compute-statistics debug-on-error)

(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))))