GNU bug report logs - #28936
move_it_in_display_line_to returns MOVE_POS_MATCH_OR_ZV before ZV

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Keith David Bershatsky <esq@HIDDEN>; Keywords: moreinfo; dated Sun, 22 Oct 2017 03:04:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Added tag(s) moreinfo. Request was from Noam Postavsky <npostavs@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 28936 <at> debbugs.gnu.org:


Received: (at 28936) by debbugs.gnu.org; 25 Oct 2017 05:30:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Oct 25 01:30:49 2017
Received: from localhost ([127.0.0.1]:60587 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1e7EHA-0008E0-Vo
	for submit <at> debbugs.gnu.org; Wed, 25 Oct 2017 01:30:49 -0400
Received: from gateway34.websitewelcome.com ([192.185.148.196]:13518)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <esq@HIDDEN>) id 1e7EH9-0008Ds-Cx
 for 28936 <at> debbugs.gnu.org; Wed, 25 Oct 2017 01:30:47 -0400
Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9])
 by gateway34.websitewelcome.com (Postfix) with ESMTP id 7FFCA2F78E
 for <28936 <at> debbugs.gnu.org>; Wed, 25 Oct 2017 00:30:44 -0500 (CDT)
Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP
 id 7EH6eS8UH5b6T7EH6eiYQX; Wed, 25 Oct 2017 00:30:44 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com
 ; s=default;
 h=Content-Type:MIME-Version:Subject:To:From:Message-ID:Date:
 Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description:
 Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
 In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=MxLwTm1xM18EmHAnTSXOmNIjCnOAF2dYpaGp35txfuM=; b=nIpHC0slNTG2HNijJ2tLDwESvk
 d890FsJNWKzd9prNbwJqUaklrfvgsND08UhsT1Wj3cmS3E/l61DuGhoCOJE5vYxu2gutv3cAykFZh
 e745G/8aQ8Qze8T/EwdS1aNaYknO0lEL3/1w2kurztttVC/40MDSrO6yrxyVKiIKo8HLqNByu4Qt4
 1rUxa4vtEI+j222r56dTkLI0LxdoY6KX/u5IlcJFHfnaRsB8V6ntahg9A/3DrH5ttUPg+JZs3M4Xa
 mCLGFpr9EjkNFFIuN46fF2bbQIS19cEmU+NO/zWnQRPLTWVeAQWG284m5z7aSpUOUtOr4iJ8x64lz
 AzXoetew==;
Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:57539
 helo=server.private)
 by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256)
 (Exim 4.87) (envelope-from <esq@HIDDEN>) id 1e7EH5-001ANZ-TQ
 for 28936 <at> debbugs.gnu.org; Wed, 25 Oct 2017 00:30:44 -0500
Date: Tue, 24 Oct 2017 22:30:43 -0700
Message-ID: <m2r2trvloc.wl%esq@HIDDEN>
From: Keith David Bershatsky <esq@HIDDEN>
To: 28936 <at> debbugs.gnu.org
Subject: enhancement request: remove vertical scroll bar automatically when
 not needed
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
X-AntiAbuse: This header was added to track abuse,
 please include it with any abuse report
X-AntiAbuse: Primary Hostname - gator3053.hostgator.com
X-AntiAbuse: Original Domain - debbugs.gnu.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - lawlist.com
X-BWhitelist: no
X-Source-IP: 45.48.239.195
X-Exim-ID: 1e7EH5-001ANZ-TQ
X-Source: 
X-Source-Args: 
X-Source-Dir: 
X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.private)
 [45.48.239.195]:57539
X-Source-Auth: lawlist
X-Email-Count: 2
X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t
X-Local-Domain: yes
X-Spam-Score: -2.8 (--)
X-Debbugs-Envelope-To: 28936
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.8 (--)

The previous message should have been sent to 16475, rather than 28936.  If a moderator would like to delete the last message, please feel free to do so.  I have already forwarded a duplicate of the previous message to 16475.

Thanks,

Keith




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#28936; Package emacs. Full text available.

Message received at 28936 <at> debbugs.gnu.org:


Received: (at 28936) by debbugs.gnu.org; 25 Oct 2017 03:46:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Oct 24 23:46:13 2017
Received: from localhost ([127.0.0.1]:60546 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1e7Cdx-0004ZG-7o
	for submit <at> debbugs.gnu.org; Tue, 24 Oct 2017 23:46:13 -0400
Received: from gateway22.websitewelcome.com ([192.185.47.163]:30026)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <esq@HIDDEN>) id 1e7Cdv-0004XY-OH
 for 28936 <at> debbugs.gnu.org; Tue, 24 Oct 2017 23:46:12 -0400
Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8])
 by gateway22.websitewelcome.com (Postfix) with ESMTP id F3E62553A
 for <28936 <at> debbugs.gnu.org>; Tue, 24 Oct 2017 22:46:09 -0500 (CDT)
Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP
 id 7CdreypUsDL8r7Cdsepe4T; Tue, 24 Oct 2017 22:46:09 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com
 ; s=default;
 h=Content-Type:MIME-Version:Subject:Cc:To:From:Message-ID:Date:
 Sender:Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:
 Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
 In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=SRx/D6mrm7/v3nBCuYa3H0XYGU4KeE/0hnpyLBFb7a8=; b=BOFYbxau4Ut0v13FaD6hjKBuhE
 bfQEvGbJsMJXpNz+NU5HL/hv1aoPnsQJIPGJjM2FloqNlU6PrVABc9uQ2VrMsCYIPmps2hN6FjpAd
 fCG6eXUdWRF0u4rpLvSwrkHJcYbEDJ1ATwubJXsw5xXEsB55u3WPKc/hU+O+bmbCusi+my3mLQ7h5
 QBorPwKPydF/kLmG5Ouc+SDhbuieEaDtRLW0bQHedwsZ28k5+O4Z2h9VZsTNO6pE5EIrOpyxtKmX9
 yS8pvjvd5fPTgMYGMCCmxxilRsoXvfYV9Ps86XmqnFS127AdO+hmqGqUIxmk3DWPj3piHpOsE07qX
 2wf1qacA==;
Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:56708
 helo=server.private)
 by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256)
 (Exim 4.87) (envelope-from <esq@HIDDEN>)
 id 1e7Cdr-004Cyy-HM; Tue, 24 Oct 2017 22:46:07 -0500
Date: Tue, 24 Oct 2017 20:46:06 -0700
Message-ID: <m21slrc2kh.wl%esq@HIDDEN>
From: Keith David Bershatsky <esq@HIDDEN>
To: 28936 <at> debbugs.gnu.org
Subject: enhancement request: remove vertical scroll bar automatically when
 not needed
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
X-AntiAbuse: This header was added to track abuse,
 please include it with any abuse report
X-AntiAbuse: Primary Hostname - gator3053.hostgator.com
X-AntiAbuse: Original Domain - debbugs.gnu.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - lawlist.com
X-BWhitelist: no
X-Source-IP: 45.48.239.195
X-Exim-ID: 1e7Cdr-004Cyy-HM
X-Source: 
X-Source-Args: 
X-Source-Dir: 
X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.private)
 [45.48.239.195]:56708
