fix: make doom-module-from-path's PATH arg required
This commit is contained in:
parent
a5bb50e957
commit
a67b212b99
1 changed files with 15 additions and 26 deletions
|
@ -211,33 +211,22 @@ This doesn't require modules to be enabled. For enabled modules us
|
||||||
if (file-exists-p path)
|
if (file-exists-p path)
|
||||||
return (expand-file-name path)))
|
return (expand-file-name path)))
|
||||||
|
|
||||||
(defun doom-module-from-path (&optional path enabled-only)
|
(defun doom-module-from-path (path &optional enabled-only)
|
||||||
"Returns a cons cell (CATEGORY . MODULE) derived from PATH (a file path).
|
"Returns a cons cell (CATEGORY . MODULE) derived from PATH (a file path).
|
||||||
If ENABLED-ONLY, return nil if the containing module isn't enabled."
|
If ENABLED-ONLY, return nil if the containing module isn't enabled."
|
||||||
(if (null path)
|
(let* ((file-name-handler-alist nil)
|
||||||
(if doom--current-module
|
(path (expand-file-name path)))
|
||||||
(if enabled-only
|
(save-match-data
|
||||||
(and (doom-module-p (car doom--current-module)
|
(cond ((string-match "/modules/\\([^/]+\\)/\\([^/]+\\)\\(?:/.*\\)?$" path)
|
||||||
(cdr doom--current-module))
|
(when-let* ((category (doom-keyword-intern (match-string 1 path)))
|
||||||
doom--current-module)
|
(module (intern (match-string 2 path))))
|
||||||
doom--current-module)
|
(and (or (null enabled-only)
|
||||||
(ignore-errors
|
(doom-module-p category module))
|
||||||
(doom-module-from-path (file!))))
|
(cons category module))))
|
||||||
(let* ((file-name-handler-alist nil)
|
((file-in-directory-p path doom-core-dir)
|
||||||
(path (expand-file-name (or path (file!)))))
|
(cons :core nil))
|
||||||
(save-match-data
|
((file-in-directory-p path doom-user-dir)
|
||||||
(cond ((string-match "/modules/\\([^/]+\\)/\\([^/]+\\)\\(?:/.*\\)?$" path)
|
(cons :user nil))))))
|
||||||
(when-let* ((category (doom-keyword-intern (match-string 1 path)))
|
|
||||||
(module (intern (match-string 2 path))))
|
|
||||||
(and (or (null enabled-only)
|
|
||||||
(doom-module-p category module))
|
|
||||||
(cons category module))))
|
|
||||||
((or (string-match-p (concat "^" (regexp-quote doom-core-dir)) path)
|
|
||||||
(file-in-directory-p path doom-core-dir))
|
|
||||||
(cons :core (intern (file-name-base path))))
|
|
||||||
((or (string-match-p (concat "^" (regexp-quote doom-user-dir)) path)
|
|
||||||
(file-in-directory-p path doom-user-dir))
|
|
||||||
(cons :user (intern (file-name-base path)))))))))
|
|
||||||
|
|
||||||
(defun doom-module-load-path (&optional module-dirs)
|
(defun doom-module-load-path (&optional module-dirs)
|
||||||
"Return a list of file paths to activated modules.
|
"Return a list of file paths to activated modules.
|
||||||
|
@ -569,7 +558,7 @@ CATEGORY and MODULE can be omitted When this macro is used from inside a module
|
||||||
(and (cond (flag (memq flag (doom-module-get category module :flags)))
|
(and (cond (flag (memq flag (doom-module-get category module :flags)))
|
||||||
(module (doom-module-p category module))
|
(module (doom-module-p category module))
|
||||||
(doom--current-flags (memq category doom--current-flags))
|
(doom--current-flags (memq category doom--current-flags))
|
||||||
((if-let (module (doom-module-from-path))
|
((if-let (module (doom-module-from-path (macroexpand '(file!))))
|
||||||
(memq category (doom-module-get (car module) (cdr module) :flags))
|
(memq category (doom-module-get (car module) (cdr module) :flags))
|
||||||
(error "(modulep! %s %s %s) couldn't figure out what module it was called from (in %s)"
|
(error "(modulep! %s %s %s) couldn't figure out what module it was called from (in %s)"
|
||||||
category module flag (file!)))))
|
category module flag (file!)))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue