Refactor doom-module-from-path

If PATH is omitted, use (FILE!); also use doom-keyword-intern.
This commit is contained in:
Henrik Lissner 2018-06-12 20:50:41 +02:00
parent 64d354ae35
commit 4c2107d595
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -119,14 +119,14 @@ This doesn't require modules to be enabled. For enabled modules us
(defun doom-module-from-path (&optional path)
"Returns a cons cell (CATEGORY . MODULE) derived from PATH (a file path)."
(or doom--current-module
(when path
(let ((path (or path (FILE!))))
(save-match-data
(setq path (file-truename path))
(when (string-match "/modules/\\([^/]+\\)/\\([^/]+\\)/.*$" path)
(when-let* ((module (match-string 1 path))
(submodule (match-string 2 path)))
(cons (intern (concat ":" module))
(intern submodule))))))))
(when-let* ((category (match-string 1 path))
(module (match-string 2 path)))
(cons (doom-keyword-intern category)
(intern module))))))))
(defun doom-module-load-path (&optional all-p)
"Return a list of absolute file paths to activated modules. If ALL-P is