Subject: Re: bug#68786: 30.0.50; Horizontal overscroll

From: Andrey Listopadov <[email-masked]>
Date: Mon, 29 Jan 2024 20:53:34 +0300

Eli Zaretskii <[email-masked]> writes:

> The above can also be done with horizontal scroll bar, if instead of
> dragging the scroll-bar's "thumb" you click on the arrow at the right
> side of the scroll bar.  At least it works here (perhaps this depends
> on the toolkit, I don't know).

I'm using GNOME, and in its toolkit the scrollbars are "modern",
i.e. flat and without any buttons.

> So I think the inconsistency is much smaller than you think, and we
> should stop right here and talk about why this makes you uncomfortable
> or requires any changes in your opinion.  I personally find nothing
> bad or unexpected with the ability to scroll past the last visible
> character: after all, if the user doesn't want that, he/she can avoid
> scrolling farther than he/she wants.

The reason I made the piece of code that prevents this is because
usually when I'm scrolling to the right (I'm using line truncation all
the time), I don't want to overshoot the code I want to see.  With the
touchpad it's quite easy to do, because the acceleration of the
scrolling motion is pretty high, but I usually want it to be that high,
otherwise it feels like a /drag/.

> It is true that most other applications don't vary the thumb size, but
> Emacs has always behaved like it does, so changing it to follow the
> other apps is not an option at this point, at least not by default.
>
> Having said that, ...
>
>> I would like to ask for a feature to limit the horizontal scroll by the
>> longest line, much like the horizontal scrollbar works by default. It
>> may not be the longest line in the buffer, as calculating this for huge
>> buffers is probably too impactful unless we can cache the longest line
>> length until the buffer is changed.  Or maybe Emacs already knows the
>> buffer's "dimensions", I don't know.
>
> ... I won't object to such a feature, provided that it's optional and
> OFF by default, and also that it is supported on as many toolkits as
> is practical.  Patches welcome.

Fair enough.  Right now I can't send a patch, because I don't have the
solution for this problem.  The piece of code I sent works for me, but
it's not general by any means, and has a lot of subtle flaws.

Maybe if you could point me out to parts of Emacs that do the
calculation of the longest visible line for the scroll bar so I could
adopt it instead of doing hacky unscallable-face-font-width-based
calculation?  Or maybe help me think of a better way to calculate this.

Thanks!