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

From: Keith David Bershatsky <[email-masked]>
Date: Thu, 26 Oct 2017 11:56:08 -0700

Thank you for the suggestion about using w->min_hscroll.

Unfortunately, w->min_hscroll returns a value of 0 in this example.

Here is a link to a new screen-shot based upon the revised bug-hscroll test incorporating w->min_hscroll:

https://www.lawlist.com/images/bug_hscroll_02.png

And, here is the revised test used as a basis to create the new screen-shot:

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, min_hscroll;
  SET_TEXT_POS_FROM_MARKER (start_text_position, w->start);
  start_display (&it, w, start_text_position);
  first_x = it.first_visible_x;
  min_hscroll = w->min_hscroll;
  bidi_unshelve_cache (itdata, false);
  Lisp_Object my_object_one = make_number (first_x);
  Lisp_Object my_object_two = make_number (min_hscroll);
  AUTO_STRING (my_string_one, "it.first_visible_x:  %s | w->min_hscroll:  %d");
  CALLN (Fmessage, my_string_one, my_object_one, my_object_two);
  return make_number (first_x);
}

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

DATE:  [10-26-2017 08:56:23] <26 Oct 2017 18:56:23 +0300>
FROM:  Eli Zaretskii <[email-masked]>
> 
>  * * *
> > 
> > • hscrolling_current_line_p is true.
> > • w->suspend_auto_hscroll is false.
> > • w->hscroll > 0.
> > • All non-current lines are also hscrolled.
> > • it.first_visible_x == 0.
> > 
> > What would be a good method to programmatically test to see whether all other lines are hscrolled given the above?
> 
> The above means that auto-hscroll is set to 'current-line'.  In this
> case, the line that shows point is hscrolled by w->hscroll, and all
> the other lines are hscrolled by w->min_hscroll (in units of the
> frame's canonical character width).