* [Feature request] I suggest delete-frame command can prompt user for confirmation
@ 2021-11-14 2:59 Christopher M. Miles
2021-11-15 1:15 ` Michael Heerdegen
0 siblings, 1 reply; 9+ messages in thread
From: Christopher M. Miles @ 2021-11-14 2:59 UTC (permalink / raw)
To: Emacs Help
[-- Attachment #1: Type: text/plain, Size: 949 bytes --]
I found I always accidentally confused [C-x 5 0] and [C-x 5 o] keybindings. I hope Emacs can add add
prompt confirmation to avoid user accidentally delete frame. Because it can't undo with winner
package etc.
#+begin_src emacs-lisp
(defun my/delete-frame-confirm (origin-func &optional args)
"Ask user to confirm whether really delete frame.
To avoid accidentally [C-x 5 0] delete frame which confused with keybinding [C-x 5 o]."
(if (yes-or-no-p "Are you sure to delete current frame? ")
(apply origin-func args)
(message "I don't want to delete frame accidently!")))
(advice-add 'delete-frame :around #'my/delete-frame-confirm)
#+end_src
What do you think?
--
[ stardiviner ]
I try to make every word tell the meaning that I want to express.
Blog: https://stardiviner.github.io/
IRC(freenode): stardiviner, Matrix: stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Feature request] I suggest delete-frame command can prompt user for confirmation
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
0 siblings, 1 reply; 9+ messages in thread
From: Michael Heerdegen @ 2021-11-15 1:15 UTC (permalink / raw)
To: help-gnu-emacs
"Christopher M. Miles" <numbchild@gmail.com> writes:
> #+begin_src emacs-lisp
> (defun my/delete-frame-confirm (origin-func &optional args)
> "Ask user to confirm whether really delete frame.
> To avoid accidentally [C-x 5 0] delete frame which confused with keybinding [C-x 5 o]."
> (if (yes-or-no-p "Are you sure to delete current frame? ")
> (apply origin-func args)
> (message "I don't want to delete frame accidently!")))
>
> (advice-add 'delete-frame :around #'my/delete-frame-confirm)
> #+end_src
>
> What do you think?
I think it would be annoying and soon you would as often accidentally
say "yes" as you accidentally close frames now. At least I can say that
it would not work for me.
Wouldn't it be much more useful to be able to restore a killed frame?
Michael.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Feature request] I suggest delete-frame command can prompt user for confirmation
2021-11-15 1:15 ` Michael Heerdegen
@ 2021-11-15 3:04 ` Michael Heerdegen
2021-11-15 3:39 ` [External] : " Drew Adams
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Michael Heerdegen @ 2021-11-15 3:04 UTC (permalink / raw)
To: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [External] : Re: [Feature request] I suggest delete-frame command can prompt user for confirmation
2021-11-15 3:04 ` Michael Heerdegen
@ 2021-11-15 3:39 ` Drew Adams
2021-11-15 5:24 ` Lars Ingebrigtsen
2021-11-15 15:52 ` [SOLVED] " Christopher M. Miles
2 siblings, 0 replies; 9+ messages in thread
From: Drew Adams @ 2021-11-15 3:39 UTC (permalink / raw)
To: Michael Heerdegen, help-gnu-emacs@gnu.org
Depending on what's really needed, you can also
just make a frame invisible (and later make it
visible). You do this by changing the value of
frame parameter `visibility'.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [Feature request] I suggest delete-frame command can prompt user for confirmation
2021-11-15 3:04 ` Michael Heerdegen
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-15 15:52 ` [SOLVED] " Christopher M. Miles
2 siblings, 2 replies; 9+ messages in thread
From: Lars Ingebrigtsen @ 2021-11-15 5:24 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
Michael Heerdegen <michael_heerdegen@web.de> writes:
> 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?
[...]
> (defun my-restore-killed-frame (&optional n)
> (interactive "p")
> (let ((frames-before (frame-list)))
Perhaps Emacs should have this command built-in? Sounds generally
useful to me.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 9+ messages in thread
* [SOLVED] Re: [Feature request] I suggest delete-frame command can prompt user for confirmation
2021-11-15 3:04 ` Michael Heerdegen
2021-11-15 3:39 ` [External] : " Drew Adams
2021-11-15 5:24 ` Lars Ingebrigtsen
@ 2021-11-15 15:52 ` Christopher M. Miles
2 siblings, 0 replies; 9+ messages in thread
From: Christopher M. Miles @ 2021-11-15 15:52 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: help-gnu-emacs
[-- Attachment #1: Type: text/plain, Size: 1487 bytes --]
This is great. Have a way to restore killed frame will be a good replacement for my suggestion.
Thanks for your sharing. Michael.
Michael Heerdegen <michael_heerdegen@web.de> writes:
> 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.
--
[ stardiviner ]
I try to make every word tell the meaning that I want to express.
Blog: https://stardiviner.github.io/
IRC(freenode): stardiviner, Matrix: stardiviner
GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-11-17 10:06 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).