Additional fixes for 'get-mru-frame' (Bug#80397)

* src/frame.c (delete_frame): Call 'get-mru-frame' safely and
with EXCLUDE-FRAME argument set up correctly.
* lisp/frame.el (get-mru-frames, get-mru-frame): Fix doc-strings.
This commit is contained in:
Martin Rudalics 2026-03-06 09:51:21 +01:00
parent 5c1ef38b5b
commit 8034e48630
2 changed files with 11 additions and 10 deletions

View file

@ -2627,8 +2627,8 @@ optional FRAME is nil, use the selected frame."
(defun get-mru-frames (&optional all-frames
exclude-child-frames
exclude-frame)
"Return a frame list sorted by most recent use and filtered by ALL-FRAMES.
Compute the result using `frame-use-time', which see. Tooltip, and
"Return list of frames sorted by most recent use and filtered by ALL-FRAMES.
Compute the result using `frame-use-time', which see. Tooltip and
minibuffer only frames are never candidates. If optional argument
EXCLUDE-CHILD-FRAMES is non-nil, eliminate child frames as candidates.
If EXCLUDE-FRAME is non-nil, it is a frame to exclude, for example, the
@ -2640,11 +2640,11 @@ have special meanings:
- `visible' means consider all visible frames on the current terminal
or EXCLUDE-FRAME's terminal if EXCLUDE-FRAME is non-nil.
- 0 (the number zero) means consider all all visible and iconified
- 0 (the number zero) means consider all visible and iconified
frames on the current terminal or EXCLUDE-FRAME's terminal if
EXCLUDE-FRAME is non-nil.
Any other value of ALL-FRAMES means consider all frames."
Any other value means consider all frames."
(setq all-frames (or all-frames t))
(let* ((terminal (frame-terminal (or exclude-frame (selected-frame))))
(frame-list
@ -2665,7 +2665,7 @@ Any other value of ALL-FRAMES means consider all frames."
(sort frame-list :key #'frame-use-time :reverse t)))
(defun get-mru-frame (&optional all-frames exclude-child-frames exclude-frame)
"Return the most recently used frame on frames specified by ALL-FRAMES.
"Return the most recently used frame among frames specified by ALL-FRAMES.
Compute the result using `frame-use-time', which see. Tooltip, and
minibuffer only frames are never candidates. If optional argument
EXCLUDE-CHILD-FRAMES is non-nil, eliminate child frames as candidates.
@ -2678,11 +2678,11 @@ have special meanings:
- `visible' means consider all visible frames on the current terminal
or EXCLUDE-FRAME's terminal if EXCLUDE-FRAME is non-nil.
- 0 (the number zero) means consider all all visible and iconified
frames on the current terminal or EXCLUDE-FRAME's terminal if
EXCLUDE-FRAME is non-nil.
- 0 (the number zero) means consider all visible and iconified frames on
the current terminal or EXCLUDE-FRAME's terminal if EXCLUDE-FRAME is
non-nil.
Any other value of ALL-FRAMES means consider all frames."
Any other value means consider all frames."
(car (get-mru-frames all-frames exclude-child-frames exclude-frame)))
;;;; Frame/display capabilities.

View file

@ -2756,10 +2756,11 @@ delete_frame (Lisp_Object frame, Lisp_Object force)
/* Find the most recently used visible frame among all
frames on the same terminal as FRAME, excluding FRAME
which we are about to delete. */
frame1 = calln (Qget_mru_frame, Qvisible, frame);
frame1 = safe_calln (Qget_mru_frame, Qvisible, Qnil, frame);
if (!NILP (frame1))
{
struct frame *f1 = XFRAME (frame1);
if (FRAME_TOOLTIP_P (f1)
|| FRAME_TERMINAL (f) != FRAME_TERMINAL (f1)
|| !FRAME_VISIBLE_P (f1)