unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Adding a binding for 'undo-redo'
@ 2021-09-29  1:56 Dmitry Gutov
  2021-09-29  5:38 ` Lars Ingebrigtsen
  2021-09-29 16:25 ` [External] : " Drew Adams
  0 siblings, 2 replies; 16+ messages in thread
From: Dmitry Gutov @ 2021-09-29  1:56 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 604 bytes --]

Hi all,

This discussion has been living in a subthread, but I think it deserves 
a separate one, for all to see.

The main technical hurdle to adding this binding was the lack of a good 
binding, but Richard suggested C-? and C-M-_, which should cover both 
GUI Emacs and tty. This change doesn't change the existing 'undo' 
binding, so it's not going to break anybody's workflow. But it adds a 
key combination we can recommend to the users who are accustomed to 
separate 'undo' and 'redo' commands.

WDYT? Should we add this to Emacs 28?

A follow-up patch could add 'undo-redo' to cua-mode as well.

[-- Attachment #2: undo-redo-bindings.diff --]
[-- Type: text/x-patch, Size: 1680 bytes --]

diff --git a/etc/NEWS b/etc/NEWS
index 21cc3c50cd..6b1e74eddd 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -957,7 +957,11 @@ for CJK text mixed with Latin text.
 +++
 ** New command 'undo-redo'.
 It undoes previous undo commands, but doesn't record itself as an
-undoable command.
+undoable command. It is bound to 'C-?' and 'C-M-_', the first binding
+works well in graphical mode, and the second one is easy to hit on tty.
+
+For full conventional undo/redo behavior, you can also customize the
+user option 'undo-no-redo' to t.
 
 +++
 ** New commands 'copy-matching-lines' and 'kill-matching-lines'.
diff --git a/lisp/bindings.el b/lisp/bindings.el
index 343f1ba0fa..9a3505058c 100644
--- a/lisp/bindings.el
+++ b/lisp/bindings.el
@@ -994,6 +994,9 @@ undo-repeat-map
   "Keymap to repeat undo key sequences `C-x u u'.  Used in `repeat-mode'.")
 (put 'undo 'repeat-map 'undo-repeat-map)
 
+(define-key global-map (kbd "C-?") 'undo-redo)
+(define-key global-map [?\C-\M-_] 'undo-redo)
+
 (define-key esc-map "!" 'shell-command)
 (define-key esc-map "|" 'shell-command-on-region)
 (define-key esc-map "&" 'async-shell-command)
diff --git a/lisp/simple.el b/lisp/simple.el
index dd480396f6..7eba33116d 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -2942,8 +2942,9 @@ undo-equiv-table
 (defvar undo-in-region nil
   "Non-nil if `pending-undo-list' is not just a tail of `buffer-undo-list'.")
 
-(defvar undo-no-redo nil
-  "If t, `undo' doesn't go through redo entries.")
+(defcustom undo-no-redo nil
+  "If t, `undo' doesn't go through redo entries."
+  :type 'boolean)
 
 (defvar pending-undo-list nil
   "Within a run of consecutive undo commands, list remaining to be undone.

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-09-30  7:13 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-29  1:56 Adding a binding for 'undo-redo' Dmitry Gutov
2021-09-29  5:38 ` Lars Ingebrigtsen
2021-09-29 11:26   ` Dmitry Gutov
2021-09-29 12:21     ` Bozhidar Batsov
2021-09-29 15:50     ` Lars Ingebrigtsen
2021-09-29 19:37       ` Dmitry Gutov
2021-09-29 16:26     ` [External] : " Drew Adams
2021-09-29 13:02   ` Eli Zaretskii
2021-09-29 16:25 ` [External] : " Drew Adams
2021-09-29 16:34   ` Eli Zaretskii
2021-09-29 16:46   ` Manuel Uberti
2021-09-29 17:08   ` Alfred M. Szmidt
2021-09-29 17:25     ` Drew Adams
2021-09-29 19:17       ` Dmitry Gutov
2021-09-29 19:29         ` Drew Adams
2021-09-30  7:13       ` Alfred M. Szmidt

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).