0

I have found the following lisp code in an init.el file. I am wondering if this code logic is correct. I am learning Elisp and have reviewed the documentation and searched Stack Overflow. If this is too basic a question to ask, please direct me to a source:

(when (not package-archive-contents)
  (package-refresh-contents))

My understanding is that logic says that if there is no package-archive file, then refresh the cache .

Following are my questions:

  1. Does Emacs download a cache for each of the sources in the package-archive list?
  2. If package-refresh-contents is called only if the cache is absent, how do we (Emacs) keep the archive current? Do we have to manually use M-x package-refresh-contents?
0

package-archive-content is used by use-package . it is the utility for installing packages. The snippet that you are quoting indeed refreshes the content or the list-packages in case it is empty.

It isn't a cache, it is only a list.

To update the list you need to manually call M-x list-packages and update it with U.

This update process might take a while therefore it shouldn't really be part of the init file for every time you fire up Emacs.

  • <f1> v package-archive-contents RET: "Cache of the contents of the Emacs Lisp Package Archive.[...]". To some extent, this is just a question of semantics of course, what exactly do you mean when you say "cache". – npostavs Jun 17 '18 at 13:49
  • @npostavs I meant if Emacs will download a copy of the Emacs Lisp Archive. It looks from your response that is what it does. – Vinod Jun 18 '18 at 3:47
  • Ah, I think the confusion here is that this variable is a cache of the package list (i.e., it is indeed "only a list" and also a cache). – npostavs Jun 18 '18 at 12:17
  • I.e. it is the "contents" in the sense of a "table of contents" at the beginning of a book. It's the list of what is available, rather than "the whole book". – phils Dec 14 '18 at 23:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.