bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#29002: it.first_visible_x is erroneously 0 while horizontal scrollin


From: Keith David Bershatsky
Subject: bug#29002: it.first_visible_x is erroneously 0 while horizontal scrolling.
Date: Wed, 25 Oct 2017 18:03:07 -0700

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 via email to

[Prev in Thread] Current Thread [Next in Thread]