Subject: Re: bug#56393: Actually fix the long lines display bug

From: Gregory Heytings <[email-masked]>
Date: Sat, 16 Jul 2022 19:39:18 +0000

I just pushed several improvements to the feature branch.

A few comments:

It turns out that it is not possible to calculate the restriction in 
start_display and/or in redisplay_window, because the restriction must 
also be used outside of redisplay.  I tried various approaches, and my 
conclusion is that the best place to calculate the restriction is 
init_iterator.

Using the size of the glyph matrix also turned out to be impractical, 
because the glyph matrix grows when the default font size becomes smaller 
(for example with C-x C-M--) but does not shrink when it becomes larger 
(with C-x C-M-+).  So I've used another formula, still based on 
window_body_{width,height}.

The optimizations now only apply to buffers which contain long lines, so 
the C-u 37100 C-p recipe in xdisp.c works as expected.

I also replaced the WITH_NARROWED_BEGV macro with another one, 
SET_WITH_NARROWED_BEGV.  I'm not convinced that defining another function, 
for example find_newline_no_quit_with_narrowed_begv, would be optimal, 
especially given that there is (in get_visually_first_element) a simple 
assignment that must be evaluated with a narrowed BEGV.