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

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

[elpa] master 462f566 44/63: Don't leave unreadable objects in the undo


From: Noam Postavsky
Subject: [elpa] master 462f566 44/63: Don't leave unreadable objects in the undo list
Date: Mon, 17 Jul 2017 22:54:17 -0400 (EDT)

branch: master
commit 462f5667fc9b68f03a6d93d8d4e877dbc38b49ca
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Don't leave unreadable objects in the undo list
    
    * yasnippet.el (yas--commit-snippet): Remove overlay object after
    deleting it.
    (yas--markers-to-points): Drop marker object.
    (yas--points-to-markers): Create a new marker object.
---
 yasnippet.el | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/yasnippet.el b/yasnippet.el
index b618f73..a3a1eaa 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -3293,7 +3293,8 @@ This renders the snippet as ordinary text."
                (overlay-buffer control-overlay))
       (setq yas-snippet-beg (overlay-start control-overlay))
       (setq yas-snippet-end (overlay-end control-overlay))
-      (delete-overlay control-overlay))
+      (delete-overlay control-overlay)
+      (setf (yas--snippet-control-overlay snippet) nil))
 
     (let ((yas--inhibit-overlay-hooks t))
       (when yas--active-field-overlay
@@ -3448,8 +3449,9 @@ If so cleans up the whole snippet up."
 ;;
 ;; This was found useful for performance reasons, so that an excessive
 ;; number of live markers aren't kept around in the
-;; `buffer-undo-list'.  We reuse the original marker object, although
-;; that's probably not necessary.
+;; `buffer-undo-list'.  We don't reuse the original marker object
+;; because that leaves an unreadable object in the history list and
+;; undo-tree persistence has trouble with that.
 ;;
 ;; This shouldn't bring horrible problems with undo/redo, but you
 ;; never know.
@@ -3457,16 +3459,13 @@ If so cleans up the whole snippet up."
 (defun yas--markers-to-points (snippet)
   "Save all markers of SNIPPET as positions."
   (yas--snippet-map-markers (lambda (m)
-                              (prog1 (cons (marker-position m) m)
+                              (prog1 (marker-position m)
                                 (set-marker m nil)))
                             snippet))
 
 (defun yas--points-to-markers (snippet)
   "Restore SNIPPET's marker positions, saved by `yas--markers-to-points'."
-  (yas--snippet-map-markers (lambda (p-m)
-                              (set-marker (cdr p-m) (car p-m))
-                              (cdr p-m))
-                            snippet))
+  (yas--snippet-map-markers #'copy-marker snippet))
 
 (defun yas--maybe-move-to-active-field (snippet)
   "Try to move to SNIPPET's active (or first) field and return it if found."



reply via email to

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