-
Notifications
You must be signed in to change notification settings - Fork 151
/
bootstrap.el
181 lines (159 loc) · 7.13 KB
/
bootstrap.el
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
;;; bootstrap.el --- Initialize straight.el -*- lexical-binding: t -*-
;; We need these libraries in this file, bootstrap.el. The libraries
;; for straight.el are required in that file.
(require 'bytecomp)
(require 'cl-lib)
(let* ((bootstrap.el
;; If this file is accessed through a symlink (this may happen
;; when an old version of the bootstrap snippet is used to
;; load straight.el), resolve it. We need to be looking at
;; the actual file, since the eventual target of the
;; symlink is the only way we can actually identify the
;; straight.el repository (which might be called something
;; else).
(file-truename
(or
;; If the file is being loaded from the init-file.
load-file-name
;; If the file is being evaluated with something like
;; `eval-buffer'.
buffer-file-name)))
(straight.el
(expand-file-name
"straight.el" (file-name-directory bootstrap.el))))
;; This logic replicates that in `straight--build-compile',
;; and is used to silence byte-compile warnings and other cruft.
(cl-letf (((symbol-function #'save-some-buffers) #'ignore)
((symbol-function #'byte-compile-log-1) #'ignore)
((symbol-function #'byte-compile-log-file) #'ignore)
((symbol-function #'byte-compile-log-warning) #'ignore))
(let ((byte-compile-warnings nil)
(byte-compile-verbose nil)
(message-log-max nil)
(inhibit-message t)
(emacs-version-changed t))
;; Argument 0 means (for some reason) to byte-compile even if
;; the .elc file does not already exist (but not if the .elc
;; file is at least as new as the .el file).
(byte-recompile-file straight.el nil 0)
(catch 'emacs-version-changed
;; straight.el has a fun hack that throws
;; `emacs-version-changed' if the version of Emacs has changed
;; since the last time it was byte-compiled. This prevents us
;; from accidentally loading invalid byte-code, hopefully.
(load (file-name-sans-extension
(expand-file-name straight.el default-directory))
nil 'nomessage)
(setq emacs-version-changed nil))
(when emacs-version-changed
;; In safe mode, sacrifice performance for safety. When using
;; Emacs-version-specific build directories, do the same to
;; avoid hitting the `emacs-version-changed' error due to a
;; byte-compiled straight.el.
(if (or (bound-and-true-p straight-safe-mode)
(bound-and-true-p straight-use-version-specific-build-dir))
(load straight.el nil 'nomessage 'nosuffix)
;; Don't use the optional LOAD argument for
;; `byte-compile-file' because it emits a message.
(byte-compile-file straight.el)
(load (file-name-sans-extension
(expand-file-name straight.el default-directory))
nil 'nomessage))))))
;; This assures the byte-compiler that we know what we are doing when
;; we reference functions and variables from straight.el below. It
;; does not actually do anything at runtime, since the `straight'
;; feature has already been provided by loading straight.elc above.
(require 'straight)
(straight--log 'init "Loading bootstrap.el")
(straight--log
'env "Git commit: %s"
(lambda ()
(let* ((dir (file-name-directory load-file-name))
(default-directory dir))
(straight-vc-git-get-commit
(file-name-nondirectory
(directory-file-name dir))))))
(when straight-log
(straight--transaction-exec
'logging
:later
(lambda ()
(straight--log 'init "Finished Emacs init")
(straight--log
'modification-detection
"Modification detection mode: %S"
straight-check-for-modifications)))
(mapatoms
(lambda (func)
(when (and (commandp func)
(string-prefix-p "straight-" (symbol-name func)))
(let ((advice-name (intern (format "straight--log-advice--%S" func))))
(defalias
advice-name
(lambda (&rest args)
(when (called-interactively-p 'any)
(straight--log
'ui "Invoked command %S with args: %S" func args))))
(advice-add func :before advice-name))))))
;; In case this is a reinit, and straight.el was already loaded, we
;; have to explicitly clear the caches.
(straight--reset-caches)
;; We start by registering the default recipe repositories. This is
;; done first so that any dependencies of straight.el can be looked up
;; correctly.
;; This is kind of aggressive but we really don't have a good
;; mechanism at present for customizing the default recipe
;; repositories anyway. So don't even try to cater to that use case.
(setq straight-recipe-repositories nil)
(straight-use-recipes '(org-elpa :local-repo nil))
(straight-use-recipes '(melpa :type git :host github
:repo "melpa/melpa"
:build nil))
(if straight-recipes-gnu-elpa-use-mirror
(straight-use-recipes
'(gnu-elpa-mirror :type git :host github
:repo "emacs-straight/gnu-elpa-mirror"
:build nil))
(straight-use-recipes `(gnu-elpa :type git
:repo ,straight-recipes-gnu-elpa-url
:local-repo "elpa"
:build nil)))
(straight-use-recipes
'(nongnu-elpa :type git
:repo "https://git.savannah.gnu.org/git/emacs/nongnu.git"
:depth (full single-branch)
:local-repo "nongnu-elpa"
:build nil))
(straight-use-recipes '(el-get :type git :host github
:repo "dimitri/el-get"
:build nil))
(if straight-recipes-emacsmirror-use-mirror
(straight-use-recipes
'(emacsmirror-mirror :type git :host github
:repo "emacs-straight/emacsmirror-mirror"
:build nil))
(straight-use-recipes '(emacsmirror :type git :host github
:repo "emacsmirror/epkgs"
:nonrecursive t
:build nil)))
;; Then we register (and build) straight.el itself.
(straight-use-package `(straight :type git :host github
:repo ,(format "%s/straight.el"
straight-repository-user)
:files ("straight*.el")
:branch ,straight-repository-branch))
(if (straight--modifications 'check-on-save)
(straight-live-modifications-mode +1)
(straight-live-modifications-mode -1))
(when (straight--modifications 'watch-files)
(straight-watcher-start))
(if straight-use-symlinks
(straight-symlink-emulation-mode -1)
(straight-symlink-emulation-mode +1))
(if straight-enable-package-integration
(straight-package-neutering-mode +1)
(straight-package-neutering-mode -1))
(if straight-enable-use-package-integration
(straight-use-package-mode +1)
(straight-use-package-mode -1))
;;; bootstrap.el ends here