X-Source-Auth: lawlist
X-Email-Count: 2
X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t
X-Local-Domain: yes
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 28936
Cc: Drew Adams <drew.adams@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.5 (/)

Here is a first draft with a simple test (modifying xdisp.c), which probably nukes more than just the selected window's scroll bars when removing them, but it may be sufficient to revive this enhancement request in the event anyone is interested.

 finish_scroll_bars:

   if ((WINDOW_HAS_VERTICAL_SCROLL_BAR (w) || WINDOW_HAS_HORIZONTAL_SCROLL_BAR (w))
        && ZV - BEGV > BUF_Z (XBUFFER (w->contents)) - w->window_end_pos - marker_position (w->start))
    {
      if (WINDOW_HAS_VERTICAL_SCROLL_BAR (w))
	/* Set the thumb's position and size.  */
	set_vertical_scroll_bar (w);

      if (WINDOW_HAS_HORIZONTAL_SCROLL_BAR (w))
	/* Set the thumb's position and size.  */
	set_horizontal_scroll_bar (w);

      /* Note that we actually used the scroll bar attached to this
	 window, so it shouldn't be deleted at the end of redisplay.  */
      if (FRAME_TERMINAL (f)->redeem_scroll_bar_hook)
        (*FRAME_TERMINAL (f)->redeem_scroll_bar_hook) (w);
    }
    else
      {
        (*FRAME_TERMINAL (f)->condemn_scroll_bars_hook) (f);
        (*FRAME_TERMINAL (f)->judge_scroll_bars_hook) (f);
      }


Keith




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#28936; Package emacs. Full text available.

Message received at 28936 <at> debbugs.gnu.org:


Received: (at 28936) by debbugs.gnu.org; 23 Oct 2017 13:55:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Oct 23 09:55:41 2017
Received: from localhost ([127.0.0.1]:57825 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1e6dCf-0002hH-I8
	for submit <at> debbugs.gnu.org; Mon, 23 Oct 2017 09:55:41 -0400
Received: from eggs.gnu.org ([208.118.235.92]:45064)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1e6dCe-0002hB-Am
 for 28936 <at> debbugs.gnu.org; Mon, 23 Oct 2017 09:55:40 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <eliz@HIDDEN>) id 1e6dCU-0003sL-JJ
 for 28936 <at> debbugs.gnu.org; Mon, 23 Oct 2017 09:55:35 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_20,RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:56682)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1e6dCU-0003sH-FJ; Mon, 23 Oct 2017 09:55:30 -0400
Received: from [176.228.60.248] (port=2833 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1e6dCT-0008CG-TW; Mon, 23 Oct 2017 09:55:30 -0400
Date: Mon, 23 Oct 2017 16:55:17 +0300
Message-Id: <83h8uq9dfe.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Keith David Bershatsky <esq@HIDDEN>
In-reply-to: <m21slufnj3.wl%esq@HIDDEN> (message from Keith David
 Bershatsky on Sun, 22 Oct 2017 22:20:32 -0700)
Subject: Re: bug#28936: move_it_in_display_line_to returns
 MOVE_POS_MATCH_OR_ZV before ZV
References: <m21slufnj3.wl%esq@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 28936
Cc: 28936 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: Eli Zaretskii <eliz@HIDDEN>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

> Date:  Sun, 22 Oct 2017 22:20:32 -0700
> From:  Keith David Bershatsky <esq@HIDDEN>
> Cc:  28936 <at> debbugs.gnu.org
> 
> I was able to verify this evening that it.current_x is indeed 0 immediately following a call to `move_it_by_lines (&it, 0)` when the issue is present.

Then perhaps the problem happens because of some factors you didn't
include in your recipe.  The comments talk about adding
lnum_pixel_width, and about using auto-hscroll = current-line mode,
but the recipe mentions nothing about that.  Is the recipe complete?

> It may be that move_it_in_display_line_to is reaching the correct X, but is merely throwing the wrong label/result in this situation -- i.e., it is not really reaching a POS or ZV.

No, that's extremely improbable, to say the least.  Like I said: these
functions work in Emacs all the time, and if they'd fail like you
describe, we'd have gazillion of display bugs.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#28936; Package emacs. Full text available.

Message received at 28936 <at> debbugs.gnu.org:


Received: (at 28936) by debbugs.gnu.org; 23 Oct 2017 05:20:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Oct 23 01:20:38 2017
Received: from localhost ([127.0.0.1]:56498 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1e6VAE-0004KY-5e
	for submit <at> debbugs.gnu.org; Mon, 23 Oct 2017 01:20:38 -0400
Received: from gateway22.websitewelcome.com ([192.185.47.65]:12933)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <esq@HIDDEN>) id 1e6VAB-0004KQ-VK
 for 28936 <at> debbugs.gnu.org; Mon, 23 Oct 2017 01:20:36 -0400
Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4])
 by gateway22.websitewelcome.com (Postfix) with ESMTP id 59A251DC6D
 for <28936 <at> debbugs.gnu.org>; Mon, 23 Oct 2017 00:20:34 -0500 (CDT)
Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP
 id 6VA9e9HCypOTv6VAAexf9U; Mon, 23 Oct 2017 00:20:34 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com
 ; s=default;
 h=Content-Type:MIME-Version:Subject:Cc:To:From:Message-ID:Date:
 Sender:Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:
 Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
 In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=EaE/IHZ4rXUq5BbtzWRY7GVjCO9l+bDgXO7SPXOjxh4=; b=EoKBLc0j5UwIz4yJSbGxO22AWt
 Np8JAfa1ow0ew12QkxQ0EC8z0GZhKw1+tFFQnzwHAPCCuxt1zDPbhETpOEW/nelwRzh+N7gzOnAIB
 In7icK4bxN1nrSqMblzDZbUO0MZFIKGgWn/ybhVvadetZE8/fV3bb1kgQ3W0BDPZpMV/J6QGo/Xf2
 elVY0Ba6qtFR1kBUy9uMXdZq7sUf0fBKNYf7PKjzCkApH5IKCqGKJajLiUdiUAvIte9vkGa9Md3Th
 k8JCmQg9hN2DmKsto7XzLlzIyml/fHyImlbQAYp555IvSTahV0ZcJkdEv1c/RveuB4RwL55Q5Ixxi
 10ZwxRyQ==;
Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:50949
 helo=server.private)
 by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256)
 (Exim 4.87) (envelope-from <esq@HIDDEN>)
 id 1e6VA9-002bt0-IT; Mon, 23 Oct 2017 00:20:33 -0500
Date: Sun, 22 Oct 2017 22:20:32 -0700
Message-ID: <m21slufnj3.wl%esq@HIDDEN>
From: Keith David Bershatsky <esq@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#28936: move_it_in_display_line_to returns
 MOVE_POS_MATCH_OR_ZV before ZV
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
X-AntiAbuse: This header was added to track abuse,
 please include it with any abuse report
X-AntiAbuse: Primary Hostname - gator3053.hostgator.com
X-AntiAbuse: Original Domain - debbugs.gnu.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - lawlist.com
X-BWhitelist: no
X-Source-IP: 45.48.239.195
X-Exim-ID: 1e6VA9-002bt0-IT
X-Source: 
X-Source-Args: 
X-Source-Dir: 
X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.private)
 [45.48.239.195]:50949
