From f984d46a9bef69a9ef4d307b7893e9248ea1b547 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 20 May 2018 00:57:57 +0200 Subject: [PATCH] Fix featurep! & load! calls while byte-compiling The would prioritize load-file-name over byte-compile-current-file during byte-compiling, which would result featurep! being unable to resolve the current module and load! from figuring out where "here" was to build its relative paths from. --- core/core-packages.el | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/core-packages.el b/core/core-packages.el index 9e630ceef..e1d16bfc3 100644 --- a/core/core-packages.el +++ b/core/core-packages.el @@ -565,10 +565,13 @@ the lookup is relative to `load-file-name', `byte-compile-current-file' or If NOERROR is non-nil, don't throw an error if the file doesn't exist." (or (symbolp filesym) (signal 'wrong-type-argument (list 'symbolp filesym))) - (let ((path (or path - (and load-file-name (file-name-directory load-file-name)) + (let ((path (or (when path + (cond ((stringp path) path) + ((symbolp path) (symbol-value path)) + ((listp path) (eval path t)))) (and (bound-and-true-p byte-compile-current-file) (file-name-directory byte-compile-current-file)) + (and load-file-name (file-name-directory load-file-name)) (and buffer-file-name (file-name-directory buffer-file-name)) (error "Could not detect path to look for '%s' in" filesym))) @@ -618,7 +621,8 @@ Module FLAGs are set in your config's `doom!' block, typically in When this macro is used from inside a module, MODULE and SUBMODULE can be omitted. eg. (featurep! +flag1)" (unless submodule - (let* ((path (or load-file-name byte-compile-current-file)) + (let* ((path (or (bound-and-true-p byte-compile-current-file) + load-file-name)) (module-pair (doom-module-from-path path))) (unless module-pair (error "featurep! couldn't detect what module its in! (in %s)" path))