Skip to content

Commit

Permalink
[radian-software#267] Rebuild straight.el on Emacs version change
Browse files Browse the repository at this point in the history
  • Loading branch information
raxod502 committed Apr 22, 2018
1 parent bf396ff commit 5acd948
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
26 changes: 21 additions & 5 deletions bootstrap.el
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,35 @@
(let ((byte-compile-warnings nil)
(byte-compile-verbose nil)
(message-log-max nil)
(inhibit-message t))
(inhibit-message t)
(emacs-version-changed t))
;; Compile and load files necessary for straight.el in reverse
;; dependency order.
;;
;; Argument 0 means (for some reason) to byte-compile even if
;; the .elc file does not already exist.
(byte-recompile-file straight-compat.el nil 0)
(load (expand-file-name (concat straight-compat.el "c")
default-directory)
nil 'nomessage 'nosuffix)
(catch 'emacs-version-changed
;; straight-compat.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.
(load (expand-file-name (concat straight-compat.el "c")
default-directory)
nil 'nomessage 'nosuffix)
(setq emacs-version-changed nil))
(when emacs-version-changed
;; Don't use the optional LOAD argument for
;; `byte-compile-file' because it emits a message.
(byte-compile-file straight-compat.el)
(load (expand-file-name (concat straight-compat.el "c")
default-directory)
nil 'nomessage 'nosuffix))
;; Actually load the package manager. This doesn't do anything
;; except initialize some caches.
(byte-recompile-file straight.el nil 0)
(if emacs-version-changed
(byte-compile-file straight.el)
(byte-recompile-file straight.el nil 0))
(load (expand-file-name (concat straight.el "c")
default-directory)
nil 'nomessage 'nosuffix))))
Expand Down
11 changes: 11 additions & 0 deletions straight-compat.el
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,21 @@
;; This file contains definitions of functions and macros that do not
;; appear in older versions of Emacs supported by straight.el.

;; It also has a fun hack that allows the bootstrap process to detect
;; whether the Emacs version has changed since straight.el was last
;; byte-compiled.

;; See straight.el for more information.

;;; Code:

;; Hack!
(eval
`(unless (equal
(emacs-version)
,(eval-when-compile (emacs-version)))
(throw 'emacs-version-changed nil)))

;; Not defined before Emacs 25.1
(unless (fboundp 'if-let)
(defmacro if-let (varlist then &optional else)
Expand Down

0 comments on commit 5acd948

Please sign in to comment.