aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilip Kaludercic2025-12-23 19:39:31 +0100
committerPhilip Kaludercic2026-01-10 12:38:05 +0100
commitc8d19034aa9997aed6a5ffe65064920b48c76e5f (patch)
tree1ce9ed57cc51be4ee9c1a6bf9e50df66c6087b58
parent881be95cddcab3cf37373678002c35334c177c97 (diff)
downloademacs-c8d19034aa9997aed6a5ffe65064920b48c76e5f.tar.gz
emacs-c8d19034aa9997aed6a5ffe65064920b48c76e5f.zip
Allow 'package-isolate' to fetch missing packages
* lisp/emacs-lisp/package.el (package-isolate): Fetch missing packages and make them available in the new Emacs process, but not the current one. * etc/NEWS: Mention change.
-rw-r--r--etc/NEWS5
-rw-r--r--lisp/emacs-lisp/package.el42
2 files changed, 31 insertions, 16 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 6df77525bf6..98059ef15f6 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2804,6 +2804,11 @@ When called from Lisp, it now only accepts a symbol.
2804When invoking the command in a Dired buffer with marked files, 2804When invoking the command in a Dired buffer with marked files,
2805the command will only copy those files. 2805the command will only copy those files.
2806 2806
2807---
2808*** 'package-isolate' can now also install packages.
2809If a package is missing, 'package-isolate' will fetch the missing
2810tarballs and prepare them to be activated in the sub-process.
2811
2807+++ 2812+++
2808*** package-x.el is now obsolete. 2813*** package-x.el is now obsolete.
2809 2814
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index fccaf9f9f3e..19e412d5fd3 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -2484,14 +2484,16 @@ argument, don't ask for confirmation to install packages."
2484(defun package-isolate (packages &optional temp-init) 2484(defun package-isolate (packages &optional temp-init)
2485 "Start an uncustomized Emacs and only load a set of PACKAGES. 2485 "Start an uncustomized Emacs and only load a set of PACKAGES.
2486Interactively, prompt for PACKAGES to load, which should be specified 2486Interactively, prompt for PACKAGES to load, which should be specified
2487separated by commas. 2487separated by commas. If called from Lisp, PACKAGES should be a list of
2488If called from Lisp, PACKAGES should be a list of packages to load. 2488`package-desc' objects to load. If an element of PACKAGES is not
2489If TEMP-INIT is non-nil, or when invoked with a prefix argument, 2489installed, it will be fetched, but not activated in the current session.
2490the Emacs user directory is set to a temporary directory. 2490If TEMP-INIT is non-nil, or when invoked with a prefix argument, the
2491This command is intended for testing Emacs and/or the packages 2491Emacs user directory is set to a temporary directory. This command is
2492in a clean environment." 2492intended for testing Emacs and/or the packages in a clean environment."
2493 (interactive 2493 (interactive
2494 (cl-loop for p in (cl-loop for p in (package--alist) append (cdr p)) 2494 (cl-loop for p in (append
2495 (cl-loop for p in (package--alist) append (cdr p))
2496 (cl-loop for p in package-archive-contents append (cdr p)))
2495 unless (package-built-in-p p) 2497 unless (package-built-in-p p)
2496 collect (cons (package-desc-full-name p) p) into table 2498 collect (cons (package-desc-full-name p) p) into table
2497 finally return 2499 finally return
@@ -2500,21 +2502,27 @@ in a clean environment."
2500 (completing-read-multiple 2502 (completing-read-multiple
2501 "Packages to isolate: " table 2503 "Packages to isolate: " table
2502 nil t) 2504 nil t)
2503 collect (alist-get c table nil nil #'string=)) 2505 collect (alist-get c table nil nil #'string=))
2504 current-prefix-arg))) 2506 current-prefix-arg)))
2505 (let* ((name (concat "package-isolate-" 2507 (let* ((name (concat "package-isolate-"
2506 (mapconcat #'package-desc-full-name packages ","))) 2508 (mapconcat #'package-desc-full-name packages ",")))
2507 (all-packages (delete-consecutive-dups 2509 (all-packages (package-compute-transaction
2508 (sort (append packages (mapcan #'package--dependencies packages)) 2510 packages (mapcan #'package-desc-reqs packages)))
2509 (lambda (p0 p1) 2511 (package-alist (copy-tree package-alist t))
2510 (string< (package-desc-name p0) (package-desc-name p1)))))) 2512 (temp-install-dir nil) initial-scratch-message load-list)
2511 initial-scratch-message package-load-list) 2513 (when-let* ((missing (seq-remove #'package-installed-p all-packages))
2514 (package-user-dir (make-temp-file "package-isolate" t)))
2515 (setq temp-install-dir (list package-user-dir))
2516 ;; We bind `package-activate-1' to prevent activating the package
2517 ;; in `package-unpack' for this session.
2518 (cl-letf (((symbol-function #'package-activate-1) #'ignore))
2519 (package-download-transaction missing)))
2512 (with-temp-buffer 2520 (with-temp-buffer
2513 (insert ";; This is an isolated testing environment, with these packages enabled:\n\n") 2521 (insert ";; This is an isolated testing environment, with these packages enabled:\n\n")
2514 (dolist (package all-packages) 2522 (dolist (package all-packages)
2515 (push (list (package-desc-name package) 2523 (push (list (package-desc-name package)
2516 (package-version-join (package-desc-version package))) 2524 (package-version-join (package-desc-version package)))
2517 package-load-list) 2525 load-list)
2518 (insert ";; - " (package-desc-full-name package)) 2526 (insert ";; - " (package-desc-full-name package))
2519 (unless (memq package packages) 2527 (unless (memq package packages)
2520 (insert " (dependency)")) 2528 (insert " (dependency)"))
@@ -2535,7 +2543,9 @@ in a clean environment."
2535 ,@(mapcar 2543 ,@(mapcar
2536 (lambda (dir) 2544 (lambda (dir)
2537 `(add-to-list 'package-directory-list ,dir)) 2545 `(add-to-list 'package-directory-list ,dir))
2538 (cons package-user-dir package-directory-list)) 2546 (append (list package-user-dir)
2547 temp-install-dir
2548 package-directory-list))
2539 (setq package-load-list ',package-load-list) 2549 (setq package-load-list ',package-load-list)
2540 (package-activate-all))))))) 2550 (package-activate-all)))))))
2541 2551