emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Re: cc-mode fontification feels random


From: Alan Mackenzie
Subject: Re: [PATCH] Re: cc-mode fontification feels random
Date: Tue, 31 Aug 2021 10:54:23 +0000

Hello, Stefan.

On Mon, Aug 30, 2021 at 16:11:18 -0400, Stefan Monnier wrote:
> > Because good defaults matter, and if we have proper input preemption of
> > stealth JIT working, there should be no downside.

> `jit-lock-stealth-time` defaults to nil (i.e. stealth fontification is
> disabled by default) for a good reason: it used to be enabled.

> The known downsides are:
> - we don't have good input preemption
> - it eats up your battery with no clear benefit
>   [ Because you end up re-fontifying the whole rest of the buffer after
>     every buffer modification.  ]

Ah, so that's why stealth was disabled by default - the battery.

For my current project (finding CC Mode "found types") stealth
fontification is not ideal - what I need is a single pass through the
whole buffer to detect the types, and that should be as fast as
possible.  The current stealth fontification is not fast (it doesn't
need to be) and carries on working until Emacs is shut down.

So, it seems I want something like stealth, but not quite.  How about,
say jit-lock-single-fontification - it would apply to individual buffers
only, would scan through the buffer precisely once, and would do just
enough 500-byte chunks at at time to take 0.05 seconds (configurable).

On my machine in C Mode, approximately 100 chunks are fontified per
second.  So if we had jit-lock-single-nice at 0.1 seconds, the time
taken to scan xdisp.c would be approximately 1 to 1.5 minutes.  On a
smaller file, say syntax.c (a tenth of the size) it would take 5 - 10
seconds.  This is barely worse than context fontification, and would
only happen at mode start up.

> If we want to keep the buffers fully fontified, then it's crucial to make
> sure every tiny buffer modification doesn't force re-fontifying most of the
> rest of the buffer.

Yes.  This feels like a difficult problem, otherwise it would have been
done a long time ago.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]