X-Source-Auth: lawlist
X-Email-Count: 1
X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t
X-Local-Domain: yes
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 28936
Cc: 28936 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

I was able to verify this evening that it.current_x is indeed 0 immediately following a call to `move_it_by_lines (&it, 0)` when the issue is present.

It may be that move_it_in_display_line_to is reaching the correct X, but is merely throwing the wrong label/result in this situation -- i.e., it is not really reaching a POS or ZV.  Since my loop was relying on the label/result, the loop exited too early.  To test the correct X and wrong label/result theory, would take some time for me to work on because I would like to find the precise location inside move_it_in_display_line_to where the label/result is being returned.  I will continue to think about this and tinker ...

Keith

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

DATE:  [10-22-2017 12:53:47] <22 Oct 2017 22:53:47 +0300>
FROM:  Eli Zaretskii <eliz@HIDDEN>
> 
> > Date:  Sun, 22 Oct 2017 11:05:45 -0700
> > From:  Keith David Bershatsky <esq@HIDDEN>
> > Cc:  28936 <at> debbugs.gnu.org
> > 
> >   SET_TEXT_POS_FROM_MARKER (start_text_position, w->start);
> >   start_display (&it, w, start_text_position);
> >   move_it_to (&it, PT, it.last_visible_x, it.last_visible_y - 1, -1, MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
> >   target_x = it.current_x;
> >   move_it_by_lines (&it, 0);
> 
> Did you verify that it.current_x is zero after this line?  If not, you
> will not get to the right X coordnate here:
> 
> >   rc = move_it_in_display_line_to_x (w, &it, target_x);




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#28936; Package emacs. Full text available.

Message received at 28936 <at> debbugs.gnu.org:


Received: (at 28936) by debbugs.gnu.org; 22 Oct 2017 19:54:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Oct 22 15:54:02 2017
Received: from localhost ([127.0.0.1]:56252 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1e6MJu-0003Su-2i
	for submit <at> debbugs.gnu.org; Sun, 22 Oct 2017 15:54:02 -0400
Received: from eggs.gnu.org ([208.118.235.92]:55786)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1e6MJs-0003Sa-WA
 for 28936 <at> debbugs.gnu.org; Sun, 22 Oct 2017 15:54:01 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <eliz@HIDDEN>) id 1e6MJi-0002OG-TA
 for 28936 <at> debbugs.gnu.org; Sun, 22 Oct 2017 15:53:55 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:43959)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1e6MJi-0002O9-Pp; Sun, 22 Oct 2017 15:53:50 -0400
Received: from [176.228.60.248] (port=1874 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1e6MJi-0005Lg-8e; Sun, 22 Oct 2017 15:53:50 -0400
Date: Sun, 22 Oct 2017 22:53:47 +0300
Message-Id: <83vaj79cxg.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Keith David Bershatsky <esq@HIDDEN>
In-reply-to: <m2shebgirq.wl%esq@HIDDEN> (message from Keith David
 Bershatsky on Sun, 22 Oct 2017 11:05:45 -0700)
Subject: Re: bug#28936: move_it_in_display_line_to returns
 MOVE_POS_MATCH_OR_ZV before ZV
References: <m2shebgirq.wl%esq@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 28936
Cc: 28936 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: Eli Zaretskii <eliz@HIDDEN>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

> Date:  Sun, 22 Oct 2017 11:05:45 -0700
> From:  Keith David Bershatsky <esq@HIDDEN>
> Cc:  28936 <at> debbugs.gnu.org
> 
>   SET_TEXT_POS_FROM_MARKER (start_text_position, w->start);
>   start_display (&it, w, start_text_position);
>   move_it_to (&it, PT, it.last_visible_x, it.last_visible_y - 1, -1, MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
>   target_x = it.current_x;
>   move_it_by_lines (&it, 0);

Did you verify that it.current_x is zero after this line?  If not, you
will not get to the right X coordnate here:

>   rc = move_it_in_display_line_to_x (w, &it, target_x);




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#28936; Package emacs. Full text available.

Message received at 28936 <at> debbugs.gnu.org:


Received: (at 28936) by debbugs.gnu.org; 22 Oct 2017 19:41:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Oct 22 15:41:33 2017
Received: from localhost ([127.0.0.1]:56238 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1e6M7o-0003AL-Sa
	for submit <at> debbugs.gnu.org; Sun, 22 Oct 2017 15:41:33 -0400
Received: from eggs.gnu.org ([208.118.235.92]:53745)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1e6M7n-0003A9-KR
 for 28936 <at> debbugs.gnu.org; Sun, 22 Oct 2017 15:41:32 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <eliz@HIDDEN>) id 1e6M7d-00069O-KG
 for 28936 <at> debbugs.gnu.org; Sun, 22 Oct 2017 15:41:26 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:43859)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1e6M7d-00069F-GW; Sun, 22 Oct 2017 15:41:21 -0400
Received: from [176.228.60.248] (port=1870 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1e6M7c-0004hW-Af; Sun, 22 Oct 2017 15:41:21 -0400
Date: Sun, 22 Oct 2017 22:41:14 +0300
Message-Id: <83wp3n9did.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Keith David Bershatsky <esq@HIDDEN>
In-reply-to: <m2r2tvgf7x.wl%esq@HIDDEN> (message from Keith David
 Bershatsky on Sun, 22 Oct 2017 12:22:26 -0700)
Subject: Re: nRe: bug#28936: move_it_in_display_line_to returns
 MOVE_POS_MATCH_OR_ZV before ZV
References: <m2r2tvgf7x.wl%esq@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 28936
Cc: 28936 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: Eli Zaretskii <eliz@HIDDEN>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

> Date:  Sun, 22 Oct 2017 12:22:26 -0700
> From:  Keith David Bershatsky <esq@HIDDEN>
> Cc:  28936 <at> debbugs.gnu.org
> 
> The issue is observable at a distance of approximately up to five (5) text characters prior to ZV, rather than a distance of just one (1) it->pixel_width.  And, the issue is only present when word-wrap is non-nil.  In the example of a buffer containing only "Hello world!", the wrong result is observable on the letter "w", and on the letter "o", and on the letter "r" and on the letter "l", and on the letter "d", and on the exclamation point.  If my recollection is collect when trying out the example, the wrong result was also observable on the space between "hello" and "world".

There's something you didn't tell, because otherwise what you describe
is done all the time by the display engine, and it is certainly
incorrect that it's impossible to get to a given X coordinate, with or
without word-wrap.

It is possible that you didn't reset current_x before the iteration,
or that the window-start point is not where you think it is.  Or
something else.  This code works, it's the workhorse of many Emacs
display operations.

> The code that I borrowed is from xdisp.c at approximately 22680:  "while (it.current_x + it.pixel_width <= target_x".

That doesn't mean anything: the code you copied tries to find the
character _before_ target_x, whereas you are trying to get to target_x
itself.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#28936; Package emacs. Full text available.

Message received at 28936 <at> debbugs.gnu.org:


Received: (at 28936) by debbugs.gnu.org; 22 Oct 2017 19:22:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Oct 22 15:22:31 2017
Received: from localhost ([127.0.0.1]:56230 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1e6LpP-0002gv-8I
	for submit <at> debbugs.gnu.org; Sun, 22 Oct 2017 15:22:31 -0400
Received: from gateway24.websitewelcome.com ([192.185.51.61]:22297)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <esq@HIDDEN>) id 1e6LpO-0002gm-3Z
 for 28936 <at> debbugs.gnu.org; Sun, 22 Oct 2017 15:22:30 -0400
Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7])
 by gateway24.websitewelcome.com (Postfix) with ESMTP id B5B61C3CE
 for <28936 <at> debbugs.gnu.org>; Sun, 22 Oct 2017 14:22:28 -0500 (CDT)
Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP
 id 6LpMeEIWPHEIm6LpMeM5HX; Sun, 22 Oct 2017 14:22:28 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com
 ; s=default;
 h=Content-Type:MIME-Version:Subject:Cc:To:From:Message-ID:Date:
 Sender:Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:
 Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
 In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=uPpwDKh9uTcwAFEfO1yfE2VpsIGJZYG/Kzc44T0wpVI=; b=R+7Tfj3TQQHL1Qofptrasqfhou
 E4t65kpwV0u/9+jO8I0vEywCIhX/nw4K+X3j2buBF26ajZq/XhQ/ECm1Mj64wPmR7yle5NL5UVWMS
 dl3rnogxkSl+62GbbRm5dqEa2YhquIVPPHUR4tsn47mEGMip38QCrNpDbwxVjYz5Yq9wfPP5Oqlrg
 NEiw+lwtGbssG7PcSVC+FrCDNJzKChDUR+e90Q1yInAi40SN8Y9m0LbkgQLChhekdT3Su6ipMbiCq
 HGtG/uT8U+pcDQy408QlJ7xEL/wtlrhjOx0Xe/ILXI1IGUcGMrupsDTmSqfKS1pRdhlk3DdO2Gf2T
 IdUy1IiQ==;
Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:50613
 helo=server.private)
 by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256)
 (Exim 4.87) (envelope-from <esq@HIDDEN>)
 id 1e6LpM-003Awp-0K; Sun, 22 Oct 2017 14:22:28 -0500
