]> git.eshelyaron.com Git - emacs.git/commitdiff
track-changes.el: Keep a bit more info when logging an error
authorStefan Monnier <monnier@iro.umontreal.ca>
Thu, 30 May 2024 23:00:23 +0000 (19:00 -0400)
committerEshel Yaron <me@eshelyaron.com>
Sat, 1 Jun 2024 17:04:57 +0000 (19:04 +0200)
* lisp/emacs-lisp/track-changes.el (track-changes--recover-from-error):
Add arg `info`.
(track-changes-fetch, track-changes--after): Use it to preserve a bit
more information about errors.

(cherry picked from commit 436b344be36152acbac693009c560b6bfb9697a2)

lisp/emacs-lisp/track-changes.el

index 2824a70586d4d5a804907e4a063d5ece8d3637e9..958def17a2f3faadc5fae7bf78602d8c320dde64 100644 (file)
@@ -272,7 +272,8 @@ returns nil, otherwise it returns the value returned by FUNC
 and re-enable the TRACKER corresponding to ID."
   (cl-assert (memq id track-changes--trackers))
   (unless (equal track-changes--buffer-size (buffer-size))
-    (track-changes--recover-from-error))
+    (track-changes--recover-from-error
+     `(buffer-size ,track-changes--buffer-size ,(buffer-size))))
   (let ((beg nil)
         (end nil)
         (before t)
@@ -443,7 +444,7 @@ returned to a consistent state."
   "List of errors encountered.
 Each element is a triplet (BUFFER-NAME BACKTRACE RECENT-KEYS).")
 
-(defun track-changes--recover-from-error ()
+(defun track-changes--recover-from-error (&optional info)
   ;; We somehow got out of sync.  This is usually the result of a bug
   ;; elsewhere that causes the before-c-f and after-c-f to be improperly
   ;; paired, or to be skipped altogether.
@@ -452,7 +453,7 @@ Each element is a triplet (BUFFER-NAME BACKTRACE RECENT-KEYS).")
       (message "Recovering from confusing calls to `before/after-change-functions'!")
     (warn "Missing/incorrect calls to `before/after-change-functions'!!
 Details logged to `track-changes--error-log'")
-    (push (list (buffer-name)
+    (push (list (buffer-name) info
                 (let* ((bf (backtrace-frames
                             #'track-changes--recover-from-error))
                        (tail (nthcdr 50 bf)))
@@ -573,7 +574,7 @@ Details logged to `track-changes--error-log'")
                        track-changes--before-end
                        (point-max)))))
         ;; BEG..END is not covered by previous `before-change-functions'!!
-        (track-changes--recover-from-error)
+        (track-changes--recover-from-error `(unexpected-after ,beg ,end ,len))
       ;; Note the new changes.
       (when (< beg (track-changes--state-beg track-changes--state))
         (setf (track-changes--state-beg track-changes--state) beg))