Subject: Re: bug#24094: 25.1.50; revert-buffer error in CC mode

From: Óscar Fuentes <[email-masked]>
Date: Fri, 29 Jul 2016 20:43:03 +0200

Richard Copley <[email-masked]> writes:

> It's hard to describe precisely (especially as I don't have a
> corrupted buffer here and now), but being guided by your question,
> we're talking about one or two larger chunks and not at the end of the
> buffer but in the "middle".

Yes, sometimes the missing chunk(s) are in the middle of the file. AFAIR
they are always quite large. I can't confirm the case of more than one
chunk, though.

Appreciating the damage is complicated by the fact that it not evident
what's missing at first sight: in the case I describe on my previous
email, when the error happened and swtiched to the affected buffer it
only displayed one line (the first one); then, pressed cursor-down and
the other eight lines appeared from nowhere.

> My impression FWIW is that it is *as if* Emacs has done
> "diff-buffer-with-file" and is attempting to apply the resulting patch
> to the buffer (perhaps with the laudable intention of saving space in
> the undo buffer), and has failed after a deletion and before an
> insertion. But that is uninformed speculation.

I suspected some undo-related problem when I experienced the problem
some weeks ago. Then, disabled undo before the revert on my Magit code:

-            (revert-buffer t t)
+            (progn
+              (setq buffer-undo-list t)
+              (revert-buffer t t)

to no avail. It looks more like a cache issue to me now: c-mode is using
some stale info computed before the revert.