Subject: Re: bug#53885: Autoload package-installed-p

From: Corwin Brust <[email-masked]>
Date: Thu, 10 Feb 2022 03:23:19 -0600

On Thu, Feb 10, 2022 at 3:06 AM Augusto Stoffel <[email-masked]> wrote:
>
> On Wed,  9 Feb 2022 at 09:39, Corwin Brust <[email-masked]> wrote:
>
> > On Wed, Feb 9, 2022, 08:39 Augusto Stoffel <[email-masked]> wrote:
> >
> >  By the way, there are two issues with this code snippet.  First, you
> >  should call '(package-refresh-contents)' to make sure you have the
> >  package list from MELPA.
> >
> > I believe this was changed with the implementation of "early-init".  We don't need to expressly call
> > `package-refresh-contents' since Emacs 27, see:
> > https://github.com/emacs-mirror/emacs/blob/master/etc/NEWS.27#L227
>
> This is a different matter.  What I was saying is, you need to download
> the package list from MELPA before trying to install a missing package.

This is taken care of by a call to package-installed-p in the case
where it does not receive a package description as the first argument
and when no min-version is passed, as in my "reproducer".  Or maybe I
still don't understand.

> If you delete ~/.emacs.d/elpa, your configuration as you showed it won't
> be able to bootstrap.

I don't think I called for deleting anything; I just set-up a
non-standard place for the installation of packages.  But I suspect
I'm missing your point.

>
> Autoloading 'package-installed-p' wouldn't cause any harm, but it also
> doesn't solve any problems, so why bother?

Here I don't agree.  Consider:

(when (not (package-installed-p 'foo))
  (package-install-package 'foo))

This seems to DTRT; the package does get installed whereas in the
present world a backtrace is triggered unless we first take care to
load package.el.