feat: add doom-module-locate-paths function

This is a common idiom within Doom's internals, to create a list
of (existing) module files in any desired order.
This commit is contained in:
Henrik Lissner 2022-09-23 17:59:57 +02:00
parent e9ef904eee
commit fef7c27bbc
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -189,6 +189,16 @@ returns nil, otherwise an absolute path."
if (file-exists-p path) if (file-exists-p path)
return (expand-file-name path))))))) return (expand-file-name path)))))))
(defun doom-module-locate-paths (module-list file)
"Return all existing paths to FILE under each module in MODULE-LIST.
MODULE-LIST is a list of cons cells (GROUP . NAME). See `doom-module-list' for
an example."
(cl-loop with file = (file-name-sans-extension file)
for (group . name) in module-list
if (doom-module-locate-path group name file)
collect it))
(defun doom-module-from-path (path &optional 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."