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

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

[nongnu] elpa/annotate d60feb9cab 106/372: Merge pull request #45 from c


From: ELPA Syncer
Subject: [nongnu] elpa/annotate d60feb9cab 106/372: Merge pull request #45 from cage2/master
Date: Fri, 4 Feb 2022 16:58:22 -0500 (EST)

branch: elpa/annotate
commit d60feb9cabace219c5247ccbce94f56474b62ec3
Merge: d84bfd56b8 0d315a806e
Author: Bastian Bechtold <bastibe@users.noreply.github.com>
Commit: GitHub <noreply@github.com>

    Merge pull request #45 from cage2/master
    
    Preventing loss of undo list
---
 annotate.el | 34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

diff --git a/annotate.el b/annotate.el
index dc91676870..55e8cf348a 100644
--- a/annotate.el
+++ b/annotate.el
@@ -143,8 +143,8 @@ major mode is a member of this list (space separated 
entries)."
   "The string used when a string is truncated with an ellipse")
 
 (defun annotate-annotations-exist-p ()
-  (find-if 'annotationp
-           (overlays-in 0 (buffer-size))))
+  (cl-find-if 'annotationp
+              (overlays-in 0 (buffer-size))))
 
 (defun annotate-initialize-maybe ()
   "Initialize annotate mode only if buffer's major mode is not in the 
blacklist (see:
@@ -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
@@ -832,7 +836,7 @@ essentially what you get from:
                    old-checksum
                    new-checksum
                    (not (string= old-checksum new-checksum)))
-          (lwarn "annotate-mode"
+          (lwarn '(annotate-mode)
                  :warning
                  annotate-warn-file-changed-control-string
                  filename))



reply via email to

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