all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: npostavs@users.sourceforge.net
To: Eli Zaretskii <eliz@gnu.org>
Cc: ahyatt@gmail.com, 5718@debbugs.gnu.org, gavenkoa@gmail.com
Subject: bug#5718: scroll-margin in buffer with small line count.
Date: Fri, 13 Jan 2017 23:18:56 -0500	[thread overview]
Message-ID: <871sw6z32n.fsf@users.sourceforge.net> (raw)
In-Reply-To: <831swfcmhz.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 07 Jan 2017 10:17:28 +0200")

Eli Zaretskii <eliz@gnu.org> writes:

>
>> The issues with `scroll-down-command' (and `next-line', below) remain.
>> I find the following change fixes the problem for `scroll-down-command',
>> though I'm not sure whether it's the right thing to do.
>> 
>> --- a/src/window.c
>> +++ b/src/window.c
>> @@ -5148,7 +5148,7 @@ window_scroll_pixel_based (Lisp_Object window, int n, bool whole, bool noerror)
>>          in the scroll margin at the bottom.  */
>>        move_it_to (&it, PT, -1,
>>                   (it.last_visible_y - WINDOW_HEADER_LINE_HEIGHT (w)
>> -                  - this_scroll_margin - 1),
>> +                  - this_scroll_margin - 1 - frame_line_height),
>>                   -1,
>>                   MOVE_TO_POS | MOVE_TO_Y);
>
> Can you explain why this fixes the problem?  IOW, what was the problem
> with the original code, and why moving to the previous screen line
> here solves the problem?
>
> Also, does this correction need to be conditional on the new variable
> in some way, or is it correct in the general case as well?

Actually, this is also a problem with partial lines.  I didn't notice at
first, because Emacs produces a window with a partial line by default
when I do `C-x 2'.  AFAICT, it's not related with the new variable,
except that the problem becomes more obvious with maximal margins.  In
Emacs 25.1, using a window where (window-screen-lines) => 20.22, and a
scroll-margin of 100, doing `scroll-down-command' leaves 5 full lines
above point, while `scroll-up-command' leaves 4 full lines (and the
partial one) below point.

So in the code, I think the problem is that it.last_visible_y includes
the partial line, while this_scroll_margin is just the integer
scroll_margin multiplied by pixels per line.  I guess to fix it,
subtracting the partial line height would be more correct than
frame_line_height.

>> 
>> The problem involves partial lines.  In a window where
>> (window-screen-lines) returns 7.222, doing M-: (vertical-motion '(0.0
>> . 1)) does not scroll the window, which lets point end up 1 line away
>> from the center.  Doing M-: (vertical-motion '(0.0 . -1)) does scroll
>> the window, keeping the point in the center (as expected).
>> 
>> Adjusting the window so that (window-screen-lines) returns 7.0, there is
>> no discrepancy between up and down motion.
>> 
>> I guess there is some incorrect boundary condition in try_scrolling,
>> though I haven't worked out where.

Looks like the same kind of problem as the other case, I can fix it
again by subtracting frame_line_height, though again, subtracting the
partial height is probably more correct.

---   i/src/xdisp.c
+++   w/src/xdisp.c
@@ -15369,7 +15369,7 @@ try_scrolling (Lisp_Object window, bool just_this_one_p,
         either that ypos or PT, whichever comes first.  */
       start_display (&it, w, startp);
       scroll_margin_y = it.last_visible_y - this_scroll_margin
-        - frame_line_height * extra_scroll_margin_lines;
+        - frame_line_height * (1 + extra_scroll_margin_lines);
       move_it_to (&it, PT, -1, scroll_margin_y - 1, -1,
                  (MOVE_TO_POS | MOVE_TO_Y));







  reply	other threads:[~2017-01-14  4:18 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-14 17:26 bug#5718: scroll-margin in buffer with small line count Oleksandr Gavenko
2016-08-11  4:11 ` Andrew Hyatt
2016-08-11 12:03   ` npostavs
2016-08-11 13:05     ` Oleksandr Gavenko
2016-08-11 13:24       ` Noam Postavsky
2016-08-12  7:54         ` Oleksandr Gavenko
2016-08-11 15:28     ` Eli Zaretskii
2016-08-13 22:01       ` npostavs
2016-08-14  2:36         ` Eli Zaretskii
2016-09-11 20:58           ` npostavs
2016-09-12  6:19             ` martin rudalics
2016-09-14  2:23               ` npostavs
2016-09-14  5:30                 ` martin rudalics
2016-09-12 17:36             ` Eli Zaretskii
2016-09-14  2:40               ` npostavs
2016-09-14 17:26                 ` Eli Zaretskii
2017-01-03  0:48                   ` npostavs
2017-01-07  8:17                     ` Eli Zaretskii
2017-01-14  4:18                       ` npostavs [this message]
2017-01-14  7:58                         ` Eli Zaretskii
2017-01-15 21:43                           ` npostavs
2017-01-16 17:08                             ` Eli Zaretskii
2017-01-21 18:46                               ` npostavs
2017-01-21 19:17                                 ` Eli Zaretskii
2017-01-22 17:21                                   ` npostavs
2017-01-22 17:58                                     ` Eli Zaretskii
2017-01-29  0:57                                       ` npostavs
2017-01-30 15:29                                         ` Eli Zaretskii
2017-01-31  4:52                                           ` npostavs
2017-01-31 15:33                                             ` Eli Zaretskii
2017-02-03  2:40                                               ` npostavs

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871sw6z32n.fsf@users.sourceforge.net \
    --to=npostavs@users.sourceforge.net \
    --cc=5718@debbugs.gnu.org \
    --cc=ahyatt@gmail.com \
    --cc=eliz@gnu.org \
    --cc=gavenkoa@gmail.com \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.