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

From: Ihor Radchenko <[email-masked]>
Date: Tue, 16 Aug 2022 19:30:11 +0800

Eli Zaretskii <[email-masked]> writes:

>> Also, I just checked some of my org files and found a >15k chars long line.
>
> 5k shouldn't present a problem, especially when some/most of it is
> invisible (as frequently is the case in Org).  15k might be a problem,
> indeed, depending on what's there.  However, since you never
> complained about long lines until this day, I guess it isn't such a
> big problem.

You are likely right. Note that this branch of the discussion mostly
started from me clarifying data about some large Org files. I did not
imply that Org files commonly have very long lines. Simply large-sized
Org files are more common (5-20Mb).

Also, regarding most of the lines being invisible. Unless I miss
something, jit-lock actually tries to trigger fontification in the
invisible lines when we have something like:
-- <window top>
* headline
<Mbs of invisible text hidden using 'invisible text property>
* another headline
-- <window bottom>

I even had to write a dedicated filter in
org-fold-core.el:org-fold-core-fontify-region (on Org main branch) to
avoid fontification inside hidden text.

-- 
Ihor Radchenko,
Org mode contributor,
Learn more about Org mode at https://orgmode.org/.
Support Org development at https://liberapay.com/org-mode,
or support my work at https://liberapay.com/yantar92