refactor: do Emacs version check at compile time too

In case the user tries to byte-compile Doom with the wrong version of
Emacs.
This commit is contained in:
Henrik Lissner 2022-09-13 18:00:34 +02:00
parent 3a0f1aa3ef
commit 75881c7d45
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -49,31 +49,32 @@
;; ;;
;;; Code: ;;; Code:
;; Doom's minimum supported version of Emacs is 27.1. Its my goal to support one (eval-and-compile ; Check version at both compile and runtime.
;; major version below the stable release, for about a year or until stable is ;; Doom's minimum supported version of Emacs is 27.1. Its my goal to support
;; ubiquitous (or at least easily accessible) across Linux distros. ;; one major version below the stable release, for about a year or until
(when (< emacs-major-version 27) ;; stable is ubiquitous (or at least easily accessible) across Linux distros.
(user-error (when (< emacs-major-version 27)
(concat (user-error
"Detected Emacs " emacs-version ", but Doom requires 27.1 or newer.\n\n" (concat
"The version of Emacs in use is located at:\n\n " (car command-line-args) "\n\n" "Detected Emacs " emacs-version ", but Doom requires 27.1 or newer.\n\n"
"A guide for installing a newer version of Emacs can be found at:\n\n " "The version of Emacs in use is located at:\n\n " (car command-line-args) "\n\n"
(format "https://docs.doomemacs.org/-/install/%s" "A guide for installing a newer version of Emacs can be found at:\n\n "
(cond ((eq system-type 'darwin) "on-macos") (format "https://docs.doomemacs.org/-/install/%s"
((memq system-type '(cygwin windows-nt ms-dos)) "on-windows") (cond ((eq system-type 'darwin) "on-macos")
("on-linux"))) ((memq system-type '(cygwin windows-nt ms-dos)) "on-windows")
"\n\n" ("on-linux")))
(if (not noninteractive) "\n\n"
(concat "If you believe this error is a mistake, run 'doom doctor' on the command line\n" (if (not noninteractive)
"to diagnose common issues with your config and system.") (concat "If you believe this error is a mistake, run 'doom doctor' on the command line\n"
(concat "Alternatively, either update your $PATH environment variable to include the\n" "to diagnose common issues with your config and system.")
"path of the desired Emacs executable OR alter the $EMACS environment variable\n" (concat "Alternatively, either update your $PATH environment variable to include the\n"
"to specify the exact path or command needed to invoke Emacs. For example:\n\n" "path of the desired Emacs executable OR alter the $EMACS environment variable\n"
(let ((command (ignore-errors (file-name-nondirectory (cadr (member "--load" command-line-args)))))) "to specify the exact path or command needed to invoke Emacs. For example:\n\n"
(concat " $ EMACS=/path/to/valid/emacs " command " ...\n" (let ((command (ignore-errors (file-name-nondirectory (cadr (member "--load" command-line-args))))))
" $ EMACS=\"/Applications/Emacs.app/Contents/MacOS/Emacs\" " command " ...\n" (concat " $ EMACS=/path/to/valid/emacs " command " ...\n"
" $ EMACS=\"snap run emacs\" " command " ...\n")) " $ EMACS=\"/Applications/Emacs.app/Contents/MacOS/Emacs\" " command " ...\n"
"\nAborting..."))))) " $ EMACS=\"snap run emacs\" " command " ...\n"))
"\nAborting..."))))))
;; Doom needs to be synced/rebuilt if either Doom or Emacs has been ;; Doom needs to be synced/rebuilt if either Doom or Emacs has been
;; up/downgraded. This is because byte-code isn't backwards compatible, and many ;; up/downgraded. This is because byte-code isn't backwards compatible, and many