From: Philip Kaludercic <philipk@posteo.net>
To: Thierry Volpiatto <thievol@posteo.net>
Cc: Eli Zaretskii <eliz@gnu.org>, 72141@debbugs.gnu.org
Subject: bug#72141: 29.4; package-upgrade vs package-load-list
Date: Mon, 12 Aug 2024 16:36:43 +0000 [thread overview]
Message-ID: <877ccl8zqc.fsf@posteo.net> (raw)
In-Reply-To: <87ikwgjjl3.fsf@posteo.net> (Thierry Volpiatto's message of "Sun, 04 Aug 2024 17:15:04 +0000")
Thierry Volpiatto <thievol@posteo.net> writes:
> Hello Philip,
>
> Philip Kaludercic <philipk@posteo.net> writes:
>
>> Gladly, then I'd like to try it out it and perhaps write a ERT test.
>
> Patch attached, please review and test it before merging ;-)
Sorry for the delay.
> Thanks.
>
> --
> Thierry
>
> From 292e251a383c1fb53cc377cd32f71705e6742f85 Mon Sep 17 00:00:00 2001
> From: Thierry Volpiatto <thievol@posteo.net>
> Date: Sat, 3 Aug 2024 06:07:28 +0200
> Subject: [PATCH] Fix bug#72141, package-upgrade should not include disabled
> packages
>
> * lisp/emacs-lisp/package.el (package--upgradeable-packages):
> Rewrite with a new optional arg to filter out disabled packages from
> output.
> (package-upgrade, package-upgrade-all): Use it and filter out built-in
> packages from completion according package-install-upgrade-built-in
> value.
> ---
> lisp/emacs-lisp/package.el | 60 ++++++++++++++++++++++----------------
> 1 file changed, 35 insertions(+), 25 deletions(-)
>
> diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
> index 7cae8d68bc0..83996c9d6de 100644
> --- a/lisp/emacs-lisp/package.el
> +++ b/lisp/emacs-lisp/package.el
> @@ -2259,11 +2259,15 @@ had been enabled."
> "Upgrade package NAME if a newer version exists."
> (interactive
> (list (completing-read
> - "Upgrade package: " (package--upgradeable-packages t) nil t)))
> + "Upgrade package: " (package--upgradeable-packages
> + package-install-upgrade-built-in
> + 'ignore-disabled)
> + nil t)))
> (let* ((package (if (symbolp name)
> name
> (intern name)))
> (pkg-desc (cadr (assq package package-alist)))
> + ;; Keep this binding for non-interactive use.
> (package-install-upgrade-built-in (not pkg-desc)))
> ;; `pkg-desc' will be nil when the package is an "active built-in".
> (if (and pkg-desc (package-vc-p pkg-desc))
> @@ -2275,32 +2279,37 @@ had been enabled."
> ;; before. Mark it as installed explicitly.
> (and pkg-desc 'dont-select)))))
>
> -(defun package--upgradeable-packages (&optional include-builtins)
> +(defun package--upgradeable-packages (&optional
> + include-builtins ignore-disabled)
> ;; Initialize the package system to get the list of package
> ;; symbols for completion.
> (package--archives-initialize)
> - (mapcar
> - #'car
> - (seq-filter
> - (lambda (elt)
> - (or (let ((available
> - (assq (car elt) package-archive-contents)))
> - (and available
> - (or (and
> - include-builtins
> - (not (package-desc-version (cadr elt))))
> - (version-list-<
> - (package-desc-version (cadr elt))
> - (package-desc-version (cadr available))))))
> - (package-vc-p (cadr elt))))
> - (if include-builtins
> - (append package-alist
> - (mapcan
> - (lambda (elt)
> - (when (not (assq (car elt) package-alist))
> - (list (list (car elt) (package--from-builtin elt)))))
> - package--builtins))
> - package-alist))))
> + (let ((pkgs (if include-builtins
> + (append package-alist
> + (append package-alist
> + (mapcan
> + (lambda (elt)
> + (when (not (assq (car elt) package-alist))
> + (list
> + (list
> + (car elt)
> + (package--from-builtin elt)))))
> + package--builtins)))
> + package-alist)))
> + (cl-loop for (sym desc) in pkgs
> + for available =
> + (if-let ((av (assq sym package-archive-contents)))
> + (if ignore-disabled
> + (and (not (package-disabled-p sym cversion)) av) av))
^
This loop really confused me. Specifically here
If I am not mistaken, cversion might be set by the last iteration, no?
In that case, we are passing some version string unrelated to sym?
I am leaning towards keeping the existing loop, i.e. not rewriting
anything while fixing a bug. It is probably easier for me to do that.
Do you have any comments on tricks or traps that I should keep in mind?
> + for cversion = (and available (package-desc-version desc))
> + when (or (and available
> + (or (and include-builtins (not cversion))
> + (and cversion
> + (version-list-<
> + cversion
> + (package-desc-version (cadr available))))))
> + (package-vc-p desc))
> + collect sym)))
>
> ;;;###autoload
> (defun package-upgrade-all (&optional query)
> @@ -2315,7 +2324,8 @@ from ELPA by either using `\\[package-upgrade]' or
> `\\<package-menu-mode-map>\\[package-menu-mark-install]' after `\\[list-packages]'."
> (interactive (list (not noninteractive)))
> (package-refresh-contents)
> - (let ((upgradeable (package--upgradeable-packages)))
> + (let ((upgradeable (package--upgradeable-packages
> + package-install-upgrade-built-in 'ignore-disabled)))
> (if (not upgradeable)
> (message "No packages to upgrade")
> (when (and query
Thierry Volpiatto <thievol@posteo.net> writes:
> Thierry Volpiatto <thievol@posteo.net> writes:
>
>> Hello Philip,
>>
>> Philip Kaludercic <philipk@posteo.net> writes:
>>
>>> Gladly, then I'd like to try it out it and perhaps write a ERT test.
>>
>> Patch attached, please review and test it before merging ;-)
>>
>> Thanks.
>
> Also, I recently had to read package.el code and I found many loops are
> too complex and/or too difficult to read, here are some:
>
[...]
>
> I have a patch for this, let me know if interested, or perhaps I should
> open a new bug report ?
I have some spare time now, and if I also find some spare energy, I plan
to clean up a number of things in package.el, mainly removing duplicate
logic and making the code more flexible. I'll start work on a separate
branch, and that's why I am not too enthusiastic about these kinds of
changes on master (for now).
--
Philip Kaludercic on peregrine
next prev parent reply other threads:[~2024-08-12 16:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-16 14:46 bug#72141: 29.4; package-upgrade vs package-load-list Thierry Volpiatto
2024-07-27 7:14 ` Eli Zaretskii
2024-07-28 11:47 ` Philip Kaludercic
2024-07-28 12:27 ` Thierry Volpiatto
2024-07-28 12:27 ` Eli Zaretskii
2024-07-28 12:39 ` Thierry Volpiatto
2024-08-01 6:48 ` Thierry Volpiatto
2024-08-03 3:22 ` Thierry Volpiatto
2024-08-04 14:57 ` Philip Kaludercic
2024-08-04 17:15 ` Thierry Volpiatto
2024-08-10 17:16 ` Thierry Volpiatto
2024-08-12 16:36 ` Philip Kaludercic [this message]
2024-08-12 17:36 ` Thierry Volpiatto
2024-08-12 18:16 ` Thierry Volpiatto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877ccl8zqc.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=72141@debbugs.gnu.org \
--cc=eliz@gnu.org \
--cc=thievol@posteo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).