From e3f338b9347b03a698aa3764b9c40c7c3dbc1ade Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 22 Feb 2019 01:48:59 -0500 Subject: [PATCH] Fix package file-missing errors at compile-time --- core/core-modules.el | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/core-modules.el b/core/core-modules.el index 3007460cc..88b7bbafc 100644 --- a/core/core-modules.el +++ b/core/core-modules.el @@ -335,10 +335,16 @@ to least)." (defvar doom-disabled-packages) (defmacro def-package! (name &rest plist) - "This is a thin wrapper around `use-package'." - `(use-package ,name - ,@(if (memq name doom-disabled-packages) `(:disabled t)) - ,@plist)) + "This is a thin wrapper around `use-package'. It is ignored if the NAME +package is disabled." + (unless (or (memq name doom-disabled-packages) + ;; At compile-time, use-package will forcibly load its package to + ;; prevent compile-time errors. However, Doom users can + ;; intentionally disable packages, resulting if file-missing + ;; package errors, so we preform this check at compile time: + (and (bound-and-true-p byte-compile-current-file) + (not (locate-library (symbol-name name))))) + `(use-package ,name ,@plist))) (defmacro def-package-hook! (package when &rest body) "Reconfigures a package's `def-package!' block.