From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#5718: scroll-margin in buffer with small line count. Date: Fri, 13 Jan 2017 23:18:56 -0500 Message-ID: <871sw6z32n.fsf@users.sourceforge.net> 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> <831swfcmhz.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1484367497 9007 195.159.176.226 (14 Jan 2017 04:18:17 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 14 Jan 2017 04:18:17 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) Cc: ahyatt@gmail.com, 5718@debbugs.gnu.org, gavenkoa@gmail.com To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jan 14 05:18:12 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 1cSFn9-0001kO-U2 for geb-bug-gnu-emacs@m.gmane.org; Sat, 14 Jan 2017 05:18:12 +0100 Original-Received: from localhost ([::1]:46385 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cSFnE-0001vC-8E for geb-bug-gnu-emacs@m.gmane.org; Fri, 13 Jan 2017 23:18:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52491) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cSFn5-0001us-2g for bug-gnu-emacs@gnu.org; Fri, 13 Jan 2017 23:18:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cSFn0-0006Wz-G8 for bug-gnu-emacs@gnu.org; Fri, 13 Jan 2017 23:18:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:37848) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cSFn0-0006Wv-Cv for bug-gnu-emacs@gnu.org; Fri, 13 Jan 2017 23:18:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cSFn0-0005c1-3x for bug-gnu-emacs@gnu.org; Fri, 13 Jan 2017 23:18:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 14 Jan 2017 04:18:02 +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.148436748021564 (code B ref 5718); Sat, 14 Jan 2017 04:18:02 +0000 Original-Received: (at 5718) by debbugs.gnu.org; 14 Jan 2017 04:18:00 +0000 Original-Received: from localhost ([127.0.0.1]:53247 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cSFmx-0005bk-VZ for submit@debbugs.gnu.org; Fri, 13 Jan 2017 23:18:00 -0500 Original-Received: from mail-io0-f196.google.com ([209.85.223.196]:35427) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cSFmv-0005bV-Qy for 5718@debbugs.gnu.org; Fri, 13 Jan 2017 23:17:58 -0500 Original-Received: by mail-io0-f196.google.com with SMTP id m98so7542540iod.2 for <5718@debbugs.gnu.org>; Fri, 13 Jan 2017 20:17:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=U5xTCcZvs0G+wUZJPtVceL2CSl7qUiQWalo3vu996dg=; b=Q9GMNxBynb4qZiCGDcpyEG8mbILzfpprRqkO6JjKgBBFGRMPFq7cmrCBrjwkh8ecaK DNuk4MqoWcawp3BesFed35bQeQlQx6RaoSGOm4pH2KsYFEA0MG5Ae7LverW50t5unkLx nwvHFZDl9zECkIMp6W/Ltz8zfwyEKnANE7R8kZxpYm/XhqgeLn8RwwLY9YzXyt/qvABP GTCFP2wOByXg+EvwbPeixlrhk/Hh6jJmPnWxQuDphS5FMWs/32+A8DN2PNLJgCOvNxhg BABG5io7yATbJrM+DVYqTGrb98LNj9WYwlCAGrqkKTOmRHjpjSp83S0dcG/yH61UiBLv 4Swg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=U5xTCcZvs0G+wUZJPtVceL2CSl7qUiQWalo3vu996dg=; b=rmI18PGyHLNIQ9mNEDBEzoCE6V+s87esHX7VOB6JVUZgy0/VP7BWKaIBn9h8ig3zsq s7jy1HKz6x+Bf89sok/NSNj8Hfmb1QrnWJ4c17MUErXI5e/AelAOPdf3msPgp0uXqs90 IbFvajVEzIvT3nxSSTbRNKPIt+VsfDEr6PumryOtid6u9nw0rSwRgK5rWRVaxZMWwraG q0fEPhVj72wBJk3+iMGygUnA11DhCxsSBSrvkoJyWoObDZ0MS+vaR6qo4OQf5uzLSC76 1J7ztgcVpRjzfEm3TV0RdWnkhV2Se73hVRE3mfCTBUx7abRWiS5CGfTN4gpZf8YXfIUL EN6A== X-Gm-Message-State: AIkVDXIrBJJX+Nk+zCAb2djvWBH8LzitMyagYS6HMVHZAXIhDGb2O3f3tV7asiNAw99wyA== X-Received: by 10.107.195.204 with SMTP id t195mr21183333iof.46.1484367472188; Fri, 13 Jan 2017 20:17:52 -0800 (PST) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id s1sm2104774itb.21.2017.01.13.20.17.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 13 Jan 2017 20:17:51 -0800 (PST) In-Reply-To: <831swfcmhz.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 07 Jan 2017 10:17:28 +0200") 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:128102 Archived-At: Eli Zaretskii 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));