From: Michael Heerdegen <michael_heerdegen@web.de>
To: help-gnu-emacs@gnu.org
Subject: Re: [Feature request] I suggest delete-frame command can prompt user for confirmation
Date: Mon, 15 Nov 2021 04:04:12 +0100 [thread overview]
Message-ID: <874k8ektlf.fsf@web.de> (raw)
In-Reply-To: 878rxqte1m.fsf@web.de
Michael Heerdegen <michael_heerdegen@web.de> writes:
> Wouldn't it be much more useful to be able to restore a killed frame?
Like this maybe?
#+begin_src emacs-lisp
(require 'frameset)
(require 'cl-lib)
(defvar my-killed-frame-ring-size 10)
(defvar my-killed-frames (make-ring my-killed-frame-ring-size))
(advice-add 'delete-frame :before #'my-remember-deleted-frame)
(defun my-remember-deleted-frame (&optional frame _force)
(ring-insert my-killed-frames
(frameset-save (list (or frame (selected-frame))))))
(defun my-restore-killed-frame (&optional n)
(interactive "p")
(let ((frames-before (frame-list)))
(frameset-restore (ring-ref my-killed-frames (- (or n 1) 1)))
(let ((restored (cl-set-difference (frame-list) frames-before)))
(when (and restored (not (cdr restored)))
(select-frame-set-input-focus (car restored))))))
(global-set-key [?\C-x ?5 ?t] #'my-restore-killed-frame)
#+end_src
Michael.
next prev parent reply other threads:[~2021-11-15 3:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-14 2:59 [Feature request] I suggest delete-frame command can prompt user for confirmation Christopher M. Miles
2021-11-15 1:15 ` Michael Heerdegen
2021-11-15 3:04 ` Michael Heerdegen [this message]
2021-11-15 3:39 ` [External] : " Drew Adams
2021-11-15 5:24 ` Lars Ingebrigtsen
2021-11-15 16:00 ` Vote for a Emacs built-in command to undo/restore killed frame Christopher M. Miles
2021-11-15 23:43 ` [Feature request] I suggest delete-frame command can prompt user for confirmation Michael Heerdegen
2021-11-17 10:06 ` Christopher M. Miles
2021-11-15 15:52 ` [SOLVED] " Christopher M. Miles
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=874k8ektlf.fsf@web.de \
--to=michael_heerdegen@web.de \
--cc=help-gnu-emacs@gnu.org \
/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.
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).