Thank you for your post — I have already replaced `use-package`
in my config with `with-package`. I was not using many features
of the former to begin with, but just as a clean sort of wrapper
for setting up packages. `with-package` seems to suit my needs
nicely.
I am seeing one issue so far, and was wondering if you had any
thoughts on the matter. I used `with-package` to set up a package
I wanted to just try out. I later deleted the package with
`package-delete`, but its name still remains in
`package-selected-packages`.
In hindsight, I should have simply installed this package
manually if I were merely testing it, but what if later on down
the line I decide I no longer need some other package I had
declared in my config? Is there a way to tidily and
programmatically remove said package from
`package-selected-packages` that could tie in with my use of
`with-package`?
The only alternative I have thought of so far was to replace the
use of `package-selected-packages` with running a check whether a
package was installed using `(unless package-installed-p)`, then
installing it (or not). Which is too bad, because I like being
asked for my consent to install packages upon a fresh init.
Hi Brendan,
Thanks for reading the post and for leaving a response!
I was in the same boat, using very few features of ‘use-package’ before
replacing it with something much simpler. I’m happy to see someone else
has found it useful too. Do you have a dotfiles repo you would like to
share?
I think I understand what you’re getting at. So you’ve done
(with-package 'foo ...)
followed by M-x package-install-selected-packages. Then you did M-x
package-delete foo but ‘foo’ remains in ‘package-selected-packages’?
I just tried this on my system and found that ‘foo’ was removed from
‘package-selected-packages’ automatically after using M-x
package-delete, so maybe our Emacs are behaving differently. (I’m on
version 28.0.50.)
In any case, ‘package-selected-packages’ stores the names of packages
explicitly installed by the user, not necessarily those which are
actually present and installed at this moment, so I believe it is doing
its job correctly. You could manually remove ‘foo’ from the list; or
delete all occurences of (with-package 'foo ...) from your init file
before restarting Emacs. That way, it won’t be re-installed again
through M-x package-install-selected-packages.
Does that make any sense? Let me know if I’ve misunderstood your
question.
Greg.
Hi Gregory,
Your explanation makes sense, and I am now seeing the same
behavior you're describing—a deleted package is automatically
removed from `package-selected-packages`. I may have been doing
something silly, and have since wiped my packages and restarted
my Emacs session along with reinstalling all the packages I
specified with `with-package`. Sorry for the false alarm, but
your answer was helpful in furthering my understanding :)
-Brendan
On Fri, Apr 9, 2021, at 10:48 PM, Gregory Chamberlain wrote:
> Hi Brendan,> > Thanks for reading the post and for leaving a response!> > I was in the same boat, using very few features of ‘use-package’ before> replacing it with something much simpler. I’m happy to see someone else> has found it useful too. Do you have a dotfiles repo you would like to> share?> > I think I understand what you’re getting at. So you’ve done> > (with-package 'foo ...)> > followed by M-x package-install-selected-packages. Then you did M-x> package-delete foo but ‘foo’ remains in ‘package-selected-packages’?> > I just tried this on my system and found that ‘foo’ was removed from> ‘package-selected-packages’ automatically after using M-x> package-delete, so maybe our Emacs are behaving differently. (I’m on> version 28.0.50.)> > In any case, ‘package-selected-packages’ stores the names of packages> explicitly installed by the user, not necessarily those which are> actually present and installed at this moment, so I believe it is doing> its job correctly. You could manually remove ‘foo’ from the list; or> delete all occurences of (with-package 'foo ...) from your init file> before restarting Emacs. That way, it won’t be re-installed again> through M-x package-install-selected-packages.> > Does that make any sense? Let me know if I’ve misunderstood your> question.> > Greg.>