unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Keith David Bershatsky <esq@lawlist.com>
To: 29002@debbugs.gnu.org
Subject: bug#29002: it.first_visible_x is erroneously 0 while horizontal scrolling.
Date: Wed, 25 Oct 2017 18:03:07 -0700	[thread overview]
Message-ID: <m2h8umbu0k.wl%esq@lawlist.com> (raw)

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 "<wheel-right>") (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





             reply	other threads:[~2017-10-26  1:03 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-26  1:03 Keith David Bershatsky [this message]
2017-10-26  3:45 ` bug#29002: it.first_visible_x is erroneously 0 while horizontal scrolling Keith David Bershatsky
2017-10-26  4:51   ` Eli Zaretskii
2017-10-26  6:20 ` Keith David Bershatsky
2017-10-26 15:56   ` Eli Zaretskii
2017-10-26 18:56 ` Keith David Bershatsky
2017-10-29 11:23   ` Eli Zaretskii
2017-10-29 17:29 ` Keith David Bershatsky
2017-10-29 18:29   ` Eli Zaretskii
2017-10-29 18:56     ` Eli Zaretskii
2017-10-29 18:56 ` Keith David Bershatsky
2017-10-29 19:23   ` Eli Zaretskii
2017-10-29 19:08 ` Keith David Bershatsky
2017-10-29 20:12 ` Keith David Bershatsky
2017-10-30 18:02   ` Eli Zaretskii
2017-10-30 19:36 ` Keith David Bershatsky
2017-11-04  9:32   ` Eli Zaretskii
2017-11-05  0:16 ` Keith David Bershatsky
2017-11-05  9:15 ` Keith David Bershatsky
2017-11-05 10:44   ` Eli Zaretskii
2017-11-05 16:59 ` Keith David Bershatsky
2017-11-05 18:12   ` Eli Zaretskii
2017-11-06  1:05 ` Keith David Bershatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2h8umbu0k.wl%esq@lawlist.com \
    --to=esq@lawlist.com \
    --cc=29002@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).