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.