Andy Piper wrote:
At 05:36 PM 11/6/2001 -0500, Paul Krause wrote:
>That's for sure. It especially bites me when I compile and skip to the
>next-error, which is usually line 2394 in a 3500 line file. The file gets
>fontified and parsed, but to edit it, but have to check out from perforce.
>Then not only does the fortification and parsing start all over, but the
>buffer-position gets trashed (probably an unrelated bug in perforce.el, but
>I never figured it out), and I'm back on line 1 again. Kinda sucks.
Yeah, I get this. I think its actually a bug in XEmacs related to
revert-buffer. Doing the md5 thing avoids both problems.
some suggestions in how to make this patch workable:
1] it's never ok to hide a bug by working around it rather than fixing it.
2] don't do anything clever like use md5.
3] keep in mind there are many revert-buffer hooks, some of which explicitly
replace the normal operation of inserting the file. your patch as is completely
runs over them. the only hook that you can [reasonably safely] optimize away is
`after-revert-hook' [and possibly `before-revert-hook']. to make your patch
safe, it would have to do all the steps to actually revert the buffer, but do it
in another buffer, and then finally compare the results and skip calling
`after-revert-hook' if they're the same. if semantic hooks off of
`after-revert-hook' [which it probably does], you're in luck. with a bit of
effort you can also avoid having the before/after-change functions called.
4] if you do implement this, it should *always* be on. no variable to control
its behavior. instead, we simply make a behavior change in `after-revert-hook'
-- it's not called if the buffer contents don't change as a result of the
revert.
for reference, here's the doc for revert-buffer:
(revert-buffer &optional IGNORE-AUTO NOCONFIRM PRESERVE-MODES)
Documentation:
Replace the buffer text with the text of the visited file on disk.
This undoes all changes since the file was visited or saved.
With a prefix argument, offer to revert from latest auto-save file, if
that is more recent than the visited file.
This command also works for special buffers that contain text which
doesn't come from a file, but reflects some other data base instead:
for example, Dired buffers and buffer-list buffers. In these cases,
it reconstructs the buffer contents from the appropriate data base.
When called from Lisp, the first argument is IGNORE-AUTO; only offer
to revert from the auto-save file when this is nil. Note that the
sense of this argument is the reverse of the prefix argument, for the
sake of backward compatibility. IGNORE-AUTO is optional, defaulting
to nil.
Optional second argument NOCONFIRM means don't ask for confirmation at
all.
Optional third argument PRESERVE-MODES non-nil means don't alter
the files modes. Normally we reinitialize them using `normal-mode'.
If the value of `revert-buffer-function' is non-nil, it is called to
do all the work for this command. Otherwise, the hooks
`before-revert-hook' and `after-revert-hook' are run at the beginning
and the end, and if `revert-buffer-insert-file-contents-function' is
non-nil, it is called instead of rereading visited file contents.
ben