From: Juri Linkov <juri@linkov.net>
To: emacs-devel@gnu.org
Subject: Undo mode
Date: Thu, 20 Jan 2022 22:45:00 +0200 [thread overview]
Message-ID: <86tudyw1ir.fsf@mail.linkov.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 816 bytes --]
It would be more convenient to have a special mode `undo-mode'
that is disabled by default.
To enable undo-mode, it will possible to select from the main menu:
Edit >
Enable Undo Mode
Then after enabling it, more menu items will appear on the menu:
Edit >
Disable Undo Mode
Undo
Redo
Also the current number of undo-limit will be hard-coded
for more convenience:
diff --git a/src/undo.c b/src/undo.c
index 5d705945c4..510d6e8692 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -386,7 +386,7 @@ truncate_undo_list (struct buffer *b)
if (size_so_far > undo_strong_limit)
break;
last_boundary = prev;
- if (size_so_far > undo_limit)
+ if (size_so_far > 160000)
break;
}
Does this make sense?
If not, wouldn't be more preferable the following patch
that does the opposite?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: undelete-frame-max.patch --]
[-- Type: text/x-diff, Size: 8199 bytes --]
diff --git a/lisp/frame.el b/lisp/frame.el
index 5926a4d748..599ffe591a 100644
--- b/lisp/frame.el
+++ a/lisp/frame.el
@@ -2529,6 +2529,13 @@
(if iconify (iconify-frame this) (delete-frame this)))
(setq this next))))
+\f
+(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
@@ -2536,7 +2543,7 @@
(defun undelete-frame--handle-delete-frame (frame)
"Save the configuration of frames deleted with `delete-frame'.
-Only the 16 most recently deleted frames are saved."
+Only the `undelete-frame-max' most recently deleted frames are saved."
(when (frame-live-p frame)
(setq undelete-frame--deleted-frames
(cons
@@ -2555,54 +2562,45 @@
(cons '(display . :never)
frameset-filter-alist))))
undelete-frame--deleted-frames))
- (if (> (length undelete-frame--deleted-frames) 16)
+ (if (> (length undelete-frame--deleted-frames) undelete-frame-max)
(setq undelete-frame--deleted-frames
(butlast undelete-frame--deleted-frames)))))
-(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)))
+(add-hook 'after-init-hook
+ (lambda ()
+ (add-hook 'delete-frame-functions
+ #'undelete-frame--handle-delete-frame -75)))
(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 16, 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 `undelete-frame-max',
+where 1 is most recently deleted frame, undelete the ARGth deleted frame.
When called from Lisp, returns the new frame."
(interactive "P")
- (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)))))))))
+ (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))))))))
\f
;;; Window dividers.
(defgroup window-divider nil
diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index e5a070b24a..36cbd6a9c5 100644
--- b/lisp/menu-bar.el
+++ a/lisp/menu-bar.el
@@ -109,14 +109,9 @@
(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 (and undelete-frame-mode
- (car undelete-frame--deleted-frames))
+ :visible (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
--- b/src/frame.c
+++ a/src/frame.c
@@ -2385,7 +2385,7 @@
doc: /* Delete FRAME, eliminating it from use.
FRAME must be a live frame and defaults to the selected one.
-When `undelete-frame-mode' is enabled, the 16 most recently deleted
+When `undelete-frame-max' is more than 0, the most recently deleted
frames can be undeleted with `undelete-frame', which see.
A frame may not be deleted if its minibuffer serves as surrogate
diff --git a/doc/emacs/frames.texi b/doc/emacs/frames.texi
index ba58f70caf..c641b8ccb1 100644
--- b/doc/emacs/frames.texi
+++ a/doc/emacs/frames.texi
@@ -515,12 +515,14 @@
@item C-x 5 u
@kindex C-x 5 u
@findex undelete-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.
+@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.
@item C-z
@kindex C-z @r{(X windows)}
diff --git a/etc/NEWS b/etc/NEWS
index fdbfd9b1be..2e748ce7c5 100644
--- b/etc/NEWS
+++ a/etc/NEWS
@@ -287,11 +287,12 @@
+++
*** Deleted frames can now be undeleted.
-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.
+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.
next reply other threads:[~2022-01-20 20:45 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-20 20:45 Juri Linkov [this message]
2022-01-21 0:42 ` Undo mode Stefan Monnier
2022-01-21 8:16 ` Juri Linkov
2022-01-21 11:44 ` Eli Zaretskii
2022-01-21 13:50 ` Stefan Monnier
2022-01-21 15:07 ` Gregory Heytings
2022-01-21 1:57 ` Po Lu
2022-01-21 3:11 ` [External] : " Drew Adams
2022-01-21 3:40 ` Po Lu
2022-01-21 5:35 ` Drew Adams
2022-01-21 7:56 ` Tracking master (was: [External] : Re: Undo mode) Kévin Le Gouguec
2022-01-21 12:50 ` [External] : Re: Undo mode Stefan Monnier
2022-01-21 16:45 ` Drew Adams
2022-01-21 8:18 ` Juri Linkov
2022-01-21 8:56 ` Lars Ingebrigtsen
2022-01-21 9:15 ` Po Lu
2022-01-21 9:17 ` Lars Ingebrigtsen
2022-01-21 12:52 ` Stefan Monnier
2022-01-21 11:41 ` Eli Zaretskii
2022-01-21 7:17 ` Eli Zaretskii
2022-01-21 10:09 ` Stefan Kangas
2022-01-21 10:19 ` Gregory Heytings
2022-01-21 16:45 ` [External] : " Drew Adams
2022-01-21 11:56 ` Eli Zaretskii
2022-01-22 9:51 ` Stefan Kangas
2022-01-22 10:36 ` Eli Zaretskii
2022-01-22 12:01 ` Stefan Kangas
2022-01-21 8:41 ` Gregory Heytings
2022-01-21 9:40 ` Po Lu
2022-01-21 9:57 ` Gregory Heytings
2022-01-21 10:19 ` Po Lu
2022-01-21 10:26 ` Gregory Heytings
2022-01-21 10:34 ` Po Lu
2022-01-21 10:45 ` Gregory Heytings
2022-01-21 10:51 ` Po Lu
2022-01-21 12:10 ` Eli Zaretskii
2022-01-21 11:58 ` Eli Zaretskii
2022-01-21 13:50 ` Gregory Heytings
2022-01-21 14:32 ` Eli Zaretskii
2022-01-21 14:48 ` Gregory Heytings
2022-01-21 19:41 ` Eli Zaretskii
2022-01-21 20:58 ` Gregory Heytings
2022-01-22 0:47 ` Po Lu
2022-01-22 7:11 ` Eli Zaretskii
2022-01-22 8:32 ` Gregory Heytings
2022-01-22 8:52 ` Eli Zaretskii
2022-01-22 9:08 ` Gregory Heytings
2022-01-22 9:47 ` Po Lu
2022-01-22 9:51 ` Stefan Kangas
2022-01-22 9:58 ` Po Lu
2022-01-22 10:32 ` Eli Zaretskii
2022-01-22 11:15 ` Gregory Heytings
2022-01-22 11:18 ` Eli Zaretskii
2022-01-22 13:37 ` Gregory Heytings
2022-01-21 11:48 ` Eli Zaretskii
2022-01-21 13:18 ` Yuri Khan
2022-01-21 14:29 ` Eli Zaretskii
2022-01-21 15:07 ` Yuri Khan
2022-01-21 19:22 ` Eli Zaretskii
2022-01-21 16:46 ` [External] : " Drew Adams
2022-01-22 18:04 ` Juri Linkov
2022-01-21 8:55 ` Lars Ingebrigtsen
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86tudyw1ir.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=emacs-devel@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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.