Date: Sun, 22 Oct 2017 12:22:26 -0700
Message-ID: <m2r2tvgf7x.wl%esq@HIDDEN>
From: Keith David Bershatsky <esq@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: nRe: bug#28936: move_it_in_display_line_to returns
 MOVE_POS_MATCH_OR_ZV before ZV
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
X-AntiAbuse: This header was added to track abuse,
 please include it with any abuse report
X-AntiAbuse: Primary Hostname - gator3053.hostgator.com
X-AntiAbuse: Original Domain - debbugs.gnu.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - lawlist.com
X-BWhitelist: no
X-Source-IP: 45.48.239.195
X-Exim-ID: 1e6LpM-003Awp-0K
X-Source: 
X-Source-Args: 
X-Source-Dir: 
X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.private)
 [45.48.239.195]:50613
X-Source-Auth: lawlist
X-Email-Count: 1
X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t
X-Local-Domain: yes
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 28936
Cc: 28936 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

The issue is observable at a distance of approximately up to five (5) text characters prior to ZV, rather than a distance of just one (1) it->pixel_width.  And, the issue is only present when word-wrap is non-nil.  In the example of a buffer containing only "Hello world!", the wrong result is observable on the letter "w", and on the letter "o", and on the letter "r" and on the letter "l", and on the letter "d", and on the exclamation point.  If my recollection is collect when trying out the example, the wrong result was also observable on the space between "hello" and "world".

The code that I borrowed is from xdisp.c at approximately 22680:  "while (it.current_x + it.pixel_width <= target_x".

I am running out the door for a few hours, and can try changing the while loop condition when I return -- however, I am fairly confident that copying the code at 22680 for this particular use case is what is needed.

Thanks,

Keith

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

DATE:  [10-22-2017 11:30:45] <22 Oct 2017 21:30:45 +0300>
FROM:  Eli Zaretskii <eliz@HIDDEN>
> 
> * * *
> 
> > With respect to `move_it_in_display_line`, I was not able to reliably land on `it.first_visible_x + lnum_pixel_width` when horizontal scrolling to the right AND text truncated on the left.  IT overshoots the target by one text character.
> 
> This means you have an off-by-one error, probably because you are
> not computing the target X coordinate correctly.  The mistake I show
> below is probably the same mistake you do elsewhere.
> 
> >   while (it->current_x + it->pixel_width <= target_x
> 
> This condition will cause the iterator to attempt to get to the
> character _after_ point, where it will hit ZV.  So what you see, viz.:
> 
> > STEP #5:  Observe that the result is "1" when it should be "2".
> 
> is expected.  You should change the condition to this:
> 
>    while (it->current_x < target_x




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#28936; Package emacs. Full text available.

Message received at 28936 <at> debbugs.gnu.org:


Received: (at 28936) by debbugs.gnu.org; 22 Oct 2017 18:31:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Oct 22 14:31:06 2017
Received: from localhost ([127.0.0.1]:56181 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1e6L1d-00061H-Pt
	for submit <at> debbugs.gnu.org; Sun, 22 Oct 2017 14:31:06 -0400
Received: from eggs.gnu.org ([208.118.235.92]:44125)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1e6L1c-00060m-7g
 for 28936 <at> debbugs.gnu.org; Sun, 22 Oct 2017 14:31:04 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <eliz@HIDDEN>) id 1e6L1S-0005h0-7f
 for 28936 <at> debbugs.gnu.org; Sun, 22 Oct 2017 14:30:58 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40,RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:43094)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1e6L1S-0005gn-3t; Sun, 22 Oct 2017 14:30:54 -0400
Received: from [176.228.60.248] (port=1799 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1e6L1R-0006R5-2p; Sun, 22 Oct 2017 14:30:53 -0400
Date: Sun, 22 Oct 2017 21:30:45 +0300
Message-Id: <83zi8j9gru.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Keith David Bershatsky <esq@HIDDEN>
In-reply-to: <m2shebgirq.wl%esq@HIDDEN> (message from Keith David
 Bershatsky on Sun, 22 Oct 2017 11:05:45 -0700)
Subject: Re: bug#28936: move_it_in_display_line_to returns
 MOVE_POS_MATCH_OR_ZV before ZV
References: <m2shebgirq.wl%esq@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 28936
Cc: 28936 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: Eli Zaretskii <eliz@HIDDEN>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

> Date:  Sun, 22 Oct 2017 11:05:45 -0700
> From:  Keith David Bershatsky <esq@HIDDEN>
> Cc:  28936 <at> debbugs.gnu.org
> 
> Thank you, Eli, for looking into #28936.

I don't think there's any bug here.

> With respect to `move_it_in_display_line`, I was not able to reliably land on `it.first_visible_x + lnum_pixel_width` when horizontal scrolling to the right AND text truncated on the left.  IT overshoots the target by one text character.

This means you have an off-by-one error, probably because you are
not computing the target X coordinate correctly.  The mistake I show
below is probably the same mistake you do elsewhere.

>   while (it->current_x + it->pixel_width <= target_x

This condition will cause the iterator to attempt to get to the
character _after_ point, where it will hit ZV.  So what you see, viz.:

> STEP #5:  Observe that the result is "1" when it should be "2".

is expected.  You should change the condition to this:

   while (it->current_x < target_x




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#28936; Package emacs. Full text available.

Message received at 28936 <at> debbugs.gnu.org:


Received: (at 28936) by debbugs.gnu.org; 22 Oct 2017 18:05:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Oct 22 14:05:49 2017
Received: from localhost ([127.0.0.1]:56170 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1e6KdB-0005MS-FM
	for submit <at> debbugs.gnu.org; Sun, 22 Oct 2017 14:05:49 -0400
Received: from gateway36.websitewelcome.com ([192.185.188.18]:38871)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <esq@HIDDEN>) id 1e6Kd9-0005MK-HY
 for 28936 <at> debbugs.gnu.org; Sun, 22 Oct 2017 14:05:48 -0400
Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7])
 by gateway36.websitewelcome.com (Postfix) with ESMTP id AFD18401028BC
 for <28936 <at> debbugs.gnu.org>; Sun, 22 Oct 2017 13:05:46 -0500 (CDT)
Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP
 id 6Kd8eDUQcHEIm6Kd8eLHky; Sun, 22 Oct 2017 13:05:46 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com
 ; s=default;
 h=Content-Type:MIME-Version:Subject:Cc:To:From:Message-ID:Date:
 Sender:Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:
 Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
 In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=uHcBAbaWCaBYTJ1mMDsHmFJOt36+k7YDEupk8JnKIFs=; b=CmXYnPxooy5Lco4HDjXpPJ0ncP
 oL2z7xwq0aLm/jeSDJM/0gHn2eob+efKK0prCYypqn4xCggjDYdy4fGqlnj+zf9WeyXXrs/cCXPRJ
 7K9b3KAU5cZwMRmOhMTL7mcpFRHlKIQz46BZkhhBmYyO8etpEebNNQp4sk7QQcduAzxnE2U0gufWB
 gzszO/P6UxUWZEzKuYiZsNBLep1FTdI06kovR3q8p4KXlvbMlR8OLP0ykYUVOa8W6alQbMi6SH+K5
 RInAA3qxJn7dNG/P9dmbbAEtZ7C3JSd0wX7qVmnn1g5f2741fX3F/oWPMjsJi7h+KFjVPD7082NZg
 GywQEM3w==;
Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:50067
 helo=server.private)
 by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256)
 (Exim 4.87) (envelope-from <esq@HIDDEN>)
 id 1e6Kd7-0029sE-Pt; Sun, 22 Oct 2017 13:05:45 -0500
