refactor(lib): doom-load

This commit is contained in:
Henrik Lissner 2024-09-01 13:04:54 -04:00
parent 8475d29f3c
commit d6db88162e
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -151,20 +151,17 @@ If NOERROR, don't throw an error if PATH doesn't exist."
(signal (car e) (cdr e)))
(error
(setq path (locate-file path load-path (get-load-suffixes)))
(signal (cond ((not (and path (featurep 'doom)))
'error)
((file-in-directory-p path (expand-file-name "cli" doom-core-dir))
'doom-cli-error)
((file-in-directory-p path doom-core-dir)
'doom-core-error)
((file-in-directory-p path doom-user-dir)
'doom-user-error)
((file-in-directory-p path doom-profile-dir)
'doom-profile-error)
((file-in-directory-p path doom-modules-dir)
'doom-module-error)
('doom-error))
(list path e)))))
(if (not (and path (featurep 'doom)))
(signal (car e) (cdr e))
(cl-loop for (err . dir)
in `((doom-cli-error . ,(expand-file-name "cli" doom-core-dir))
(doom-core-error . ,doom-core-dir)
(doom-user-error . ,doom-user-dir)
(doom-profile-error . ,doom-profile-dir)
(doom-module-error . ,doom-modules-dir))
if (file-in-directory-p path dir)
do (signal err (list (file-relative-name path (expand-file-name "../" dir))
e)))))))
(defun doom-require (feature &optional filename noerror)
"Like `require', but handles and enhances Doom errors.