Subject: bug#9246: Scrolling bug with word-wrap in emacs -nw

From: Antoine Levitt <[email-masked]>
Date: Thu, 29 Dec 2011 23:45:25 +0100

24/12/11 18:22, Eli Zaretskii
>> From: Antoine Levitt <[email-masked]>
>> Cc: [email-masked],  [email-masked]
>> Date: Sat, 24 Dec 2011 18:04:03 +0100
>> 
>> >  -- Variable: window-scroll-functions
>> >      [...]
>> >      *Warning:* don't use this feature to alter the way the window is
>> >      scrolled.  It's not designed for that, and such use probably won't
>> >      work.
>> >
>> > But erc does precisely that which the manual says not to do.  It
>> > shouldn't.
>> >
>> > Incidentally, all this trickery is no longer needed with Emacs 24:
>> > just setting scroll-conservatively to a value larger than 100 will do
>> > the job nicely and without any problems.
>> 
>> So, should erc-scrollbottom be changed?
>
> Definitely.  It shouldn't use window-scroll-functions.

So is there a hook it could use?

Incidentally, this warning doesn't get displayed on C-h v, it might be a
good idea to move it.

>
>> Only using scroll-conservatively instead of erc-scrolltobottom has a few
>> disadvantages. erc-scrolltobottom has the advantage that one can never
>> see past the end of a buffer, similar to other IRC clients (and indeed,
>> text editors). With scroll-conservatively, if a window has say 2/3 the
>> height of the buffer, scrolling up and down results in one seeing the
>> bottom of the buffer around the middle of the window.
>
> Only if you scroll by scroll bar or by C-v with a numeric argument.
> Just typing will never get you past the buffer end (obviously).

No need for a numeric argument before C-v, just doing it recenters the
view past the buffer end.

>
>> Actually, this is a behavior I'd like for emacs as a whole, to make it
>> behave more like other editors that never display anything past the end
>> of text. Is there any way to do it, some other variable one could set in
>> addition to scroll-conservatively?
>
> Maybe, I don't know.

If you don't know, it probably means there isn't ;)

I tried to hack something together, but I couldn't make it work, because
I couldn't find an appropriate way to express "if the window is
displaying stuff past the end of buffer" (using window-end and
buffer-end does not work, because window-end can never be past
buffer-end). Ideally, it'd hook up after scroll-up-command, and recenter
appropriately. With that in place, I don't think anything can get past
the end of the buffer.