Date: Sun, 22 Oct 2017 11:05:45 -0700
Message-ID: <m2shebgirq.wl%esq@HIDDEN>
From: Keith David Bershatsky <esq@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#28936: move_it_in_display_line_to returns
 MOVE_POS_MATCH_OR_ZV before ZV
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
X-AntiAbuse: This header was added to track abuse,
 please include it with any abuse report
X-AntiAbuse: Primary Hostname - gator3053.hostgator.com
X-AntiAbuse: Original Domain - debbugs.gnu.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - lawlist.com
X-BWhitelist: no
X-Source-IP: 45.48.239.195
X-Exim-ID: 1e6Kd7-0029sE-Pt
X-Source: 
X-Source-Args: 
X-Source-Dir: 
X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.private)
 [45.48.239.195]:50067
X-Source-Auth: lawlist
X-Email-Count: 1
X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t
X-Local-Domain: yes
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 28936
Cc: 28936 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.0 (/)

Thank you, Eli, for looking into #28936.

With respect to `move_it_in_display_line`, I was not able to reliably land on `it.first_visible_x + lnum_pixel_width` when horizontal scrolling to the right AND text truncated on the left.  IT overshoots the target by one text character.  After trial an error, I assumed that this one text character overshoot was due to a built-in limitation of that function.  Hence, I have written `move_it_in_display_line_to_x` so that I can reach any X.

I was able to reproduce the MOVE_POS_MATCH_OR_ZV bug when word-wrap is non-nil.  I have disabled the workaround of `&& IT_CHARPOS (*IT) == ZV` so that we can see the bug in action.

I have not yet created a minimal working example to demonstrate the MOVE_LINE_TRUNCATED bug when trying to reach an X that is approximately 1000 or greater while horizontal scrolling a current line.  There is a comment about that issue below:  "When `auto-hscroll-mode' is set to ..."

Here is a recipe demonstrating the MOVE_POS_MATCH_OR_ZV bug:

STEP #1:  Add the two functions below at an appropriate location in xdisp.c.

STEP #2:  Launch the Emacs containing the new functions.

STEP #3:  In a scratch buffer, type:  Hello world!

[ZV must immediately follow "!" for this example to work.]

STEP #4:  Place the cursor somewhere on the word "world", and evaluate: (bug-28936 (selected-window))

STEP #5:  Observe that the result is "1" when it should be "2".

int
move_it_in_display_line_to_x (struct window *w, struct it *it, int target_x)
{
  struct it saved_it;
  void *saved_data = bidi_shelve_cache ();
  enum move_it_result rc = MOVE_X_REACHED;
  int new_x, prev_x;
  /* Advance straight to `it->first_visible_x` if IT is prior thereto. */
  if (it->current_x < it->first_visible_x)
    move_it_in_display_line_to (it, ZV, it->first_visible_x, MOVE_TO_POS | MOVE_TO_X);
  /* When `auto-hscroll-mode' is set to `current-line` and we are horizontal scrolling
  a long line that approaches or exceeds an `it.current.x` of approximately 1000, `rc`
  will erroneously return early with a MOVE_LINE_TRUNCATED indicator  without pushing
  forwards until IT reaches the target_x.  As a workaround, ignore MOVE_LINE_TRUNCATED. */
  while (it->current_x + it->pixel_width <= target_x
         && (rc == MOVE_X_REACHED
             || rc == MOVE_LINE_TRUNCATED
             || (it->line_wrap == WORD_WRAP
                 && rc == MOVE_POS_MATCH_OR_ZV)))
    {
      SAVE_IT (saved_it, *it, saved_data);
      new_x = it->current_x + it->pixel_width;
      if (new_x == it->current_x)
        new_x++;
      rc = move_it_in_display_line_to (it, ZV, new_x, MOVE_TO_POS | MOVE_TO_X);
      if (ITERATOR_AT_END_OF_LINE_P (it)
          || FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
          /* There is a bug in `move_it_in_display_line_to' such that it returns
          MOVE_POS_MATCH_OR_ZV before reaching ZV when the latter is at the end
          of the line:  abcdefg[EOB].  The workaround is to add an extra check
          using IT_CHARPOS and comparing it to ZV. */
          || (rc == MOVE_POS_MATCH_OR_ZV
              /* && IT_CHARPOS (*it) == ZV */
              ))
        break;
    }
  /* When word-wrap is on, TO_X may lie past the end of a wrapped line.
  Then it->current is the character on the next line, so backtrack to the
  space before the wrap point.  */
  if (it->line_wrap == WORD_WRAP
      && rc == MOVE_LINE_CONTINUED)
    {
      prev_x = max (it->current_x - 1, 0);
      RESTORE_IT (it, &saved_it, saved_data);
      move_it_in_display_line_to (it, -1, prev_x, MOVE_TO_X);
    }
  bidi_unshelve_cache (saved_data, true);
  return rc;
}

