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: Sat, 26 Aug 2023 07:30:37 +0000 Message-ID: <87o7iutg4i.fsf@posteo.net> References: <61352d45-21a6-466b-be7b-7755a6260356@gmail.com> <83a5uemfxy.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="28463"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Andrey Samsonov , Stefan Monnier , 65475@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 26 09:31:25 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 1qZnlV-0007Dw-2f for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 26 Aug 2023 09:31:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZnlE-00072a-8J; Sat, 26 Aug 2023 03:31:08 -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 1qZnl3-00070h-HG for bug-gnu-emacs@gnu.org; Sat, 26 Aug 2023 03:31:01 -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 1qZnl3-0008Bl-8f for bug-gnu-emacs@gnu.org; Sat, 26 Aug 2023 03:30:57 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qZnl8-0003Ch-8I for bug-gnu-emacs@gnu.org; Sat, 26 Aug 2023 03:31: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: Sat, 26 Aug 2023 07:31: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.169303505812306 (code B ref 65475); Sat, 26 Aug 2023 07:31:02 +0000 Original-Received: (at 65475) by debbugs.gnu.org; 26 Aug 2023 07:30:58 +0000 Original-Received: from localhost ([127.0.0.1]:41650 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZnl3-0003CP-UU for submit@debbugs.gnu.org; Sat, 26 Aug 2023 03:30:58 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:43067) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZnl0-0003C8-AO for 65475@debbugs.gnu.org; Sat, 26 Aug 2023 03:30:56 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id A07AE240106 for <65475@debbugs.gnu.org>; Sat, 26 Aug 2023 09:30:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1693035043; bh=gH8GF52s4L7TDDDT23fAUZ7LLHMiW4/fwJ7uR5PsWrU=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=Vg1v7DlcJKz+oJcaMeeL9fjT2PR//NgXnreHpM42y/RI1HX4MkhtQOfCeDTYXCZYJ kydOphR965kkqJX57hQuXxyRQQFftc0oItQp3t49QgXnPC3wkyKDKkhtpOsXNtt2iF XPuUCTVvF2bFxx5DluMBudSDJbVnSNOBsEKVOR5IC2abzqa5Sxkar9/s/CnyAF37s9 U3yHSAom8FzUJ2bikT9KwhMo5WRxZO6YHPB1X8KgS7gabG0GpOjUNqo0KeMbexWi6g Hh/j/BF5+C3mocjIKW86uec1RNzgr7GoY5TWITFZ6Ke0VDMGSie4NFKP9BDqo5E5PQ CCB8uCeifxGIA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4RXpQ55zYCz9s4S; Sat, 26 Aug 2023 09:30:37 +0200 (CEST) In-Reply-To: <83a5uemfxy.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 26 Aug 2023 10:16:25 +0300") X-Hashcash: 1:20:230826:samsonov.box@gmail.com::P4dELq0l+n/HYrzw:nK7 X-Hashcash: 1:20:230826:eliz@gnu.org::Te5uDo2ctJk3CnRt:0tz0 X-Hashcash: 1:20:230826:monnier@iro.umontreal.ca::FMu0TSMij6aobGwh:6Vsm X-Hashcash: 1:20:230826:65475@debbugs.gnu.org::/BSsx7/TOsTlbP6g:6qpC 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:268477 Archived-At: --=-=-= Content-Type: text/plain Eli Zaretskii writes: >> Date: Wed, 23 Aug 2023 18:02:14 +0600 >> From: Andrey Samsonov >> >> Steps to reproduce: >> >> 1. Start 'emacs -Q --init-directory ', where is directory >> with only zero-sized 'init.el' file >> 2. M-x package-install RET mines RET >> 3. M-x package-install RET chess RET >> 4. C-h v package-selected-packages RET: Its value is (chess mines) >> 5. M-x package-delete RET mines RET >> 6. C-h v package-selected-packages RET: Its value is (chess) >> 7. M-x package-delete RET chess RET >> >> Actual behavior: >> >> 8. C-h v package-selected-packages RET: Its value is (chess) >> >> Expected behavior: >> >> 8. C-h v package-selected-packages RET: Its value is nil > > Philip, Stefan: any comments? The issue here is that `package--save-selected-packages' only updates the value of `package-selected-packages', if the new value is non-nil, presumably because the VALUE argument is optional, and it should be possible to invoke the function without any new value, just wishing to save the current one to disk (in fact this behaviour is required for the `after-init-hook'-trick to work). But if 'chess is removed from '(chess), the value is nil, hence nothing happens. One could imagine allowing a special value like 'empty to resolve the issue: --=-=-= Content-Type: text/plain Content-Disposition: inline diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index e1172d69bf0..6d0ad274795 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -1982,8 +1982,11 @@ package--find-non-dependencies (defun package--save-selected-packages (&optional value) "Set and save `package-selected-packages' to VALUE." - (when value - (setq package-selected-packages value)) + (cond + ((eq value 'empty) + (setq package-selected-packages nil)) + ((not (null package-selected-packages)) + (setq package-selected-packages value))) (if after-init-time (customize-save-variable 'package-selected-packages package-selected-packages) (add-hook 'after-init-hook #'package--save-selected-packages))) @@ -2527,7 +2530,7 @@ package-delete ;; Don't deselect if this is an older version of an ;; upgraded package. (package--newest-p pkg-desc)) - (package--save-selected-packages (remove name package-selected-packages))) + (package--save-selected-packages (or (remove name package-selected-packages) 'empty))) (cond ((not (string-prefix-p (file-name-as-directory (expand-file-name package-user-dir)) (expand-file-name dir))) --=-=-= Content-Type: text/plain -- Philip Kaludercic --=-=-=--