Refactor package init process
quelpa is now initialized by doom-initialize-packages.
This commit is contained in:
parent
60e14d01ec
commit
b1bf67f630
2 changed files with 13 additions and 17 deletions
|
@ -5,6 +5,8 @@
|
|||
(require 'quelpa)
|
||||
(require 'async)
|
||||
|
||||
(doom-initialize-packages)
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-refresh-packages (&optional force-p)
|
||||
"Refresh ELPA packages."
|
||||
|
@ -33,9 +35,7 @@
|
|||
"Get which backend the package NAME was installed with. Can either be elpa or
|
||||
quelpa. Throws an error if NOERROR is nil and the package isn't installed."
|
||||
(cl-assert (symbolp name) t)
|
||||
(cond ((and (or (quelpa-setup-p)
|
||||
(error "Could not initialize quelpa"))
|
||||
(assq name quelpa-cache))
|
||||
(cond ((assq name quelpa-cache)
|
||||
'quelpa)
|
||||
((assq name package-alist)
|
||||
'elpa)
|
||||
|
@ -50,7 +50,6 @@ quelpa. Throws an error if NOERROR is nil and the package isn't installed."
|
|||
list, whose car is NAME, and cdr the current version list and latest version
|
||||
list of the package."
|
||||
(cl-assert (symbolp name) t)
|
||||
(doom-initialize-packages)
|
||||
(when-let* ((desc (cadr (assq name package-alist))))
|
||||
(let* ((old-version (package-desc-version desc))
|
||||
(new-version
|
||||
|
@ -76,15 +75,13 @@ list of the package."
|
|||
"Return PROPerty in NAME's plist."
|
||||
(cl-assert (symbolp name) t)
|
||||
(cl-assert (keywordp prop) t)
|
||||
(doom-initialize-packages)
|
||||
(plist-get (cdr (assq name doom-packages)) prop))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom-package-different-backend-p (name)
|
||||
"Return t if NAME (a package's symbol) has a new backend than what it was
|
||||
installed with. Returns nil otherwise, or if package isn't installed."
|
||||
"Return t if a package named NAME (a symbol) has a new backend than what it
|
||||
was installed with. Returns nil otherwise, or if package isn't installed."
|
||||
(cl-assert (symbolp name) t)
|
||||
(doom-initialize-packages)
|
||||
(and (package-installed-p name)
|
||||
(let* ((plist (cdr (assq name doom-packages)))
|
||||
(old-backend (doom-package-backend name 'noerror))
|
||||
|
@ -194,6 +191,7 @@ If INCLUDE-IGNORED-P is non-nil, includes missing packages that are ignored,
|
|||
i.e. they have an :ignore property.
|
||||
|
||||
Used by `doom//packages-install'."
|
||||
(doom-initialize-packages t)
|
||||
(cl-loop for desc in (doom-get-packages)
|
||||
for (name . plist) = desc
|
||||
if (and (or include-ignored-p
|
||||
|
@ -209,7 +207,6 @@ Used by `doom//packages-install'."
|
|||
"Update `quelpa-cache' upon a successful `package-delete'."
|
||||
(let ((name (package-desc-name desc)))
|
||||
(when (and (not (package-installed-p name))
|
||||
(quelpa-setup-p)
|
||||
(assq name quelpa-cache))
|
||||
(map-delete quelpa-cache name)
|
||||
(quelpa-save-cache)
|
||||
|
@ -284,8 +281,6 @@ package.el as appropriate."
|
|||
(desc (cadr (assq name package-alist))))
|
||||
(pcase (doom-package-backend name)
|
||||
('quelpa
|
||||
(or (quelpa-setup-p)
|
||||
(error "Failed to initialize quelpa"))
|
||||
(let ((quelpa-upgrade-p t))
|
||||
(quelpa (assq name quelpa-cache))))
|
||||
('elpa
|
||||
|
@ -307,8 +302,6 @@ package.el as appropriate."
|
|||
(user-error "%s isn't installed" name))
|
||||
(let ((inhibit-message (not doom-debug-mode))
|
||||
quelpa-p)
|
||||
(unless (quelpa-setup-p)
|
||||
(error "Could not initialize QUELPA"))
|
||||
(when (assq name quelpa-cache)
|
||||
(map-delete quelpa-cache name)
|
||||
(quelpa-save-cache)
|
||||
|
|
|
@ -181,9 +181,9 @@ it anyway."
|
|||
(quiet! (doom//reload-autoloads))))
|
||||
|
||||
(defun doom-initialize-packages (&optional force-p load-p)
|
||||
"Crawls across your emacs.d to fill `doom-modules' (from init.el) and
|
||||
`doom-packages' (from packages.el files), if they aren't set already. Also runs
|
||||
every enabled module's init.el.
|
||||
"Crawls across your emacs.d to fill `doom-modules' (from init.el),
|
||||
`doom-packages' (from packages.el files) and `quelpa-cache'. If they aren't set
|
||||
already. Also runs every enabled module's init.el.
|
||||
|
||||
If FORCE-P is non-nil, do it even if they are.
|
||||
|
||||
|
@ -212,7 +212,10 @@ This aggressively reloads core autoload files."
|
|||
(mapc #'_load (file-expand-wildcards (expand-file-name "autoload/*.el" doom-core-dir)))
|
||||
(_load (expand-file-name "init.el" doom-emacs-dir) nil 'interactive)))
|
||||
(when (or force-p (not doom-packages))
|
||||
(setq doom-packages nil)
|
||||
(require 'quelpa)
|
||||
(setq doom-packages nil
|
||||
quelpa-initialized-p nil)
|
||||
(quelpa-setup-p)
|
||||
(_load (expand-file-name "packages.el" doom-core-dir))
|
||||
(cl-loop for key being the hash-keys of doom-modules
|
||||
if (doom-module-path (car key) (cdr key) "packages.el")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue