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