Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

emacs

reload

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?

like image 954
blueFast Avatar asked Oct 25 '13 12:10

blueFast


4 Answers

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))
like image 121
Alex Ott Avatar answered Nov 05 '22 00:11

Alex Ott


Have you tried using the auto-revert-tail-mode? - Invoked with M-x auto-revert-tail-mode

like image 35
Squidly Avatar answered Nov 04 '22 23:11

Squidly


Lee Hinman wrote an amazingly detailed and helpful writeup about working with log files in Emacs using auto-revert-tail-mode at Writequit.org called, well, "Working with log files in Emacs".

like image 4
Mallory-Erik Avatar answered Nov 05 '22 00:11

Mallory-Erik


You can also use the excellent itail tool from which can be installed from the MELPA repository. You invoke it as follows:-

`M-x` itail

You can use itail with local files as well as remote files using TRAMP. More information about itail can be found here.

like image 3
ksinkar Avatar answered Nov 05 '22 00:11

ksinkar