I'm reading through the definition of package-initialize
to try and understand what goes on under the hood, and part of what it does is to read the package archive files. I see it comparing version numbers, but I don't fully understand what it's doing at a high level.
I'm looking at this method:
(defun package-read-archive-contents (archive)
"Re-read archive contents for ARCHIVE.
If successful, set the variable `package-archive-contents'.
If the archive version is too new, signal an error."
;; Version 1 of 'archive-contents' is identical to our internal
;; representation.
(let* ((contents-file (format "archives/%s/archive-contents" archive))
(contents (package--read-archive-file contents-file)))
(when contents
(dolist (package contents)
(package--add-to-archive-contents package archive)))))
I think it's being used to make sure that the packages we're loading also have their descriptors added to the package archives (e.g. .emacs.d/elpa/melpa-stable/archive-contents
if they're not already in there. But I'm not clear on what these archive-contents
files are used for, since running a command like package-list-packages
communicates with the remote package archive.
I apologize if this question is a bit muddled, but I'm trying to push through the awkward early stage of learning emacs.
I should also probably mention that the reason I started investigating the internals of package-initialize
was to figure out if there's some kind of lazy-loading that I could be doing, rather than loading everything as soon as emacs starts up.