GNU bug report logs -
#71384
treesit-font-lock-fontify-region unnecessarily re-unfontify's
Previous Next
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.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 71384 in the body.
You can then email your comments to 71384 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71384
; Package
emacs
.
(Wed, 05 Jun 2024 22:56:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
JD Smith <jdtsmith <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 05 Jun 2024 22:56:01 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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.
(defun treesit-font-lock-fontify-region (start end &optional loudly)
"Fontify the region between START and END.
If LOUDLY is non-nil, display some debugging information."
(when (or loudly treesit--font-lock-verbose)
(message "Fontifying region: %s-%s" start end))
(treesit-update-ranges start end)
(font-lock-unfontify-region start end)
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71384
; Package
emacs
.
(Thu, 06 Jun 2024 05:41:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 71384 <at> debbugs.gnu.org (full text, mbox):
> 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? We don't say that
treesit-font-lock-fontify-region _must_ be called _only_ from
font-lock-default-fontify-region, do we?
Adding Yuan in case he has comments.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71384
; Package
emacs
.
(Thu, 06 Jun 2024 11:37:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 71384 <at> debbugs.gnu.org (full text, mbox):
> 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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71384
; Package
emacs
.
(Sat, 01 Mar 2025 02:09:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 71384 <at> debbugs.gnu.org (full text, mbox):
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?
Added tag(s) moreinfo.
Request was from
Stefan Kangas <stefankangas <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sat, 01 Mar 2025 02:09:02 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71384
; Package
emacs
.
(Wed, 05 Mar 2025 15:05:04 GMT)
Full text and
rfc822 format available.
Message #19 received at 71384 <at> debbugs.gnu.org (full text, mbox):
> 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
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#71384
; Package
emacs
.
(Sun, 09 Mar 2025 11:15:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 71384 <at> debbugs.gnu.org (full text, mbox):
tags 71384 wontfix
close 71384
thanks
Yuan Fu <casouri <at> gmail.com> writes:
> 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.
OK, I'm therefore closing this as wontfix.
Added tag(s) wontfix.
Request was from
Stefan Kangas <stefankangas <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sun, 09 Mar 2025 11:15:02 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
71384 <at> debbugs.gnu.org and JD Smith <jdtsmith <at> gmail.com>
Request was from
Stefan Kangas <stefankangas <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sun, 09 Mar 2025 11:15:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 06 Apr 2025 11:24:26 GMT)
Full text and
rfc822 format available.
This bug report was last modified 91 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.