[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/undo-tree 4dd6905 028/195: Discard marker adjustment un
From: |
Stefan Monnier |
Subject: |
[elpa] externals/undo-tree 4dd6905 028/195: Discard marker adjustment undo entries. |
Date: |
Sat, 28 Nov 2020 13:41:14 -0500 (EST) |
branch: externals/undo-tree
commit 4dd690526560c56821073bd67e2e787fe11e0c2d
Author: tsc25 <tsc25@cantab.net>
Commit: tsc25 <tsc25@cantab.net>
Discard marker adjustment undo entries.
In buffer-undo-list, these entries are treated specially by Emacs'
garbage-collection code in alloc.c (they don't count during the mark phase,
and the sweep phase deletes entries for garbage-collected markers). But we
can't emulate this behaviour from Elisp.
Discarding these entries at least prevents dead markers being resurrected by
undo-tree-mode, and allows them to be garbage-collected. Standard Emacs undo
fails to restore markers correctly anyway (byg#4803), so the impact should
hopefully be small.
---
undo-tree.el | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/undo-tree.el b/undo-tree.el
index 1e5bf25..e34f712 100644
--- a/undo-tree.el
+++ b/undo-tree.el
@@ -406,6 +406,26 @@
;; 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.)
+;;
+;;
+;;
+;; Drawbacks
+;; =========
+;;
+;; Emacs' undo system is deeply embedded in Emacs. In particular, garbage
+;; collection treats the `buffer-undo-list' specially: references to markers
+;; in `buffer-undo-list' don't count during the mark phase, and the sweep
+;; phase removes undo entries for markers that have been garbage-collected.
+;; This behaviour is implemented in C as part of the garbage collection code,
+;; and it is difficult or impossible to emulate in Elisp.
+;;
+;; To avoid dead markers being resurrected in `undo-tree-mode', and to allow
+;; them to be garbage-collected, `undo-tree-mode' doesn't record marker
+;; adjustments. Markers are rarely explicitly created by users, so the impact
+;; of this will primarily be through its effects on other features that make
+;; use of markers. However, undoing marker adjustments is anyway buggy in
+;; standard Emacs' undo (see Emacs bug#4803), so it seems plausible that
+;; relatively little code relies heavily on correct marker restoration.
@@ -913,16 +933,21 @@ which is defined in the `warnings' library.\n")
(defun undo-list-pop-changeset ()
;; Pop changeset from `buffer-undo-list'.
- ;; discard undo boundaries at head of list
- (while (null (car buffer-undo-list))
+ ;; discard undo boundaries and marker adjustment entries at head of list
+ (while (or (null (car buffer-undo-list))
+ (and (consp (car buffer-undo-list))
+ (markerp (caar buffer-undo-list))))
(setq buffer-undo-list (cdr buffer-undo-list)))
+ ;; pop elements up to next undo boundary
(unless (eq (car buffer-undo-list) 'undo-tree-canary)
- ;; pop elements up to next undo boundary
(let* ((changeset (cons (pop buffer-undo-list) nil))
(p changeset))
(while (car buffer-undo-list)
(setcdr p (cons (pop buffer-undo-list) nil))
- (setq p (cdr p)))
+ ;; discard marker adjustment entries (see Commentary, above)
+ (if (and (consp (cadr p)) (markerp (car (cadr p))))
+ (setcdr p nil)
+ (setq p (cdr p))))
changeset)))
- [elpa] externals/undo-tree 30dc485 013/195: Clear visualizer data when quitting visualizer., (continued)
- [elpa] externals/undo-tree 30dc485 013/195: Clear visualizer data when quitting visualizer., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree e0b8308 015/195: Implemented commands to set buffer state to any given undo-tree node., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 0368f0f 006/195: Implemented undo-tree visualisation., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 711dd60 003/195: Implemented undo-tree data structure and undo command., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree b15904c 023/195: Update timestamps when nodes are visited by undo/redo., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 21d3c89 004/195: Implemented redo command., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree f87f815 024/195: Added utility functions for use in discarding undo history., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree dcabd4f 002/195: Added .gitignore to ignore byte-compiled elisp files., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree f370170 019/195: Rewrote undo-tree-draw-tree and undo-tree-draw-subtree, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 73c1d04 007/195: Lumped visualizer data into single undo-tree node entry,, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 4dd6905 028/195: Discard marker adjustment undo entries.,
Stefan Monnier <=
- [elpa] externals/undo-tree 09fb370 027/195: Added lighter to undo-tree-mode., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree b074b86 029/195: Updated commentary, and switched to GPLv3., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree c00c1fe 031/195: Add new undo-tree-kill-visualizer to before-change-functions hook, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree aaa4c6d 012/195: Don't create new marker each time we draw a node., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 159c9b4 005/195: Implemented undo-tree branch switching., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 0bbfa5c 026/195: Tweaked commentary., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 86fb076 034/195: Fixed keybindings., Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 948386b 035/195: Modified undo-tree-visualizer-active-branch-face, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree bca52bf 042/195: Added undo-tree-mode-lighter customization option, Stefan Monnier, 2020/11/28
- [elpa] externals/undo-tree 50ccefd 043/195: Fixed bug in undo-tree-discard-node., Stefan Monnier, 2020/11/28