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

From: Stefan Monnier <[email-masked]>
Date: Fri, 21 Jan 2022 12:52:35 -0500

Eli Zaretskii [2021-11-16 19:40:08] wrote:
>> +(add-hook 'delete-frame-functions #'undeleted-frame--save-deleted-frame)
>
> I'd rather we didn't do that by default.  Several reasons:
>
>   . the startup code deletes the terminal frame, so the above means we
>     will always load frameset, which is not a small package, at
>     startup, even if the user has no use for this functionality

Clearly we should avoid putting the special initial-frame in the undo
log since we don't want (and can't) recreate it later anyway.

But as for loading the package, the problem is more general in the sense
that maybe we should refrain from loading the package just because
a frame is deleted.

So maybe we should change the code so the hook's function doesn't
require loading `frameset.el`.  AFAICT fundamentally, the only function
from `frameset.el` that it needs is `frameset-filter-params`, so maybe
we should move some of that code to `frame.el`.

To make up for it, maybe we can move some of the `undelete-frame` code
to `frameset.el` since it can't be used without `frameset.el` anyway?

>   . saving configurations of 16 deleted frames _by_default_ means we
>     again impose on all users something that only some of them will use

IIUC framesets are designed to be serializable so they shouldn't hold on
to external data like buffers and windows, so such 16 elements should
cost very little in terms of heap use.

        Stefan