Revert "Use cached compiled tree-sitter queries for range settings"

This reverts commit e28ec76271.

* lisp/treesit.el (treesit-range-rules): Use treesit-query-compile.
This commit is contained in:
Yuan Fu 2025-10-30 18:05:10 -07:00
parent b0eaaf7366
commit b5c290cfbd
No known key found for this signature in database
GPG key ID: 56E19BC57664A442

View file

@ -757,7 +757,22 @@ that encompasses the region between START and END."
(when (null host)
(signal 'treesit-error (list "Value of :host option cannot be omitted")))
(when (treesit-available-p)
(push (list (treesit--compile-query-with-cache host query)
;; Don't replace this with
;; `treesit--compile-query-with-cache'.
;; `treesit-query-compile' is lazy and don't actually
;; load the grammar until the query is
;; used. `treesit--compile-query-with-cache' compiles
;; eagerly so it's not safe to use for this function
;; which might be called when loading a package. To
;; do it properly like font-lock, we need to not
;; compile the queries here, and compile them with
;; `treesit--compile-query-with-cache' when major
;; mode is enabled. Let's just keep things simple
;; and keep range rules as-is. Because for range
;; rules, the queries generally don't need to
;; computed dynamically, and queries are simple and
;; few, so recompiling isn't as much of a problem.
(push (list (treesit-query-compile host query)
embed local offset range-fn)
result)))
(setq host nil embed nil offset nil local nil range-fn nil))))