|
From: | Gregory Heytings |
Subject: | Re: Major modes using `widen' is a good, even essential, programming practice. |
Date: | Mon, 08 Aug 2022 10:41:08 +0000 |
jit-lock calls the functions with two arguments, BEG and END, and expects them to work only on that chunk of text.That is not the case: it expects the function to "fontify" *at least* from BEG to END, but is quite happy to let it fontify more (and the function can return a value indicating which portion was actually returned in that case).
And how much is "more"? There's a reason it's called "jit-lock" and not "aot-lock", isn't it?
The docstring of jit-lock-mode is quite clear about this: it's a "demand-driven buffer fontification", "triggered by Emacs C code", with which "fontification occurs when necessary" when motion commands "would otherwise reveal unfontified areas". Likewise "the START and END of the region to fontify" in the docstring of jit-lock-functions give the bounds within which fontification is supposed to happen. Exceeding these bounds a bit, say by a few hundred characters, is okay; considering that they are mere hints and that the whole buffer can potentially be modified isn't.
Furthermore, it's clear that fontification of BEG..END may need to look at text before BEG (and occasionally beyond END as well).
Yes, and that's one the reasons why the locked narrowed region is in fact quite large. For example, with emacs -Q, the size (width x height) of the window is 2880 characters, and the locked narrowed region is 16800 characters, roughly equally distributed before and after point. That's (inside a long line) about three screenfulls before and three screenfulls after point.
[Prev in Thread] | Current Thread | [Next in Thread] |