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: Tue, 13 Sep 2016 22:23:07 -0400 Message-ID: <877faf1apg.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> <57D6490F.1000103@gmx.at> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1473819802 20187 195.159.176.226 (14 Sep 2016 02:23:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 14 Sep 2016 02:23:22 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) Cc: ahyatt@gmail.com, gavenkoa@gmail.com, 5718@debbugs.gnu.org To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Sep 14 04:23:18 2016 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 1bjzr1-0004L2-WF for geb-bug-gnu-emacs@m.gmane.org; Wed, 14 Sep 2016 04:23:16 +0200 Original-Received: from localhost ([::1]:52642 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjzqy-000529-Lk for geb-bug-gnu-emacs@m.gmane.org; Tue, 13 Sep 2016 22:23:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59173) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjzqr-000523-U5 for bug-gnu-emacs@gnu.org; Tue, 13 Sep 2016 22:23:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bjzqn-0007Wz-WF for bug-gnu-emacs@gnu.org; Tue, 13 Sep 2016 22:23:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33082) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bjzqn-0007Wq-SA for bug-gnu-emacs@gnu.org; Tue, 13 Sep 2016 22:23:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1bjzqn-0002uO-Lx for bug-gnu-emacs@gnu.org; Tue, 13 Sep 2016 22:23:01 -0400 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: Wed, 14 Sep 2016 02:23: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.147381977411164 (code B ref 5718); Wed, 14 Sep 2016 02:23:01 +0000 Original-Received: (at 5718) by debbugs.gnu.org; 14 Sep 2016 02:22:54 +0000 Original-Received: from localhost ([127.0.0.1]:59027 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjzqf-0002u0-RH for submit@debbugs.gnu.org; Tue, 13 Sep 2016 22:22:54 -0400 Original-Received: from mail-it0-f52.google.com ([209.85.214.52]:38108) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bjzqc-0002tl-RL for 5718@debbugs.gnu.org; Tue, 13 Sep 2016 22:22:51 -0400 Original-Received: by mail-it0-f52.google.com with SMTP id n143so4264311ita.1 for <5718@debbugs.gnu.org>; Tue, 13 Sep 2016 19:22:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=43BUcs29/BqNyhd1aWG60d5jrXUaXADu1r222yTMqP0=; b=OuvrlaqeicyojNsBvErVzxmYUUstxfGQONKVBEApX9LaTKMZoujsmhCPM7FX4EvvDg wbjd2r6qyaAgXIOsQDozTWSdCxAA3iOZhr1+OKlX0pyS6g46f2Ks8IpjleCNwAEyJunH 90q6E5x+sploOZE/d1pYdwK9vMFO8gSlY5Bpymt7rMmXTmK1t/Y24Tke56OzElF4rcpN L5QYGRdzuwI5dK8XDRLjrG9ff4jSbq0qSHis+SpwHTEB0lL1nyzwd7cERemHg6EZ64yY SYJutjVnmaJ8xvx0SoVRG7gtGs1EqvErQMUaRhQyW5zFsdkDBPFQmpOrhATdTKFjlPEp NjyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version :content-transfer-encoding; bh=43BUcs29/BqNyhd1aWG60d5jrXUaXADu1r222yTMqP0=; b=RxeXBzjjg0F+GQz9373Nv1+Kdde1x5nkrqP7QIZZjC1MosAs7Q0kh6Lgy0EYwJLMY5 hm7gf3WNE98QXahZP6xaUbsxntv5JxTECSCfGjw3yd0ghYlOfS9OCL20EQAe5Q6GQlWF ogdL2wmEfvdgJWKOvkbWyGJtviYqR+gae5yws7nFOOoKSTye4CO5+G1/BxogdHwlcuWi L/4kQyaQBocryYZLzxOg/ErRnj+hzBI/5svnlSYwDAnEiqj0tD5UMHpShKkGe7Ty0B8m ZhCrLKkMFFe8t/C6qP813nVh6GHwmULmEmAEEsFCb6WEZvxh1L6cGVuYFbEFkk+EDKTl ev4A== X-Gm-Message-State: AE9vXwOAG2VF9ZfuKx/LEg3BQRChRu03/Lsvb4uMnTf+KWCrjLkcopQMBkQVcg0zU484FA== X-Received: by 10.107.180.200 with SMTP id d191mr1510261iof.36.1473819765196; Tue, 13 Sep 2016 19:22:45 -0700 (PDT) Original-Received: from zony ([45.2.7.130]) by smtp.googlemail.com with ESMTPSA id r123sm17980585ith.1.2016.09.13.19.22.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Sep 2016 19:22:44 -0700 (PDT) In-Reply-To: <57D6490F.1000103@gmx.at> (martin rudalics's message of "Mon, 12 Sep 2016 08:19:59 +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:123276 Archived-At: martin rudalics writes: > int window_total_lines > - =3D window->total_lines * WINDOW_FRAME_LINE_HEIGHT (window) > + =3D (window->total_lines * WINDOW_FRAME_LINE_HEIGHT (window) > + - WINDOW_MODE_LINE_HEIGHT (window)) > > Please use another name instead of "window_total_lines" here. And > please explain why you can't use Fwindow_text_height here (i.e., why > header lines, horizontal scrollbars and window dividers apparently don't > count). Oh, I just didn't think of those, I don't think there is a reason not to use it. How about this (I use window_box_height instead of Fwindow_text_height just to save the bother of struct window* to Lisp_Object conversion): @@ -4799,10 +4799,7 @@ window_scroll_margin (struct window *window, enum ma= rgin_unit unit) if (scroll_margin > 0) { int frame_line_height =3D default_line_pixel_height (window); - int window_total_lines - =3D (window->total_lines * WINDOW_FRAME_LINE_HEIGHT (window) - - WINDOW_MODE_LINE_HEIGHT (window)) - / frame_line_height; + int window_lines =3D window_box_height (window) / frame_line_height; int margin, max_margin; double ratio =3D 0.25; @@ -4812,7 +4809,7 @@ window_scroll_margin (struct window *window, enum mar= gin_unit unit) ratio =3D max (0.0, ratio); ratio =3D min (ratio, 0.5); } - max_margin =3D (int) (window_total_lines * ratio); + max_margin =3D (int) (window_lines * ratio); margin =3D max (0, scroll_margin); margin =3D min (scroll_margin, max_margin); > > +(defmacro window-with-test-buffer-window (&rest body) > > Please call it =E2=80=98window-test-with-test-buffer-window=E2=80=99 to c= onsistentlyy > keep the =E2=80=98window-test-=E2=80=99 prefix on everything defined in t= his file. Oops, right.