From: Dmitry Gutov <dmitry@gutov.dev>
To: 66223@debbugs.gnu.org
Cc: yuan fu <casouri@gmail.com>
Subject: bug#66223: treesit-major-mode-setup should not call font-lock-mode
Date: Wed, 27 Sep 2023 03:17:57 +0300 [thread overview]
Message-ID: <0f34478f-6d41-078d-295e-15caa4556b3f@gutov.dev> (raw)
X-Debbugs-CC: Yuan Fu <casouri@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".
next reply other threads:[~2023-09-27 0:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-27 0:17 Dmitry Gutov [this message]
2023-09-27 7:21 ` bug#66223: treesit-major-mode-setup should not call font-lock-mode Yuan Fu
2023-09-27 8:51 ` Dmitry Gutov
2023-09-27 11:15 ` Stefan Kangas
2023-09-27 19:42 ` Dmitry Gutov
2023-09-28 0:23 ` Yuan Fu
2023-09-28 3:40 ` Eli Zaretskii
2023-09-28 4:55 ` Yuan Fu
2023-10-08 23:03 ` Yuan Fu
2023-10-08 23:05 ` Dmitry Gutov
2023-10-09 5:04 ` Yuan Fu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0f34478f-6d41-078d-295e-15caa4556b3f@gutov.dev \
--to=dmitry@gutov.dev \
--cc=66223@debbugs.gnu.org \
--cc=casouri@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.