From: Yuan Fu <casouri@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Set-window-vscroll sometimes doesn't work
Date: Mon, 19 Oct 2020 16:39:11 -0400 [thread overview]
Message-ID: <E1E73BDD-D94C-4C53-AAF5-5AD89761C9B3@gmail.com> (raw)
In-Reply-To: <834kmqp1ts.fsf@gnu.org>
>>
>> What I came up with is this:
>>
>> For (scroll-up 1):
>
> That's your problem, right there: scroll-up is not the right command
> for this. Scroll commands work by setting window-start, and you don't
> want that with large images. They also move by window-full, again
> something that is not appropriate for scrolling images. You'd need a
> different command for your use case.
>
> Please read the code in simple.el, the functions line-move,
> line-move-1, and line-move-partial -- those perform scrolling of tall
> images when needed. You will find there how to decide when to set
> vscroll and to what value; I suggest to use a similar strategy.
Sorry for the confusion, I didn't mean to use scroll-up directly, I meant “(my-scroll-up 1)”.
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:
(set-window-start nil point-of-image t)
(set-window-vscroll nil (* 2 (default-line-height)) t)
>
>>
>> 1. If the first row is a normal line (i.e., with normal height), scroll up normally by one display line.
>> 2. If the first row is an image, adjust vscroll += frame-default-pixel-line-height
>> 3. If the first row is an image and we have scrolled to the bottom of the image, i.e., vscroll = image-height, scroll up one display line and set vscroll to 0.
>
> You can do it this way, but I think it will be confusing because
> scroll-up is rarely used with an argument of 1.
>
> But if you insist on doing this inside scroll-up, then items 2 and 3
> should do what line-move-visual etc. in simple.el do when they need to
> scroll a tall image. They do exactly what you describe above (they
> also do other stuff, which you can remove if you want).
The strategy also works with an argument larger than 1. Again, those functions never need to scroll and adjust vscroll in the same time.
>
>> In other words, sometimes we are not really scrolling, but faking a scroll by adjusting vscroll. IIUC window_scroll_pixel_based moves it by move_it_by_lines and set window-start to it. That’s not what we want when we want to fake scroll by adjusting vscroll: in that case we don’t want to change window-start.
>
> 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.
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?
Thanks,
Yuan
next prev parent reply other threads:[~2020-10-19 20:39 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-18 0:35 Set-window-vscroll sometimes doesn't work Yuan Fu
2020-10-18 14:34 ` Eli Zaretskii
2020-10-18 17:24 ` Yuan Fu
2020-10-18 17:31 ` Eli Zaretskii
2020-10-18 17:51 ` Yuan Fu
2020-10-18 17:55 ` Eli Zaretskii
2020-10-18 18:02 ` Yuan Fu
2020-10-18 19:12 ` Yuan Fu
2020-10-18 19:19 ` Eli Zaretskii
2020-10-18 20:06 ` Yuan Fu
2020-10-19 2:23 ` Eli Zaretskii
[not found] ` <B1D235FE-49B8-4F0A-9C02-78B7E3244C47@gmail.com>
2020-10-19 6:00 ` Yuan Fu
2020-10-19 16:24 ` Eli Zaretskii
2020-10-19 16:56 ` Yuan Fu
2020-10-19 17:23 ` Eli Zaretskii
2020-10-19 20:39 ` Yuan Fu [this message]
2020-10-20 16:04 ` Eli Zaretskii
2020-10-20 18:00 ` Yuan Fu
2020-10-20 18:19 ` Yuan Fu
2020-10-21 16:25 ` Eli Zaretskii
2020-10-21 19:05 ` Yuan Fu
2020-10-22 4:16 ` Yuan Fu
2020-10-22 16:08 ` Eli Zaretskii
2020-10-22 16:50 ` Yuan Fu
2020-10-22 17:09 ` Eli Zaretskii
2020-10-22 19:33 ` Yuan Fu
2020-10-23 6:05 ` Eli Zaretskii
2020-10-23 16:48 ` Yuan Fu
2020-10-23 18:11 ` Eli Zaretskii
2020-10-23 20:30 ` Yuan Fu
2020-10-24 7:17 ` Eli Zaretskii
2020-10-26 8:38 ` Jens C. Jensen
2020-10-26 15:18 ` Eli Zaretskii
2020-10-27 18:10 ` Yuan Fu
2020-10-27 18:32 ` Eli Zaretskii
2020-10-22 16:05 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1E73BDD-D94C-4C53-AAF5-5AD89761C9B3@gmail.com \
--to=casouri@gmail.com \
--cc=eliz@gnu.org \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).