From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#11464: 24.1.50; pos-visible-in-window-p returns a false positive with bidi text Date: Sat, 19 May 2012 15:26:24 +0300 Message-ID: <83k408z79r.fsf@gnu.org> References: <87y5owjcto.fsf@gmail.com> <83pqa8vsxw.fsf@gnu.org> <87fwb1dagj.fsf_-_@gmail.com> <83wr4do1qv.fsf@gnu.org> <87bolor98t.fsf@gmail.com> <83sjf0nolt.fsf@gnu.org> <87pqa3csuc.fsf@gmail.com> <83likqojxl.fsf@gnu.org> <83fwayo6mz.fsf@gnu.org> <83ehqindec.fsf@gnu.org> <87wr49ex07.fsf@gmail.com> <83vcjtswst.fsf@gnu.org> <87obplepfl.fsf@gmail.com> <83sjexsp0y.fsf@gnu.org> <87k409emno.fsf@gmail.com> <83obplsi3g.fsf@gnu.org> <8762btimdw.fsf@gmail.com> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: dough.gmane.org 1337430404 20111 80.91.229.3 (19 May 2012 12:26:44 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 19 May 2012 12:26:44 +0000 (UTC) Cc: 11464@debbugs.gnu.org, mwd@cert.org To: Ari Roponen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat May 19 14:26:43 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SVik6-0004am-0p for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 May 2012 14:26:42 +0200 Original-Received: from localhost ([::1]:42777 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SVik5-0005aC-FP for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 May 2012 08:26:41 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:60284) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SVik2-0005a5-43 for bug-gnu-emacs@gnu.org; Sat, 19 May 2012 08:26:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SVik0-0005Rt-4e for bug-gnu-emacs@gnu.org; Sat, 19 May 2012 08:26:37 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:52415) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SVik0-0005Rp-1B for bug-gnu-emacs@gnu.org; Sat, 19 May 2012 08:26:36 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SVikP-0001a8-Q7 for bug-gnu-emacs@gnu.org; Sat, 19 May 2012 08:27:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 May 2012 12:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 11464 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 11464-submit@debbugs.gnu.org id=B11464.13374304216073 (code B ref 11464); Sat, 19 May 2012 12:27:01 +0000 Original-Received: (at 11464) by debbugs.gnu.org; 19 May 2012 12:27:01 +0000 Original-Received: from localhost ([127.0.0.1]:33728 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SVikN-0001Zt-Cc for submit@debbugs.gnu.org; Sat, 19 May 2012 08:27:00 -0400 Original-Received: from mtaout21.012.net.il ([80.179.55.169]:42433) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SVikK-0001Ze-0Y for 11464@debbugs.gnu.org; Sat, 19 May 2012 08:26:57 -0400 Original-Received: from conversion-daemon.a-mtaout21.012.net.il by a-mtaout21.012.net.il (HyperSendmail v2007.08) id <0M4900400RT5OU00@a-mtaout21.012.net.il> for 11464@debbugs.gnu.org; Sat, 19 May 2012 15:26:22 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.210.75]) by a-mtaout21.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0M49004QTRVYNU20@a-mtaout21.012.net.il>; Sat, 19 May 2012 15:26:22 +0300 (IDT) In-reply-to: <8762btimdw.fsf@gmail.com> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:60212 Archived-At: > X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, > RCVD_IN_DNSWL_LOW,T_DKIM_INVALID autolearn=ham version=3.3.2 > From: Ari Roponen > Cc: mwd@cert.org, 11464@debbugs.gnu.org > Date: Fri, 18 May 2012 17:39:39 +0300 > > Eli Zaretskii writes: > > > Thanks. This is consistent with top_y and bottom_y, but leaves open > > the question why move_it_to didn't advance one more line. I will try > > to reproduce this on my system before I bother you with more > > questions. > > In case it helps, I found out this: > > Using emacs-24 rev. 107994 (your original patch): > > ./emacs -Q -fn "DejaVu Sans Mono-10" -l bug.el > => "Should be nil: nil" > > ./emacs -Q -fn "DejaVu Sans Mono-12" -l bug.el > => "Should be nil: t" > > In both cases, the latin letters use the given font, and the Hebrew > letters are displayed with corresponding "Arimo" font: > > xft:-unknown-DejaVu Sans Mono-normal-normal-normal-*-16-*-*-*-m-0-iso10646-1 (#x44) > xft:-unknown-Arimo-normal-normal-normal-*-16-*-*-*-*-0-iso10646-1 (#x9BD) I couldn't find an Arimo font that supports Hebrew. However, I found several fonts already installed on my system with which I could reproduce all of your 3 cases. It turned out there was a subtle misfeature in move_it_to, which pos_visible_p calls, that would produce a situation where bottom_y computed in pos_visible_p could be less that it.last_visible_y. That misfeature caused the computation of bottom_y produce inaccurate result. By fixing that misfeature (see below), I was able to revert the comparison against bottom_y to what it originally was, and get correct results from pos_visible_p in all the cases I tried. In general, if move_it_to stops at the bottom of the window, the last line's bottom_y cannot be less than last_visible_y, because that means there's one more line (partially) visible in the window. So the comparison I originally installed is the correct one. I installed the patch below as revision 108008 on the emacs-24 branch. Please test. Ari and Michael, many thanks for your help in working on this tricky problem. === modified file 'src/ChangeLog' --- src/ChangeLog 2012-05-15 16:17:42 +0000 +++ src/ChangeLog 2012-05-19 12:14:11 +0000 @@ -1,3 +1,13 @@ +2012-05-19 Eli Zaretskii + + * xdisp.c (move_it_to): Under MOVE_TO_Y, when restoring iterator + state after an additional call to move_it_in_display_line_to, keep + the values of it->max_ascent and it->max_descent found for the + entire line. + (pos_visible_p): Revert the comparison against bottom_y to what it + was in revid eliz@gnu.org-20120513182235-4p6386j761ld0nwb. + (Bug#11464) + 2012-05-15 Eli Zaretskii * xdisp.c (pos_visible_p): Fix last change. (Bug#11464) === modified file 'src/xdisp.c' --- src/xdisp.c 2012-05-15 16:17:42 +0000 +++ src/xdisp.c 2012-05-19 12:14:11 +0000 @@ -1313,7 +1313,7 @@ pos_visible_p (struct window *w, EMACS_I visible_p = bottom_y > window_top_y; else if (top_y < it.last_visible_y) visible_p = 1; - if (bottom_y <= it.last_visible_y + if (bottom_y >= it.last_visible_y && it.bidi_p && it.bidi_it.scan_dir == -1 && IT_CHARPOS (it) < charpos) { @@ -8689,8 +8689,18 @@ move_it_to (struct it *it, EMACS_INT to_ { /* If TO_Y is in this line and TO_X was reached above, we scanned too far. We have to restore - IT's settings to the ones before skipping. */ + IT's settings to the ones before skipping. But + keep the more accurate values of max_ascent and + max_descent we've found while skipping the rest + of the line, for the sake of callers, such as + pos_visible_p, that need to know the line + height. */ + int max_ascent = it->max_ascent; + int max_descent = it->max_descent; + RESTORE_IT (it, &it_backup, backup_data); + it->max_ascent = max_ascent; + it->max_descent = max_descent; reached = 6; } else