Minor, general refactors to package API

This commit is contained in:
Henrik Lissner 2019-07-26 20:17:09 +02:00
parent 6fcaa80355
commit 1a72cf0677
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 14 additions and 19 deletions

View file

@ -129,23 +129,19 @@ was installed with."
(while (re-search-forward "(package! " nil t) (while (re-search-forward "(package! " nil t)
(save-excursion (save-excursion
(goto-char (match-beginning 0)) (goto-char (match-beginning 0))
(unless (string-match-p (unless (let ((ppss (syntax-ppss)))
"^.*;" (buffer-substring-no-properties (or (nth 3 ppss)
(line-beginning-position) (nth 4 ppss)))
(point))) (cl-destructuring-bind (name . plist)
(cl-destructuring-bind (name . plist) (cdr (sexp-at-point)) (cdr (sexp-at-point))
(push (cons name (push (cons
(plist-put plist :modules name (plist-put
(cond ((file-in-directory-p file doom-private-dir) plist :modules
'((:private))) (list (doom-module-from-path file))))
((file-in-directory-p file doom-core-dir)
'((:core)))
((doom-module-from-path file)))))
doom-packages))))))) doom-packages)))))))
((debug error) ((debug error)
(signal 'doom-package-error (signal 'doom-package-error
(list (or (doom-module-from-path file) (list (doom-module-from-path file)
'(:private . packages))
e)))))) e))))))
;;;###autoload ;;;###autoload
@ -161,9 +157,8 @@ ones."
doom-packages doom-packages
doom-disabled-packages) doom-disabled-packages)
(doom--read-module-packages-file (doom--read-module-packages-file
(expand-file-name "packages.el" doom-core-dir) (doom-path doom-core-dir "packages.el") all-p t)
all-p t) (let ((private-packages (doom-path doom-private-dir "packages.el")))
(let ((private-packages (expand-file-name "packages.el" doom-private-dir)))
(unless all-p (unless all-p
;; We load the private packages file twice to ensure disabled packages ;; We load the private packages file twice to ensure disabled packages
;; are seen ASAP, and a second time to ensure privately overridden ;; are seen ASAP, and a second time to ensure privately overridden
@ -173,7 +168,6 @@ ones."
(mapc #'doom--read-module-packages-file (mapc #'doom--read-module-packages-file
(doom-files-in doom-modules-dir (doom-files-in doom-modules-dir
:depth 2 :depth 2
:full t
:match "/packages\\.el$")) :match "/packages\\.el$"))
(cl-loop for key being the hash-keys of doom-modules (cl-loop for key being the hash-keys of doom-modules
for path = (doom-module-path (car key) (cdr key) "packages.el") for path = (doom-module-path (car key) (cdr key) "packages.el")

View file

@ -146,7 +146,8 @@ necessary package metadata is initialized and available for them."
(when noninteractive (when noninteractive
(add-hook 'kill-emacs-hook #'doom--finalize-straight)) (add-hook 'kill-emacs-hook #'doom--finalize-straight))
(dolist (package (straight--directory-files (straight--build-dir))) (dolist (package (straight--directory-files (straight--build-dir)))
(add-to-list 'load-path (directory-file-name (straight--build-dir package))))) (cl-pushnew (directory-file-name (straight--build-dir package))
load-path)))
(when (or force-p (not doom-packages)) (when (or force-p (not doom-packages))
(doom-log "Initializing doom-packages") (doom-log "Initializing doom-packages")
(setq doom-disabled-packages nil (setq doom-disabled-packages nil