Your question are actually two questions asked:
- How can I show if a file has changed on disk?
- How can I show a notification in the mode-line?
From what you provide as additional information:
I'm trying to troubleshoot why auto-revert doesn't work for me, and such an indication would help.
I conclude that the more important one and your actual question is:
How can I show if a file has changed on diskHow can I show if a file has changed on disk
One part required to arrive at a solution was already given in the comment to your question by Phil Hudson mentioning verify-visited-file-modtime
. The missing part was how to run this function periodically and give a visual feedback if a file was modified by an external application.
The code below if placed in the initialization file does what you ask for:
(defun check-external-file-modification ()
(if (verify-visited-file-modtime)
nil
(message "%s" "Info: BUFFER changed by external application")
)
(run-with-timer 5 nil 'check-external-file-modification)
)
(check-external-file-modification)
Notice that the value 5
in the code above means that the check is done each 5 seconds, but you can change it also to any (also a floating point) other value.
The notification about changed file status is shown each 5 seconds in the minibuffer and mirrored in *Messages*
.
YouYour other question:
- How can I show notifications in the mode-line?
is worth another question if the code you have written yourself for this purpose and for your specific Mode Line layout should for some reason not work as expected.