help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Set-window-vscroll sometimes doesn't work


From: Eli Zaretskii
Subject: Re: Set-window-vscroll sometimes doesn't work
Date: Tue, 20 Oct 2020 19:04:02 +0300

> From: Yuan Fu <casouri@gmail.com>
> Date: Mon, 19 Oct 2020 16:39:11 -0400
> Cc: help-gnu-emacs@gnu.org
> 
> These functions only handle the case where the line is taller than the 
> window, so they either adjust vscroll or scroll with scroll-up/down but never 
> both, which isn’t too helpful. Because in my use case I sometimes need to 
> scroll and adjust vscroll in the same time. Suppose I have a line followed by 
> an image in my buffer:
> 
> +------------------------------------+
> |        first line                  |
> +------------------------------------+
> |        image                       |
> |                                    |
> |                                    |
> |                                    |
> |                                    |
> |                                    |
> |                                    |
> +------------------------------------+
> 
> 
> And I want to “scroll 3 lines up", then with my strategy I need to scroll up 
> one display line and adjust vscroll to 2x default-line-height. In other word:

You could write a function that scrolls by 1 screen line, either by
scroll-up/down or with vscroll, then call that function 3 times, and
let it do its job each of these 3 times.  Then you'd still be able to
reuse most of the code that already exists, by following the same
convention: either scroll-up/down or set vscroll.

> > Indeed, that's not what we want.  Which is why scroll commands are not
> > the right starting point for what you want to do.
> 
> Maybe I should state what I want to do clearly: I want to achieve the smooth 
> scrolling when both scrolling and moving point, i.e., both scroll-up/down and 
> next/previous-line, that ensures I never have annoying jumpy images.

Once again: scroll-up/down normally scroll by whole window, or by its
large fraction.  It is not a good idea to mix that with pixel-wise
scrolling of images.

> With my limited knowledge, setting window-start (aka scroll) and setting 
> vscroll in the same time is the only way to to get what I want. But it is 
> against the design of the display engine. Is there anyway out of this?

Not without rewriting significant parts of the display code.  Forcing
window-start and setting vscroll conceptually contradict each other,
so your interpretation of avoiding the contradiction by doing one and
then the other is bound to cause problems in other use cases.

That is why I suggest to stick to the code in simple.el as much as
possible: it is well tested and works, AFAIU you need to change it
very little to be able to scroll images that are smaller than the
window height -- that test is in a small number of places and can be
replaced by something else.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]