[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Any expert on font-lock machinery able to provide some insight
From: |
Eli Zaretskii |
Subject: |
Re: Any expert on font-lock machinery able to provide some insight |
Date: |
Fri, 03 Jan 2025 13:58:03 +0200 |
> Date: Fri, 3 Jan 2025 11:26:11 +0100
> From: Harald Kirsch <pifpafpuf@gmx.de>
>
> Hi font-lock experts?
>
> I am working on a font-lock function and see it called by the jit-lock
> timer at weird times.
>
> I see a normal font-lock function call after a change, for example when
> inserting a character. But then I see
>
> - calls when moving the cursor (no scroll)
> - when setting the mark
> - when moving the mouse into **another** frame
> - when moving the mouse into yet **another** frame
This is expected. Lisp programs sometimes need to make layout
calculations for some reason. For example, when you move the cursor
with C-f, Emacs needs to know the buffer position that corresponds to
the character to the right of the previous one. Since you can have
several different faces and fonts in a buffer, the answer to that
question needs to execute some of the layout code that is part of the
display engine, and that will call jit-lock if the corresponding
region of the buffer text was not yet fontified.
> I understand that when the function does not return
>
> (jit-lock-bounds beg . end)
>
> jit-lock assumes the region was fontified just fine. For completeness I
> also added the an explicit (jit-lock-bounds beg . end) return to my
> font-lock function. Same behavior.
>
> But it seems I am missing another channel of information which triggers
> font-locking too often.
Why does it bother you that it happens too often?
> With describe-char I do see
>
> There are text properties here:
> fontified defer
>
> not going away. Can this point to the problem?
This should only happen with buffer positions that were not yet
fontified. If the buffer position was already fontified, the value
should be t.