Follow buffer in emacs, a la tail -f or less +F

blueFast picture blueFast · Oct 25, 2013 · Viewed 7.8k times · Source

I would like to analyze a log file in emacs while it is growing. Is it possible to have a buffer follow a file? It is not needed that the file be editable (which raises all sort of questions): read-only mode would suffice.

My problem in more detail is this:

  1. I open the logfile en emacs
  2. I am looking for some error in the logfile
  3. I realize it is not there because the buffer is not up-to-date
  4. I have to manually reload the buffer (revert-buffer)

I would like to improve this workflow by letting emacs do the reloading automagically. Maybe a periodic revert-buffer? How to setup such periodic reloading?

Answer

Alex Ott picture Alex Ott · Oct 25, 2013

Use the auto-revert-tail-mode to do this... I have following in my ~/.emacs (just to convenience...):

(add-to-list 'auto-mode-alist '("\\.log\\'" . auto-revert-mode))