From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#5718: scroll-margin in buffer with small line count. Date: Sat, 07 Jan 2017 10:17:28 +0200 Message-ID: <831swfcmhz.fsf@gnu.org> References: <4B9D1C61.70903@gmail.com> <87mvkjy0l5.fsf@users.sourceforge.net> <83fuqbfhpb.fsf@gnu.org> <87a8ggwcoo.fsf@users.sourceforge.net> <83inv4cc0s.fsf@gnu.org> <87d1ka17dr.fsf@users.sourceforge.net> <834m5l9g1d.fsf@gnu.org> <874m5j19wi.fsf@users.sourceforge.net> <83zina75pa.fsf@gnu.org> <87pok555q4.fsf@users.sourceforge.net> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1483777106 9527 195.159.176.226 (7 Jan 2017 08:18:26 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 7 Jan 2017 08:18:26 +0000 (UTC) Cc: ahyatt@gmail.com, 5718@debbugs.gnu.org, gavenkoa@gmail.com To: npostavs@users.sourceforge.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jan 07 09:18:21 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cPmCb-0000xB-9f for geb-bug-gnu-emacs@m.gmane.org; Sat, 07 Jan 2017 09:18:13 +0100 Original-Received: from localhost ([::1]:56419 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPmCf-0004C5-JS for geb-bug-gnu-emacs@m.gmane.org; Sat, 07 Jan 2017 03:18:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPmCV-0004An-FK for bug-gnu-emacs@gnu.org; Sat, 07 Jan 2017 03:18:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cPmCQ-0004mR-FI for bug-gnu-emacs@gnu.org; Sat, 07 Jan 2017 03:18:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:58382) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cPmCQ-0004mN-BP for bug-gnu-emacs@gnu.org; Sat, 07 Jan 2017 03:18:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cPmCQ-0007uu-0O for bug-gnu-emacs@gnu.org; Sat, 07 Jan 2017 03:18:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 07 Jan 2017 08:18:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 5718 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 5718-submit@debbugs.gnu.org id=B5718.148377705030392 (code B ref 5718); Sat, 07 Jan 2017 08:18:01 +0000 Original-Received: (at 5718) by debbugs.gnu.org; 7 Jan 2017 08:17:30 +0000 Original-Received: from localhost ([127.0.0.1]:45548 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cPmBt-0007u8-Pu for submit@debbugs.gnu.org; Sat, 07 Jan 2017 03:17:30 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:39121) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cPmBr-0007tt-Qf for 5718@debbugs.gnu.org; Sat, 07 Jan 2017 03:17:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cPmBi-0004df-4L for 5718@debbugs.gnu.org; Sat, 07 Jan 2017 03:17:22 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:43917) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cPmBX-0004Zr-IR; Sat, 07 Jan 2017 03:17:07 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1964 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1cPmBW-0005gq-91; Sat, 07 Jan 2017 03:17:06 -0500 In-reply-to: <87pok555q4.fsf@users.sourceforge.net> (npostavs@users.sourceforge.net) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:127865 Archived-At: > From: npostavs@users.sourceforge.net > Cc: 5718@debbugs.gnu.org, ahyatt@gmail.com, gavenkoa@gmail.com > Date: Mon, 02 Jan 2017 19:48:03 -0500 > > > [1:text/plain Hide] > > Eli Zaretskii writes: > > >> From: npostavs@users.sourceforge.net > >> Cc: 5718@debbugs.gnu.org, ahyatt@gmail.com, gavenkoa@gmail.com > >> Date: Tue, 13 Sep 2016 22:40:29 -0400 > >> > >> Eli Zaretskii writes: > >> >> I have a patch set for fixing this and allowing the user to change the > >> >> maximum margin from 0.25. The latter doesn't quite work perfectly, for > >> >> some reason when setting the maximum margin to 0.5 and scroll-margin to > >> >> 100, `scroll-down-command' doesn't keep point centered in the window, > >> >> even though other commands (e.g. `scroll-up-command') do. > [...] > > > > ... given the above, I now understand that your interpretation of 0.5 > > is "half the window minus one line", which leaves the center line for > > point. Is that so? > > Yes, I hadn't quite thought it through, but that was my intention. I've > updated the code to clarify this. Thanks. I think the remaining issues are minor (modulo the couple of questions below), so I think you should install your changes > 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? > (defun line-move (arg &optional noerror _to-end try-vscroll) > ... > (unless (and auto-window-vscroll try-vscroll > ;; Only vscroll for single line moves > (= (abs arg) 1) > ;; Under scroll-conservatively, the display engine > ;; does this better. > (zerop scroll-conservatively) > ... > (line-move-partial arg noerror)) > ... > (prog1 (line-move-visual arg noerror) > > 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. Could be some off-by-one error when comparing with the window height. This sounds like a minor issue in an extreme (and thus rare) situation, so I'm not sure it should prevent installing this. Thanks.