Restore public interfaces for accessing built-in package info

These functions were removed in ab36f58922
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.
This commit is contained in:
Xiyue Deng 2026-06-06 14:49:06 -07:00 committed by Philip Kaludercic
parent ea3d78898a
commit 927a7fff5e
No known key found for this signature in database
3 changed files with 27 additions and 2 deletions

View file

@ -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.

View file

@ -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

View file

@ -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