From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#51883: 29.0.50; Command to get accidentally deleted frames back Date: Tue, 16 Nov 2021 19:40:08 +0200 Message-ID: <838rxo0zk7.fsf@gnu.org> References: <87czn1gfb1.fsf@web.de> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29412"; mail-complaints-to="usenet@ciao.gmane.io" Cc: michael_heerdegen@web.de, 51883@debbugs.gnu.org To: Gregory Heytings Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 16 18:41:11 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mn2SE-0007RC-Ks for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Nov 2021 18:41:10 +0100 Original-Received: from localhost ([::1]:45358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mn2SD-00039j-EH for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 16 Nov 2021 12:41:09 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:43430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mn2S7-00039W-0u for bug-gnu-emacs@gnu.org; Tue, 16 Nov 2021 12:41:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47498) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mn2S6-0006H3-P3 for bug-gnu-emacs@gnu.org; Tue, 16 Nov 2021 12:41:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mn2S6-0000pB-85 for bug-gnu-emacs@gnu.org; Tue, 16 Nov 2021 12:41:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 Nov 2021 17:41:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51883 X-GNU-PR-Package: emacs Original-Received: via spool by 51883-submit@debbugs.gnu.org id=B51883.16370844243073 (code B ref 51883); Tue, 16 Nov 2021 17:41:02 +0000 Original-Received: (at 51883) by debbugs.gnu.org; 16 Nov 2021 17:40:24 +0000 Original-Received: from localhost ([127.0.0.1]:59044 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mn2RT-0000nV-LL for submit@debbugs.gnu.org; Tue, 16 Nov 2021 12:40:24 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:42532) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mn2RS-0000nB-37 for 51883@debbugs.gnu.org; Tue, 16 Nov 2021 12:40:22 -0500 Original-Received: from [2001:470:142:3::e] (port=56582 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mn2RM-00068P-Je; Tue, 16 Nov 2021 12:40:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=jg0rrbQ8rvsYCqEboMjezK2q4lsz8tYXDFvZiCgX5UU=; b=d8WfJcTlvUNZ 1aum/8Uk3X+dpioO4DAKBix3JMuIopEFrdrYbkbUCnI7tfOiYEhTm0nNWkIF20BiTlf0iV1ESiA/R uZ7FRAd6TcrvRLrVvczeEYJHQSzsP6pdELuY/7VTaxeIU6diswjX8FOP3avW4Qy9OMNc1GbcK/vq1 7DTwvbNO+xnAusANtGH3N7Ptg42WTowx4HnRf2iG4UsfV0yLj7WorhtdOz/1qL1rXyaoj6rXOJBoN 2WMW4RSWO+Znvdar70c3wqJiHM/jG4fNNj7AGbKHUAqqZs8co8nO7dz1A4tjN01zyPF3mn/xxoeuk bvQlkE/26NXWcC+TlceG3A==; Original-Received: from [87.69.77.57] (port=4919 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mn2RM-0003m6-85; Tue, 16 Nov 2021 12:40:16 -0500 In-Reply-To: (message from Gregory Heytings on Tue, 16 Nov 2021 17:05:07 +0000) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:220136 Archived-At: > Date: Tue, 16 Nov 2021 17:05:07 +0000 > From: Gregory Heytings > Cc: Michael Heerdegen > > Slightly improved patch attached. Thanks, I have some comments below. > +(@code{make-frame-command}). A prefix argument undeletes the last deleted > +frame, a numerical prefix argument between 0 and 15 undeletes the > +corresponding deleted frame, where 0 is the most recently deleted frame. This is unusual meaning of prefix argument. Why not use zero for the last, 1 for the one before that, etc.? > +--- > +** Frames > + > ++++ > +*** With a prefix argument, the key 'C-x 5 2' undeletes deleted frames. I would make the heading shorter and more to the point: *** Deleted frames can now be undeleted. > +(eval-when-compile (require 'frameset)) > + > +(defvar undelete-frame--deleted-frames nil > + "Internal variable used by `undelete-frame--save-deleted-frame'.") > + > +(defun undeleted-frame--save-deleted-frame (frame) > + "Save the configuration of frames deleted with `delete-frame'. > +Only the 16 most recently deleted frames are saved." > + (when (frame-live-p frame) > + (setq undelete-frame--deleted-frames > + (cons (cons > + (display-graphic-p) > + (frameset-save (list frame))) > + undelete-frame--deleted-frames)) > + (if (> (length undelete-frame--deleted-frames) 16) > + (setq undelete-frame--deleted-frames > + (butlast undelete-frame--deleted-frames))))) > + > +(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 . using add-hook in Emacs's own code _by_default_ is not a good style; hooks are for customizing the default behavior . saving configurations of 16 deleted frames _by_default_ means we again impose on all users something that only some of them will use So I'd suggest instead making this an opt-in feature or maybe even minor mode. Only when turned on should we save away the deleted frames. (And did you consider wrapping this into some history-like feature, where users could interactively select which past frame to restore?) > +The 16 most recently deleted frames can however be undeleted with > +`undelete-frame', which see. The "however" part is "out of the blue" here; I'd drop it.