Subject: bug#72141: 29.4; package-upgrade vs package-load-list

From: Thierry Volpiatto <[email-masked]>
Date: Sat, 10 Aug 2024 17:16:54 +0000

Thierry Volpiatto <[email-masked]> writes:

> Hello Philip,
>
> Philip Kaludercic <[email-masked]> 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:

--8<---------------cut here---------------start------------->8---
(equal
 ;; old
 (mapcar #'symbol-name (mapcar #'car package-alist))
 ;; new
 (mapcar (lambda (pkg) (symbol-name (car pkg))) package-alist))

(equal
 ;; old
 (mapcar
  (lambda (p) (cons (package-desc-full-name p) p))
  (delq nil
        (mapcar (lambda (p) (unless (package-built-in-p p) p))
                (apply #'append (mapcar #'cdr (package--alist))))))
 ;; new
 (cl-loop for (p desc) in package-alist
          unless (package-built-in-p p)
          collect (cons (package-desc-full-name desc) desc)))

;; Change w3m to an installed package in your Emacs.
(let ((alist (package-desc-extras (cadr (assq 'w3m package-alist)))))
  (equal
   ;; old
   (mapcar #'macroexp-quote
           (apply #'nconc
                  (mapcar (lambda (pair) (list (car pair) (cdr pair))) alist)))
   ;; new
   (cl-loop for lst in alist
            nconc `(,(car lst) ,(macroexp-quote (cdr lst))))))

(equal
 ;; old
 (mapcar #'file-truename
         (cl-remove-if-not #'stringp
                           (mapcar #'car load-history)))
 ;; new
 (cl-loop for (name _rest) in load-history
          when (stringp name)
          collect (file-truename name)))
--8<---------------cut here---------------end--------------->8---

I have a patch for this, let me know if interested, or perhaps I should
open a new bug report ?

-- 
Thierry