From: Juri Linkov <juri@linkov.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: michael_heerdegen@web.de, Gregory Heytings <gregory@heytings.org>,
51883@debbugs.gnu.org
Subject: bug#51883: 29.0.50; Command to get accidentally deleted frames back
Date: Mon, 24 Jan 2022 20:12:48 +0200 [thread overview]
Message-ID: <8635ld0zq7.fsf@mail.linkov.net> (raw)
In-Reply-To: <jwvmtjm5emq.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sun, 23 Jan 2022 16:26:20 -0500")
[-- Attachment #1: Type: text/plain, Size: 1031 bytes --]
>> I didn't mean to keep actual frames around. I thought about keeping
>> only the same data that is used by `clone-frame` to make a new frame
>> identical to the original frame. In case of `undelete-frame` this data
>> can be used to make a frame identical to the deleted frame.
>> I.e. a lightweight version of framesets, that avoids loading frameset.el.
>> This mostly means that after deleting the frame, only frame parameters
>> are kept from garbage collection, that later can be reused when making
>> a new frame on undeletion.
>
> Ah, got it, thanks. Then fully agreed. I was heading in the same
> direction when I suggested to try and use as little as possible of
> `frameset.el` and move the resulting code to `frame.el`.
While copying some code from `clone-frame` to `undelete-frame`,
I noticed that `clone-frame` doesn't work on non-GTK builds,
because window-id frame parameters keep frame-specific X-windows,
so `clone-frame` is broken in emacs-28.
Eli, is it ok to push the first patch to the release branch?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: clone-frame-fix.patch --]
[-- Type: text/x-diff, Size: 703 bytes --]
diff --git a/lisp/frame.el b/lisp/frame.el
index 599ffe591a..5de554eee6 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 window-id outer-window-id parent-id)))
+ (frame-parameters frame)))
(new-frame (make-frame)))
(when windows
(window-state-put windows (frame-root-window new-frame) 'safe))
[-- Attachment #3: Type: text/plain, Size: 74 bytes --]
Then the second patch for master removes the dependency on frameset.el:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: undelete-frame-without-frameset.patch --]
[-- Type: text/x-diff, Size: 3431 bytes --]
diff --git a/lisp/frame.el b/lisp/frame.el
index 599ffe591a..5de554eee6 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -2529,8 +2530,6 @@ delete-other-frames
(if iconify (iconify-frame this) (delete-frame this)))
(setq this next))))
-(eval-when-compile (require 'frameset))
-
(defvar undelete-frame--deleted-frames nil
"Internal variable used by `undelete-frame--handle-delete-frame'.")
@@ -2540,20 +2539,12 @@ undelete-frame--handle-delete-frame
(when (frame-live-p frame)
(setq undelete-frame--deleted-frames
(cons
- (cons
+ (list
(display-graphic-p)
- (frameset-save
- (list frame)
- ;; When the daemon is started from a graphical
- ;; environment, TTY frames have a 'display' parameter set
- ;; to the value of $DISPLAY (see the note in
- ;; `server--on-display-p'). Do not store that parameter
- ;; in the frameset, otherwise `frameset-restore' attempts
- ;; to restore a graphical frame.
- :filters (if (display-graphic-p)
- frameset-filter-alist
- (cons '(display . :never)
- frameset-filter-alist))))
+ (seq-remove (lambda (elem)
+ (memq (car elem) '(name window-id outer-window-id parent-id)))
+ (frame-parameters frame))
+ (window-state-get (frame-root-window frame)))
undelete-frame--deleted-frames))
(if (> (length undelete-frame--deleted-frames) 16)
(setq undelete-frame--deleted-frames
@@ -2583,26 +2574,25 @@ undelete-frame
(if (consp arg)
(user-error "Missing deleted frame number argument")
(let* ((number (pcase arg ('nil 1) ('- -1) (_ arg)))
- (frames (frame-list))
- (frameset (nth (1- number) undelete-frame--deleted-frames))
+ (frame-data (nth (1- number) undelete-frame--deleted-frames))
(graphic (display-graphic-p)))
(if (not (<= 1 number 16))
(user-error "%d is not a valid deleted frame number argument"
number)
- (if (not frameset)
+ (if (not frame-data)
(user-error "No deleted frame with number %d" number)
- (if (not (eq graphic (car frameset)))
+ (if (not (eq graphic (nth 0 frame-data)))
(user-error
"Cannot undelete a %s display frame on a %s display"
(if graphic "non-graphic" "graphic")
(if graphic "graphic" "non-graphic"))
(setq undelete-frame--deleted-frames
- (delq frameset undelete-frame--deleted-frames))
- (frameset-restore (cdr frameset))
- (let ((frame (car (seq-difference (frame-list) frames))))
- (when frame
- (select-frame-set-input-focus frame)
- frame)))))))))
+ (delq frame-data undelete-frame--deleted-frames))
+ (let* ((default-frame-alist (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)
+ frame))))))))
\f
;;; Window dividers.
(defgroup window-divider nil
next prev parent reply other threads:[~2022-01-24 18:12 UTC|newest]
Thread overview: 87+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-15 23:38 bug#51883: 29.0.50; Command to get accidentally deleted frames back Michael Heerdegen
2021-11-16 7:53 ` Juri Linkov
2021-11-16 8:14 ` Lars Ingebrigtsen
2021-11-16 20:46 ` Juri Linkov
2021-11-16 8:49 ` Visuwesh via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-11-16 20:20 ` Juri Linkov
2021-11-16 15:17 ` Gregory Heytings
2021-11-16 17:05 ` Gregory Heytings
2021-11-16 17:40 ` Eli Zaretskii
2021-11-16 21:29 ` Gregory Heytings
2021-11-17 10:02 ` Gregory Heytings
2021-11-17 13:11 ` Eli Zaretskii
2021-11-17 17:06 ` Juri Linkov
2021-11-17 17:14 ` Eli Zaretskii
2021-11-19 9:00 ` Gregory Heytings
2021-11-19 12:17 ` Eli Zaretskii
2021-11-24 0:44 ` Gregory Heytings
2021-11-27 11:36 ` Michael Heerdegen
2021-11-27 11:53 ` Gregory Heytings
2021-11-27 12:05 ` Eli Zaretskii
2021-11-27 12:12 ` Gregory Heytings
2021-11-27 12:30 ` Andreas Schwab
2021-11-27 12:34 ` Eli Zaretskii
2021-11-27 12:23 ` Michael Heerdegen
2021-11-27 12:40 ` Eli Zaretskii
2021-11-27 13:22 ` Michael Heerdegen
2021-11-27 13:26 ` Eli Zaretskii
2021-11-27 13:34 ` Michael Heerdegen
2021-11-27 13:56 ` Eli Zaretskii
2021-11-27 13:59 ` Michael Heerdegen
2021-11-27 14:02 ` Eli Zaretskii
2021-11-27 14:08 ` Michael Heerdegen
2021-11-27 14:47 ` Eli Zaretskii
2021-11-27 14:12 ` Gregory Heytings
2021-11-27 14:24 ` Michael Heerdegen
2021-11-27 14:26 ` Gregory Heytings
2021-11-27 14:33 ` Michael Heerdegen
2021-11-27 14:42 ` Gregory Heytings
2021-11-27 14:54 ` Michael Heerdegen
2021-11-27 17:19 ` Gregory Heytings
2021-11-28 15:47 ` Michael Heerdegen
2021-11-29 13:38 ` Gregory Heytings
2021-11-29 18:18 ` Michael Heerdegen
2021-11-29 19:07 ` Michael Heerdegen
2021-11-29 20:19 ` Juri Linkov
2022-01-13 8:32 ` Juri Linkov
2022-01-14 8:12 ` Juri Linkov
2022-01-16 20:59 ` Juri Linkov
2022-01-17 0:08 ` Michael Heerdegen
2022-01-17 8:24 ` Juri Linkov
2022-01-17 13:00 ` Eli Zaretskii
2022-01-17 18:41 ` Juri Linkov
2022-01-17 18:51 ` Eli Zaretskii
2022-01-18 18:30 ` Juri Linkov
2022-01-19 18:37 ` Juri Linkov
2022-01-19 20:17 ` Eli Zaretskii
2021-12-12 2:44 ` Michael Heerdegen
2022-01-10 8:13 ` Michael Heerdegen
2021-11-27 14:48 ` Eli Zaretskii
2021-11-27 12:13 ` Michael Heerdegen
2022-01-22 18:10 ` Juri Linkov
2022-01-21 17:52 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-22 18:08 ` Juri Linkov
2022-01-22 21:26 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-23 9:11 ` Juri Linkov
2022-01-23 16:01 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-23 18:12 ` Juri Linkov
2022-01-23 21:26 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-24 18:12 ` Juri Linkov [this message]
2022-01-24 18:32 ` Eli Zaretskii
2022-01-25 9:28 ` martin rudalics
2022-01-25 12:29 ` Eli Zaretskii
2022-01-25 15:58 ` martin rudalics
2022-01-27 17:21 ` Juri Linkov
2022-01-27 17:27 ` Eli Zaretskii
2022-01-27 17:48 ` Juri Linkov
2022-01-24 23:00 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-01-27 17:19 ` Juri Linkov
2022-01-30 16:39 ` Juri Linkov
2022-01-30 16:59 ` Eli Zaretskii
2022-01-30 17:17 ` Juri Linkov
2022-01-30 18:17 ` Eli Zaretskii
2022-01-30 20:49 ` Juri Linkov
2021-11-16 20:30 ` Juri Linkov
2021-11-17 4:13 ` Richard Stallman
2021-11-17 10:07 ` Gregory Heytings
2021-11-17 16:39 ` bug#51883: [External] : " Drew Adams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8635ld0zq7.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=51883@debbugs.gnu.org \
--cc=gregory@heytings.org \
--cc=michael_heerdegen@web.de \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).