Add frame parameters 'cloned-from' and 'undeleted' (bug#80104)

* lisp/frame.el (clone-frame): Set the frame parameter
'cloned-from'.
(undelete-frame): Set the frame parameter 'undeleted'.
* src/frame.c (syms_of_frame): <Qcloned_from> <Qundeleted>: New
DEFSYM.
(syms_of_frame): Add 'Qcloned_from' and 'Qundeleted' to
'frame_internal_parameters'.
* doc/lispref/frames.texi: Document these frame parameters.
* etc/NEWS: Announce the new frame parameters.
This commit is contained in:
Stéphane Marks 2026-01-03 09:28:03 +01:00 committed by Martin Rudalics
parent 4606510f65
commit 51498a88cf
4 changed files with 39 additions and 5 deletions

View file

@ -198,6 +198,11 @@ A normal hook run by @code{make-frame} before it creates the frame.
An abnormal hook run by @code{make-frame} after it created the frame.
Each function in @code{after-make-frame-functions} receives one
argument, the frame just created.
You can consult the frame parameters @code{cloned-from} and
@code{undeleted} in your function to determine if a frame was cloned
using @command{clone-frame}, or if it was undeleted using
@command{undelete-frame}. @xref{Frame Parameters}.
@end defvar
Note that any functions added to these hooks by your initial file are
@ -2206,8 +2211,18 @@ left position ratio is preserved if the @sc{cdr} of the cell is either
@code{t} or @code{left-only}. The top position ratio is preserved if
the @sc{cdr} of the cell is either @code{t} or @code{top-only}. This
parameter has not been yet implemented on text terminals.
@end table
@vindex cloned-from@r{, a frame parameter}
@item cloned-from
The original frame if this frame was made via @code{clone-frame}
(@pxref{Creating Frames,,,emacs, the Emacs Manual}).
@vindex undeleted@r{, a frame parameter}
@item undeleted
This is non-@code{nil} if this frame was undeleted using the command
@command{undelete-frame} (@pxref{Frame Commands,,,emacs, the Emacs
Manual}).
@end table
@node Mouse Dragging Parameters
@subsubsection Mouse Dragging Parameters

View file

@ -482,6 +482,18 @@ frames into one of these frames and deletes the other one.
Unlike with other frame names, an attempt to rename to "F<number>" throws
an error when a frame of that name already exists.
+++
*** New frame parameters 'cloned-from' and 'undeleted'.
The frame parameter 'cloned-from' is set to the frame from which the new
frame is cloned using the command 'clone-frame'.
The frame parameter 'undeleted is set to t when a frame is undeleted
using the command 'undelete-frame'.
These are useful if you need to detect a cloned frame or undeleted frame
in hooks like 'after-make-frame-functions' and
'server-after-make-frame-hook'.
** Mode Line
+++

View file

@ -957,9 +957,10 @@ also select the new frame."
(windows (unless no-windows
(window-state-get (frame-root-window frame))))
(default-frame-alist
(seq-remove (lambda (elem)
(memq (car elem) frame-internal-parameters))
(frame-parameters frame)))
(append `((cloned-from . ,frame))
(seq-remove (lambda (elem)
(memq (car elem) frame-internal-parameters))
(frame-parameters frame))))
new-frame)
(when (and frame-resize-pixelwise
(display-graphic-p frame))
@ -3169,7 +3170,9 @@ When called from Lisp, returns the new frame."
(if graphic "graphic" "non-graphic"))
(setq undelete-frame--deleted-frames
(delq frame-data undelete-frame--deleted-frames))
(let* ((default-frame-alist (nth 1 frame-data))
(let* ((default-frame-alist
(append `((undeleted . t))
(nth 1 frame-data)))
(frame (make-frame)))
(window-state-put (nth 2 frame-data) (frame-root-window frame) 'safe)
(select-frame-set-input-focus frame)

View file

@ -7196,6 +7196,8 @@ syms_of_frame (void)
DEFSYM (Qfont_parameter, "font-parameter");
DEFSYM (Qforce, "force");
DEFSYM (Qinhibit, "inhibit");
DEFSYM (Qcloned_from, "cloned-from");
DEFSYM (Qundeleted, "undeleted");
for (int i = 0; i < ARRAYELTS (frame_parms); i++)
{
@ -7580,6 +7582,8 @@ allow `make-frame' to show the current buffer even if its hidden. */);
#else
frame_internal_parameters = list3 (Qname, Qparent_id, Qwindow_id);
#endif
frame_internal_parameters = Fcons (Qcloned_from, frame_internal_parameters);
frame_internal_parameters = Fcons (Qundeleted, frame_internal_parameters);
DEFVAR_LISP ("alter-fullscreen-frames", alter_fullscreen_frames,
doc: /* How to handle requests to resize fullscreen frames.