Subject: Re: bug#18545: 24.4.50: Bug - forward-line inside with-selected-window

From: martin rudalics <[email-masked]>
Date: Sat, 27 Sep 2014 15:36:49 +0200

> AFAIU, this means the window is not being redrawn on each
 > forward-line; not even its mode line is updated.  You should be able
 > to confirm this if you turn on trace-redisplay (assuming you've built
 > with GLYPH_DEBUG, a.k.a. "--enable-checking=glyphs") -- you will not
 > see the window announced in the trace.  (Btw, turning off
 > blink-cursor-mode removes a lot of clutter from the redisplay trace,
 > so I suggest to do that in these experiments.)

I attach an output, can't make much head or tail of it.  The *sidebar*
window is the one with the problem, the .emacs window the one on the
right of it.

 > If you add to the function that calls forward-line a message showing
 > point, do you see the value of point move on each forward-line even
 > though the window is not redrawn?

Simply copied from the *Messages* buffer the positions appear as:

17
22
27
32
37
42
47
52
57
62
67
72
77
82
87
92
97
102
107
112
117
122 [28 times]
127
132 [21 times]
137 [23 times]
142 [23 times]
147 [7 times]
Auto-saving...
147 [3 times]
152
157 [22 times]
162 [23 times]
167 [23 times]
172 [9 times]

Each line contains four characters and apparently stuttering begins
at position 122.

 >>   >        if (!cursor_row_fully_visible_p (w, 0, 0))
 >>   >          {
 >>   > 	   w->cursor.vpos = -1;
 >>   > 	   clear_glyph_matrix (w->desired_matrix);
 >>   > 	   goto try_to_scroll;
 >>   > 	}
 >>   >
 >>   > after the call to set_cursor_from_row on line 16322.
 >>   >
 >>   > If this doesn't work, please see why.
 >>
 >> It fails to do anything because running cursor_row_fully_visible_p
 >> returns at
 >>
 >>     if (!MATRIX_ROW_PARTIALLY_VISIBLE_P (w, row))
 >>       return 1;
 >>
 >> and this one apparently fails to detect that the row is partially visible
 >> because of
 >>
 >> (gdb) p row->height
 >> $5 = 16
 >> (gdb) p row->visible_height
 >> $6 = 16
 >>
 >> Any ideas?
 >
 > What is last_visible_y in that window?  To see that, step into
 > try_window called on line 16235, wait until it calls start_display,
 > and look at it.last_visible_y.

At the xdisp.c line reading:

   while (it.current_y < it.last_visible_y)

I have

(gdb) p it.last_visible_y
$7 = 442

and (just to confirm the earlier posted) at the xdisp.c line reading

	  if (new_vpos >= w->cursor.y)

I have:

(gdb) p new_vpos
$10 = 426
(gdb) p w->cursor.y
$11 = 432

 >> BTW is there a way to print the value returned by a macro in gdb?
 >
 > Yes, just print it:
 >
 >   (gdb) p MATRIX_ROW_PARTIALLY_VISIBLE_P (w, row)

Here I get

(gdb) p MATRIX_ROW_PARTIALLY_VISIBLE_P (w, row)
No symbol "__FILE__" in current context.

 > If this doesn't work, perhaps you didn't build with -g3,

I used CPPFLAGS='-DGLYPH_DEBUG=1' CFLAGS='-O0 -g3'

 > or your
 > compiler is buggy.

Hmm...

martin

As an aside, in my function calling `forward-line' I found this

;;   (unless (pos-visible-in-window-p (point) (selected-window))
;;     (recenter (- (window-height) 2)))) ; what for did I use that ?

commented out at least since 2008-06-24.  Apparently something here did
behave differently many years ago.  BTW, the bug does not disappear when
I comment in those lines.