[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/undo-tree f3fc5cd 037/195: Modified undo-tree-undo/redo
From: |
Stefan Monnier |
Subject: |
[elpa] externals/undo-tree f3fc5cd 037/195: Modified undo-tree-undo/redo to always replace redo/undo entries |
Date: |
Sat, 28 Nov 2020 13:41:16 -0500 (EST) |
branch: externals/undo-tree
commit f3fc5cd6ec3d689d81b59f12d0b8a958f53db569
Author: tsc25 <tsc25@cantab.net>
Commit: tsc25 <tsc25@cantab.net>
Modified undo-tree-undo/redo to always replace redo/undo entries
with new ones generated by primitive-undo, as the new changesets will
restore
the point more reliably.
---
undo-tree.el | 52 ++++++++++++++++++++++++++++++----------------------
1 file changed, 30 insertions(+), 22 deletions(-)
diff --git a/undo-tree.el b/undo-tree.el
index cdc8eb8..3f4753f 100644
--- a/undo-tree.el
+++ b/undo-tree.el
@@ -5,7 +5,7 @@
;; Copyright (C) 2009 Toby Cubitt
;; Author: Toby Cubitt <toby-undo-tree@dr-qubit.org>
-;; Version: 0.1.3
+;; Version: 0.1.4
;; Keywords: undo, redo, history, tree
;; URL: http://www.dr-qubit.org/emacs.php
@@ -458,6 +458,11 @@
;;; Change Log:
;;
+;; Version 0.1.4
+;; * modified `undo-tree-undo' and `undo-tree-redo' to always replace
+;; redo/undo entries with new ones generated by `primitive-undo', as the new
+;; changesets will restore the point more reliably
+;;
;; Version 0.1.3
;; * fixed `undo-tree-visualizer-quit' to remove `after-change-functions'
;; hook there, rather than in `undo-tree-kill-visualizer'
@@ -1054,8 +1059,9 @@ which is defined in the `warnings' library.\n")
(setq node (undo-tree-grow-backwards node nil))
(setf (undo-tree-root buffer-undo-tree) node)
(setq buffer-undo-list '(nil undo-tree-canary))
- (setf (undo-tree-size buffer-undo-tree) size))
- ))))
+ (setf (undo-tree-size buffer-undo-tree) size)))
+ ;; discard undo history if necessary
+ (undo-tree-discard-history))))
(defun undo-list-byte-size (undo-list)
@@ -1133,15 +1139,17 @@ Within the undo-tree visualizer, the following keys are
available:
(undo-tree-node-undo
(undo-tree-current buffer-undo-tree))))
;; pop redo entries that `primitive-undo' has added to
- ;; `buffer-undo-list' and record them in current node's redo record if
- ;; they're not already there
- (if (undo-tree-node-redo (undo-tree-current buffer-undo-tree))
- (undo-list-pop-changeset)
- (setf (undo-tree-node-redo (undo-tree-current buffer-undo-tree))
- (undo-list-pop-changeset))
- (incf (undo-tree-size buffer-undo-tree)
- (undo-list-byte-size
- (undo-tree-node-redo (undo-tree-current buffer-undo-tree)))))
+ ;; `buffer-undo-list' and record them in current node's redo record,
+ ;; replacing existing entry if one already exists
+ (when (undo-tree-node-redo (undo-tree-current buffer-undo-tree))
+ (decf (undo-tree-size buffer-undo-tree)
+ (undo-list-byte-size
+ (undo-tree-node-redo (undo-tree-current buffer-undo-tree)))))
+ (setf (undo-tree-node-redo (undo-tree-current buffer-undo-tree))
+ (undo-list-pop-changeset))
+ (incf (undo-tree-size buffer-undo-tree)
+ (undo-list-byte-size
+ (undo-tree-node-redo (undo-tree-current buffer-undo-tree))))
;; rewind current node
(setf (undo-tree-current buffer-undo-tree)
(undo-tree-node-previous (undo-tree-current buffer-undo-tree)))
@@ -1149,8 +1157,6 @@ Within the undo-tree visualizer, the following keys are
available:
(setf (undo-tree-node-timestamp (undo-tree-current buffer-undo-tree))
(current-time))))
- ;; discard undo history if necessary
- (undo-tree-discard-history)
;; inform user if at branch point
(when (> (undo-tree-num-branches) 1) (message "Undo branch point!"))))
@@ -1184,14 +1190,16 @@ Within the undo-tree visualizer, the following keys are
available:
(setf (undo-tree-node-timestamp current) (current-time))
;; redo one record from undo tree
(primitive-undo 1 (undo-copy-list (undo-tree-node-redo current)))
- ;; discard undo entries that `primitive-undo' has added to
- ;; `buffer-undo-list' since we already know how to undo from here
- ;; (NOTE: should we instead overwrite old undo entry for safety's
- ;; sake?)
- (setq buffer-undo-list '(nil undo-tree-canary)))))
-
- ;; discard undo history if necessary
- (undo-tree-discard-history)
+ ;; pop undo entries that `primitive-undo' has added to
+ ;; `buffer-undo-list' and record them in current node's undo record,
+ ;; replacing existing entry if one already exists
+ (when (undo-tree-node-undo current)
+ (decf (undo-tree-size buffer-undo-tree)
+ (undo-list-byte-size (undo-tree-node-undo current))))
+ (setf (undo-tree-node-undo current) (undo-list-pop-changeset))
+ (incf (undo-tree-size buffer-undo-tree)
+ (undo-list-byte-size (undo-tree-node-undo current))))))
+
;; inform user if at branch point
(when (> (undo-tree-num-branches) 1) (message "Undo branch point!"))))
- [elpa] externals/undo-tree 50ccefd 043/195: Fixed bug in undo-tree-discard-node., (continued)
- [elpa] externals/undo-tree 50ccefd 043/195: Fixed bug in undo-tree-discard-node., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree fd3fc5c 046/195: Pass null argument to kill-buffer call in undo-tree-visualizer-quit,, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 45751ef 050/195: Fixed bug in undo-tree-switch-branch., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree f454e88 001/195: Started project to add vim-like undo tree handling to emacs., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree b2eab5a 016/195: Made visualizer buffer read-only., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 4877b0f 008/195: Added markers to record positions of nodes in visualizer., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 7f3c87d 030/195: Added installation instructions to commentary, and keybinding documentation, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree c8b2659 032/195: Prevented undo-tree-kill-visualizer from killing visualizer when undoing/redoing, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree c041ce8 033/195: Added missing (eval-when-compile (require 'cl)) line., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 3b1a83f 036/195: Fixed undo-tree-visualizer-quit to make it remove kill visualizer hook, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree f3fc5cd 037/195: Modified undo-tree-undo/redo to always replace redo/undo entries,
Stefan Monnier <=
- [elpa] externals/undo-tree f93420b 038/195: Remap undo-only to undo-tree-undo in undo-tree-map., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree f8c3abf 039/195: Replaced save-excursion's with with-current-buffer., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 723eeeb 040/195: Improved undo-tree-visualizer-quit behaviour, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 8871f91 041/195: Added header containing git repository URL., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 3f5cc71 045/195: Updated commentary to include register commands,, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 5176770 047/195: Added missing Change Log entry., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree f44688d 048/195: Prevent debugger being called on "No further redo information" error., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree bff9f31 049/195: Made undo-tree-visualizer-quit select window displaying parent buffer, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 04b1a6f 054/195: Fixed bugs in history-discarding logic., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 227473a 058/195: Modified undo-tree-node defstruct and macros to allow arbitrary meta-data, Stefan Monnier, 2020/11/28