diff --git a/doc/lispref/frames.texi b/doc/lispref/frames.texi index 8b2a493a5e1..303c047023b 100644 --- a/doc/lispref/frames.texi +++ b/doc/lispref/frames.texi @@ -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 diff --git a/etc/NEWS b/etc/NEWS index bd60249708c..321ce929cb0 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -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" 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 +++ diff --git a/lisp/frame.el b/lisp/frame.el index 071e121246b..b9e47175f66 100644 --- a/lisp/frame.el +++ b/lisp/frame.el @@ -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) diff --git a/src/frame.c b/src/frame.c index 8d478de7268..ec227ce276d 100644 --- a/src/frame.c +++ b/src/frame.c @@ -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.