Subject: Re: bug#27008: 26.0.50; auto-hscroll-mode and scroll-left

From: Stephen Berman <[email-masked]>
Date: Sun, 21 May 2017 22:12:27 +0200

On Sun, 21 May 2017 18:23:10 +0300 Eli Zaretskii <[email-masked]> wrote:

>> From: Stephen Berman <[email-masked]>
>> Date: Sun, 21 May 2017 16:10:04 +0200
>> 
>> When auto-hscroll-mode is set to `current-line' and scroll-left is
>> invoked with arguments ARG > 0 and SET-MINIMUM non-nil, then when the
>> current line is automatically horizontally scrolled, all other lines in
>> the buffer are scrolled back to logical BOL, i.e. SET-MINIMUM is ignored
>> (except on the current line).  To reproduce:
>> 
>> 0. emacs -Q
>> 1. Set auto-hscroll-mode to `current-line'.
>> 2. Type `C-x C-f /path/to/hscroll-bug RET' (the attached file).
>> 3. Type `M-x toggle-truncate-lines' and `M-: (scroll-left 32 t)'.
>> 4. Type `C-p' repeatedly.
>> => When point is on the third line, and for all subsequent vertical
>>    motion, all lines but the current one are displayed starting at BOL
>>    instead of column SET-MINIMUM.
>
> I don't understand what you expected instead.  

I expected behavior similar to when auto-hscroll-mode is set to t and I
evaluate (scroll-left 32 t): in that case, automatic scrolling still
happens on long enough lines, but the minimum hscroll is respected.  So
with auto-hscroll-mode set to `current-line' I expected to get scrolling
of the current line and the rest of the lines would be displayed as if
the window's left edge was at column 32.

>                                                current-line hscrolling
> is designed to be disabled when manual scrolling is used, so using
> scroll-left is incompatible with automatic hscrolling and should have
> disabled it.  

Why should current-line hscrolling be different from window hscrolling
in this respect?  In other words, since automatic window hscrolling
still works when scroll-left is executed, why shouldn't current-line
hscrolling also work then?

>               If anything, I could understand a complaint that the
> current line is still hscrolled in this recipe, but otherwise I think
> your expectations are a tad too much; the effect you describe is more
> or less what I intended to happen.

There is an oddity that I doubt you intended: when point is at the left
window edge of the current line (e.g. via C-a), column-number-mode shows
it at column 0, though this is not displayed, and indeed typing C-n does
not advance point until it reaches column 33 (SET-MINIMUM + 1);
nevertheless, all the other lines are displayed from their respective
BOL, i.e. column 0 (as you point out below).  When scrolling vertically
through the buffer with C-p and C-n or the arrow keys, this looks very
strange.

> Technically, the minimum hscroll is implemented by the same code which
> calculates the window's hscroll value upon redisplay, and in
> current-line hscrolling that value affects only the current line, the
> rest of the window is displayed as if the hscroll is zero.

Is this necessary?  Why can't the other lines be displayed with hscroll
set to w->min_hscroll, as they are with auto-hscroll-mode set to t?

Steve Berman