emacs-diffs
[Top][All Lists]
Advanced

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

master 3ac1a7b6fe6: (track-changes-fetch): Fix nested use case


From: Stefan Monnier
Subject: master 3ac1a7b6fe6: (track-changes-fetch): Fix nested use case
Date: Mon, 15 Apr 2024 16:07:02 -0400 (EDT)

branch: master
commit 3ac1a7b6fe6d324339ca5c36ffdce3985f6c55a1
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    (track-changes-fetch): Fix nested use case
    
    * lisp/emacs-lisp/track-changes.el (track-changes-fetch):
    Don't presume that if there's nothing to do we're on
    `track-changes--clean-trackers`.
---
 lisp/emacs-lisp/track-changes.el | 38 +++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/lisp/emacs-lisp/track-changes.el b/lisp/emacs-lisp/track-changes.el
index df4aad0d596..9e62b8bdf30 100644
--- a/lisp/emacs-lisp/track-changes.el
+++ b/lisp/emacs-lisp/track-changes.el
@@ -335,23 +335,27 @@ and re-enable the TRACKER corresponding to ID."
                             (substring before (- (length before)
                                                  (- endb prevend)))))
               (setq lenbefore (length before)))))))
-    (if (null beg)
-        (progn
-          (cl-assert (null states))
-          (cl-assert (memq id track-changes--clean-trackers))
-          (cl-assert (eq (track-changes--tracker-state id)
-                         track-changes--state))
-          ;; Nothing to do.
-          nil)
-      (cl-assert (not (memq id track-changes--clean-trackers)))
-      (cl-assert (<= (point-min) beg end (point-max)))
-      ;; Update the tracker's state *before* running `func' so we don't risk
-      ;; mistakenly replaying the changes in case `func' exits non-locally.
-      (setf (track-changes--tracker-state id) track-changes--state)
-      (unwind-protect (funcall func beg end (or before lenbefore))
-        ;; Re-enable the tracker's signal only after running `func', so
-        ;; as to avoid recursive invocations.
-        (cl-pushnew id track-changes--clean-trackers)))))
+    (unwind-protect
+        (if (null beg)
+            (progn
+              (cl-assert (null states))
+              ;; We may have been called in the middle of another
+              ;; `track-changes-fetch', in which case we may be in a clean
+              ;; state but not yet on `track-changes--clean-trackers'
+              ;;(cl-assert (memq id track-changes--clean-trackers))
+              (cl-assert (eq (track-changes--tracker-state id)
+                             track-changes--state))
+              ;; Nothing to do.
+              nil)
+          (cl-assert (not (memq id track-changes--clean-trackers)))
+          (cl-assert (<= (point-min) beg end (point-max)))
+          ;; Update the tracker's state *before* running `func' so we don't 
risk
+          ;; mistakenly replaying the changes in case `func' exits non-locally.
+          (setf (track-changes--tracker-state id) track-changes--state)
+          (funcall func beg end (or before lenbefore)))
+      ;; Re-enable the tracker's signal only after running `func', so
+      ;; as to avoid recursive invocations.
+      (cl-pushnew id track-changes--clean-trackers))))
 
 ;;;; Auxiliary functions.
 



reply via email to

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