DEFUN ("bug-28936", Fbug_28936, Sbug_28936, 1, 1, 0,
       doc: /* Demonstrate the Emacs bug # 28936. */)
  (Lisp_Object window)
{
  struct window *w = decode_live_window (window);
  struct it it;
  void *itdata = bidi_shelve_cache ();
  struct text_pos start_text_position;
  int target_x;
  enum move_it_result rc;
  struct buffer *b = XBUFFER (w->contents);
  b->word_wrap_ = Qt;
  SET_TEXT_POS_FROM_MARKER (start_text_position, w->start);
  start_display (&it, w, start_text_position);
  move_it_to (&it, PT, it.last_visible_x, it.last_visible_y - 1, -1, MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y);
  target_x = it.current_x;
  move_it_by_lines (&it, 0);
  rc = move_it_in_display_line_to_x (w, &it, target_x);
  bidi_unshelve_cache (itdata, false);
  return make_number (rc);
}




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#28936; Package emacs. Full text available.

Message received at 28936 <at> debbugs.gnu.org:


Received: (at 28936) by debbugs.gnu.org; 22 Oct 2017 14:13:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Oct 22 10:13:05 2017
Received: from localhost ([127.0.0.1]:55999 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1e6Gzx-0006Dz-Bn
	for submit <at> debbugs.gnu.org; Sun, 22 Oct 2017 10:13:05 -0400
Received: from eggs.gnu.org ([208.118.235.92]:54557)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1e6Gzv-0006DW-W2
 for 28936 <at> debbugs.gnu.org; Sun, 22 Oct 2017 10:13:04 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <eliz@HIDDEN>) id 1e6Gzm-0007gE-0J
 for 28936 <at> debbugs.gnu.org; Sun, 22 Oct 2017 10:12:58 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-0.0 required=5.0 tests=BAYES_40,RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:40029)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1e6Gzl-0007g9-Ta; Sun, 22 Oct 2017 10:12:53 -0400
Received: from [176.228.60.248] (port=1259 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1e6Gzl-0005z5-Da; Sun, 22 Oct 2017 10:12:53 -0400
Date: Sun, 22 Oct 2017 17:12:50 +0300
Message-Id: <83efpvb7a5.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Keith David Bershatsky <esq@HIDDEN>
In-reply-to: <m24lqr3gsg.wl%esq@HIDDEN> (message from Keith David
 Bershatsky on Sat, 21 Oct 2017 22:14:39 -0700)
Subject: Re: bug#28936: move_it_in_display_line_to returns MOVE_POS_MATCH_OR_ZV
 before ZV
References: <m260b73mvx.wl%esq@HIDDEN> <m24lqr3gsg.wl%esq@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 28936
Cc: 28936 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: Eli Zaretskii <eliz@HIDDEN>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

> Date: Sat, 21 Oct 2017 22:14:39 -0700
> From: Keith David Bershatsky <esq@HIDDEN>
> 
> Here is a second draft move_it_in_display_line_to_x, with compatibility for word-wrap and also horizontal scrolling the current line that erroneously returns MOVE_LINE_TRUNCATED when trying to reach a target X that is about 1,000 pixels from the beginning of the line.

Once again, please show either a recipe in "emacs -Q" or a stand-alone
code snippet, which demonstrate the issues you mention.  FWIW, I
couldn't find such vulnerabilities by code inspection.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#28936; Package emacs. Full text available.

Message received at 28936 <at> debbugs.gnu.org:


Received: (at 28936) by debbugs.gnu.org; 22 Oct 2017 14:10:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Oct 22 10:10:33 2017
Received: from localhost ([127.0.0.1]:55994 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1e6GxU-0006A6-TV
	for submit <at> debbugs.gnu.org; Sun, 22 Oct 2017 10:10:33 -0400
Received: from eggs.gnu.org ([208.118.235.92]:52210)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1e6GxT-00069u-M7
 for 28936 <at> debbugs.gnu.org; Sun, 22 Oct 2017 10:10:31 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <eliz@HIDDEN>) id 1e6GxJ-00063O-74
 for 28936 <at> debbugs.gnu.org; Sun, 22 Oct 2017 10:10:26 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD
 autolearn=disabled version=3.3.2
Received: from fencepost.gnu.org ([2001:4830:134:3::e]:39742)
 by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <eliz@HIDDEN>)
 id 1e6GxI-00063E-VN; Sun, 22 Oct 2017 10:10:21 -0400
