purcell / emacs.d

An Emacs configuration bundle with batteries included
BSD 2-Clause "Simplified" License
6.84k stars 2.05k forks source link

Builtins, multiple versions, and new installs #771

Closed warmenhoven closed 3 years ago

warmenhoven commented 3 years ago

Trying to (require-package 'project '(0 5 3)) doesn't work, because 'project is builtin, and even though the version isn't sufficient, (package-install 'project) will just choose the builtin. The package-desc needs to be passed in. Along with that, I try to select the highest version.

The return value from (package-install package) is sometimes nil if the package was not previously downloaded, so I've changed the return value of (require-package) to be whether the package is actually installed. (I tested this by rm -rf the package-user-dir and then starting up emacs.)

warmenhoven commented 3 years ago

I'm not sure my comment above was entirely clear. As an example, in init-selectrum.el, there is the form (when (maybe-require-package 'selectrum). maybe-require-package returns the value of require-package, and if the package is not already installed, returns the value of package-install, which sometimes return nil if the package is not already downloaded, even if the install is later successful.

purcell commented 3 years ago

Thanks for tracking this down.

I committed a slightly more concise version of this in https://github.com/purcell/emacs.d/commit/18816a9ffbc4b607d9b2409fa6775996573b3c76, which I believe is equivalent, but please correct me if I'm mistaken.

warmenhoven commented 3 years ago

I like yours better. Thanks!