Subject: bug#23098: 25.0.92; (recenter -1) can leave point in the middle of the window

From: Jorgen Schäfer <[email-masked]>
Date: Wed, 23 Mar 2016 19:40:50 +0000

Hello!
The use case here are buffers like comint or IRC chat buffers. It's nice to
keep the last line of the buffer flush with the last line of the window, to
show the maximum amount of data. (recenter -1) at the end of a buffer is
supposed to do just that. In this case, it does not, but instead leaves
point in the *middle* of the window.

If it is not possible to display that line halfway (which sounds like a
missing feature to begin with), I would expect Emacs to least try to leave
point as low in the window as possible, instead of in the middle of the
window. C-l likewise won't move point any further down, for example.

Regards,
Jorgen

On Wed, Mar 23, 2016 at 8:18 PM Eli Zaretskii <[email-masked]> wrote:

> > From: Jorgen Schaefer <[email-masked]>
> > Date: Wed, 23 Mar 2016 19:40:27 +0100
> >
> > Evaluating the following code in "emacs -Q" leaves point in the middle
> > of the window, instead of at the end of the window as expected. Certain
> > modes (IRC) want to keep the buffer flushed at the end of the window,
> > this problem interferes with that behavior and causes very weird jumpy
> > scrolling.
> >
> >
> > (require 'cl)
> > (let* ((b (get-buffer-create "*Bug Repro*"))
> >        (w (selected-window))
> >        (l (window-height w))
> >        o)
> >   (set-window-buffer w b)
> >   (select-window w)
> >   (set-buffer b)
> >   (erase-buffer)
> >   (cl-dotimes (i (* l 2))
> >               (insert "foo\n"))
> >   (goto-char (point-min))
> >   (forward-line (+ l 2))
> >   (setq o (make-overlay (point) (point)))
> >   (overlay-put o 'after-string "\n")
> >   (goto-char (point-max))
> >   (recenter -1))
> >
> >
> > That is, if there is a multi-line overlay that would be shown only
> > halfway.
>
> I'm not sure I understand: are you trying to display a window whose
> start point is in the middle of an overlay string?  That's not
> possible, AFAIK.  The window-start point must be a buffer position.
>