[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Font Locking issue: Need help/advice
From: |
Yuan Fu |
Subject: |
Re: Font Locking issue: Need help/advice |
Date: |
Fri, 3 Apr 2020 19:48:02 -0400 |
> On Apr 3, 2020, at 6:36 PM, David Engster <address@hidden> wrote:
>
>> - What happens on the GIF? How I can fix this? How to avoid similar
>> in the future?
>
> What happens here is that the initial font-lock goes over the whole
> currently visible section, but as soon as you edit one line, font-lock
> will be called only for the part of the buffer that has changed, and it
> seems your font-lock rules work differently in this case because the
> context has changed.
>
>> - In fact, I would like to be able to independently receive the
>> answer to the question "Why did this happen?" so I'm interesting
>> on debugging practices. How to debug similar issues?
>
> For better understanding how font-lock actually works, I highly
> recommend using font-lock-studio
>
> https://github.com/Lindydancer/font-lock-studio
>
> Also, take a look at the other linked packages in the description. In
> your case, 'highlight-refontification' could be useful to see which
> parts of the buffer actually get refontified when you edit it.
>
> -David
>
It is also helpful to look at jit-lock.el since that’s the default on-the-fly
fortification facility. Basically it marks all text after the changed region
(including the region) as “unfontified” when you edit the buffer. And the
redisplay (C) code will call jit-lock functions (which calls font-lock
functions) to fontify the unfontified text when it needs to display them. IIUC
jit-lock is given chunks of unfontified text (several thousand characters) each
time.
Yuan