From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#62720: 29.0.60; Not easy at all to upgrade :core packages like Eglot Date: Thu, 13 Apr 2023 07:38:28 +0000 Message-ID: <87leiwdyff.fsf@posteo.net> References: <87a5zj2vfo.fsf@gmail.com> <83pm898xb9.fsf@gnu.org> <87h6tlleg0.fsf@gmail.com> <8335558qc7.fsf@gnu.org> <83sfd5761f.fsf@gnu.org> <87zg7djrgr.fsf@gmail.com> <83o7nt73za.fsf@gnu.org> <83mt3d73c2.fsf@gnu.org> <87r0sptinq.fsf@posteo.net> <83jzyh706c.fsf@gnu.org> <875ya1tdwf.fsf@posteo.net> <83edop6sdy.fsf@gnu.org> <831qkp6o0i.fsf@gnu.org> <83wn2h5825.fsf@gnu.org> <87wn2gkhzr.fsf@posteo.net> <83cz485oxi.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10499"; mail-complaints-to="usenet@ciao.gmane.io" Cc: larsi@gnus.org, 62720@debbugs.gnu.org, joaotavora@gmail.com, monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Apr 13 09:39:21 2023 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 1pmrY9-0002Yr-Ac for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 13 Apr 2023 09:39:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pmrXs-0004vt-Nz; Thu, 13 Apr 2023 03:39:04 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pmrXq-0004va-SC for bug-gnu-emacs@gnu.org; Thu, 13 Apr 2023 03:39:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pmrXq-00045v-K2 for bug-gnu-emacs@gnu.org; Thu, 13 Apr 2023 03:39:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pmrXq-0004vb-43 for bug-gnu-emacs@gnu.org; Thu, 13 Apr 2023 03:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 13 Apr 2023 07:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62720 X-GNU-PR-Package: emacs Original-Received: via spool by 62720-submit@debbugs.gnu.org id=B62720.168137149318883 (code B ref 62720); Thu, 13 Apr 2023 07:39:02 +0000 Original-Received: (at 62720) by debbugs.gnu.org; 13 Apr 2023 07:38:13 +0000 Original-Received: from localhost ([127.0.0.1]:42456 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pmrX2-0004uV-Ta for submit@debbugs.gnu.org; Thu, 13 Apr 2023 03:38:13 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]:59575) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pmrWz-0004uG-Ku for 62720@debbugs.gnu.org; Thu, 13 Apr 2023 03:38:11 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id BE2232400D0 for <62720@debbugs.gnu.org>; Thu, 13 Apr 2023 09:38:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1681371482; bh=4lQ/WtmbS0jnXrsEcJCMle/YUc2uCqZhqNCvg7aSDvA=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=Q2Y7rnui/gjq4OdukyZa2z0EkrVg81B0i34MUuO7fhjJpARtDB4+0l2RAoxFr1agl SILUOVAWjn1Tsge9a2QzYPKqAx26YLskMv68rsGBaBB3VByeipxh4nSpuGM4uiXn5y k06F1w0ERJBGTAOZz6M1Gcae+tY3NLwKrJH4hs1+HNfbE2PaecvE32PesJlPIe2hdb 45Lwiwsi+jncluZ9yyNUHdbS7NhPokmai6qbDv/RlcobDGc4cqf0f3f+sPClRfXbws gua40PO0jt3lHeTqeSlVr0expPoPID1qBXG7dSZ5cvXimnVFMhlclDFbqvImpdzCFQ Jv3MxCLfkzUIQ== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Pxryv4wlHz9rxD; Thu, 13 Apr 2023 09:37:59 +0200 (CEST) In-Reply-To: <83cz485oxi.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 13 Apr 2023 08:30:49 +0300") Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:259839 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Eli Zaretskii writes: >> From: Philip Kaludercic >> Cc: Jo=C3=A3o T=C3=A1vora , >> monnier@iro.umontreal.ca, >> 62720@debbugs.gnu.org, larsi@gnus.org >> Date: Wed, 12 Apr 2023 19:39:20 +0000 >>=20 >> >> Please, in normal non-shouting case, explain to me how you think >> >> that the behavior of an existing >> >> command can be changed with "completely separate code".=20 >> > >> > I already did: either (1) add a prefix argument to an existing >> > command, which will then trigger the new behavior, or (2) add a >> > separate command. >>=20 >> Here you have (1): > > Thanks. This is almost on-target, but it modifies > package-compute-transaction. Is that necessary? I have found an alternative that doesn't change the way `package-compute-transaction' works, but requires a small change in `package-install': --=-=-= Content-Type: text/plain Content-Disposition: inline diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index f92afe56b76..461e92f27d8 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -797,6 +797,17 @@ package-built-in-p (require 'finder-inf nil t) ; For `package--builtins'. (assq package package--builtins)))))) +(defun package--upgradable-built-in-p (package) + "Return non-nil if PACKAGE if the built-in version is used." + (and (not (assq (cond + ((package-desc-p package) + (package-desc-name package)) + ((stringp package) (intern package)) + ((symbolp package) package) + ((error "Unknown package format: %S" package))) + (package--alist))) + (package-built-in-p package))) + (defun package--autoloads-file-name (pkg-desc) "Return the absolute name of the autoloads file, sans extension. PKG-DESC is a `package-desc' object." @@ -2187,7 +2198,9 @@ package-install "Install the package PKG. PKG can be a `package-desc' or a symbol naming one of the available packages in an archive in `package-archives'. When -called interactively, prompt for the package name. +called interactively, prompt for the package name. When invoked +with a prefix argument, the prompt will include built-in packages +that can be upgraded via an archive. Mark the installed package as selected by adding it to `package-selected-packages'. @@ -2205,11 +2218,13 @@ package-install (package--archives-initialize) (list (intern (completing-read "Install package: " - (delq nil - (mapcar (lambda (elt) - (unless (package-installed-p (car elt)) - (symbol-name (car elt)))) - package-archive-contents)) + (mapcan + (lambda (elt) + (and (or (and current-prefix-arg + (package--upgradable-built-in-p (car elt))) + (not (package-installed-p (car elt)))) + (list (car elt)))) + package-archive-contents) nil t)) nil))) (package--archives-initialize) @@ -2221,11 +2236,16 @@ package-install (package--save-selected-packages (cons name package-selected-packages))) (if-let* ((transaction - (if (package-desc-p pkg) - (unless (package-installed-p pkg) - (package-compute-transaction (list pkg) - (package-desc-reqs pkg))) - (package-compute-transaction () (list (list pkg)))))) + (cond + ((package--upgradable-built-in-p pkg) + (let ((desc (cadr (assq name package-archive-contents)))) + (package-compute-transaction + (list desc) (package-desc-reqs desc)))) + ((package-desc-p pkg) + (and (not (package-installed-p pkg)) + (package-compute-transaction + (list pkg) (package-desc-reqs pkg)))) + ((package-compute-transaction () (list (list pkg))))))) (progn (package-download-transaction transaction) (package--quickstart-maybe-refresh) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable The idea here is that if we detect that a package is built-in, we "pre-compute" part of the transaction and resolve the rest. This does not install any unnecessary dependencies. When `package-install' is invoked interactively without a prefix argument, the "new" code cannot run, since none of the completion candidates satisfy `package--upgradable-built-in-p' (or whatever we end up calling the predicate). Note that (package-install 'eglot) does download code, but I believe that this is the correct approach and would align with what Jo=C3=A3o wanted. >> +(defun package--upgradable-built-in-p (package) >> + "Check if a built-in PACKAGE can be upgraded. >> +This command differs from `package-built-in-p' in that it only > ^^^^^^^^^^^^ > This is not a command, this is a function. I will address these issues as soon as we have working code. > Also, the name has a problem I pointed out earlier in this discussion: > "upgradeable" does not tell well enough what the function tests. > >> @@ -2187,7 +2210,9 @@ package-install >> "Install the package PKG. >> PKG can be a `package-desc' or a symbol naming one of the >> available packages in an archive in `package-archives'. When >> -called interactively, prompt for the package name. >> +called interactively, prompt for the package name. When invoked >> +with a prefix argument, the prompt will include built-in packages >> +that can be upgraded via an archive. > > I wonder whether an invocation with the prefix argument should include > _only_ built-in packages in the prompt? This could be a useful > feature regardless, and so would allow us to keep this option for > future uses. > > Finally, there's still discussion going on whether built-in packages > should be handled only by package-update, not by package-install, > since built-in packages are always "installed". WDYT? --=-=-=--