Merge from origin/emacs-31

498eafb4f1 ; * lisp/help.el (temp-buffer-resize-mode): Doc fix (bug#...
19a7d4ce7c Fix behavior of 'temp-buffer-resize-mode' (Bug#81207)
927a7fff5e Restore public interfaces for accessing built-in package ...
ea3d78898a Allow uninstalling dependency with multiple installations
4a3d5b110e Fix memcpy size in 'merge_faces'
This commit is contained in:
Eli Zaretskii 2026-06-13 06:16:54 -04:00
commit 4a86a530de
5 changed files with 69 additions and 16 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
@ -2379,6 +2395,15 @@ installed), maybe you need to \\[package-refresh-contents]")
(equal (cadr (assq (package-desc-name pkg) package-alist))
pkg))
(defun package--dependency-p (pkg)
"Return non-nil if PKG is a dependency."
(let ((name (package-desc-name pkg)))
(catch 'is-dependency
(dolist (ent (package--alist) nil)
(dolist (desc (cdr ent))
(when (assq name (package-desc-reqs desc))
(throw 'is-dependency t)))))))
(declare-function comp-el-to-eln-filename "comp.c")
(defvar package-vc-repository-store)
(defun package--delete-directory (dir)
@ -2439,9 +2464,14 @@ If NOSAVE is non-nil, the package is not removed from
;; `package-selected-packages' even if it can't be deleted.
(when (and (null nosave)
(package--user-selected-p name)
(or
;; Don't deselect if this is an older version of an
;; upgraded package.
(package--newest-p pkg-desc))
(package--newest-p pkg-desc)
;; Don't deselect if the package is a dependency and
;; there are multiple installations (bug#81082).
(and (length< (alist-get name package-alist) 1)
(package--dependency-p pkg-desc))))
(package--save-selected-packages (remove name package-selected-packages)))
(cond ((not (string-prefix-p (file-name-as-directory
(expand-file-name package-user-dir))
@ -2452,7 +2482,16 @@ If NOSAVE is non-nil, the package is not removed from
((and (null force)
(setq pkg-used-elsewhere-by
(let ((package-alist new-package-alist))
(package--used-elsewhere-p pkg-desc)))) ;See bug#65475
(package--used-elsewhere-p pkg-desc))) ;See bug#65475
(and-let* ((other (package-get-descriptor
name 'installed
(lambda (pkg-other)
(not (equal pkg-desc pkg-other))))))
(not (yes-or-no-p
(format "Package `%s' is used by `%s' as dependency, but `%s' is also available. Use that instead?"
(package-desc-full-name pkg-desc)
(package-desc-name pkg-used-elsewhere-by)
(package-desc-full-name other))))))
;; Don't delete packages used as dependency elsewhere.
(error "Package `%s' is used by `%s' as dependency, not deleting"
(package-desc-full-name pkg-desc)

View file

@ -1998,18 +1998,20 @@ function is called, the window to be resized is selected."
(define-minor-mode temp-buffer-resize-mode
"Toggle auto-resizing temporary buffer windows (Temp Buffer Resize Mode).
When Temp Buffer Resize mode is enabled, the windows in which we
show a temporary buffer are automatically resized in height to
When Temp Buffer Resize mode is enabled, the windows in which Emacs
shows a temporary buffer are automatically resized in height to
fit the buffer's contents, but never more than
`temp-buffer-max-height' nor less than `window-min-height'.
A window is resized only if it has been specially created for the
buffer. Windows that have shown another buffer before are not
resized. A frame is resized only if `fit-frame-to-buffer' is
non-nil.
When this mode is enabled, a window is resized only if it has been
specially created for a temporary buffer. Windows that have shown
another buffer before being reused for displaying a temporary buffer
are not resized (but note that if `even-window-sizes' is non-nil, they
might beresized in some situations anyway). A frame is resized only
if `fit-frame-to-buffer' is non-nil.
This mode is used by `help', `apropos' and `completion' buffers,
and some others."
and some others, when they display their pop-up buffers."
:global t :group 'help
(if temp-buffer-resize-mode
;; `help-make-xrefs' may add a `back' button and thus increase the
@ -2050,6 +2052,9 @@ provided `fit-frame-to-buffer' is non-nil."
(quit-cadr (cadr (window-parameter window 'quit-restore))))
;; Resize WINDOW only if it was made by `display-buffer'.
(when (or (and (eq quit-cadr 'window)
;; When WINDOW was reused, its buffer must be the one
;; initially shown in it (Bug#81207).
(eq buffer (nth 3 (window-parameter window 'quit-restore)))
(or (and (window-combined-p window)
(not (eq fit-window-to-buffer-horizontally
'only))

View file

@ -7272,7 +7272,7 @@ merge_faces (struct window *w, Lisp_Object face_name, int face_id,
Lisp_Object lface_attrs[LFACE_VECTOR_SIZE];
int i;
memcpy (lface_attrs, face->lface, LFACE_VECTOR_SIZE);
memcpy (lface_attrs, face->lface, sizeof lface_attrs);
/* Make explicit any attributes whose value is 'reset'. */
for (i = 1; i < LFACE_VECTOR_SIZE; i++)
if (EQ (lface_attrs[i], Qreset))

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