summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2024-04-15 16:06:54 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2024-04-15 16:06:54 -0400
commit3ac1a7b6fe6d324339ca5c36ffdce3985f6c55a1 (patch)
treeaf52733f47c8eda64bc8a72cefd39f886ab7c270 /lisp/emacs-lisp
parent5fda398fb3bbda43dab37a0c187c90ad4bc4d1b0 (diff)
downloademacs-3ac1a7b6fe6d324339ca5c36ffdce3985f6c55a1.tar.gz
(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`.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r--lisp/emacs-lisp/track-changes.el38
1 files 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.