From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Corwin Brust Newsgroups: gmane.emacs.bugs Subject: bug#53885: Autoload package-installed-p Date: Wed, 9 Feb 2022 09:39:46 -0600 Message-ID: References: <87a6f0nly1.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000061b21205d797a57a" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40380"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Lars Ingebrigtsen , 53885@debbugs.gnu.org To: Augusto Stoffel Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Feb 09 17:13:21 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nHpar-000ALh-QX for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 09 Feb 2022 17:13:21 +0100 Original-Received: from localhost ([::1]:58274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nHpaq-0001MM-O9 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 09 Feb 2022 11:13:20 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:41020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nHp6c-000118-9Y for bug-gnu-emacs@gnu.org; Wed, 09 Feb 2022 10:42:06 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58464) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nHp5a-0001Nq-5X for bug-gnu-emacs@gnu.org; Wed, 09 Feb 2022 10:42:05 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nHp5Z-0005E7-T5 for bug-gnu-emacs@gnu.org; Wed, 09 Feb 2022 10:41:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Corwin Brust Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 09 Feb 2022 15:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53885 X-GNU-PR-Package: emacs Original-Received: via spool by 53885-submit@debbugs.gnu.org id=B53885.164442120819979 (code B ref 53885); Wed, 09 Feb 2022 15:41:01 +0000 Original-Received: (at 53885) by debbugs.gnu.org; 9 Feb 2022 15:40:08 +0000 Original-Received: from localhost ([127.0.0.1]:52356 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHp4h-0005CB-WE for submit@debbugs.gnu.org; Wed, 09 Feb 2022 10:40:08 -0500 Original-Received: from mail-ej1-f47.google.com ([209.85.218.47]:36361) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nHp4e-0005BW-AO for 53885@debbugs.gnu.org; Wed, 09 Feb 2022 10:40:06 -0500 Original-Received: by mail-ej1-f47.google.com with SMTP id u20so4182563ejx.3 for <53885@debbugs.gnu.org>; Wed, 09 Feb 2022 07:40:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LAG7BSfrbM7sn9DLYfNiifl3E0L108U7+Dsa8cByEtE=; b=3sOvxpq9iyKpfGzzon8V5JJAQ7QlHRFAnVrCdsu2UdVB2o+r4j8re9bsNodKEbr8tD H0tzfeAsy3P7iKhjmLRceFImLn3VGHPtpVdHACEoVPLR/Bv0XP0UN7X2tQ6r/6IePimT /KnsmfxnerUbxqbF5tKI+WBOri1i4y8OIMPToBU6BZXBAbwvMrcEcOIfrTwgmMMOxCxp hnRSxV5a8jCDBvSGil0M6l7Zf1G8HN/FrTl3aoIVfRoPYqLOrp/A2gnuxbdrRVeeBxw3 asowVZTZpKjxNEYyITJqnqIt/rnMuosVWahtBUbTmE6eSlHL1NB4C/L4lN0PKs6q8kCk mqGg== X-Gm-Message-State: AOAM533wJB7kUyeZJ+ePFCyopuejIkz8qB6ZxSUB34LrjKvMT58goCB4 igiq0PFAf8ntaKJGpYs+zn/hVp7cRFJEc5AC/UY= X-Google-Smtp-Source: ABdhPJyv2hvueDazkU/FYpFRvyQfOObTE/1CzBabJn5S0RsDJT6NrG2067GdRMVQPDyXa+kbVhkX09ELWrWgj2Rwpws= X-Received: by 2002:a17:907:7292:: with SMTP id dt18mr2348821ejc.667.1644421198228; Wed, 09 Feb 2022 07:39:58 -0800 (PST) In-Reply-To: <87a6f0nly1.fsf@gmail.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:226487 Archived-At: --00000000000061b21205d797a57a Content-Type: text/plain; charset="UTF-8" Hi Augusto! On Wed, Feb 9, 2022, 08:39 Augusto Stoffel 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 > 'use-package' would be subject to removal by 'package-autoremove'. To > fix this, something like > > (add-hook 'after-init-hook > (lambda () (package--update-selected-packages '(use-package) > nil))) > > is needed. > I wasn't aware of this idiosyncrasy. I will look at package.el further FTR, in my own configuration I expressly set-up package-selected-packages. In any case, this bug report stems from a Reddit user's perception of breakage with the Emacs 28 pre-release binaries recently added to alpha. I simply created a minimal reproducer from that person's use/expectations. Do you agree the (corrected) reproducer given should be sufficient to demonstrate the change provided by adding the autoload, if the patch is applied? As things stand presently, I'm having trouble thinking of use-cases for package-installed-p that would not start with (require 'package). > I think a more user-friendly 'package-ensure-installed' function is in > order here. I believe the use-package package provides some > functionality for this, but there is no good built-in equivalent (which > is needed even by use-package users). > I love this idea. Would you be interested to open a new bug report for this feature request, perhaps offering a patch if you are so inclined? FWIW, I agree that ,if/when something more robust is added expressly to support the batch installation of packages, the need for this autoload (and perhaps all user-facing use-cases for package-installed-p) may be greatly reduced. That said, it's not clear to me whether general consensus will be to support a "default automation" function (or functions) for this, or that what we have is "enough" for each of us to do things as we wish. It might make sense to open a discussion on the development list to discuss this potential improvement. Finally, in case it may help, here is a formula I have often used to 'bootstrap' a batch install of packages: (setq package-selected-packages '(foo bar baz)) (mapc (lambda(pkg) (when (not (require pkg nil t) (package-install pkg)) package-selected-packages) For myself, I'm not using `package-autoremove'. I typically remove (actually rename, usually) my ELPA folder and then relaunch Emacs. My configuration (just like the user on behalf of whom I reported this "bug"), will then install the features I'm (still) using. I'm glad you are watching out for people who do use the auto-remove package feature. Regards, Corwin --00000000000061b21205d797a57a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Augusto!

