return treesit_query;
}
+/* Bsically treesit_ensure_query_compiled but can signal. */
+static
+void treesit_ensure_query_compiled_signal (Lisp_Object lisp_query)
+{
+ Lisp_Object signal_symbol = Qnil;
+ Lisp_Object signal_data = Qnil;
+ TSQuery *treesit_query = treesit_ensure_query_compiled (lisp_query,
+ &signal_symbol,
+ &signal_data);
+
+ if (treesit_query == NULL)
+ xsignal (signal_symbol, signal_data);
+}
+
/* Resolve language symbol LANG according to
treesit-language-remap-alist. */
static
doc: /* Compile QUERY to a compiled query.
Querying with a compiled query is much faster than an uncompiled one.
+So it's a good idea to use compiled query in tight loops, etc.
+
LANGUAGE is the language this query is for.
If EAGER is non-nil, immediately load LANGUAGE and compile the query.
if (NILP (Ftreesit_query_p (query)))
wrong_type_argument (Qtreesit_query_p, query);
CHECK_SYMBOL (language);
- if (TS_COMPILED_QUERY_P (query))
- return query;
treesit_initialize ();
+ if (TS_COMPILED_QUERY_P (query))
+ {
+ if (NILP (eager))
+ return query;
+ treesit_ensure_query_compiled_signal (query);
+ return query;
+ }
+
Lisp_Object lisp_query = make_treesit_query (query, language);
/* Maybe actually compile. */
return lisp_query;
else
{
- Lisp_Object signal_symbol = Qnil;
- Lisp_Object signal_data = Qnil;
- TSQuery *treesit_query = treesit_ensure_query_compiled (lisp_query,
- &signal_symbol,
- &signal_data);
-
- if (treesit_query == NULL)
- xsignal (signal_symbol, signal_data);
-
+ treesit_ensure_query_compiled_signal (lisp_query);
return lisp_query;
}
}