From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Keith David Bershatsky Newsgroups: gmane.emacs.bugs Subject: bug#29002: it.first_visible_x is erroneously 0 while horizontal scrolling. Date: Wed, 25 Oct 2017 18:03:07 -0700 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Trace: blaine.gmane.org 1508979877 15455 195.159.176.226 (26 Oct 2017 01:04:37 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 26 Oct 2017 01:04:37 +0000 (UTC) To: 29002@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 26 03:04:30 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 1e7Wak-0001CA-8j for geb-bug-gnu-emacs@m.gmane.org; Thu, 26 Oct 2017 03:04:15 +0200 Original-Received: from localhost ([::1]:50479 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Wao-0007c5-3W for geb-bug-gnu-emacs@m.gmane.org; Wed, 25 Oct 2017 21:04:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Wab-0007aL-Ss for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2017 21:04:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7WaY-0005uj-NL for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2017 21:04:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:53312) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e7WaY-0005ub-Il for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2017 21:04:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1e7WaY-0002JD-Au for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2017 21:04:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Keith David Bershatsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 26 Oct 2017 01:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 29002 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: Emacs Bug Reports Original-Received: via spool by submit@debbugs.gnu.org id=B.15089798218838 (code B ref -1); Thu, 26 Oct 2017 01:04:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Oct 2017 01:03:41 +0000 Original-Received: from localhost ([127.0.0.1]:33759 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e7WaC-0002IU-UN for submit@debbugs.gnu.org; Wed, 25 Oct 2017 21:03:41 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:55358) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e7WaA-0002IC-Ey for submit@debbugs.gnu.org; Wed, 25 Oct 2017 21:03:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7Wa3-0005K0-To for submit@debbugs.gnu.org; Wed, 25 Oct 2017 21:03:33 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:37208) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e7Wa3-0005Je-QY for submit@debbugs.gnu.org; Wed, 25 Oct 2017 21:03:31 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e7Wa2-0007SE-BC for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2017 21:03:31 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e7WZz-0005Ff-3h for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2017 21:03:30 -0400 Original-Received: from gateway36.websitewelcome.com ([192.185.192.36]:20915) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e7WZy-00059g-QB for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2017 21:03:27 -0400 Original-Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway36.websitewelcome.com (Postfix) with ESMTP id E24D5400F7EA7 for ; Wed, 25 Oct 2017 20:03:10 -0500 (CDT) Original-Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP id 7WZhe5yeftuxm7WZheV8JP; Wed, 25 Oct 2017 20:03:10 -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=4wPeo4dQNJtvAaE+DuSZcM4RkG7myJ8wP6ZIW56sYjo=; b=gs5v/T5kXwMyuvjq5y6f0PspWK KT0SJRPQy+GAwYac/1zTE38jpKa56BkfQDKBgU1P0Crj/RfPqmN1OXDCyNoF14+SqjfVw/qCY6/QJ POirCoyIn2SIVv8i7DRr7pmQihk459auWEUaGPU6f3eYKNAfgr79wYWuYQeEMMuNwTMEJIpZHGshE ej6umZQsOOtL4wOaYr+Ipn+j1OVDTNIKSqnJcytkm4setOxognlDQatSkuKuzhdfyM/nVnSHNelA8 MtUVJ8zewFIEY+rWnrP/XVO/4yn8sNPMt0J7yPTxHFqW3fcrZEencFmnOEGk60qHzhEEqPgcyA+uV WgsAi/OA==; Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:51747 helo=server.private) by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.87) (envelope-from ) id 1e7WZg-000cEj-Op for bug-gnu-emacs@gnu.org; Wed, 25 Oct 2017 20:03:08 -0500 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: 1e7WZg-000cEj-Op 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]:51747 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-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:138987 Archived-At: I am working on developing crosshairs (#17684) and multiple fake cursors (#22873). As part of that work, I need the correct it.first_visible_x in the example recipe listed below. I have tried to workaround the bug by using w->hscroll * FRAME_COLUMN_WIDTH (f); however, I have not been able to come up with a programmatic test to identify the bug in order to implement the workaround. Implementing a workaround is complicated because I visit each visible screen line with IT, and hscl is true in this situation: bool hscl = (!w->suspend_auto_hscroll && EQ (Fbuffer_local_value (Qauto_hscroll_mode, w->contents), Qcurrent_line) && w->hscroll > 0); Here is the recipe: STEP #1: Build a new Emacs master branch incorporating the function `bug-hscroll` at an appropriate location inside xdisp.c. DEFUN ("bug-hscroll", Fbug_hscroll, Sbug_hscroll, 0, 0, 0, doc: /* Demonstrate the Emacs hscroll bug. */) (void) { struct window *w = decode_live_window (selected_window); struct it it; void *itdata = bidi_shelve_cache (); struct text_pos start_text_position; int first_x; SET_TEXT_POS_FROM_MARKER (start_text_position, w->start); start_display (&it, w, start_text_position); first_x = it.first_visible_x; bidi_unshelve_cache (itdata, false); Lisp_Object my_object_one = make_number (first_x); AUTO_STRING (my_string_one, "This is the value of it.first_visible_x: %s"); CALLN (Fmessage, my_string_one, my_object_one); return make_number (first_x); } void syms_of_xdisp (void) { defsubr (&Sbug_hscroll); DEFSYM (Qbug_hscroll, "bug-hscroll"); *** } STEP #2: Open the newly built Emacs; open a scratch buffer; and evaluate the following elisp code. (define-key global-map (kbd "") (lambda () (interactive) (scroll-right 1))) (define-key global-map [f5] (lambda () (interactive) (bug-hscroll))) (setq-local auto-hscroll-mode 'current-line) (setq display-line-numbers t) (setq truncate-lines t) STEP #3: Paste some miscellaneous long lines into the scratch buffer, e.g.,: Aliquam erat volutpat. Nunc eleifend leo vitae magna. In id erat non orci commodo lobortis. Proin neque massa, cursus ut, gravida ut, lobortis eget, lacus. Sed diam. Praesent fermentum tempor tellus. Nullam tempus. Mauris ac felis vel velit tristique imperdiet. Donec at pede. Etiam vel neque nec dui dignissim bibendum. Vivamus id enim. Phasellus neque orci, porta a, aliquet quis, semper a, massa. Phasellus purus. Pellentesque tristique imperdiet tortor. Nam euismod tellus id erat. Nullam eu ante vel est convallis dignissim. Fusce suscipit, wisi nec facilisis facilisis, est dui fermentum leo, quis tempor ligula erat quis odio. Nunc porta vulputate tellus. Nunc rutrum turpis sed pede. Sed bibendum. Aliquam posuere. Nunc aliquet, augue nec adipiscing interdum, lacus tellus malesuada massa, quis varius mi purus non odio. Pellentesque condimentum, magna ut suscipit hendrerit, ipsum augue ornare nulla, non luctus diam neque sit amet urna. Curabitur vulputate vestibulum lorem. Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor, at vulputate neque nulla lacinia eros. Sed id ligula quis est convallis tempor. Curabitur lacinia pulvinar nibh. Nam a sapien. Nullam eu ante vel est convallis dignissim. Fusce suscipit, wisi nec facilisis facilisis, est dui fermentum leo, quis tempor ligula erat quis odio. Nunc porta vulputate tellus. Nunc rutrum turpis sed pede. Sed bibendum. Aliquam posuere. Nunc aliquet, augue nec adipiscing interdum, lacus tellus malesuada massa, quis varius mi purus non odio. Pellentesque condimentum, magna ut suscipit hendrerit, ipsum augue ornare nulla, non luctus diam neque sit amet urna. Curabitur vulputate vestibulum lorem. Fusce sagittis, libero non molestie mollis, magna orci ultrices dolor, at vulputate neque nulla lacinia eros. Sed id ligula quis est convallis tempor. Curabitur lacinia pulvinar nibh. Nam a sapien. STEP #4: Place the cursor at the END of one of the newly pasted long lines of miscellaneous text. STEP #5: Scroll right using the horizontal mouse wheel (if you have one, or some equivalent thereof if you don't). STEP #6: Press the F5 key. See that it.first_visible_x is GREATER than 0. STEP #7: Move the arrow key one character to the left. We remain horizontally scrolled to the right; i.e., pressing the left arrow-key does not cancel the horizontal scrolling. STEP #8: Press the F5 key. See that it.first_visible_x is erroneously 0. EXPECTATION: it.first_visible_x should be equal to w->hscroll * FRAME_COLUMN_WIDTH (f). And, keep in mind that the current-line can also horizontally scroll ... Thanks, Keith