[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 8cc1b9035c 2/2: Revert "Add undelete-frame-max instead of undelet
From: |
Eli Zaretskii |
Subject: |
master 8cc1b9035c 2/2: Revert "Add undelete-frame-max instead of undelete-frame-mode (bug#51883)" |
Date: |
Mon, 17 Jan 2022 07:53:07 -0500 (EST) |
branch: master
commit 8cc1b9035cbe12c684139de0ad1590661ea45c3c
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>
Revert "Add undelete-frame-max instead of undelete-frame-mode (bug#51883)"
This reverts commit 714e11d53534416b6519396a9df5d62054731810.
That commit was unilateral and disregarded past discussions.
---
doc/emacs/frames.texi | 14 ++++-----
etc/NEWS | 11 ++++---
lisp/frame.el | 80 ++++++++++++++++++++++++++-------------------------
lisp/menu-bar.el | 7 ++++-
src/frame.c | 2 +-
5 files changed, 59 insertions(+), 55 deletions(-)
diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi
index ba58f70caf..c641b8ccb1 100644
--- a/doc/emacs/frames.texi
+++ b/doc/emacs/frames.texi
@@ -515,14 +515,12 @@ error if there is only one frame.
@item C-x 5 u
@kindex C-x 5 u
@findex undelete-frame
-@findex undelete-frame-max
-Undelete one of the recently deleted frames. The user option
-@code{undelete-frame-max} specifies the maximum number of deleted
-frames to keep (the default is 1). Without a prefix argument,
-undelete the most recently deleted frame. With a numerical prefix
-argument between 1 and the number specified by @code{undelete-frame-max},
-where 1 is the most recently deleted frame, undelete the corresponding
-deleted frame.
+@findex undelete-frame-mode
+When @code{undelete-frame-mode} is enabled, undelete one of the 16
+most recently deleted frames. Without a prefix argument, undelete the
+most recently deleted frame. With a numerical prefix argument between
+1 and 16, where 1 is the most recently deleted frame, undelete the
+corresponding deleted frame.
@item C-z
@kindex C-z @r{(X windows)}
diff --git a/etc/NEWS b/etc/NEWS
index fdbfd9b1be..2e748ce7c5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -287,12 +287,11 @@ height use 'window-height' in combination with
'body-lines'.
+++
*** Deleted frames can now be undeleted.
-The most recently deleted frame can be undeleted with 'C-x 5 u' when
-the new user option 'undelete-frame-max' has its default value 1.
-Without a prefix argument, undelete the most recently deleted frame.
-With a numerical prefix argument between 1 and 'undelete-frame-max',
-where 1 is the most recently deleted frame, undelete the corresponding
-deleted frame.
+The 16 most recently deleted frames can be undeleted with 'C-x 5 u' when
+'undelete-frame-mode' is enabled. Without a prefix argument, undelete
+the most recently deleted frame. With a numerical prefix argument
+between 1 and 16, where 1 is the most recently deleted frame, undelete
+the corresponding deleted frame.
** Tab Bars and Tab Lines
diff --git a/lisp/frame.el b/lisp/frame.el
index 5926a4d748..599ffe591a 100644
--- a/lisp/frame.el
+++ b/lisp/frame.el
@@ -2529,13 +2529,6 @@ deleting them."
(if iconify (iconify-frame this) (delete-frame this)))
(setq this next))))
-
-(defcustom undelete-frame-max 1
- "Maximum number of deleted frames before oldest are thrown away."
- :type 'integer
- :group 'frames
- :version "29.1")
-
(eval-when-compile (require 'frameset))
(defvar undelete-frame--deleted-frames nil
@@ -2543,7 +2536,7 @@ deleting them."
(defun undelete-frame--handle-delete-frame (frame)
"Save the configuration of frames deleted with `delete-frame'.
-Only the `undelete-frame-max' most recently deleted frames are saved."
+Only the 16 most recently deleted frames are saved."
(when (frame-live-p frame)
(setq undelete-frame--deleted-frames
(cons
@@ -2562,45 +2555,54 @@ Only the `undelete-frame-max' most recently deleted
frames are saved."
(cons '(display . :never)
frameset-filter-alist))))
undelete-frame--deleted-frames))
- (if (> (length undelete-frame--deleted-frames) undelete-frame-max)
+ (if (> (length undelete-frame--deleted-frames) 16)
(setq undelete-frame--deleted-frames
(butlast undelete-frame--deleted-frames)))))
-(add-hook 'after-init-hook
- (lambda ()
- (add-hook 'delete-frame-functions
- #'undelete-frame--handle-delete-frame -75)))
+(define-minor-mode undelete-frame-mode
+ "Enable the `undelete-frame' command."
+ :group 'frames
+ :global t
+ (if undelete-frame-mode
+ (add-hook 'delete-frame-functions
+ #'undelete-frame--handle-delete-frame -75)
+ (remove-hook 'delete-frame-functions
+ #'undelete-frame--handle-delete-frame)
+ (setq undelete-frame--deleted-frames nil)))
(defun undelete-frame (&optional arg)
"Undelete a frame deleted with `delete-frame'.
-Without a prefix argument, undelete the most recently deleted frame.
-With a numerical prefix argument ARG between 1 and `undelete-frame-max',
-where 1 is most recently deleted frame, undelete the ARGth deleted frame.
+Without a prefix argument, undelete the most recently deleted
+frame.
+With a numerical prefix argument ARG between 1 and 16, where 1 is
+most recently deleted frame, undelete the ARGth deleted frame.
When called from Lisp, returns the new frame."
(interactive "P")
- (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))
- (graphic (display-graphic-p)))
- (if (not (<= 1 number undelete-frame-max))
- (user-error "%d is not a valid deleted frame number argument"
- number)
- (if (not frameset)
- (user-error "No deleted frame with number %d" number)
- (if (not (eq graphic (car frameset)))
- (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))))))))
+ (if (not undelete-frame-mode)
+ (user-error "Undelete-Frame mode is disabled")
+ (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))
+ (graphic (display-graphic-p)))
+ (if (not (<= 1 number 16))
+ (user-error "%d is not a valid deleted frame number argument"
+ number)
+ (if (not frameset)
+ (user-error "No deleted frame with number %d" number)
+ (if (not (eq graphic (car frameset)))
+ (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)))))))))
;;; Window dividers.
(defgroup window-divider nil
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index e5a070b24a..36cbd6a9c5 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -109,9 +109,14 @@
(bindings--define-key menu [separator-tab]
menu-bar-separator))
+ (bindings--define-key menu [enable-undelete-frame-mode]
+ '(menu-item "Enable Undeleting Frames" undelete-frame-mode
+ :visible (null undelete-frame-mode)
+ :help "Enable undeleting frames in this session"))
(bindings--define-key menu [undelete-last-deleted-frame]
'(menu-item "Undelete Frame" undelete-frame
- :visible (car undelete-frame--deleted-frames)
+ :visible (and undelete-frame-mode
+ (car undelete-frame--deleted-frames))
:help "Undelete the most recently deleted frame"))
;; Don't use delete-frame as event name because that is a special
diff --git a/src/frame.c b/src/frame.c
index 959f0c9c14..e5d74edc16 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -2385,7 +2385,7 @@ DEFUN ("delete-frame", Fdelete_frame, Sdelete_frame, 0,
2, "",
doc: /* Delete FRAME, eliminating it from use.
FRAME must be a live frame and defaults to the selected one.
-When `undelete-frame-max' is more than 0, the most recently deleted
+When `undelete-frame-mode' is enabled, the 16 most recently deleted
frames can be undeleted with `undelete-frame', which see.
A frame may not be deleted if its minibuffer serves as surrogate