From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.help Subject: Re: Set-window-vscroll sometimes doesn't work Date: Mon, 19 Oct 2020 20:23:11 +0300 Message-ID: <834kmqp1ts.fsf@gnu.org> References: <72B62847-3F35-412A-9F74-88442A936B19@gmail.com> <83eelvsivm.fsf@gnu.org> <853C8CD1-B58B-4F22-A889-4AB2AEE3DD80@gmail.com> <83imb7qw46.fsf@gnu.org> <66013ADF-731C-4922-8AF7-EAFDBF43C33C@gmail.com> <83ft6bqv0q.fsf@gnu.org> <4F2C1811-940E-4C58-8EE0-37AA3B666E12@gmail.com> <835z77qr3f.fsf@gnu.org> <834kmrq7gy.fsf@gnu.org> <83blgyp4k2.fsf@gnu.org> <4F794407-585E-4C74-85F3-00A668FB9675@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5377"; mail-complaints-to="usenet@ciao.gmane.io" To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Oct 19 19:23:57 2020 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kUYt3-0001Gz-Dk for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 19 Oct 2020 19:23:57 +0200 Original-Received: from localhost ([::1]:41756 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUYt2-0004iV-GN for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 19 Oct 2020 13:23:56 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUYsG-0004iB-Q1 for help-gnu-emacs@gnu.org; Mon, 19 Oct 2020 13:23:08 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:38493) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUYsG-0004DS-Fy for help-gnu-emacs@gnu.org; Mon, 19 Oct 2020 13:23:08 -0400 Original-Received: from [176.228.60.248] (port=3091 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kUYsC-00055A-Kw for help-gnu-emacs@gnu.org; Mon, 19 Oct 2020 13:23:08 -0400 In-Reply-To: <4F794407-585E-4C74-85F3-00A668FB9675@gmail.com> (message from Yuan Fu on Mon, 19 Oct 2020 12:56:38 -0400) X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:124584 Archived-At: > From: Yuan Fu > Date: Mon, 19 Oct 2020 12:56:38 -0400 > Cc: help-gnu-emacs > > > But in any case, I don't see how move_it_by_lines can have anything to > > do with this: whatever you do, an image must always remain a single > > "display element", and the only way we currently have to scroll > > partial images is via vscroll. Which works, so I don't understand why > > you need any changes in window_scroll_pixel_based. > > > > 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. > > 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). > 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. > 1. Is there a way to get the line-height that an it is on? Yes, use line-pixel-height. Again, see the functions in simple.el I pointed to, they do it already. > 2. Where is the code that ensures point is always fully visible? When I move point around Emacs adjusts scrolling to keep the point fully visible, but I don’t know who’s doing that work. It's in the display engine (xdisp.c). Many places there check whether the screen line of point is fully visible and retry redisplay if not.