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 19:51:00 +0100

> After finishing to read the description I want to quit it, because I
> want the *Messages* buffer to come back. For that, I do: C-x o, thus
> switching to the focus to the *Help* buffer, and I just type in 'q' to
> quit it and instantly focus back to the *scratch* buffer.
>
> But: When I look into the *Messages* buffer, the "ghost" cursor is no
> longer at the same place. It has moved in the middle of the buffer. From
> there, the window position relative to the buffer remains the same.
>
> (Hum.. I am being over-descriptive here, but I am trying to compensate
> my low level in english)

If only everyone were as over-descriptive as you.  The behavior you see
is due to `quit-window' restoring the previous position of
`window-point' for that window.  This clearly backfires for the
*Messages* buffer.  Please file a bug report with your description.

As an aside: The problem also happens with `switch-to-prev-buffer' and
`switch-to-next-buffer' and it happens for all sorts of buffers where
text is asynchronously inserted at the end as with shell buffers and the
like.

> Ok, I suppose that, indeed, set-window-point is more appropriate.
>
> I've been able to make the whole stuff work, thanks to the various
> remarks. Since I was trying to automate the whole stuff I decided not to
> go in the macro direction. Here is the code:
>
> (defun tail-f-msgs ()
>   "Go to the enf of Messages buffer."
>   (let ((msg-window (get-buffer-window "*Messages*")))
>     (if msg-window
>         (with-current-buffer (window-buffer msg-window)
>           (set-window-point msg-window (point-max))))))
>
> ;; Make the Messages buffer stick to the end.
> (add-hook 'post-command-hook 'tail-f-msgs)
>
> Of course with that the *Messages* buffer is no longer editable, or you
> can browse it to see older lines. Next fix: make a variable to the
> follow mode.

This would be tedious.  We have to fix this in the window code.  More
precisely, we need a buffer local variable which when set and
`window-point' equals `point-max' for that buffer at the time of saving
the buffer's window's `window-point' (in your case that would be the
time when the help buffer is displayed) we would store nil in the
corresponding slot.  When restoring the buffer in the window (via
`quit-window' in your case) and we find that that slot contains nil,
we'd use the buffer's `point' as new position of `window-point'.

Thanks in advance for the bug report, martin



reply via email to

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