Subject: Re: bug#51883: 29.0.50; Command to get accidentally deleted frames back

From: Juri Linkov <[email-masked]>
Date: Thu, 27 Jan 2022 19:21:24 +0200

>> Which other parameters would you suggest to remove (on master)?
>
> It would be pretentious to answer that question.  The comment starting
> at line 261 of frameset.el tells that
>
> ;; - `window-id', `outer-window-id', `parent-id': They are assigned
> ;;   automatically and cannot be set, so keeping them is harmless, but they
> ;;   add clutter.  `window-system' is similar: it's assigned at frame
> ;;   creation, and does not serve any useful purpose later.
>
> so according to that comment, leaving 'parent-id' in the list should not
> have caused any problems.  Thanks to Juri, we know better now.

I confirm that removing 'parent-id' is sufficient to fix the bug in Emacs 28.
So here is the minimal patch for the release branch:

diff --git a/lisp/frame.el b/lisp/frame.el
index 86c52dc438..69119b4c24 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -798,8 +798,9 @@ clone-frame
          (windows (unless no-windows
                     (window-state-get (frame-root-window frame))))
          (default-frame-alist
-           (seq-remove (lambda (elem) (eq (car elem) 'name))
-                       (frame-parameters frame)))
+          (seq-remove (lambda (elem)
+                        (memq (car elem) '(name parent-id)))
+                      (frame-parameters frame)))
          (new-frame (make-frame)))
     (when windows
       (window-state-put windows (frame-root-window new-frame) 'safe))