Subject: bug#56682: locked narrowing

From: Gregory Heytings <[email-masked]>
Date: Wed, 30 Nov 2022 14:40:36 +0000

>
> I don't think I understand why it should be problematic or unsafe to 
> limit the same loop we have to a smaller region of the buffer.
>

I see that you already changed the loop to scan from BEG to Z to only scan 
from BEGV to ZV; somehow I missed that change.  I don't think even that is 
correct: a command could insert text in the buffer outside of BEGV/ZV. 
While limiting the loop to a smaller region of the buffer looks like a 
reasonable thing to do, the question is: how can we determine that region? 
And I don't see how this can be done, because the detection code is called 
only when a buffer is about to be displayed, and at that moment we cannot 
know where characters were inserted in the buffer.  What the code does now 
is "if enough characters have been inserted in the buffer since last 
redisplay, check again whether the buffer contains long lines".

>
> It should be clear that triggering such long searches should not be too 
> hard.
>

The search is not that long, and it is not triggered for regular editing 
commands, e.g. while typing or when killing / yanking a line in a buffer.