Received: from [176.228.60.248] (port=1258 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1e6GxI-00052s-CR; Sun, 22 Oct 2017 10:10:20 -0400
Date: Sun, 22 Oct 2017 17:10:17 +0300
Message-Id: <83fuabb7ee.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Keith David Bershatsky <esq@HIDDEN>
In-reply-to: <m260b73mvx.wl%esq@HIDDEN> (message from Keith David
 Bershatsky on Sat, 21 Oct 2017 20:02:58 -0700)
Subject: Re: bug#28936: move_it_in_display_line_to returns MOVE_POS_MATCH_OR_ZV
 before ZV
References: <m260b73mvx.wl%esq@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
X-Received-From: 2001:4830:134:3::e
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: 28936
Cc: 28936 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Reply-To: Eli Zaretskii <eliz@HIDDEN>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

> Date: Sat, 21 Oct 2017 20:02:58 -0700
> From: Keith David Bershatsky <esq@HIDDEN>
> 
> 1.  `move_it_in_display_line' could use an additional comment at the outset to let readers know that it is not compatible with moving to X in a horizontal scrolling and/or truncate lines situation.  The existing commentary that it was intended for external use was insufficient to deter me, and it required a learning curve on my part to better understand its limited potential use.

More commentary can never do any harm, but the incompatibility you
describe is news to me.  Can you show a recipe in "emacs -Q" that
would demonstrate this issue?  Or show a complete code snippet,
starting with start_display or init_iterator, where this issue
happens?

> 2.  When IT is on the last line in the buffer containing a few or more characters, `move_it_in_display_line_to' stops short of the target X and erroneously returns MOVE_POS_MATCH_OR_ZV when used as follows.  I have display-line-numbers set to a non-nil value in the event that makes a difference.  There is nothing special in terms of text-properties or overlays present in the buffer.
> 
>     int target_x = [Some arbitrary X that is a few characters before ZV.];
> 
>     move_it_in_display_line_to (it, ZV, target_x, MOVE_TO_POS | MOVE_TO_X);

You don't show how the value of 'it' was set up before this call, so
it's hard to look into this issue.  I can only tell that I've reviewed
all the code paths that lead to MOVE_POS_MATCH_OR_ZV being returned,
and they all seem to be conditioned either on reaching the position or
hitting ZV.  Maybe I missed something, but without a complete code
snippet that's the best I could do.

> The workaround is to compare the result of MOVE_POS_MATCH_OR_ZV with IT_CHARPOS to ensure that we are really at a ZV situation.

MOVE_POS_MATCH_OR_ZV doesn't necessarily mean you are at ZV, you could
also be at POS or after it.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#28936; Package emacs. Full text available.

Message received at 28936 <at> debbugs.gnu.org:


Received: (at 28936) by debbugs.gnu.org; 22 Oct 2017 05:14:45 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Oct 22 01:14:45 2017
Received: from localhost ([127.0.0.1]:54850 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1e68az-0007tg-Gg
	for submit <at> debbugs.gnu.org; Sun, 22 Oct 2017 01:14:45 -0400
Received: from gateway30.websitewelcome.com ([192.185.192.34]:34129)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <esq@HIDDEN>) id 1e68ax-0007tX-0U
 for 28936 <at> debbugs.gnu.org; Sun, 22 Oct 2017 01:14:43 -0400
Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9])
 by gateway30.websitewelcome.com (Postfix) with ESMTP id 6232452FE
 for <28936 <at> debbugs.gnu.org>; Sun, 22 Oct 2017 00:14:42 -0500 (CDT)
Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP
 id 68aueM4Y45b6T68aved28q; Sun, 22 Oct 2017 00:14:42 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com
 ; s=default;
 h=Content-Type:MIME-Version:Subject:To:From:Message-ID:Date:
 Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description:
 Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
 In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=m4dW39vb7N5UJ4BcxhJkrLefty2g1K7owlPk2j8hKAg=; b=LwubBlR1qymD6M45DkSyx6D03Z
 PQvrSSjC2xiMgPlWzvsWTZdIHe7fnHH9VwZmNmR5BBCJQOOXp9hE6Wn2aumaijiJM/oxebPvTJ5kg
 mQeZ0Ew7kQsp5h4gMlXg41fcETd3k2fMK0E0Hq1IoZc4W6r3oWPl8O/DPxkhGqCisn4En3WTKyxdU
 nVkdaKnT5PNRMfEuEq0KFhQViLY/zjqOTOPZtAQ1ES351Ut6h6cP1twdUB3BXZHeCcAE6IRP/iMWG
 jTCN8ifqNTJ8HTXVNqr6OKAepRi9xVBFcfngVDNw7xCSHCxomWQUvvfgnusTeIRTbEt38YEcNJKSi
 S4fRYQXg==;
Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:53887
 helo=server.private)
 by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256)
 (Exim 4.87) (envelope-from <esq@HIDDEN>) id 1e68au-0049Ps-Ju
 for 28936 <at> debbugs.gnu.org; Sun, 22 Oct 2017 00:14:40 -0500
Date: Sat, 21 Oct 2017 22:14:39 -0700
Message-ID: <m24lqr3gsg.wl%esq@HIDDEN>
From: Keith David Bershatsky <esq@HIDDEN>
To: 28936 <at> debbugs.gnu.org
Subject: move_it_in_display_line_to returns MOVE_POS_MATCH_OR_ZV before ZV
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
X-AntiAbuse: This header was added to track abuse,
 please include it with any abuse report
X-AntiAbuse: Primary Hostname - gator3053.hostgator.com
X-AntiAbuse: Original Domain - debbugs.gnu.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - lawlist.com
X-BWhitelist: no
X-Source-IP: 45.48.239.195
X-Exim-ID: 1e68au-0049Ps-Ju
X-Source: 
X-Source-Args: 
X-Source-Dir: 
X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.private)
 [45.48.239.195]:53887
X-Source-Auth: lawlist
X-Email-Count: 1
X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t
X-Local-Domain: yes
X-Spam-Score: 0.5 (/)
X-Debbugs-Envelope-To: 28936
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: 0.5 (/)

Here is a second draft move_it_in_display_line_to_x, with compatibility for word-wrap and also horizontal scrolling the current line that erroneously returns MOVE_LINE_TRUNCATED when trying to reach a target X that is about 1,000 pixels from the beginning of the line.

int
move_it_in_display_line_to_x (struct window *w, struct it *it, int target_x)
{
  struct it saved_it;
  void *saved_data = bidi_shelve_cache ();
  enum move_it_result rc = MOVE_X_REACHED;
  int new_x, prev_x;
  /* Advance straight to `it->first_visible_x` if IT is prior thereto. */
  if (it->current_x < it->first_visible_x)
    move_it_in_display_line_to (it, ZV, it->first_visible_x, MOVE_TO_POS | MOVE_TO_X);
  /* When horizontal scrolling a long line that approach or exceed an `it.current.x`
  of approximately 1000, `rc` will erroneously return early as MOVE_LINE_TRUNCATED
  without pushing on forwards until it reaches the target_x.  As a workaround, we
  ignore MOVE_LINE_TRUNCATED.  It is uncertain whether this is a bug. */
  while (it->current_x + it->pixel_width <= target_x
         && (rc == MOVE_X_REACHED
             || rc == MOVE_LINE_TRUNCATED
             || (it->line_wrap == WORD_WRAP
                 && rc == MOVE_POS_MATCH_OR_ZV)))
    {
      SAVE_IT (saved_it, *it, saved_data);
      new_x = it->current_x + it->pixel_width;
      if (new_x == it->current_x)
        new_x++;
      rc = move_it_in_display_line_to (it, ZV, new_x, MOVE_TO_POS | MOVE_TO_X);
      if (ITERATOR_AT_END_OF_LINE_P (it)
          || FETCH_BYTE (IT_BYTEPOS (*it)) == '\n'
          /* There is a bug in `move_it_in_display_line_to' such that it returns
          MOVE_POS_MATCH_OR_ZV before reaching ZV when the latter is at the end
          of the line:  abcdefg[EOB].  The workaround is to add an extra check
          using IT_CHARPOS and comparing it to ZV. */
          || (rc == MOVE_POS_MATCH_OR_ZV
              && IT_CHARPOS (*it) == ZV))
        break;
    }
  /* When word-wrap is on, TO_X may lie past the end of a wrapped line.
  Then it->current is the character on the next line, so backtrack to the
  space before the wrap point.  */
  if (it->line_wrap == WORD_WRAP
      && rc == MOVE_LINE_CONTINUED)
    {
      prev_x = max (it->current_x - 1, 0);
      RESTORE_IT (it, &saved_it, saved_data);
      move_it_in_display_line_to (it, -1, prev_x, MOVE_TO_X);
    }
  bidi_unshelve_cache (saved_data, true);
  return rc;
}




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#28936; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 22 Oct 2017 03:03:29 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 21 23:03:29 2017
Received: from localhost ([127.0.0.1]:54823 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1e66Xw-0004Y2-Vd
	for submit <at> debbugs.gnu.org; Sat, 21 Oct 2017 23:03:29 -0400
Received: from eggs.gnu.org ([208.118.235.92]:33328)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <esq@HIDDEN>) id 1e66Xv-0004Xp-1R
 for submit <at> debbugs.gnu.org; Sat, 21 Oct 2017 23:03:27 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <esq@HIDDEN>) id 1e66Xo-00085U-N6
 for submit <at> debbugs.gnu.org; Sat, 21 Oct 2017 23:03:21 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,T_DKIM_INVALID
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:47024)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <esq@HIDDEN>) id 1e66Xo-00084o-Jj
 for submit <at> debbugs.gnu.org; Sat, 21 Oct 2017 23:03:20 -0400
