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

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

[elpa] master 0db65ee 20/40: Don't clobber match data in modification ho


From: Noam Postavsky
Subject: [elpa] master 0db65ee 20/40: Don't clobber match data in modification hooks
Date: Wed, 26 Oct 2016 23:06:33 +0000 (UTC)

branch: master
commit 0db65ee0bb746f502405f18aba5054b4fdbc55dd
Author: Noam Postavsky <address@hidden>
Commit: Noam Postavsky <address@hidden>

    Don't clobber match data in modification hooks
    
    Since modification hooks run just after any function that changes buffer
    contents, it's important to save the match data, or else the code doing
    the modification can become really confused.  See also Emacs bugs #23917
    and #23869.
    
    * yasnippet.el (yas--on-field-overlay-modification): Wrap main body in
    `save-match-data'.
---
 yasnippet.el |   17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/yasnippet.el b/yasnippet.el
index 660173a..79861ee 100644
--- a/yasnippet.el
+++ b/yasnippet.el
@@ -3416,14 +3416,15 @@ field start.  This hook does nothing if an undo is in 
progress."
     (let* ((inhibit-modification-hooks t)
            (field (overlay-get overlay 'yas--field))
            (snippet (overlay-get yas--active-field-overlay 'yas--snippet)))
-      (when (yas--skip-and-clear-field-p field beg end length)
-        ;; We delete text starting from the END of insertion.
-        (yas--skip-and-clear field end))
-      (setf (yas--field-modified-p field) t)
-      (yas--advance-end-maybe field (overlay-end overlay))
-      (save-excursion
-        (yas--field-update-display field))
-      (yas--update-mirrors snippet))))
+      (save-match-data
+        (when (yas--skip-and-clear-field-p field beg end length)
+          ;; We delete text starting from the END of insertion.
+          (yas--skip-and-clear field end))
+        (setf (yas--field-modified-p field) t)
+        (yas--advance-end-maybe field (overlay-end overlay))
+        (save-excursion
+          (yas--field-update-display field))
+        (yas--update-mirrors snippet)))))
 
 ;;; Apropos protection overlays:
 ;;



reply via email to

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