GNU bug report logs -
#66223
treesit-major-mode-setup should not call font-lock-mode
Previous Next
Reported by: Dmitry Gutov <dmitry <at> gutov.dev>
Date: Wed, 27 Sep 2023 00:19:02 UTC
Severity: normal
Done: Yuan Fu <casouri <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 66223 in the body.
You can then email your comments to 66223 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
casouri <at> gmail.com, bug-gnu-emacs <at> gnu.org
:
bug#66223
; Package
emacs
.
(Wed, 27 Sep 2023 00:19:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Dmitry Gutov <dmitry <at> gutov.dev>
:
New bug report received and forwarded. Copy sent to
casouri <at> gmail.com, bug-gnu-emacs <at> gnu.org
.
(Wed, 27 Sep 2023 00:19:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
X-Debbugs-CC: Yuan Fu <casouri <at> gmail.com>
It doesn't seem necessary (everything seems to work okay without that
call), and it's not the right thing idiomatically (the user should have
the ability to disable global-font-lock-mode).
If it does get called, the call to treesit-font-lock-recompute-features
should happen before that.
The report was triggered by somewhat unusual circumstances (somebody
trying out mmm-mode together with typescript-ts-mode:
https://github.com/dgutov/mmm-mode/issues/138), but the fix seems easy
and natural enough.
To reproduce the bug, though, try this:
(with-current-buffer (generate-new-buffer "foo")
(let (font-lock-support-mode)
(typescript-ts-mode)))
It results in
Debugger entered--Lisp error: (treesit-query-error "Node type error at"
2 "(jsx_opening_element [(nested_identifier (identifier)) (identifier)]
@typescript-ts-jsx-tag-face) (jsx_closing_element [(nested_identifier
(identifier)) (identifier)] @typescript-ts-jsx-tag-face)
(jsx_self_closing_element [(nested_identifier (identifier))
(identifier)] @typescript-ts-jsx-tag-face) (jsx_attribute
(property_identifier) @typescript-ts-jsx-attribute-face)" "Debug the
query with `treesit-query-validate'")
treesit-query-capture(#<treesit-node program in 1-1>
#<treesit-compiled-query> 1 1)
(let* ((delta-start ...
treesit--font-lock-fontify-region-1(#<treesit-node program in 1-1>
#<treesit-compiled-query> 1 1 nil nil)
(let ((sub-node (car tail)))...
treesit-font-lock-fontify-region(1 1 nil)
font-lock-fontify-syntactically-region(1 1 nil)
font-lock-default-fontify-region(1 1 nil)
font-lock-fontify-region(1 1 nil)
font-lock-default-fontify-buffer()
font-lock-fontify-buffer()
font-lock-initial-fontify()
font-lock-mode(1)
(progn (set (make-lo...
treesit-major-mode-setup()
typescript-ts-mode()
because typescript-ts-mode's treesit-font-lock-settings hide the jsx
rule (which the typescript grammar itself doesn't support, only the tsx
one does) using the absence of that feature in
treesit-font-lock-feature-list. But for that to take effect, the call to
'treesit-font-lock-recompute-features' needs to happen first. The
jit-lock conceals the problem by inhibiting the first fontification
until the major mode function has run and the buffer is visible. I ended
up disabling it in mmm-mode's auxiliary temp buffer because it spams the
message "Not enabling jit-lock: it does not work in indirect buffer".
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66223
; Package
emacs
.
(Wed, 27 Sep 2023 07:22:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 66223 <at> debbugs.gnu.org (full text, mbox):
> On Sep 26, 2023, at 5:17 PM, Dmitry Gutov <dmitry <at> gutov.dev> wrote:
>
> X-Debbugs-CC: Yuan Fu <casouri <at> gmail.com>
>
> It doesn't seem necessary (everything seems to work okay without that call), and it's not the right thing idiomatically (the user should have the ability to disable global-font-lock-mode).
>
> If it does get called, the call to treesit-font-lock-recompute-features should happen before that.
>
> The report was triggered by somewhat unusual circumstances (somebody trying out mmm-mode together with typescript-ts-mode: https://github.com/dgutov/mmm-mode/issues/138), but the fix seems easy and natural enough.
>
> To reproduce the bug, though, try this:
>
> (with-current-buffer (generate-new-buffer "foo")
> (let (font-lock-support-mode)
> (typescript-ts-mode)))
>
> It results in
>
> Debugger entered--Lisp error: (treesit-query-error "Node type error at" 2 "(jsx_opening_element [(nested_identifier (identifier)) (identifier)] @typescript-ts-jsx-tag-face) (jsx_closing_element [(nested_identifier (identifier)) (identifier)] @typescript-ts-jsx-tag-face) (jsx_self_closing_element [(nested_identifier (identifier)) (identifier)] @typescript-ts-jsx-tag-face) (jsx_attribute (property_identifier) @typescript-ts-jsx-attribute-face)" "Debug the query with `treesit-query-validate'")
> treesit-query-capture(#<treesit-node program in 1-1> #<treesit-compiled-query> 1 1)
> (let* ((delta-start ...
> treesit--font-lock-fontify-region-1(#<treesit-node program in 1-1> #<treesit-compiled-query> 1 1 nil nil)
> (let ((sub-node (car tail)))...
> treesit-font-lock-fontify-region(1 1 nil)
> font-lock-fontify-syntactically-region(1 1 nil)
> font-lock-default-fontify-region(1 1 nil)
> font-lock-fontify-region(1 1 nil)
> font-lock-default-fontify-buffer()
> font-lock-fontify-buffer()
> font-lock-initial-fontify()
> font-lock-mode(1)
> (progn (set (make-lo...
> treesit-major-mode-setup()
> typescript-ts-mode()
>
> because typescript-ts-mode's treesit-font-lock-settings hide the jsx rule (which the typescript grammar itself doesn't support, only the tsx one does) using the absence of that feature in treesit-font-lock-feature-list. But for that to take effect, the call to 'treesit-font-lock-recompute-features' needs to happen first. The jit-lock conceals the problem by inhibiting the first fontification until the major mode function has run and the buffer is visible. I ended up disabling it in mmm-mode's auxiliary temp buffer because it spams the message "Not enabling jit-lock: it does not work in indirect buffer”.
Makes sense. We can remove that line in master, and see if anything comes up. I don’t remember why I added it, I don’t think there was any particular reason.
Yuan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66223
; Package
emacs
.
(Wed, 27 Sep 2023 08:53:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 66223 <at> debbugs.gnu.org (full text, mbox):
On 27/09/2023 10:21, Yuan Fu wrote:
> Makes sense. We can remove that line in master, and see if anything comes up. I don’t remember why I added it, I don’t think there was any particular reason.
If we have to start on master, so be it. I'd like to see the fix in
emacs-29, though (at least eventually).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66223
; Package
emacs
.
(Wed, 27 Sep 2023 11:17:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 66223 <at> debbugs.gnu.org (full text, mbox):
Dmitry Gutov <dmitry <at> gutov.dev> writes:
> On 27/09/2023 10:21, Yuan Fu wrote:
>> Makes sense. We can remove that line in master, and see if anything
>> comes up. I don’t remember why I added it, I don’t think there was
>> any particular reason.
>
> If we have to start on master, so be it. I'd like to see the fix in
> emacs-29, though (at least eventually).
Sounds good to me, if no one has any objections. The call does seem
superfluous there.
I've noted this bug in my list of things to revisit before the first
Emacs 29.2 pretest. It doesn't hurt if someone else helps remembering
it too, of course.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66223
; Package
emacs
.
(Wed, 27 Sep 2023 19:43:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 66223 <at> debbugs.gnu.org (full text, mbox):
On 27/09/2023 14:15, Stefan Kangas wrote:
> I've noted this bug in my list of things to revisit before the first
> Emacs 29.2 pretest. It doesn't hurt if someone else helps remembering
> it too, of course.
Thanks!
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66223
; Package
emacs
.
(Thu, 28 Sep 2023 00:25:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 66223 <at> debbugs.gnu.org (full text, mbox):
> On Sep 27, 2023, at 1:51 AM, Dmitry Gutov <dmitry <at> gutov.dev> wrote:
>
> On 27/09/2023 10:21, Yuan Fu wrote:
>> Makes sense. We can remove that line in master, and see if anything comes up. I don’t remember why I added it, I don’t think there was any particular reason.
>
> If we have to start on master, so be it. I'd like to see the fix in emacs-29, though (at least eventually).
Yeah, let’s test this out on master for a while and apply it to emacs-29 if no one comes up and complain. It seems to me that 29.2 is still a while away.
Yuan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66223
; Package
emacs
.
(Thu, 28 Sep 2023 03:42:03 GMT)
Full text and
rfc822 format available.
Message #23 received at submit <at> debbugs.gnu.org (full text, mbox):
On September 28, 2023 2:23:41 AM GMT+02:00, Yuan Fu <casouri <at> gmail.com> wrote:
>
>
> > On Sep 27, 2023, at 1:51 AM, Dmitry Gutov <dmitry <at> gutov.dev> wrote:
> >
> > On 27/09/2023 10:21, Yuan Fu wrote:
> >> Makes sense. We can remove that line in master, and see if anything comes up. I don’t remember why I added it, I don’t think there was any particular reason.
> >
> > If we have to start on master, so be it. I'd like to see the fix in emacs-29, though (at least eventually).
>
> Yeah, let’s test this out on master for a while and apply it to emacs-29 if no one comes up and complain. It seems to me that 29.2 is still a while away.
Actually, it isn't: I was thinking about starting a pretest soon.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66223
; Package
emacs
.
(Thu, 28 Sep 2023 04:56:01 GMT)
Full text and
rfc822 format available.
Message #26 received at 66223 <at> debbugs.gnu.org (full text, mbox):
> On Sep 27, 2023, at 8:40 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
> On September 28, 2023 2:23:41 AM GMT+02:00, Yuan Fu <casouri <at> gmail.com> wrote:
>>
>>
>>> On Sep 27, 2023, at 1:51 AM, Dmitry Gutov <dmitry <at> gutov.dev> wrote:
>>>
>>> On 27/09/2023 10:21, Yuan Fu wrote:
>>>> Makes sense. We can remove that line in master, and see if anything comes up. I don’t remember why I added it, I don’t think there was any particular reason.
>>>
>>> If we have to start on master, so be it. I'd like to see the fix in emacs-29, though (at least eventually).
>>
>> Yeah, let’s test this out on master for a while and apply it to emacs-29 if no one comes up and complain. It seems to me that 29.2 is still a while away.
>
> Actually, it isn't: I was thinking about starting a pretest soon.
Thanks for the heads up. We’ll need to remember to add that change before the pretest is cut, then.
Yuan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66223
; Package
emacs
.
(Sun, 08 Oct 2023 23:05:02 GMT)
Full text and
rfc822 format available.
Message #29 received at 66223 <at> debbugs.gnu.org (full text, mbox):
> On Sep 27, 2023, at 5:23 PM, Yuan Fu <casouri <at> gmail.com> wrote:
>
>
>
>> On Sep 27, 2023, at 1:51 AM, Dmitry Gutov <dmitry <at> gutov.dev> wrote:
>>
>> On 27/09/2023 10:21, Yuan Fu wrote:
>>> Makes sense. We can remove that line in master, and see if anything comes up. I don’t remember why I added it, I don’t think there was any particular reason.
>>
>> If we have to start on master, so be it. I'd like to see the fix in emacs-29, though (at least eventually).
>
> Yeah, let’s test this out on master for a while and apply it to emacs-29 if no one comes up and complain. It seems to me that 29.2 is still a while away.
I have been running with the fix for awhile and didn’t notice anything. No one seems to have complained either. (Hopefully there are people building master and running tree-sitter modes other than me ;-)
I think we can apply this to emacs-29. Is there anything I should do? Do we just cheery-pick the commit into emac-29, or there are more elaborate operations required?
Yuan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#66223
; Package
emacs
.
(Sun, 08 Oct 2023 23:07:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 66223 <at> debbugs.gnu.org (full text, mbox):
On 09/10/2023 02:03, Yuan Fu wrote:
> I think we can apply this to emacs-29. Is there anything I should do? Do we just cheery-pick the commit into emac-29, or there are more elaborate operations required?
As per admin/notes/git-workflow (I'm not sure why it's that far away),
...
cd ~/emacs/emacs-29
git cherry-pick -xe <commit hash>
and add "Backport:" to the commit string. Then
...
Thanks!
Reply sent
to
Yuan Fu <casouri <at> gmail.com>
:
You have taken responsibility.
(Mon, 09 Oct 2023 05:05:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Dmitry Gutov <dmitry <at> gutov.dev>
:
bug acknowledged by developer.
(Mon, 09 Oct 2023 05:05:02 GMT)
Full text and
rfc822 format available.
Message #37 received at 66223-done <at> debbugs.gnu.org (full text, mbox):
> On Oct 8, 2023, at 4:05 PM, Dmitry Gutov <dmitry <at> gutov.dev> wrote:
>
> On 09/10/2023 02:03, Yuan Fu wrote:
>> I think we can apply this to emacs-29. Is there anything I should do? Do we just cheery-pick the commit into emac-29, or there are more elaborate operations required?
>
> As per admin/notes/git-workflow (I'm not sure why it's that far away),
>
> ...
> cd ~/emacs/emacs-29
> git cherry-pick -xe <commit hash>
>
> and add "Backport:" to the commit string. Then
> ...
>
> Thanks!
Done, thanks.
Yuan
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 06 Nov 2023 12:24:06 GMT)
Full text and
rfc822 format available.
This bug report was last modified 1 year and 24 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.