Received: from eggs.gnu.org ([2001:4830:134:3::10]:52529)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <esq@HIDDEN>) id 1e66Xn-00074l-7I
 for bug-gnu-emacs@HIDDEN; Sat, 21 Oct 2017 23:03:20 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <esq@HIDDEN>) id 1e66Xk-0007iZ-13
 for bug-gnu-emacs@HIDDEN; Sat, 21 Oct 2017 23:03:19 -0400
Received: from gateway24.websitewelcome.com ([192.185.51.56]:18220)
 by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
 (Exim 4.71) (envelope-from <esq@HIDDEN>) id 1e66Xj-0006i9-Nz
 for bug-gnu-emacs@HIDDEN; Sat, 21 Oct 2017 23:03:15 -0400
Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7])
 by gateway24.websitewelcome.com (Postfix) with ESMTP id A12ECED62
 for <bug-gnu-emacs@HIDDEN>; Sat, 21 Oct 2017 22:02:59 -0500 (CDT)
Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP
 id 66XTe3LqtHEIm66XTeBG9N; Sat, 21 Oct 2017 22:02:59 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com
 ; s=default;
 h=Content-Type:MIME-Version:Subject:To:From:Message-ID:Date:
 Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description:
 Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:
 In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:
 List-Post:List-Owner:List-Archive;
 bh=z1Rv8gypq4ZiVytmOr+otfMivbRWM/le7GV9c3MxMEw=; b=hiB3SbuJEgmnr9Fb8DXESQ00E4
 L4zwuOdyXgzFHwn9McD+v4TFynC21HcxegDVtRwR7KOVNCtDKoWeksc5TFM+v39lZhy1X6BsTIWzl
 1RxSCrEOCXHIxZlQm9dGZdHpDrGO3EUWkUIPaO8c5M97klh5pGZGOArUEL7COAOSd+R/LY0aD5tT0
 cH+fZsIlq4t0Bt4W7M0VGS1ZIio8AB1Uw7Am0fHcImUFTVGbDZvXWQJoCfjRB1RN2iesJFCs2xXOP
 5lpsS3HKVsmBQAYlzot5xZoMXOz15VjisHKen+/fjlI8jBWcfSdRqdNlKBGU9RYefr7nq3uIphvnB
 tW5rXk2A==;
Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:53047
 helo=server.private)
 by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256)
 (Exim 4.87) (envelope-from <esq@HIDDEN>) id 1e66XT-002MZC-0w
 for bug-gnu-emacs@HIDDEN; Sat, 21 Oct 2017 22:02:59 -0500
Date: Sat, 21 Oct 2017 20:02:58 -0700
Message-ID: <m260b73mvx.wl%esq@HIDDEN>
From: Keith David Bershatsky <esq@HIDDEN>
To: Emacs Bug Reports <bug-gnu-emacs@HIDDEN>
Subject: move_it_in_display_line_to returns MOVE_POS_MATCH_OR_ZV before ZV
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
X-AntiAbuse: This header was added to track abuse,
 please include it with any abuse report
X-AntiAbuse: Primary Hostname - gator3053.hostgator.com
X-AntiAbuse: Original Domain - gnu.org
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - lawlist.com
X-BWhitelist: no
X-Source-IP: 45.48.239.195
X-Exim-ID: 1e66XT-002MZC-0w
X-Source: 
X-Source-Args: 
X-Source-Dir: 
X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.private)
 [45.48.239.195]:53047
X-Source-Auth: lawlist
X-Email-Count: 1
X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t
X-Local-Domain: yes
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]
 [fuzzy]
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -5.0 (-----)

A couple of observations:

1.  `move_it_in_display_line' could use an additional comment at the outset to let readers know that it is not compatible with moving to X in a horizontal scrolling and/or truncate lines situation.  The existing commentary that it was intended for external use was insufficient to deter me, and it required a learning curve on my part to better understand its limited potential use.

2.  When IT is on the last line in the buffer containing a few or more characters, `move_it_in_display_line_to' stops short of the target X and erroneously returns MOVE_POS_MATCH_OR_ZV when used as follows.  I have display-line-numbers set to a non-nil value in the event that makes a difference.  There is nothing special in terms of text-properties or overlays present in the buffer.

    int target_x = [Some arbitrary X that is a few characters before ZV.];

    move_it_in_display_line_to (it, ZV, target_x, MOVE_TO_POS | MOVE_TO_X);

The workaround is to compare the result of MOVE_POS_MATCH_OR_ZV with IT_CHARPOS to ensure that we are really at a ZV situation.

Here is a working draft of what I am using for my crosshairs (#17684).

int
move_it_in_display_line_to_x (struct it *it, int target_x)
{
  struct it saved_it;
  void *saved_data = bidi_shelve_cache ();
  enum move_it_result rc = MOVE_X_REACHED;
  int new_x, prev_x;
  /* Advance straight to `it->first_visible_x` if IT is prior thereto. */
  if (it->current_x < it->first_visible_x)
    move_it_in_display_line_to (it, ZV, it->first_visible_x, MOVE_TO_POS | MOVE_TO_X);
  while (it->current_x + it->pixel_width <= target_x)
    {
      SAVE_IT (saved_it, *it, saved_data);
      new_x = it->current_x + it->pixel_width;
      if (new_x == it->current_x)
        new_x++;
      rc = move_it_in_display_line_to (it, ZV, new_x, MOVE_TO_POS | MOVE_TO_X);
      if (ITERATOR_AT_END_OF_LINE_P (it)
          || FETCH_BYTE (IT_BYTEPOS (it)) == '\n'
          /* There is a bug in `move_it_in_display_line_to' such that it returns
          MOVE_POS_MATCH_OR_ZV before reaching ZV when the latter is at the end
          of the line:  abcdefg[EOB].  The workaround is to add an extra check
          using IT_CHARPOS and comparing it to ZV. */
          || (rc == MOVE_POS_MATCH_OR_ZV
              && IT_CHARPOS (*it) == ZV))
        break;
    }
  /* When word-wrap is on, TO_X may lie past the end of a wrapped line.
  Then it->current is the character on the next line, so backtrack to the
  space before the wrap point.  */
  if (it->line_wrap == WORD_WRAP
      && rc == MOVE_LINE_CONTINUED)
    {
      prev_x = max (it->current_x - 1, 0);
      RESTORE_IT (it, &saved_it, saved_data);
      move_it_in_display_line_to (it, -1, prev_x, MOVE_TO_X);
    }
  bidi_unshelve_cache (saved_data, true);
  return rc;
}

Thanks,

Keith




Acknowledgement sent to Keith David Bershatsky <esq@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#28936; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 10 Nov 2017 02:45:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.