Subject: Re: bug#46316: 27.1; wrong horizontal scroll with truncate-lines value t

From: Eli Zaretskii <[email-masked]>
Date: Sun, 14 Feb 2021 20:50:08 +0200

> From: [email-masked]
> Cc: [email-masked]
> Date: Mon, 15 Feb 2021 00:43:32 +0900
> 
> >> (let ((buf (generate-new-buffer "tmp")))
> >>   (switch-to-buffer buf)
> >>   (setq truncate-lines t)
> >>   (dotimes (i 200)
> >>     (insert (format ":%03d" i))
> >>     (when (= 0 (% (1+ i) 100)) (insert ?\n)))
> >>   (forward-char -1)
> >>   (sit-for 1)
> >>   (set-window-hscroll nil (window-hscroll))
> >>   (save-excursion
> >>     (forward-char -100)
> >>     (insert-char ?\n 10)
> >>     ))
> >
> > Sorry, I don't think I follow: what exactly is the bug here?  What did
> > you expect to happen ,and what did actually happen?
> 
> The expression '(set-window-hscroll nil (window-hscroll))' should not
> have any effect

That's not true: calling set-window-hscroll inhibits automatic
hscrolling, until point moves for some reason.

> but if it is deleted from the form, auto-hscroll-mode works
> correctly.

I think this is expected: the text your recipe adds is not around
point, so we don't re-enable auto-hscroll.

> Not only point motion but also buffer modification should be checked for
> auto-hscroll-mode.

If you want this to happen, don't call set-window-hscroll.