From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: How to calculate X when dealing with truncate-lines non-nil. Date: Fri, 29 Sep 2017 19:25:44 +0300 Message-ID: <83poa979pz.fsf@gnu.org> References: Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1506702401 12346 195.159.176.226 (29 Sep 2017 16:26:41 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 29 Sep 2017 16:26:41 +0000 (UTC) Cc: emacs-devel@gnu.org To: Keith David Bershatsky Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 29 18:26:36 2017 Return-path: Envelope-to: ged-emacs-devel@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 1dxy7Q-0002SC-FG for ged-emacs-devel@m.gmane.org; Fri, 29 Sep 2017 18:26:28 +0200 Original-Received: from localhost ([::1]:36079 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxy7X-0007wA-QI for ged-emacs-devel@m.gmane.org; Fri, 29 Sep 2017 12:26:35 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxy6t-0007vu-IO for emacs-devel@gnu.org; Fri, 29 Sep 2017 12:25:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxy6q-000443-Ds for emacs-devel@gnu.org; Fri, 29 Sep 2017 12:25:55 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:48327) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxy6q-00043z-AC; Fri, 29 Sep 2017 12:25:52 -0400 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:1338 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1dxy6p-000604-Mk; Fri, 29 Sep 2017 12:25:52 -0400 In-reply-to: (message from Keith David Bershatsky on Thu, 28 Sep 2017 10:31:58 -0700) 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-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:218909 Archived-At: > Date: Thu, 28 Sep 2017 10:31:58 -0700 > From: Keith David Bershatsky > > I believe this issue is resolvable mathematically as follows: > > int x; > if (it.line_wrap == TRUNCATE) > x = it.current_x - it.first_visible_x; > else > x = it.current_x; > > Unless anyone sees a problem with this method, the issue is resolved. This could be a solution in some cases. The real answer depends on what exactly does your code do, something that you didn't disclose. In any case, I think that the 'it.line_wrap == TRUNCATE' condition is not needed: if you want the window-relative X coordinate, you should always subtract the first_visible_x value: if it's zero, no harm will be done.