I have a process that outputs text to a file output.log
. Sometimes this process deletes the file and starts over.
I would like to keep track of the contents of this file within Emacs automatically. I have used auto-revert-tail-mode
before, but this appends new output to the buffer, displaying content that may not be in the file anymore (e.g. because the processes deleted the previous file and created a new one).
The only command that seems to do the job is C-x C-v RET
(which calls find-alternate-file
on the original filename), but I have to type this manually.
Does Emacs provide any built-in mechanism to keep track of the contents of a file? Or perhaps there is a way to have auto-revert-tail-mode
add some marker to indicate when the file was deleted and re-created from scratch?
M-x auto-revert-mode
should do what you are looking for. It updates the content of the file.
Also when you feel that you have to do manually, you can use emacs macro (M-x kmacro-start-macro) and bind it to a key.
There is also M-x global-auto-revert-mode
that applies auto-revert-mode
to all new buffers, in case you forget it. You can set it in .emacs
with (global-auto-revert-mode 1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With