emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/undo-tree f93420b 038/195: Remap undo-only to undo-tree


From: Stefan Monnier
Subject: [elpa] externals/undo-tree f93420b 038/195: Remap undo-only to undo-tree-undo in undo-tree-map.
Date: Sat, 28 Nov 2020 13:41:16 -0500 (EST)

branch: externals/undo-tree
commit f93420ba3d5608c1fa948f81835dd3c5efc7564c
Author: tsc25 <tsc25@cantab.net>
Commit: tsc25 <tsc25@cantab.net>

    Remap undo-only to undo-tree-undo in undo-tree-map.
    Remap all motion commands to undo commands in visualizer.
---
 undo-tree.el | 47 ++++++++++++++++++++++++++++++-----------------
 1 file changed, 30 insertions(+), 17 deletions(-)

diff --git a/undo-tree.el b/undo-tree.el
index 3f4753f..07a2bdf 100644
--- a/undo-tree.el
+++ b/undo-tree.el
@@ -132,8 +132,8 @@
 ;;
 ;;
 ;;
-;; Explanation
-;; ===========
+;; Undo Systems
+;; ============
 ;;
 ;; To understand the different undo systems, it's easiest to consider an
 ;; example. Imagine you make a few edits in a buffer. As you edit, you
@@ -320,13 +320,12 @@
 ;; state that you want. But whatever you do, don't move around in the buffer
 ;; to check you've got back to where you want! Because you'll break the undo
 ;; chain, and then you'll have to traverse the entire string of undos again to
-;; get back to the point at which you broke the chain. Commands such as
-;; `undo-only', and undo in region (in transient-mark-mode), help to make
-;; using Emacs' undo a little easier, but nonetheless it remains confusing for
-;; many people.
+;; get back to the point at which you broke the chain. Undo in region and
+;; commands such as `undo-only' help to make using Emacs' undo a little
+;; easier, but nonetheless it remains confusing for many people.
 ;;
 ;;
-;; So what does undo-tree mode do? Remember the diagram we drew to represent
+;; So what does `undo-tree-mode' do? Remember the diagram we drew to represent
 ;; the history we've been discussing (make a few edits, undo a couple of them,
 ;; and edit again)? The diagram that conceptually represented our undo
 ;; history, before we started discussing specific undo systems? It looked like
@@ -367,13 +366,13 @@
 ;; the other hand you redo the change, you'll end up back at the bottom of the
 ;; most recent branch:
 ;;
-;;                                o
+;;                                o  (undo takes you here)
 ;;                                |
 ;;                                |
 ;;                                o  (start here)
 ;;                                |\
 ;;                                | \
-;;                                o  x  (redo)
+;;                                o  x  (redo takes you here)
 ;;                                |
 ;;                                |
 ;;                                o
@@ -421,13 +420,18 @@
 ;; possibility of switching between branches and accessing the full undo
 ;; history is still there.
 ;;
-;; Actually, it gets better. You don't have to imagine all these diagrams,
-;; because `undo-tree-mode' includes an undo-tree visualizer which draws them
-;; for you! In fact, it draws even better diagrams: it highlights the node
-;; representing the current buffer state, it highlights the current branch,
-;; and it can optionally display time-stamps for each buffer state. (There's
-;; one other tiny difference: the visualizer puts the most recent branch on
-;; the left rather than the right.)
+;;
+;;
+;; The Undo-Tree Visualizer
+;; ========================
+;;
+;; Actually, it gets better. You don't have to imagine all these tree
+;; diagrams, because `undo-tree-mode' includes an undo-tree visualizer which
+;; draws them for you! In fact, it draws even better diagrams: it highlights
+;; the node representing the current buffer state, it highlights the current
+;; branch, and you can toggle the display of time-stamps for each buffer
+;; state. (There's one other tiny difference: the visualizer puts the most
+;; recent branch on the left rather than the right.)
 ;;
 ;;
 ;;
@@ -563,8 +567,9 @@ in visualizer."
 
 (unless undo-tree-map
   (setq undo-tree-map (make-sparse-keymap))
-  ;; remap `undo' to `undo-tree-undo'
+  ;; remap `undo' and `undo-only' to `undo-tree-undo'
   (define-key undo-tree-map [remap undo] 'undo-tree-undo)
+  (define-key undo-tree-map [remap undo-only] 'undo-tree-undo)
   ;; bind standard undo bindings (since these match redo counterparts)
   (define-key undo-tree-map (kbd "C-/") 'undo-tree-undo)
   (define-key undo-tree-map "\C-_" 'undo-tree-undo)
@@ -580,6 +585,10 @@ in visualizer."
 (unless undo-tree-visualizer-map
   (setq undo-tree-visualizer-map (make-keymap))
   ;; vertical motion keys undo/redo
+  (define-key undo-tree-visualizer-map [remap previous-line]
+    'undo-tree-visualize-undo)
+  (define-key undo-tree-visualizer-map [remap next-line]
+    'undo-tree-visualize-redo)
   (define-key undo-tree-visualizer-map [up]
     'undo-tree-visualize-undo)
   (define-key undo-tree-visualizer-map "p"
@@ -593,6 +602,10 @@ in visualizer."
   (define-key undo-tree-visualizer-map "\C-n"
     'undo-tree-visualize-redo)
   ;; horizontal motion keys switch branch
+  (define-key undo-tree-visualizer-map [remap forward-char]
+    'undo-tree-visualize-switch-branch-right)
+  (define-key undo-tree-visualizer-map [remap backward-char]
+    'undo-tree-visualize-switch-branch-left)
   (define-key undo-tree-visualizer-map [right]
     'undo-tree-visualize-switch-branch-right)
   (define-key undo-tree-visualizer-map "f"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]