emacs-31 29f292fa875: Avoid installing packages when using 'package-isolate'

Philip Kaludercic <[email protected]> Wed, 5 Aug 2026 17:09:46 -0400 (EDT)
Newsgroups gmane.emacs.diffs
Message-ID <[email protected]>
branch: emacs-31
commit 29f292fa8754b9a456ae73c7b68a80cf42abd227
Author: Philip Kaludercic <[email protected]>
Commit: Philip Kaludercic <[email protected]>

    Avoid installing packages when using 'package-isolate'
    
    * lisp/emacs-lisp/package.el (package-isolate): When translating
    full package names into package descriptors, prefer the package
    descriptors of already installed packages to those of remote
    packages.
---
 lisp/emacs-lisp/package.el | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 0eac0c56464..4f92987e0c2 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -2623,9 +2623,23 @@ If TEMP-INIT is non-nil, or when invoked with a prefix argument, the
 Emacs user directory is set to a temporary directory.  This command is
 intended for testing Emacs and/or the packages in a clean environment."
   (interactive
-   (cl-loop for p in (append
-                      (cl-loop for p in (package--alist) append (cdr p))
-                      (cl-loop for p in (package--archive-contents) append (cdr p)))
+   (cl-loop for p in
+	    (cl-loop with installed = (cl-loop for p in (package--alist)
+                                               append (cdr p))
+		     for p in (package--archive-contents)
+		     append (cl-loop
+                             for desc in (cdr p)
+			     unless (cl-loop
+                                     for idesc in installed thereis
+                                     (and (string= (package-desc-name idesc)
+						   (package-desc-name desc))
+					  (equal (package-desc-version idesc)
+						 (package-desc-version desc))
+                                          (eq (package-desc-kind idesc)
+					      (package-desc-kind desc))))
+			     collect desc)
+		     into descs
+		     finally return (nconc installed descs))
 	    unless (package-built-in-p p)
 	    collect (cons (package-desc-full-name p) p) into table
 	    finally return