@deffn Predicate pred fn &rest nodes
Matches if function @var{fn} returns non-@code{nil} when passed each
-node in @var{nodes} as arguments.
+node in @var{nodes} as arguments. The function runs with the current
+buffer set to the buffer of node being queried.
@end deffn
Note that a predicate can only refer to capture names that appear in
signal_data))
return false;
- struct buffer *old_buffer = current_buffer;
- struct buffer *buffer = XBUFFER (XTS_PARSER (XTS_NODE (node)->parser)->buffer);
- set_buffer_internal (buffer);
-
TSNode treesit_node = XTS_NODE (node)->node;
ptrdiff_t visible_beg = XTS_PARSER (XTS_NODE (node)->parser)->visible_beg;
uint32_t start_byte_offset = ts_node_start_byte (treesit_node);
ZV = old_zv;
ZV_BYTE = old_zv_byte;
- set_buffer_internal (old_buffer);
-
return (val > 0);
}
Lisp_Object prev_result = result;
Lisp_Object predicates_table = make_vector (patterns_count, Qt);
Lisp_Object predicate_signal_data = Qnil;
+
+ struct buffer *old_buf = current_buffer;
+ set_buffer_internal (buf);
+
while (ts_query_cursor_next_match (cursor, &match))
{
/* Record the checkpoint that we may roll back to. */
ts_query_delete (treesit_query);
ts_query_cursor_delete (cursor);
}
+ set_buffer_internal (old_buf);
/* Some capture predicate signaled an error. */
if (!NILP (predicate_signal_data))