From 927a7fff5ecd11057665dcd9a1bf4faa5aff0a45 Mon Sep 17 00:00:00 2001 From: Xiyue Deng Date: Sat, 6 Jun 2026 14:49:06 -0700 Subject: [PATCH] Restore public interfaces for accessing built-in package info These functions were removed in ab36f5892203e4b1f59da7c995e0f1fa0a81d1b6 during the reorganization of package.el as part of Bug#80079. Also add a simple test for these functions to avoid future regressions. See also discussion at https://lists.gnu.org/archive/html/emacs-devel/2026-06/msg00149.html. * lisp/emacs-lisp/package.el (package-versioned-builtin-packages, package-builtin-package-version): Restore. * lisp/emacs-lisp/package-activate.el: Remove lingering comments. * test/lisp/emacs-lisp/package-tests.el (package-test-builtin-package-info): Add. --- lisp/emacs-lisp/package-activate.el | 2 -- lisp/emacs-lisp/package.el | 16 ++++++++++++++++ test/lisp/emacs-lisp/package-tests.el | 11 +++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lisp/emacs-lisp/package-activate.el b/lisp/emacs-lisp/package-activate.el index 53a3fa30836..5e2623c57f1 100644 --- a/lisp/emacs-lisp/package-activate.el +++ b/lisp/emacs-lisp/package-activate.el @@ -208,8 +208,6 @@ called via `package-activate-all'. To change which packages are loaded and/or activated, customize `package-load-list'.") (put 'package-alist 'risky-local-variable t) -;;;; Public interfaces for accessing built-in package info - ;;;###autoload (defvar package-activated-list nil ;; FIXME: This should implicitly include all builtin packages. diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index cd3c850f7a4..12b450d93db 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -534,6 +534,22 @@ package." reqs summary) + +;;; Public interfaces for accessing built-in package info + +(defun package-versioned-builtin-packages () + "Return a list of all the versioned built-in packages. +The return value is a list of names of built-in packages represented as +symbols." + (mapcar #'car package--builtin-versions)) + +(defun package-builtin-package-version (package) + "Return the version of a built-in PACKAGE given by its symbol. +The return value is a list of integers representing the version of +PACKAGE, in the format returned by `version-to-list', or nil if the +package is built-in but has no version or is not a built-in package." + (alist-get package package--builtin-versions)) + ;;; Installed packages diff --git a/test/lisp/emacs-lisp/package-tests.el b/test/lisp/emacs-lisp/package-tests.el index a2e4adb7b8e..b6fb9005e4c 100644 --- a/test/lisp/emacs-lisp/package-tests.el +++ b/test/lisp/emacs-lisp/package-tests.el @@ -1028,6 +1028,17 @@ but with a different end of line convention (bug#48137)." (list new-pkg-desc simple-depend-desc-2 simple-depend-desc-1 multi-file-desc simple-depend-desc simple-single-desc))))) +(ert-deftest package-test-builtin-package-info () + "Test public interfaces for querying package info." + (should (not (null (package-versioned-builtin-packages)))) + ;; Picking any built-in library to check the version. Update results + ;; as needed. + (require 'lisp-mnt) + (should (equal (package-builtin-package-version 'cl-lib) + (with-temp-buffer + (insert-file-contents (locate-library "cl-lib.el")) + (version-to-list (lm-version)))))) + (provide 'package-test) ;;; package-tests.el ends here