[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/undo-tree 98dbabd 125/195: Implement visualizer command
From: |
Stefan Monnier |
Subject: |
[elpa] externals/undo-tree 98dbabd 125/195: Implement visualizer commands to redo/undo to branch/register. |
Date: |
Sat, 28 Nov 2020 13:41:36 -0500 (EST) |
branch: externals/undo-tree
commit 98dbabd9e22e41fa537a1cddea41a052e41e6e95
Author: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>
Commit: Toby S. Cubitt <toby-undo-tree@dr-qubit.org>
Implement visualizer commands to redo/undo to branch/register.
---
undo-tree.el | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 75 insertions(+), 1 deletion(-)
diff --git a/undo-tree.el b/undo-tree.el
index 8e57829..91f202d 100644
--- a/undo-tree.el
+++ b/undo-tree.el
@@ -118,6 +118,15 @@
;; <right> f C-f (`undo-tree-visualize-switch-branch-right')
;; Switch to next undo-tree branch.
;;
+;; C-<up> M-{ (`undo-tree-visualize-undo-to-x')
+;; Undo changes up to last branch point.
+;;
+;; C-<down> M-} (`undo-tree-visualize-redo-to-x')
+;; Redo changes down to next branch point.
+;;
+;; <down> n C-n (`undo-tree-visualize-redo')
+;; Redo changes.
+;;
;; <mouse-1> (`undo-tree-visualizer-mouse-set')
;; Set state to node at mouse click.
;;
@@ -994,8 +1003,9 @@ in visualizer."
(defconst undo-tree-visualizer-buffer-name " *undo-tree*")
(defconst undo-tree-diff-buffer-name "*undo-tree Diff*")
-;; prevent debugger being called on "No further redo information"
+;; prevent debugger being called on "No further redo information" errors
(add-to-list 'debug-ignored-errors "^No further redo information")
+(add-to-list 'debug-ignored-errors "^No further redo information for region")
;; Install history-auto-save hooks
@@ -1058,6 +1068,13 @@ in visualizer."
(define-key map [left] 'undo-tree-visualize-switch-branch-left)
(define-key map "b" 'undo-tree-visualize-switch-branch-left)
(define-key map "\C-b" 'undo-tree-visualize-switch-branch-left)
+ ;; paragraph motion keys undo/redo to significant points in tree
+ (define-key map [remap backward-paragraph] 'undo-tree-visualize-undo-to-x)
+ (define-key map [remap forward-paragraph] 'undo-tree-visualize-redo-to-x)
+ (define-key map "\M-{" 'undo-tree-visualize-undo-to-x)
+ (define-key map "\M-}" 'undo-tree-visualize-redo-to-x)
+ (define-key map [C-down] 'undo-tree-visualize-undo-to-x)
+ (define-key map [C-up] 'undo-tree-visualize-redo-to-x)
;; mouse sets buffer state to node at click
(define-key map [mouse-1] 'undo-tree-visualizer-mouse-set)
;; toggle timestamps
@@ -3549,6 +3566,63 @@ at mouse event POS."
(undo-tree-visualizer-set (event-start (nth 1 pos))))
+(defun undo-tree-visualize-undo-to-x (&optional x)
+ "Undo to last branch point or register.
+If X is 'branch, undo to last branch point ignoring registers. If
+X is 'register, undo to last register, ignoring branch points.
+
+Interactively, a positive prefix argument specifies `branch', and
+a negative prefix argument specifies `register'."
+ (interactive "P")
+ (when (and (called-interactively-p 'any) x)
+ (setq x (prefix-numeric-value x)
+ x (if (> x 0) 'branch 'register)))
+ (let ((current (undo-tree-current buffer-undo-tree))
+ r)
+ (while (and (undo-tree-node-previous current)
+ (or (undo-tree-visualize-undo) t)
+ (setq current (undo-tree-current buffer-undo-tree))
+ ;; branch point
+ (not (or (and (or (null x) (eq x 'branch))
+ (> (undo-tree-num-branches) 1))
+ ;; register
+ (and (or (null x) (eq x 'register))
+ (setq r (undo-tree-node-register current))
+ (undo-tree-register-data-p
+ (setq r (registerv-data (get-register r))))
+ (eq current (undo-tree-register-data-node r)))
+ ))))))
+
+
+(defun undo-tree-visualize-redo-to-x (&optional x)
+ "Redo to next branch point or register.
+If X is the symbol `branch', redo to next branch point ignoring
+registers. If X is the symbol 'register', redo to next register,
+ignoring branch points.
+
+Interactively, a positive prefix argument specifies `branch', and
+a negative prefix argument specifies `register'."
+ (interactive "P")
+ (when (and (called-interactively-p 'any) x)
+ (setq x (prefix-numeric-value x)
+ x (if (> x 0) 'branch 'register)))
+ (let ((current (undo-tree-current buffer-undo-tree))
+ r)
+ (while (and (undo-tree-node-next current)
+ (or (undo-tree-visualize-redo) t)
+ (setq current (undo-tree-current buffer-undo-tree))
+ ;; branch point
+ (not (or (and (or (null x) (eq x 'branch))
+ (> (undo-tree-num-branches) 1))
+ ;; register
+ (and (or (null x) (eq x 'register))
+ (setq r (undo-tree-node-register current))
+ (undo-tree-register-data-p
+ (setq r (registerv-data (get-register r))))
+ (eq current (undo-tree-register-data-node r)))
+ ))))))
+
+
(defun undo-tree-visualizer-toggle-timestamps ()
"Toggle display of time-stamps."
(interactive)
- [elpa] externals/undo-tree 95599db 100/195: Fixed bug in visualizer selection mode when timestamps are displayed., (continued)
- [elpa] externals/undo-tree 95599db 100/195: Fixed bug in visualizer selection mode when timestamps are displayed., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 81f1417 098/195: Added diff-no-select and diff-file-local-copy compatibility hacks, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree aa7202c 103/195: Fix the way keymaps are defined., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree e69adb3 109/195: Remove now unnecessary compatibility hack for called-interactively-p., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 00ffbb6 121/195: Bump version number below which we warn against enabling persistent storage., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 5df6374 128/195: Switch to lexical binding., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 9b55464 126/195: Make undo history filename match docs., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree f566beb 106/195: Add customization option allowing timestamps to be displayed by default, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree f3e0d93 119/195: Remove ChangeLog section from package headers., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 36b341b 112/195: Cope better if undo boundary before undo-tree-canary is missing., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 98dbabd 125/195: Implement visualizer commands to redo/undo to branch/register.,
Stefan Monnier <=
- [elpa] externals/undo-tree 85efe23 116/195: Ensure auto-compression-mode is enabled when reading undo history file., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 181e84b 124/195: Minor bug fix and tweak to visualizer register display., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 0ba2d37 122/195: Fix bug in undo-tree-clear-visualizer-data., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 443d74c 111/195: Avoid triggering error when saving undo history when there's nothing to save., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 5d06288 130/195: Implement lazy undo-tree drawing in visualizer., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 4c14173 115/195: Fix undo history auto-saving., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree e352286 131/195: Fix incompatiblity with newer high-resolution timestamps., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 0ba9a0f 134/195: Bump version number., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 17d2dee 141/195: Switch order of diff comparision in diff display., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree ffb7c02 140/195: Set inhibit-read-only when creating diff view., Stefan Monnier, 2020/11/28