What is the usefulness of setting

 '(auctex                 ;
   jedi                   ; 
   magit                  ;

Doesn't emacs set the user-installed packages in package-selected-packages? What would we be doing if we override this variable?

  • "This variable is used by package-autoremove to decide which packages are no longer needed. You can use it to (re)install packages on other machines by running package-install-selected-packages."
    – phils
    Jun 15, 2020 at 13:53
  • 1
    So what if I have other packages manually installed by setting setq outside that variable? How will they be affected? Jun 15, 2020 at 19:37
  • I don't understand the question, sorry. The quoted docstring tells you what that variable does, and I assume it will have those effects regardless of how it's set.
    – phils
    Jun 15, 2020 at 21:11
  • So the variable just stores packages that we always want to keep. Are these installed/updated everytime we start emacs? Jun 16, 2020 at 3:02
  • No. Is there some reason why you thought that might happen?
    – phils
    Jun 16, 2020 at 5:17

1 Answer 1


From the variable’s documentation:

Store here packages installed explicitly by user.

Whatever you explicitly install (e.g. with the package-install command, or with a package “manager” like use-package), gets into this variable.

This variable is fed automatically by Emacs when installing a new package.

So it happens automatically! In fact, it gets saved to your custom-file if set via customize (which package.el does for you).

Still from the documentation (also mentioned by @phils in a comment)

This variable is used by package-autoremove to decide which packages are no longer needed.

Whenever you issue the package-autoremove command it consults this variable. package-autoremove will remove everything that is

  • not marked as explicitly installed (ie. not in this list), and
  • not a dependency of an explicitly installed package.

The documentation also tells another use-case:

You can use it to (re)install packages on other machines by running package-install-selected-packages.

So simply populate this variable manually, and use that command to install your favourite packages on all your machines.

To have a better picture, go to the package manager using list-packages. You will see a bunch of

  • available packages; these are available in the configured repositories (see package-archives), but not installed on your system
  • installed packages; these are what you installed explicitly. This list is exactly the same as your package-selected-packages.
  • dependency packages; these are packages that are installed on your system, but that are not in package-selected-packages. Under normal circumstances these are installed as dependencies of other packages
  • built-in packages; these are shipped with your Emacs installation and always available. You can’t remove them.
  • obsolete packages; these are packages you have installed, but there is a newer version available
  • incompat packages are packages that can’t be installed on your system. The reason is always stated by describe-package, e.g. “because it depends on Emacs 27” or “because it depends on uninstallable packages”.

For (much) more info, see the emacs(Packages) info node.

  • Thanks, so clear and extensive. I primarily asked because, even if the packages I install get copied into that variable in custom.el, I have "setq package-selected-packages" in my other init file which is run the last when loading emacs. So any user could tailor this list in case we don't want all packages we have at the moment (normally I install many packages per day just to test and forget about them, so here the idea is that I should keep the ones relevant). Does this make sense? Jun 19, 2020 at 2:51
  • Actually, whatever works for you. ☺ I add packages i want to test to my config file with use-package, and if i donʼt need them, i remove them from the config. I never set package.el variables directly anywhere. Jun 19, 2020 at 15:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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