diff --git a/lisp/cli/doctor.el b/lisp/cli/doctor.el index 07b68918b..e27911a9e 100644 --- a/lisp/cli/doctor.el +++ b/lisp/cli/doctor.el @@ -67,7 +67,7 @@ in." "\t- might depend subtly on upstream packages updates.\n" "You might need to unpin packages to get a fix for a specific commit of Emacs, " "and you should be ready to downgrade Emacs if something is just not fixable.")) - (EMACS29+ + ((> emacs-major-version 28) (warn! "Emacs %s detected" emacs-version) (explain! "Doom supports this version, but you are living on the edge! " "Be prepared for breakages in future versions of Emacs.")) @@ -108,13 +108,12 @@ in." "jansson support (i.e. a native JSON library), particularly LSP users. " "You must install a prebuilt Emacs binary with this included, or compile " "Emacs with the --with-json option.")) - (when EMACS28+ - (unless NATIVECOMP - (warn! "Emacs was not built with native compilation support") - (explain! "Users will see a substantial performance gain by building Emacs with " - "native compilation support, availible in emacs 28+." - "You must install a prebuilt Emacs binary with this included, or compile " - "Emacs with the --with-native-compilation option."))) + (unless (featurep 'native-compile) + (warn! "Emacs was not built with native compilation support") + (explain! "Users will see a substantial performance gain by building Emacs with " + "native compilation support, availible in emacs 28+." + "You must install a prebuilt Emacs binary with this included, or compile " + "Emacs with the --with-native-compilation option.")) (print! (start "Checking for private config conflicts...")) (let* ((xdg-dir (concat (or (getenv "XDG_CONFIG_HOME") diff --git a/lisp/cli/packages.el b/lisp/cli/packages.el index d967c5bec..fc30700e3 100644 --- a/lisp/cli/packages.el +++ b/lisp/cli/packages.el @@ -240,7 +240,7 @@ list remains lean." (defun doom-packages--write-missing-eln-errors () "Write .error files for any expected .eln files that are missing." - (when NATIVECOMP + (when (featurep 'native-compile) (cl-loop for file in doom-packages--eln-output-expected for eln-name = (doom-packages--eln-file-name file) for eln-file = (doom-packages--eln-output-file eln-name) @@ -254,7 +254,7 @@ list remains lean." (defun doom-packages--compile-site-files () "Queue async compilation for all non-doom Elisp files." - (when NATIVECOMP + (when (featurep 'native-compile) (cl-loop with paths = (cl-loop for path in load-path unless (file-in-directory-p path doom-local-dir) collect path) @@ -301,7 +301,7 @@ declaration) or dependency thereof that hasn't already been." (signal 'doom-package-error (list package e)))))) (progn (doom-packages--compile-site-files) - (when NATIVECOMP + (when (featurep 'native-compile) (doom-packages--wait-for-native-compile-jobs) (doom-packages--write-missing-eln-errors)) (print! (success "\033[KInstalled %d packages") (length built))) @@ -348,7 +348,7 @@ declaration) or dependency thereof that hasn't already been." (and (eq (car-safe build) :not) (setq want-byte-compile (not want-byte-compile) want-native-compile (not want-native-compile))) - (unless NATIVECOMP + (unless (featurep 'native-compile) (setq want-native-compile nil)) (and (or want-byte-compile want-native-compile) (or (file-newer-than-file-p repo-dir build-dir) @@ -365,7 +365,7 @@ declaration) or dependency thereof that hasn't already been." (straight-use-package (intern package)))) (progn (doom-packages--compile-site-files) - (when NATIVECOMP + (when (featurep 'native-compile) (doom-packages--wait-for-native-compile-jobs) (doom-packages--write-missing-eln-errors)) ;; HACK Every time you save a file in a package that straight tracks, @@ -659,7 +659,7 @@ If ELPA-P, include packages installed with package.el (M-x package-install)." (if (not regraft-repos-p) (ignore (print! (item "Skipping regrafting"))) (doom-packages--regraft-repos repos-to-regraft)) - (when NATIVECOMP + (when (featurep 'native-compile) (if (not eln-p) (ignore (print! (item "Skipping native bytecode"))) (doom-packages--purge-eln)))))))) diff --git a/lisp/doom-editor.el b/lisp/doom-editor.el index e5989b864..44e494354 100644 --- a/lisp/doom-editor.el +++ b/lisp/doom-editor.el @@ -561,7 +561,7 @@ files, so this replace calls to `pp' with the much faster `prin1'." (lambda (button) (helpful-variable (button-get button 'apropos-symbol)))))) - (when EMACS29+ + (when (> emacs-major-version 28) ;; REVIEW This should be reported upstream to Emacs. (defadvice! doom--find-function-search-for-symbol-save-excursion-a (fn &rest args) "Suppress cursor movement by `find-function-search-for-symbol'. @@ -669,7 +669,7 @@ on." ;; Emacs 29 introduced faster long-line detection, so they can afford a much ;; larger `so-long-threshold' and its default `so-long-predicate'. (if (fboundp 'buffer-line-statistics) - (unless NATIVECOMP + (unless (featurep 'native-compile) (setq so-long-threshold 5000)) ;; reduce false positives w/ larger threshold (setq so-long-threshold 400) diff --git a/lisp/doom-packages.el b/lisp/doom-packages.el index 99ec8b435..8702ee5a9 100644 --- a/lisp/doom-packages.el +++ b/lisp/doom-packages.el @@ -110,7 +110,7 @@ uses a straight or package.el command directly).") ;; ;;; native-comp -(when NATIVECOMP +(when (featurep 'native-compile) (after! comp ;; HACK Disable native-compilation for some troublesome packages (mapc (doom-partial #'add-to-list 'native-comp-deferred-compilation-deny-list) diff --git a/lisp/doom-ui.el b/lisp/doom-ui.el index dbbae91a7..edbc3abb5 100644 --- a/lisp/doom-ui.el +++ b/lisp/doom-ui.el @@ -307,7 +307,7 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original (setq resize-mini-windows 'grow-only) ;; Typing yes/no is obnoxious when y/n will do -(if EMACS28+ +(if (boundp 'use-short-answers) (setq use-short-answers t) ;; DEPRECATED Remove when we drop 27.x support (advice-add #'yes-or-no-p :override #'y-or-n-p)) @@ -513,7 +513,7 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original ;; Fix #2742: cursor is off by 4 characters in `artist-mode' ;; REVIEW Reported upstream https://debbugs.gnu.org/cgi/bugreport.cgi?bug=43811 ;; DEPRECATED Fixed in Emacs 28; remove when we drop 27 support -(unless EMACS28+ +(unless (> emacs-major-version 27) (add-hook 'artist-mode-hook #'doom-disable-line-numbers-h)) diff --git a/lisp/doom.el b/lisp/doom.el index 807ad09fa..b4e05f1ff 100644 --- a/lisp/doom.el +++ b/lisp/doom.el @@ -77,17 +77,37 @@ ;; ;;; Global constants -;; Emacs features -(defconst EMACS28+ (> emacs-major-version 27)) -(defconst EMACS29+ (> emacs-major-version 28)) -(defconst MODULES (bound-and-true-p module-file-suffix)) -(defconst NATIVECOMP (if (fboundp 'native-comp-available-p) (native-comp-available-p))) - -;; Operating system +;; DEPRECATED (defconst IS-MAC (eq system-type 'darwin)) (defconst IS-LINUX (eq system-type 'gnu/linux)) (defconst IS-WINDOWS (memq system-type '(cygwin windows-nt ms-dos))) -(defconst IS-BSD (or IS-MAC (eq system-type 'berkeley-unix))) +(defconst IS-BSD (memq system-type '(darwin berkeley-unix gnu/kfreebsd))) + +(unless (featurep 'doom) + ;; Since `system-configuration-features's docs state not to rely on it to test + ;; for features, let's give users an easier way to detect them. + (if (bound-and-true-p module-file-suffix) + (push 'dynamic-modules features)) + (if (fboundp #'json-parse-string) + (push 'jansson features)) + ;; `native-compile' exists whether or not it is functional (e.g. libgcc is + ;; available or not). This seems silly, so pretend it doesn't exist if it + ;; isn't available. + (if (featurep 'native-compile) + (if (not (native-comp-available-p)) + (delq 'native-compile features))) + + ;; DEPRECATED remove in v3 + (defconst EMACS28+ (> emacs-major-version 27)) + (defconst EMACS29+ (> emacs-major-version 28)) + ;; DEPRECATED remove in v3 + (defconst MODULES (featurep 'dynamic-modules)) + (defconst NATIVECOMP (featurep 'native-compile)) + + (make-obsolete-variable 'EMACS28+ "Use (>= emacs-major-version 28) instead" "3.0.0") + (make-obsolete-variable 'EMACS29+ "Use (>= emacs-major-version 29) instead" "3.0.0") + (make-obsolete-variable 'MODULES "Use (featurep 'dynamic-modules) instead" "3.0.0") + (make-obsolete-variable 'NATIVECOMP "Use (featurep 'native-compile) instead" "3.0.0")) ;; @@ -291,7 +311,7 @@ users).") ;; ;;; Native Compilation support (http://akrl.sdf.org/gccemacs.html) -(when NATIVECOMP +(when (featurep 'native-compile) ;; Don't store eln files in ~/.emacs.d/eln-cache (where they can easily be ;; deleted by 'doom upgrade'). (add-to-list 'native-comp-eln-load-path (file-name-concat doom-cache-dir "eln/"))) diff --git a/modules/editor/evil/config.el b/modules/editor/evil/config.el index 091385603..764f9d32f 100644 --- a/modules/editor/evil/config.el +++ b/modules/editor/evil/config.el @@ -53,7 +53,7 @@ directives. By default, this only recognizes C directives.") evil-undo-system (cond ((featurep! :emacs undo +tree) 'undo-tree) ((featurep! :emacs undo) 'undo-fu) - (EMACS28+ 'undo-redo))) + ((> emacs-major-version 27) 'undo-redo))) ;; Slow this down from 0.02 to prevent blocking in large or folded buffers ;; like magit while incrementally highlighting matches. diff --git a/modules/editor/evil/init.el b/modules/editor/evil/init.el index e55ad8e60..092976f4c 100644 --- a/modules/editor/evil/init.el +++ b/modules/editor/evil/init.el @@ -136,7 +136,7 @@ variable for an explanation of the defaults (in comments). See elisp-slime-nav embark emms - ,@(when EMACS29+ '(emoji)) + ,@(if (> emacs-major-version 28) '(emoji)) epa ert eshell @@ -226,7 +226,7 @@ variable for an explanation of the defaults (in comments). See scroll-lock selectrum sh-script - ,@(when EMACS28+ '(shortdoc)) + ,@(if (> emacs-major-version 27) '(shortdoc)) simple simple-mpc slime diff --git a/modules/emacs/vc/autoload/bug-reference-backport.el b/modules/emacs/vc/autoload/bug-reference-backport.el index 314cc6632..4b58b8701 100644 --- a/modules/emacs/vc/autoload/bug-reference-backport.el +++ b/modules/emacs/vc/autoload/bug-reference-backport.el @@ -1,5 +1,5 @@ ;;; emacs/vc/autoload/bug-reference-backport.el -*- lexical-binding: t; -*- -;;;###if (not EMACS28+) +;;;###if (< emacs-major-version 28) ;; DEPRECATED Remove when Emacs 27.x support is dropped ;; In Emacs 28, the built-in bug-reference package started consulting vc for diff --git a/modules/term/eshell/autoload/backport.el b/modules/term/eshell/autoload/backport.el index 7e3bfe82a..6024c1d2b 100644 --- a/modules/term/eshell/autoload/backport.el +++ b/modules/term/eshell/autoload/backport.el @@ -1,5 +1,5 @@ ;;; term/eshell/autoload/mode.el -*- lexical-binding: t; -*- -;;;###if (not EMACS28+) +;;;###if (< emacs-major-version 28) ;; DEPRECATED Remove this when we drop Emacs 27 support. diff --git a/modules/term/vterm/config.el b/modules/term/vterm/config.el index d52b57cf9..7ed3bedec 100644 --- a/modules/term/vterm/config.el +++ b/modules/term/vterm/config.el @@ -1,7 +1,7 @@ ;;; term/vterm/config.el -*- lexical-binding: t; -*- (use-package! vterm - :when (bound-and-true-p module-file-suffix) + :when (featurep 'dynamic-modules) :commands vterm-mode :hook (vterm-mode . doom-mark-buffer-as-real-h) :hook (vterm-mode . hide-mode-line-mode) ; modeline serves no purpose in vterm diff --git a/modules/ui/ligatures/config.el b/modules/ui/ligatures/config.el index 484945ceb..42b7af1f4 100644 --- a/modules/ui/ligatures/config.el +++ b/modules/ui/ligatures/config.el @@ -179,7 +179,7 @@ and cannot run in." ;; Harfbuzz and Mac builds do not need font-specific ligature support ;; if they are above emacs-27. - ((and EMACS28+ + ((and (> emacs-major-version 27) (or (featurep 'ns) (string-match-p "HARFBUZZ" system-configuration-features)) (featurep 'composite)) ; Emacs loads `composite' at startup