Move emacs version check into doom-initialize
Also fixes void-function errors caused by (now removed) doom-same-emacs-version-p not being defined in all the contexts it was needed. Where it was before was clumsy design.
This commit is contained in:
parent
7b1a83079d
commit
282e0d6653
3 changed files with 33 additions and 32 deletions
|
@ -117,13 +117,13 @@ modified."
|
||||||
(dolist (file (doom-files-in auto-dir :match "\\.el$" :full t))
|
(dolist (file (doom-files-in auto-dir :match "\\.el$" :full t))
|
||||||
(push file targets)))))
|
(push file targets)))))
|
||||||
(if (and (not force-p)
|
(if (and (not force-p)
|
||||||
|
(not doom-emacs-changed-p)
|
||||||
(file-exists-p doom-autoload-file)
|
(file-exists-p doom-autoload-file)
|
||||||
(not (file-newer-than-file-p (expand-file-name "init.el" doom-private-dir)
|
(not (file-newer-than-file-p (expand-file-name "init.el" doom-private-dir)
|
||||||
doom-autoload-file))
|
doom-autoload-file))
|
||||||
(not (cl-loop for file in targets
|
(not (cl-loop for file in targets
|
||||||
if (file-newer-than-file-p file doom-autoload-file)
|
if (file-newer-than-file-p file doom-autoload-file)
|
||||||
return t))
|
return t)))
|
||||||
(doom-same-emacs-version-p))
|
|
||||||
(ignore (print! (green "Doom core autoloads is up-to-date"))
|
(ignore (print! (green "Doom core autoloads is up-to-date"))
|
||||||
(doom-initialize-autoloads doom-autoload-file))
|
(doom-initialize-autoloads doom-autoload-file))
|
||||||
(doom-delete-autoloads-file doom-autoload-file)
|
(doom-delete-autoloads-file doom-autoload-file)
|
||||||
|
@ -197,14 +197,14 @@ FORCE-P (universal argument) is non-nil, regenerate it anyway.
|
||||||
This should be run whenever your `doom!' block or update your packages."
|
This should be run whenever your `doom!' block or update your packages."
|
||||||
(interactive)
|
(interactive)
|
||||||
(if (and (not force-p)
|
(if (and (not force-p)
|
||||||
|
(not doom-emacs-changed-p)
|
||||||
(file-exists-p doom-package-autoload-file)
|
(file-exists-p doom-package-autoload-file)
|
||||||
(not (file-newer-than-file-p package-user-dir doom-package-autoload-file))
|
(not (file-newer-than-file-p package-user-dir doom-package-autoload-file))
|
||||||
(not (ignore-errors
|
(not (ignore-errors
|
||||||
(cl-loop for key being the hash-keys of (doom-module-table)
|
(cl-loop for key being the hash-keys of (doom-module-table)
|
||||||
for path = (doom-module-path (car key) (cdr key) "packages.el")
|
for path = (doom-module-path (car key) (cdr key) "packages.el")
|
||||||
if (file-newer-than-file-p path doom-package-autoload-file)
|
if (file-newer-than-file-p path doom-package-autoload-file)
|
||||||
return t)))
|
return t))))
|
||||||
(doom-same-emacs-version-p))
|
|
||||||
(ignore (print! (green "Doom package autoloads is up-to-date"))
|
(ignore (print! (green "Doom package autoloads is up-to-date"))
|
||||||
(doom-initialize-autoloads doom-package-autoload-file))
|
(doom-initialize-autoloads doom-package-autoload-file))
|
||||||
(doom-delete-autoloads-file doom-package-autoload-file)
|
(doom-delete-autoloads-file doom-package-autoload-file)
|
||||||
|
@ -317,8 +317,8 @@ If RECOMPILE-P is non-nil, only recompile out-of-date files."
|
||||||
(unless recompile-p
|
(unless recompile-p
|
||||||
(doom//clean-byte-compiled-files))
|
(doom//clean-byte-compiled-files))
|
||||||
(unless targets
|
(unless targets
|
||||||
(message "Regenerating autoloads files (if necessary)")
|
|
||||||
(let ((inhibit-message t)
|
(let ((inhibit-message t)
|
||||||
|
doom-emacs-changed-p
|
||||||
noninteractive)
|
noninteractive)
|
||||||
;; But first we must be sure that Doom and your private config have
|
;; But first we must be sure that Doom and your private config have
|
||||||
;; been fully loaded. Which usually aren't so in an noninteractive
|
;; been fully loaded. Which usually aren't so in an noninteractive
|
||||||
|
|
|
@ -1,32 +1,5 @@
|
||||||
;;; -*- lexical-binding: t; no-byte-compile: t; -*-
|
;;; -*- lexical-binding: t; no-byte-compile: t; -*-
|
||||||
|
|
||||||
;; Do an Emacs version check and warn the user if it has changed.
|
|
||||||
(defvar doom--last-emacs-file (concat doom-local-dir "emacs-version.el"))
|
|
||||||
(defvar doom--last-emacs-version nil)
|
|
||||||
|
|
||||||
(defun doom-refresh-emacs-version ()
|
|
||||||
(with-temp-file doom--last-emacs-file
|
|
||||||
(princ `(setq doom--last-emacs-version ,(prin1-to-string emacs-version))
|
|
||||||
(current-buffer))))
|
|
||||||
|
|
||||||
(defun doom-same-emacs-version-p ()
|
|
||||||
(if (or doom--last-emacs-version
|
|
||||||
(load doom--last-emacs-file t t t))
|
|
||||||
(equal emacs-version doom--last-emacs-version)
|
|
||||||
(setq doom--last-emacs-version emacs-version)
|
|
||||||
(doom-refresh-emacs-version)
|
|
||||||
t))
|
|
||||||
|
|
||||||
(unless (doom-same-emacs-version-p)
|
|
||||||
(unless (y-or-n-p
|
|
||||||
(format (concat "Your version of Emacs has changed from %s to %s, which may cause incompatibility\n"
|
|
||||||
"issues. Please run `bin/doom compile :plugins` afterwards to resolve any problems.\n\n"
|
|
||||||
"Continue?")
|
|
||||||
doom--last-emacs-version
|
|
||||||
emacs-version))
|
|
||||||
(error "Aborting"))
|
|
||||||
(doom-refresh-emacs-version))
|
|
||||||
|
|
||||||
;; Eagerly load these libraries because this module may be loaded in a session
|
;; Eagerly load these libraries because this module may be loaded in a session
|
||||||
;; that hasn't been fully initialized (where autoloads files haven't been
|
;; that hasn't been fully initialized (where autoloads files haven't been
|
||||||
;; generated or `load-path' populated).
|
;; generated or `load-path' populated).
|
||||||
|
|
|
@ -80,6 +80,10 @@ file.")
|
||||||
(defvar doom-reload-hook nil
|
(defvar doom-reload-hook nil
|
||||||
"A list of hooks to run when `doom//reload-load-path' is called.")
|
"A list of hooks to run when `doom//reload-load-path' is called.")
|
||||||
|
|
||||||
|
(defvar doom-emacs-changed-p nil
|
||||||
|
"If non-nil, the running version of Emacs is different from the first time
|
||||||
|
Doom was setup, which can cause problems.")
|
||||||
|
|
||||||
(defvar doom--current-module nil)
|
(defvar doom--current-module nil)
|
||||||
(defvar doom--refreshed-p nil)
|
(defvar doom--refreshed-p nil)
|
||||||
(defvar doom--stage 'init)
|
(defvar doom--stage 'init)
|
||||||
|
@ -171,6 +175,29 @@ If RETURN-P, return the message as a string instead of displaying it."
|
||||||
;; Bootstrap helpers
|
;; Bootstrap helpers
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
(defvar doom--last-emacs-file (concat doom-local-dir "emacs-version.el"))
|
||||||
|
(defvar doom--last-emacs-version nil)
|
||||||
|
|
||||||
|
(defun doom-ensure-same-emacs-version-p ()
|
||||||
|
"Do an Emacs version check and set `doom-emacs-changed-p' if it has changed."
|
||||||
|
(if (load doom--last-emacs-file 'noerror 'nomessage 'nosuffix)
|
||||||
|
(setq doom-emacs-changed-p
|
||||||
|
(not (equal emacs-version doom--last-emacs-version)))
|
||||||
|
(with-temp-file doom--last-emacs-file
|
||||||
|
(princ `(setq doom--last-emacs-version ,(prin1-to-string emacs-version))
|
||||||
|
(current-buffer))))
|
||||||
|
(cond ((not doom-emacs-changed-p))
|
||||||
|
((y-or-n-p
|
||||||
|
(format
|
||||||
|
(concat "Your version of Emacs has changed from %s to %s, which may cause incompatibility\n"
|
||||||
|
"issues. Please run `bin/doom compile :plugins` afterwards to resolve any problems.\n\n"
|
||||||
|
"Continue?")
|
||||||
|
doom--last-emacs-version
|
||||||
|
emacs-version))
|
||||||
|
(delete-file doom--last-emacs-file))
|
||||||
|
(noninteractive (error "Aborting"))
|
||||||
|
((kill-emacs))))
|
||||||
|
|
||||||
(defun doom-ensure-packages-initialized (&optional force-p)
|
(defun doom-ensure-packages-initialized (&optional force-p)
|
||||||
"Make sure package.el is initialized."
|
"Make sure package.el is initialized."
|
||||||
(when (or force-p (not package--initialized))
|
(when (or force-p (not package--initialized))
|
||||||
|
@ -248,6 +275,7 @@ to least)."
|
||||||
;; functions from. This includes everything in core/autoload/*.el and all
|
;; functions from. This includes everything in core/autoload/*.el and all
|
||||||
;; the autoload files in your enabled modules.
|
;; the autoload files in your enabled modules.
|
||||||
(unless (doom-initialize-autoloads doom-autoload-file force-p)
|
(unless (doom-initialize-autoloads doom-autoload-file force-p)
|
||||||
|
(doom-ensure-same-emacs-version-p)
|
||||||
(doom-ensure-core-directories)
|
(doom-ensure-core-directories)
|
||||||
(doom-ensure-packages-initialized force-p)
|
(doom-ensure-packages-initialized force-p)
|
||||||
(doom-ensure-core-packages)
|
(doom-ensure-core-packages)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue