When undoing you can press Ctrl-G to redo.
This runs keyboard-quit
which signals quit
.
However this isn't convenient because as far as I know you can't run commands after keyboard-quit.
Is there a more direct way to break the undo chain, or a way to run keyboard-quit
so you can keep calling functions after it?
I tried this for an undo/redo that doesn't require explicit Ctrl-G.
(defvar-local my-undo-is-redo nil)
(defun my-redo ()
(interactive)
(let ((inhibit-quit t))
(unless my-undo-is-redo (with-local-quit (keyboard-quit)))
;; redo continued...
(undo)
(setq my-undo-is-redo t)))
(defun my-undo-only ()
(interactive)
(undo-only)
(setq my-undo-is-redo nil))
(define-key evil-normal-state-map (kbd "u") 'my-undo-only)
(define-key evil-normal-state-map (kbd "C-r") 'my-redo)
(let ((inhibit-quit t)) (with-local-quit ... (command-where-quit-might-occur) ...) (function-after-it))
.(setq last-command 'ignore)
to break the the undo chain. But then the redo chain gets broken too so it doesn't work very well...<up>
,<down>
,<left>
, and<right>
. I switched toundo-tree
and never went back. Always when I test code withemacs -Q
I notice how much I like undo-tree more than the standard undo system of Emacs.