diff --git a/core/core-lib.el b/core/core-lib.el index 3411ca60b..8abf49780 100644 --- a/core/core-lib.el +++ b/core/core-lib.el @@ -240,6 +240,23 @@ writes to `standard-output'." (save-silently t)) (prog1 ,@forms (message "")))))) +(defmacro if! (cond then &rest body) + "Expands to THEN if COND is non-nil, to BODY otherwise. +COND is checked at compile/expansion time, allowing BODY to be omitted +entirely when the elisp is byte-compiled. Use this for forms that contain +expensive macros that could safely be removed at compile time." + (declare (indent 2)) + (if (eval cond) + then + (macroexp-progn body))) + +(defmacro when! (cond &rest body) + "Expands to BODY if CONDITION is non-nil at compile/expansion time. +See `if!' for details on this macro's purpose." + (declare (indent 1)) + (when (eval cond) + (macroexp-progn body))) + ;;; Mutation (defmacro appendq! (sym &rest lists) diff --git a/core/core-ui.el b/core/core-ui.el index 45c58c826..ff4d6ad8b 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -302,7 +302,7 @@ windows, switch to `doom-fallback-buffer'. Otherwise, delegate to original (add-to-list 'default-frame-alist '(tool-bar-lines . 0)) (add-to-list 'default-frame-alist '(vertical-scroll-bars))) -(when IS-MAC +(when! IS-MAC ;; Curse Lion and its sudden but inevitable fullscreen mode! ;; NOTE Meaningless to railwaycat's emacs-mac build (setq ns-use-native-fullscreen nil) @@ -610,7 +610,7 @@ behavior). Do not set this directly, this is let-bound in `doom-init-theme-h'.") (run-hooks 'doom-load-theme-hook)) result))) -(unless EMACS27+ +(when! (not EMACS27+) ;; DEPRECATED Not needed in Emacs 27 (defadvice! doom--prefer-compiled-theme-a (orig-fn &rest args) "Have `load-theme' prioritize the byte-compiled theme.