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#65475: 29.1; package-selected-packages variable is not updated when the last package is deleted Date: Wed, 13 Sep 2023 10:01:15 +0000 Message-ID: <8734ziv1ck.fsf@posteo.net> References: <61352d45-21a6-466b-be7b-7755a6260356@gmail.com> <83a5uemfxy.fsf@gnu.org> <87o7iutg4i.fsf@posteo.net> <4604c3e3-8a6a-41b0-bf4d-9c087f151961@gmail.com> <87h6o8eec3.fsf@posteo.net> <87fs3mxmtp.fsf@posteo.net> 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="26944"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Andrey Samsonov , Eli Zaretskii , Eshel Yaron , Stefan Kangas , 65475@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Sep 13 13:51:26 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 1qgOOz-0006lS-2P for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 13 Sep 2023 13:51:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qgOOj-0004mM-TD; Wed, 13 Sep 2023 07:51:10 -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 1qgOOZ-0004SK-1P for bug-gnu-emacs@gnu.org; Wed, 13 Sep 2023 07:51:00 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qgOOX-0004ND-I9 for bug-gnu-emacs@gnu.org; Wed, 13 Sep 2023 07:50:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qgOOc-0005g5-NL for bug-gnu-emacs@gnu.org; Wed, 13 Sep 2023 07:51: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: Wed, 13 Sep 2023 11:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65475 X-GNU-PR-Package: emacs Original-Received: via spool by 65475-submit@debbugs.gnu.org id=B65475.169460580921754 (code B ref 65475); Wed, 13 Sep 2023 11:51:02 +0000 Original-Received: (at 65475) by debbugs.gnu.org; 13 Sep 2023 11:50:09 +0000 Original-Received: from localhost ([127.0.0.1]:60984 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgONl-0005eo-0p for submit@debbugs.gnu.org; Wed, 13 Sep 2023 07:50:09 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:57611) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgONh-0005dy-3K for 65475@debbugs.gnu.org; Wed, 13 Sep 2023 07:50:05 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 4076C240104 for <65475@debbugs.gnu.org>; Wed, 13 Sep 2023 13:49:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1694605794; bh=pN7fFkyR+4zGagBemLGUSjRthjsqWfMOwsVgd2dPZFQ=; h=From:To:Cc:Subject:Date:Message-ID:Autocrypt:MIME-Version:From; b=nzEYb0D65oQLy4Cfmn77jMVXPDIJaFYRDltyUtcvcgHKOjop92YmXIfte8Q6R9Wmx gZbLMRR0fQHKTuBojTiu8W4u227StUXboT0GIzrDIRI+YKXIabwHNyWBP8P66gkkhF vhdUH1kO1V1HJJ7+nMSjQUHEYhP7Y+i6nKBFcogogGDvw+U4E7QzimeF29M+MGINJi wPlb7PqZ7bW6IbCjU5A0ZFW8ads51Js2aoXSaRcopJ2xxgiwDh9M8dw44TD6UWG6u0 +33gNEi+89BhL4RBBiZvPE+Vy8HGYJ/DIMKhWCjhg87T8sXWjEmuX1k1lrwiEH8h8S I1zr4lAEfwK1Q== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4RlzJx0tTrz6tvr; Wed, 13 Sep 2023 13:49:53 +0200 (CEST) In-Reply-To: (Stefan Monnier's message of "Sun, 10 Sep 2023 22:42:38 -0400") 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:270262 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: >> + (let ((package-alist ;see bug#65475 >> (let ((pkgs (assq name package-alist))) > [...] >> + (set-default-toplevel-value 'package-alist package-alist) > [...] > > Eww!! > > If we really can't find a better option, we need to add a bunch of > comments explaining why we ended up with such a hack. It seems that it is only necessary to bind `package-alist' during the invocation of `package--used-elsewhere-p', so this is a more conservative proposal: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Handle-edge-case-when-deleting-the-last-package.patch >From a8959f1b245540a2d0d158621dedf244ac133849 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Wed, 13 Sep 2023 11:58:22 +0200 Subject: [PATCH] ; Handle edge-case when deleting the last package * lisp/emacs-lisp/package.el (package-delete): Rebind 'package-alist' while calling 'package--used-elsewhere-p'. (bug#65475) --- lisp/emacs-lisp/package.el | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 3a019905960..02691ff7aa5 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -2521,8 +2521,12 @@ package-delete nil t))) (list (cdr (assoc package-name package-table)) current-prefix-arg nil)))) - (let ((dir (package-desc-dir pkg-desc)) - (name (package-desc-name pkg-desc)) + (let* ((dir (package-desc-dir pkg-desc)) + (name (package-desc-name pkg-desc)) + (new-package-alist (let ((pkgs (assq name package-alist))) + (if (null (remove pkg-desc (cdr pkgs))) + (remq pkgs package-alist) + package-alist))) pkg-used-elsewhere-by) ;; If the user is trying to delete this package, they definitely ;; don't want it marked as selected, so we remove it from @@ -2541,7 +2545,8 @@ package-delete (package-desc-full-name pkg-desc))) ((and (null force) (setq pkg-used-elsewhere-by - (package--used-elsewhere-p pkg-desc))) + (let ((package-alist new-package-alist)) + (package--used-elsewhere-p pkg-desc)))) ;See bug#65475 ;; Don't delete packages used as dependency elsewhere. (error "Package `%s' is used by `%s' as dependency, not deleting" (package-desc-full-name pkg-desc) @@ -2562,10 +2567,7 @@ package-delete (when (file-exists-p file) (delete-file file)))) ;; Update package-alist. - (let ((pkgs (assq name package-alist))) - (delete pkg-desc pkgs) - (unless (cdr pkgs) - (setq package-alist (delq pkgs package-alist)))) + (setq package-alist new-package-alist) (package--quickstart-maybe-refresh) (message "Package `%s' deleted." (package-desc-full-name pkg-desc)))))) -- 2.39.2 --=-=-=--