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: Sun, 22 Jan 2017 12:21:20 -0500 Message-ID: <87inp7ui27.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> <871sw6z32n.fsf@users.sourceforge.net> <83o9zaax8x.fsf@gnu.org> <87k29wxam1.fsf@users.sourceforge.net> <83a8ar9bl6.fsf@gnu.org> <87pojguu7m.fsf@users.sourceforge.net> <83d1fg5iku.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1485105671 13739 195.159.176.226 (22 Jan 2017 17:21:11 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 22 Jan 2017 17:21:11 +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 Sun Jan 22 18:21:07 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 1cVLpC-00039G-5n for geb-bug-gnu-emacs@m.gmane.org; Sun, 22 Jan 2017 18:21:06 +0100 Original-Received: from localhost ([::1]:37169 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cVLpH-0000e8-Bh for geb-bug-gnu-emacs@m.gmane.org; Sun, 22 Jan 2017 12:21:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57389) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cVLpB-0000e2-Ls for bug-gnu-emacs@gnu.org; Sun, 22 Jan 2017 12:21:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cVLp8-0000i9-G3 for bug-gnu-emacs@gnu.org; Sun, 22 Jan 2017 12:21:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:40253) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cVLp8-0000i5-CP for bug-gnu-emacs@gnu.org; Sun, 22 Jan 2017 12:21:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cVLp8-0007wP-4F for bug-gnu-emacs@gnu.org; Sun, 22 Jan 2017 12:21: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: Sun, 22 Jan 2017 17:21: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.148510562330468 (code B ref 5718); Sun, 22 Jan 2017 17:21:02 +0000 Original-Received: (at 5718) by debbugs.gnu.org; 22 Jan 2017 17:20:23 +0000 Original-Received: from localhost ([127.0.0.1]:38452 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cVLoV-0007vM-Ej for submit@debbugs.gnu.org; Sun, 22 Jan 2017 12:20:23 -0500 Original-Received: from mail-io0-f196.google.com ([209.85.223.196]:34157) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cVLoS-0007v7-G1 for 5718@debbugs.gnu.org; Sun, 22 Jan 2017 12:20:20 -0500 Original-Received: by mail-io0-f196.google.com with SMTP id c80so12866861iod.1 for <5718@debbugs.gnu.org>; Sun, 22 Jan 2017 09:20:20 -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=AHy9RIW5UQ7vk7JoZWaTif8NQ0ozkp92fC6B3BvDbNA=; b=ddVjVRr7yXzsjNAUpwwMOft6+nIKgJryepnJ1ibCP/6Q5j1w272bsEx0eqheKzlPHC UESJPKirF3UOfoYmfMJbNiHNpqkOG44QbQkFYvDI9lT29fcrhz5CRGAB4WWh/ckQBAnL c9MU6O+65MStr/Dewro8C3thSbG0cQ2Ieo9bu/e1Il3V2W0zyQorENWrfHL8XuL0QegB mH55Z8TuHGewbQQEjlIMFgIIYBFgcDHt0QVyJ04ViHaXtWRYNgz2j5RPp67Q6143MZvU d5I10CKbKjO3UGkaiU6D5KhepXExMIAIy28+yq0XuR2GFoqZhmu5kTn6JizcFFoKj5tb 9oXA== 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=AHy9RIW5UQ7vk7JoZWaTif8NQ0ozkp92fC6B3BvDbNA=; b=fpD3cHFRqQ4y8iFm8MVxJHTFZWFloral62uUBD7hWQ1RQx4esj8ZaoPihk6aPK1dYx adAgbbH6lh7hrHN0TV0w118wf7z7c1k+QFJ1no1SKKT6KysD0mCZRkZ5KBNdWmyXxLE2 Z13YAsW3aLxX5EFvNSFgYAi/4ZtJQuHD+m1ZXSxQZUiA/yID/sSfnfa2O3JrVsrPIbHT KnWKfcucMClqaVSPOpdAZDZ44HBhsqpc3CotJNMu90ZFvMuTk4zdQxV1fa3mWF2BuH9o k2IepMdxIRbTNrgUC0+EkPYmljJ3SiqwVvdHvSTdDLvlRjLbcFVMH0FRGqHAnByBZKvJ hVcg== X-Gm-Message-State: AIkVDXJBJMv4kTDlDC8WcM+Q0RdrMSN4kG+fdKZaPU5TthvQ1gfuV8JW9xd0k9FwPlUAuQ== X-Received: by 10.107.178.151 with SMTP id b145mr22006570iof.69.1485105614635; Sun, 22 Jan 2017 09:20:14 -0800 (PST) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id p20sm7596126itc.2.2017.01.22.09.20.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Jan 2017 09:20:13 -0800 (PST) In-Reply-To: <83d1fg5iku.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 21 Jan 2017 21:17:05 +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:128311 Archived-At: npostavs@users.sourceforge.net writes: > > I came up with this; it works Actually, that doesn't work, I must have not compiled before testing. Eli Zaretskii writes: >> >> I'm not entirely clear why there is a branch in that code. > > Because of line-spacing, perhaps? Did you test your code when > line-spacing is at non-default value? In general, it is safer to go > to the next screen line than reason about where it will start. > >> +int >> +partial_line_height (const struct it *it_origin) >> +{ >> + struct it it = *it_origin; > > When you copy the iterator structure and modify the copy, you need to > save and restore the bidi cache, using SAVE_IT and RESTORE_IT macros. > Otherwise, the code which calls this function will work incorrectly if > it uses the original iterator after the call, because the bidi cache > is not restored to its state before the call. I came up with this modified version of partial_line_height, which does actually work. Having to do RESTORE_IT (&it, &it, it_data) is a bit unintuitive though. I don't understand what the typical use case of this macro is, if it's going to copy back the new state into the original `it', then why use a separate `it' in the first place? By the way, while testing I noticed that `set-window-text-height' doesn't take `line-spacing' into account, should it? int partial_line_height (struct it *it_origin) { int partial_height; void *it_data = NULL; struct it it; SAVE_IT (it, *it_origin, it_data); move_it_to (&it, ZV, -1, it.last_visible_y, -1, MOVE_TO_POS | MOVE_TO_Y); if (it.what == IT_EOB) { int vis_height = it.last_visible_y - it.current_y; int height = it.ascent + it.descent; partial_height = (vis_height < height) ? vis_height : 0; } else { int last_line_y = it.current_y; move_it_by_lines (&it, 1); partial_height = (it.current_y > it.last_visible_y) ? it.last_visible_y - last_line_y : 0; } RESTORE_IT (&it, &it, it_data); return partial_height; }