Q: How do I insert/modify text in a buffer without undo
noticing?
Here's the use case. I have a comment block at the start of every file that, among other things, updates a timestamp for the most recent change to a file. I'd like to be able to modify that timestamp without the undo
facilities noticing it.
The reason I want to short-circuit undo
here is due to the following edge case, which comes up when editing/compiling LaTeX documents (and probably others, but this is the one that drives me nuts most frequently):
- Make a small change to the file to see how it will affect the compiled doc
- Save the file (which updates the timestamp)
- Run
latex
on the file - Decide that the change is a bad one
undo
the changes
The problem at step (5) (undo
) is that it does not undo the change made in step (1), but rather undoes the timestamp updating in step (2). That wouldn't bother me (I could just undo
again) except that it also moves point all the way to the timestamp at the top of the file, which is almost always many, many lines away from the actual substantive change. It's very jarring and completely breaks my concentration.
I'm pitching the question with respect to a file I'm visiting, but it's more generally about modifying buffers.
So: how can I prevent undo
from noticing a specific modification to a buffer?