1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-07 15:00:34 -08:00

Add public interfaces for accessing builtin package info (Bug#78844)

* lisp/emacs-lisp/package.el (package-builtin-packages)
(package-builtin-package-version): New functions.
* doc/lispref/package.texi: Add a section 'Package Information' with
documentation for the new functions.
* etc/NEWS: Add entry for 'package-versioned-builtin-packages' and
'package-builtin-package-version'.
This commit is contained in:
Xiyue Deng 2025-06-20 21:34:45 -07:00 committed by Eli Zaretskii
parent 52b96d3a7e
commit 5c75ec6ae5
3 changed files with 48 additions and 0 deletions

View file

@ -424,3 +424,28 @@ For further details on how to make use of the package, see
the manual installed, you can also read the the manual installed, you can also read the
@url{https://elpa.gnu.org/packages/doc/compat.html#Usage, Online @url{https://elpa.gnu.org/packages/doc/compat.html#Usage, Online
Compat manual}. Compat manual}.
@node Package Information
@section Get built-in packages and versions
@cindex package information
Emacs ships built-in packages which may also be packaged externally on
ELPA. Knowing whether a built-in package has a higher version than on
ELPA or other packaging systems may be useful for external packaging
tools. Those who would like to query such information can use the
following functions.
@defun package-versioned-builtin-packages
This function returns the list of packages that are built-in to Emacs
and have a version. The returned list contains one symbol for each
built-in package that has a version, which are likely also packaged
externally on ELPA.
@end defun
@defun package-builtin-package-version package
This function returns the version of a built-in @var{package}.
@var{package} should be a symbol. The returned value is a list of
integers representing the version of PACKAGE in the format returned by
the function @code{version-to-list}, or nil if @var{package} is built-in
but has no version or is not a built-in package.
@end defun

View file

@ -2025,6 +2025,14 @@ installed, total number of packages from all the package archives, total
number of packages to upgrade and total number of new packages number of packages to upgrade and total number of new packages
available. available.
+++
*** New functions to query builtin package information.
'package-versioned-builtin-packages' returns a list of symbols of
built-in packages; 'package-builtin-package-version' returns the
version-list of a given package symbol. These functions provide public
interfaces for external tools to query information about built-in
packages.
** Rcirc ** Rcirc
+++ +++

View file

@ -669,6 +669,21 @@ called via `package-activate-all'. To change which packages are
loaded and/or activated, customize `package-load-list'.") loaded and/or activated, customize `package-load-list'.")
(put 'package-alist 'risky-local-variable t) (put 'package-alist 'risky-local-variable t)
;;;; 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))
;;;###autoload ;;;###autoload
(defvar package-activated-list nil (defvar package-activated-list nil
;; FIXME: This should implicitly include all builtin packages. ;; FIXME: This should implicitly include all builtin packages.