From e4b23d78daa3a470d71e21e3471fb0c1cc05a421 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sat, 23 Jun 2018 22:23:35 +0200 Subject: [PATCH] Refactor require! Defer its compile-time segments to run-time, which would cause many issues in conditions wrapped around it. In any case, avoid using require!, it was a poor choice to implement it and should only be used for unit tests. --- core/core-modules.el | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/core/core-modules.el b/core/core-modules.el index 66b2385f2..b19a58c12 100644 --- a/core/core-modules.el +++ b/core/core-modules.el @@ -332,23 +332,21 @@ to have them return non-nil (or exploit that to overwrite Doom's config)." (defmacro require! (category module &rest plist) "Loads the module specified by CATEGORY (a keyword) and MODULE (a symbol)." - (let ((doom-modules (copy-hash-table doom-modules))) - (apply #'doom-module-set category module - (mapcar #'eval plist)) - (let ((module-path (doom-module-locate-path category module))) - (if (directory-name-p module-path) - `(condition-case-unless-debug ex - (let ((doom--current-module ',(cons category module))) - (load! "init" ,module-path :noerror) - (let ((doom--stage 'config)) - (load! "config" ,module-path :noerror))) - ('error - (lwarn 'doom-modules :error - "%s in '%s %s' -> %s" - (car ex) ,category ',module - (error-message-string ex)))) - (warn 'doom-modules :warning "Couldn't find module '%s %s'" - category module))))) + `(let ((module-path (doom-module-locate-path ,category ',module))) + (doom-module-set ,category ',module ,@plist) + (if (directory-name-p module-path) + (condition-case-unless-debug ex + (let ((doom--current-module ',(cons category module))) + (load! "init" module-path :noerror) + (let ((doom--stage 'config)) + (load! "config" module-path :noerror))) + ('error + (lwarn 'doom-modules :error + "%s in '%s %s' -> %s" + (car ex) ,category ',module + (error-message-string ex)))) + (warn 'doom-modules :warning "Couldn't find module '%s %s'" + ,category ',module)))) (defmacro featurep! (module &optional submodule flag) "Returns t if MODULE SUBMODULE is enabled. If FLAG is provided, returns t if