bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#16377: Undo Tree regression: (error "Unrecognized entry in undo list


From: Stefan Monnier
Subject: bug#16377: Undo Tree regression: (error "Unrecognized entry in undo list undo-tree-canary")
Date: Thu, 06 Jul 2017 01:35:54 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

> +        (window-of-current-buffer (get-buffer-window (current-buffer)))
> +        (selected-window (selected-window)))
[...]
> +              (unless (eq window-of-current-buffer selected-window)

Better check (eq (window-buffer) (current-buffer)), since these two
functions are mere accessors, whereas get-buffer-window is a funny
function which returns *one of* the buffer's windows (or nil) and is
hence both more costly (it has a loop inside) and less reliable.

> -           (when (or (> (point-min) beg) (< (point-max) end))
> -             (error "Changes to be undone are outside visible portion of 
> buffer"))
> +            (when (or (> (point-min) beg) (< (point-max) end))
> +              (let ((debug-on-quit nil)
> +                    (msg (concat
> +                           "undo-tree--primitive-undo (1 of 4):"
> +                           "  "
> +                           "Changes to be undone are outside visible portion 
> of buffer.")))
> +                (signal 'quit `(,msg))))

Not sure what is the benefit of signaling `quit` rather than `error`.
Can you expand on that?

> -               ;; Insert might have invalidated some of the markers
> -               ;; via modification hooks.  Update only the currently
> -               ;; valid ones (bug#25599).
> -               (if (marker-buffer (car adj))
> -                   (set-marker (car adj)
> -                               (- (car adj) (cdr adj)))))))
> +               (set-marker (car adj)
> +                           (- (car adj) (cdr adj))))))

IIUC, this is an unintended change in your code, right?

>            ;; (MARKER . OFFSET) means a marker MARKER was adjusted by OFFSET.
>            (`(,(and marker (pred markerp)) . ,(and offset (pred integerp)))
> -           (warn "Encountered %S entry in undo list with no matching (TEXT . 
> POS) entry"
> -                 next)
> +            (let ((msg
> +                    (concat
> +                      "undo-tree--primitive-undo:  "
> +                      (format "Encountered %S entry in undo list with no 
> matching (TEXT . POS) entry"
> +                              next))))
> +              (message msg))

What is this change meant to do?

> +          (_
> +            (if (eq next 'undo-tree-canary)
> +              (message "undo-tree--primitive-undo:  catch-all found `%s'." 
> next)
> +              (error "Unrecognized entry in undo list %S" next)))))

This might make sense to work around the problem, but is clearly not an
actual fix.  IIUC Tony said it looked like a bug in undo-tree.
Has there been any progress on finding/fixing the bug there?
What is this "canary" meant to do?  If it shouldn't signal an error
here, maybe rather than the constant `undo-tree-canary`, undo-tree
should use another constant value, i.e. one that is a valid (and
harmless) undo entry.


        Stefan





reply via email to

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