fix: ensure module state is in scope for modulep!

Otherwise, doom-module-from-path (and modulep!) would fail to detect the
module they're in, or at least, modulep! would incorrectly return nil,
even for enabled modules.

This issue is what would've caused the package list or the doctor to
include/consider packages in disabled modules or behind disabled flags.
This commit is contained in:
Henrik Lissner 2022-09-10 18:59:02 +02:00
parent ce0e3a04b6
commit 45a66cda60
No known key found for this signature in database
GPG Key ID: B60957CA074D39A3
3 changed files with 14 additions and 7 deletions

View File

@ -247,7 +247,9 @@ in."
(let (doom-doctor--errors
doom-doctor--warnings)
(condition-case-unless-debug ex
(let ((doctor-file (doom-module-path (car key) (cdr key) "doctor.el"))
(let ((doom--current-module key)
(doom--current-flags (plist-get plist :flags))
(doctor-file (doom-module-path (car key) (cdr key) "doctor.el"))
(packages-file (doom-module-path (car key) (cdr key) "packages.el")))
(cl-loop with doom-output-indent = 6
for name in (let (doom-packages

View File

@ -463,9 +463,11 @@ ones."
(let (doom-packages)
(doom--read-packages private-packages nil 'noerror))
(cl-loop for key being the hash-keys of doom-modules
for path = (doom-module-path (car key) (cdr key) packages-file)
for plist = (get (car key) (cdr key))
for doom--current-flags = (plist-get plist :flags)
for doom--current-module = key
do (doom--read-packages path nil 'noerror)))
for file = (doom-path (plist-get plist :path) packages-file)
do (doom--read-packages file nil 'noerror)))
(doom--read-packages private-packages all-p 'noerror)))
(cl-remove-if-not
(if core-only-p
@ -555,13 +557,14 @@ elsewhere."
`(let* ((name ',name)
(plist (cdr (assq name doom-packages))))
;; Record what module this declaration was found in
(let ((module-list (plist-get plist :modules))
(module ',(doom-module-from-path)))
(let* ((dir (dir!))
(module-list (plist-get plist :modules))
(module (doom-module-from-path dir)))
(unless (member module module-list)
(cl-callf plist-put plist :modules
(append module-list
(list module)
(when (file-in-directory-p ,(dir!) doom-user-dir)
(when (file-in-directory-p dir doom-user-dir)
'((:user . modules)))
nil))))
;; Merge given plist with pre-existing one

View File

@ -156,7 +156,9 @@ return NULL-VALUE."
(insert-file-contents file nil 0 256)
(if (re-search-forward (format "^;;;###%s " (regexp-quote (or cookie "if")))
nil t)
(let ((load-file-name file))
(let* ((load-file-name file)
(doom--current-module (doom-module-from-path file))
(doom--current-flags (doom-module-get (car doom--current-module) (cdr doom--current-module) :flags)))
(eval (sexp-at-point) t))
null-value)))