I'm not sure how to completely reproduce this. It may be related to this other question of mine. My hope is that someone else has seen this as well and knows what causes it.
Sometimes when editing an emacs buffer, generally for a Python file, the buffer is out of date (usually because it has changed from git checkouts in other terminal tabs). So when I try to edit the buffer, it tells me that the file is out of date and if I want to edit it or revert it. I choose revert.
What happens then is that instead of reverting the file, it gets corrupted. In particular, it seems to insert chunks of the original file in the wrong place. For instance, the first 20 or so lines will be inserted twice. This error persists (but often with slightly different results) if I manually run M-x revert-buffer
.
Fortunately, I always keep my files under revision control, so I can usually detect and fix these issues, but it's pretty annoying, and there is potential for it to screw me over pretty hard or even cause me to lose data. Any suggestions on what might be causing this are welcome.
revert-buffer-function
is, and if it is notrevert-buffer--default
then check what the value (a function) actually does. You can also usedebug-on-entry
for that function, to follow what it does in the debugger.revert-buffer-insert-file-contents-function
.emacs -Q
(no init file) and with a step-by-step description, then consider filing an Emacs bug report (M-x report-emacs-bug
). If this is an Emacs bug it is quite important - users should not have their data (including programs) corrupted.