Subject: bug#16475: enhancement request: remove vertical scroll bar automatically when not needed

From: martin rudalics <[email-masked]>
Date: Thu, 26 Oct 2017 09:56:59 +0200

> More importantly, removing the scroll bar resizes the external
 > dimensions of the frame, to keep the windows' dimensions unchanged
 > (otherwise, we couldn't remove the scroll bars at the very end of the
 > window's redisplay).  You can see this in action if you toggle
 > scroll-bar-mode on and off.  So when the window shows _almost_ all the
 > text of the buffer, the frame would annoyingly oscillate in its
 > horizontal dimension.  This could be caused, for example, by echo-area
 > messages that resize the mini-window from time to time, or by the user
 > adjusting the window size.

Obviously, an equivalent of ‘set-window-scroll-bars’ would have to be
used here.

 > By contrast, other applications I saw that remove the scroll bar when
 > it is not needed leave the frame's dimensions alone, and instead leave
 > more space for text display.  That is much better, but doing this in
 > Emacs would require to restructure the code that deals with the scroll
 > bars, because we cannot change window dimensions after all the
 > redisplay decisions were made, without requiring one more redisplay
 > cycle.

We cannot simply remove scroll bars by "clearing" the unused space with
the window's background whatever that is.  There might be a highlighted
region or some other background that extends to the end of the line on
any line displayed in that window.  And obviously we have to "move" the
fringes and the margins to the right and I didn't even talk about scroll
bars on the left ...

 >> Auto-removal of horizontal scroll bars is more complicated.  Basically,
 >> we could remove the horizontal scroll bar when no line in the window had
 >> to be truncated.  But then we have space to display the next buffer line
 >> and that line could be awfully long.
 >
 > Actually, I think what happens with the removal of the horizontal
 > scroll bar mirrors the vertical scroll bar, just in the other
 > dimension.  Namely, the frame's height is modified to leave the
 > windows' dimensions unaltered.  But again, this could easily cause
 > annoying "oscillations" of the frame borders.

Again ‘set-window-scroll-bars’ would take care of that.

martin