help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to follow the end of *Messages* buffer in Emacs?


From: martin rudalics
Subject: Re: How to follow the end of *Messages* buffer in Emacs?
Date: Sat, 10 Nov 2012 12:56:14 +0100

> I am playing with Elisp, and I find convenient to have the *Messages*
> buffer always open in a window in my frame.
>
> I discovered recently that sometimes the buffer stops following the last
> lines. If I want to see the last appended lines in this buffer, I need
> to go in the buffer and jump to the end manually, with M->. Which is
> quite annoying and disruptive.

Can you please tell us when and how this happens.  Here, when I display
*Messages* in a window, I always see the last line but maybe something
about my setup is peculiar.

> I am trying to reproduce the "tail -f" command line, in a buffer. Of
> course 'auto-revert-tail-mode complains that the *Messages* is not a
> visited file... As a consequence, this mode does not want to work. But
> it gave me the idea to add a function hook when the buffer is modified.
> That function would jump to (point-max) each time that buffer is
> modified.
>
> Here is my own attempt, invoked from *Messages* buffer, with M-:
> (add-hook
>  'after-change-functions
>  (lambda (s e l) (goto-char (point-max)))
>  nil t)
>
> But it does not work. The (point) remains in the same place while I see
> the buffer is growing... The lambda function does not produce any error,
> otherwise it would have been removed from the 'after-change-functions
> hook and C-h k 'after-change-functions shows it is present.

The (goto-char (point-max)) just sets `point' in that buffer.  It does
not care whether the buffer is currently displayed in a window.  You
have to use something like

  (walk-windows
   (lambda (w)
     (when (eq (window-buffer w) (current-buffer))
       (set-window-point w (point-max))))))

within that function.

martin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]