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

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

[nongnu] elpa/annotate 01373a4420 104/372: - preventing loss of undo lis


From: ELPA Syncer
Subject: [nongnu] elpa/annotate 01373a4420 104/372: - preventing loss of undo list
Date: Fri, 4 Feb 2022 16:58:22 -0500 (EST)

branch: elpa/annotate
commit 01373a442083b4c5fab062742ddbbdeb7006bb46
Author: cage <cage-invalid@invalid>
Commit: cage <cage-invalid@invalid>

    - preventing loss of undo list
    
      According  to the  documentation  the function  'uffer-disable-undo'
      discards all  the already registered buffer's  modification. This is
      undesiderable, to  prevent this  the old buffer  list is  copied and
      restored in 'annotate--remove-annotation-property'.
---
 annotate.el | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/annotate.el b/annotate.el
index dc91676870..4a03407ec9 100644
--- a/annotate.el
+++ b/annotate.el
@@ -700,18 +700,22 @@ to 'maximum-width'."
   "Cleans up annotation properties associated with a region."
   ;; inhibit infinite loop
   (setq inhibit-modification-hooks t)
-  ;; inhibit property removal to the undo list
-  (buffer-disable-undo)
-  (save-excursion
-    (goto-char end)
-    ;; go to the EOL where the
-    ;; annotated newline used to be
-    (end-of-line)
-    ;; strip dangling display property
-    (remove-text-properties
-     (point) (1+ (point)) '(display nil)))
-  (buffer-enable-undo)
-  (setq inhibit-modification-hooks nil))
+  ;; copy undo list
+  (let ((saved-undo-list (copy-tree buffer-undo-list t)))
+    ;; inhibit property removal to the undo list (and empty it too)
+    (buffer-disable-undo)
+    (save-excursion
+      (goto-char end)
+      ;; go to the EOL where the
+      ;; annotated newline used to be
+      (end-of-line)
+      ;; strip dangling display property
+      (remove-text-properties
+       (point) (1+ (point)) '(display nil)))
+    ;; restore undo list
+    (setf buffer-undo-list saved-undo-list)
+    (buffer-enable-undo)
+    (setq inhibit-modification-hooks nil)))
 
 (defun annotate--change-guard ()
   "Returns a `facespec` with an `insert-behind-hooks` property



reply via email to

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