1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-03-12 09:51:05 -07:00
emacs/doc
Yuan Fu ad500a13e4
Compile queries in treesit-f-l-recompute-features (bug#80108)
The direct cause of the problem in the bug report is that when
user runs treesit-font-lock-recompute-features to add the
emacs-devel feature in c-ts-mode's mode hook, the added query
for emacs-devel aren't compiled.

This change consists of two parts:
1. The immediate fix: validate and compile queries in
treesit-font-lock-recompute-features.
2. To make it more fool-proof, change treesit-font-lock-rules
back to compile the queries and make
treesit--compile-query-with-cache support compiled queries. This
way, as long as the query goes through treesit-font-lock-rules,
it'll be compiled eventually and not cause slow-down. I had to
add some c-level functions, but they're kind of overdue anyway,
so I don't have any problem adding them to the API.

* lisp/treesit.el (treesit--compile-query-with-cache): Support
compiled queries.
(treesit-font-lock-rules): Compile the queries (but not
eagerly).
(treesit-font-lock-recompute-features): Validate and compile
queries.
(treesit-major-mode-setup): Remove call to
treesit-validate-and-compile-font-lock-rules since it's now
called in treesit-font-lock-recompute-features.

* src/treesit.c (Ftreesit_query_eagerly_compiled_p):
(Ftreesit_query_source): New functions.

* doc/lispref/parsing.texi (Pattern Matching): Add manual
entries for the new functions.
2026-01-01 23:21:27 -08:00
..
emacs ; Add 2026 to copyright years. 2026-01-01 12:54:34 +00:00
lispintro ; Add 2026 to copyright years. 2026-01-01 12:54:34 +00:00
lispref Compile queries in treesit-f-l-recompute-features (bug#80108) 2026-01-01 23:21:27 -08:00
man ; Add 2026 to copyright years. 2026-01-01 12:54:34 +00:00
misc ; Add 2026 to copyright years. 2026-01-01 12:54:34 +00:00
translations ; Add 2026 to copyright years. 2026-01-01 12:54:34 +00:00