On Wed, Feb 9, 2022, 08:39= Augusto Stoffel <arstoffel@gmail.com> wrote:

By the way, there are two issues with this code snippet.=C2=A0 First, you should call '(package-refresh-contents)' to make sure you have the<= br> package list from MELPA.

=
I believe this was changed with the implementation = of "early-init".=C2=A0 We don't need to expressly call `packa= ge-refresh-contents' since Emacs 27, see:
https://github.com/ema= cs-mirror/emacs/blob/master/etc/NEWS.27#L227



'use-package' would be subject to removal by 'package-autoremov= e'.=C2=A0 To
fix this, something like

=C2=A0 =C2=A0 (add-hook 'after-init-hook
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (lambda () (package--updat= e-selected-packages '(use-package) nil)))

is needed.

I wasn't aware of this idiosyncrasy. I will look at package.e= l further=C2=A0 FTR, in my own configuration I expressly set-up package-sel= ected-packages.

In any c= ase, this bug report stems from a Reddit user's perception of breakage = with the Emacs 28 pre-release binaries recently added to alpha.=C2=A0 I sim= ply created a minimal reproducer from that person's use/expectations.

Do you agree the (corrected) reproduce= r given should be sufficient to demonstrate the change provided by adding t= he autoload, if the patch is applied?

As things st= and presently, I'm having trouble thinking of use-cases for package-ins= talled-p that would not start with (require 'package).


I think a more user-friendly 'package-ensure-installed' function is= in
order here.=C2=A0 I believe the use-package package provides some
functionality for this, but there is no good built-in equivalent (which
is needed even by use-package users).

I= love this idea.=C2=A0 Would you be interested to open a new bug report for= this feature request, perhaps offering a patch if you are so inclined?=C2= =A0=C2=A0

FWIW, I agree that ,if/when something mo= re robust is added expressly to support the batch installation of packages,= the need for this autoload (and perhaps all user-facing use-cases for pack= age-installed-p) may be greatly reduced.=C2=A0=C2=A0

That said, it's not clear to me whether general consensus will be to= support a "default automation" function (or functions) for this,= or that what we have is "enough" for each of us to do things as = we wish.=C2=A0 It might make sense to open a discussion on the development = list to discuss this potential improvement.

Finall= y, in case it may help, here is a formula I have often used to 'bootstr= ap' a batch install of packages:

(setq package-select= ed-packages '(foo bar baz))
(mapc (lambda(pkg) (when (not (re= quire pkg nil t) (package-install pkg)) package-selected-packages)

For myself, I'm not using `package-autoremove'.=C2= =A0 I typically remove (actually rename, usually) my ELPA folder and then r= elaunch Emacs.=C2=A0 My configuration (just like the user on behalf of whom= I reported this "bug"), will then install the features I'm (= still) using. I'm glad you are watching out for people who do use the a= uto-remove package feature.

Regards,
Corwin
--00000000000061b21205d797a57a--