all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: emacs-devel@gnu.org
Subject: Adding a binding for 'undo-redo'
Date: Wed, 29 Sep 2021 04:56:44 +0300	[thread overview]
Message-ID: <6bb8f829-ec85-ea42-3146-c6bf8ca89495@yandex.ru> (raw)

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

             reply	other threads:[~2021-09-29  1:56 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-29  1:56 Dmitry Gutov [this message]
2021-09-29  5:38 ` Adding a binding for 'undo-redo' 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

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=6bb8f829-ec85-ea42-3146-c6bf8ca89495@yandex.ru \
    --to=dgutov@yandex.ru \
    --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.