all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#29002: it.first_visible_x is erroneously 0 while horizontal scrolling.
@ 2017-10-26  1:03 Keith David Bershatsky
  2017-10-26  3:45 ` Keith David Bershatsky
                   ` (11 more replies)
  0 siblings, 12 replies; 23+ messages in thread
From: Keith David Bershatsky @ 2017-10-26  1:03 UTC (permalink / raw)
  To: 29002

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





^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2017-11-06  1:05 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-26  1:03 bug#29002: it.first_visible_x is erroneously 0 while horizontal scrolling Keith David Bershatsky
2017-10-26  3:45 ` 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

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.