New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query compilation? #5
Comments
Not quite barraging, jit-lock will just silently fail and leave a bunch of logs in Messages. I don't think error out when calling I can see some advantages to compile the query ahead of time. 1) It would be helpful to know there is an error before calling On the other hand, compiling the query has downsides: I don't know what does If you want to continue the discussion, I suggest we continue at emacs-devel, that way others who are more knowledgable than I can join and offer their opinion. |
Alright, let's move to emacs-devel. |
(I sent an email in the thread. Assuming I didn't screw up the email headers I think my message is waiting to be approved by a moderator—it's my first message on emacs-devel.) |
Hi! My question is about the lines:
emacs/src/tree-sitter.c
Lines 1375 to 1380 in a4f90c5
Regarding error handling mostly.
In this branch queries are saved as strings and compiled in the internals on each use. In elisp-tree-sitter, you call
tsc-make-query
and usethe object it returns for calls to
tsc-query-captures
which is the analog fortree-sitter-query-capture
.What happens if your query is deformed, or simply has a typo in a node name? We call
tree-sitter-query-capture
on each keystroke intree-sitter-font-lock-fontify-region
. With the compilation occurring ahead-of-time it would fail once, but here wouldn't it barrage you with errors?Especially with patterns that aren't set in stone and can be modified like font-lock keywords, I think compiling the query when the pattern is added is better than on each execution.
One nice thing though about compiling queries only when queried is that you can call
ts_query_delete
straight away. With users compiling queries it would need to be up to garbage collection, I think.The text was updated successfully, but these errors were encountered: