Subject: bug#56682: Fix the long lines font locking related slowdowns

From: Gregory Heytings <[email-masked]>
Date: Fri, 05 Aug 2022 14:09:30 +0000

>> But if you're so annoyed by mis-fontification, why don't you just turn 
>> font-lock mode off?
>
> "If you're annoyed by Emacs's performance with large files, why don't 
> you just never open them?"
>

That's just wrong: in one case we're talking about your personal 
feelings/preferences, in the other one about Emacs' capabilities for all 
its users.

>
> I like font-lock and the visual cues that come with it. Only 
> font-locking the first 1 MB of a large file seems like a good 
> compromise: show correct highlighting where we can with reasonable 
> performance, and omit it in the rest of the file.
>

So what you prefer IIUC would be to call fontification-functions with a 
locked narrowing to 1 MB if point is before that threshold, and to not 
call fontification-functions at all after that threshold?  That might be 
another doable approach.

>> Also, why did you not protest vehemently when Stefan added 
>> syntax-wholeline-max, which also causes occasional mis-fontification?
>
> I have replied to this exact question in an earlier email. We can 
> continue this line of inquiry in that subthread.
>

Sorry, I missed that part of your earlier post:

>
> syntax-wholelines-max indeed can potentially cause problems too, but in 
> a much narrow range of situations (and only with major modes which have 
> non-trivial syntax-propertize-function).
>

You forget to metion that syntax-wholelines-max can in fact make things 
much worse, see the recipes I sent you a few days ago.  So it doesn't seem 
like it's the right approach.