GNU bug report logs - #71384
treesit-font-lock-fontify-region unnecessarily re-unfontify's

Previous Next

Package: emacs;

Reported by: JD Smith <jdtsmith <at> gmail.com>

Date: Wed, 5 Jun 2024 22:56:01 UTC

Severity: normal

Tags: moreinfo, wontfix

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Yuan Fu <casouri <at> gmail.com>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 71384 <at> debbugs.gnu.org, JD Smith <jdtsmith <at> gmail.com>
Subject: bug#71384: treesit-font-lock-fontify-region unnecessarily re-unfontify's
Date: Wed, 5 Mar 2025 07:04:09 -0800

> On Feb 28, 2025, at 6:08 PM, Stefan Kangas <stefankangas <at> gmail.com> wrote:
> 
> JD Smith <jdtsmith <at> gmail.com> writes:
> 
>>> On Jun 6, 2024, at 1:34 AM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>>> 
>>>> From: JD Smith <jdtsmith <at> gmail.com>
>>>> Date: Wed, 5 Jun 2024 18:06:54 -0400
>>>> 
>>>> The function treesit-font-lock-fontify-region in treesit.el calls
>>>> (font-lock-unfontify-region start end) right away (see below).  But this
>>>> function is called as the value of font-lock-fontify-syntactically-function
>>>> from font-lock-default-fontify-region, which has just itself made the exact
>>>> same call to font-lock-unfontify-region. I commented out that superfluous
>>>> call in treesit-font-lock-fontify-region and noticed no ill effects.
>>> 
>>> Why is that duplicate call a problem?
>> 
>> I don't know if it's ever really a problem, other than the small amount of time spent removing properties that have just been removed.
>> 
>>> We don't say that treesit-font-lock-fontify-region _must_ be called _only_ from
>>> font-lock-default-fontify-region, do we?
>> 
>> 
>> I presume the same logic would apply to font-lock-fontify-keywords-region, but
>> that does not re-run unfontify (and is obviously much older code).  Maybe
>> treesit reuses treesit-font-lock-fontify-region in non-font-lock contexts?  Feel
>> free to close if Yuan concurs.
> 
> Yuan, WDYT?  Should we do anything here, or should we close this?

I suggest we keep it. Unless a duplicate call actually impacts performance. The call helps with debugging: you can evaluate treesit-font-lock-fontify-region with M-x eval-expression to manually update fontification for a region.

Yuan



This bug report was last modified 133 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.