Subject: bug#70789: treesit navigate for outlines at bobp

From: Juri Linkov <[email-masked]>
Date: Thu, 09 May 2024 09:28:59 +0300

close 70789 30.0.50
thanks

>>  (treesit-navigate-thing (point-min) 1 'beg "\\`\\(?:class\\|method\\)\\'")
>>
>> can't find "class" at the beginning of the buffer,
>> but after inserting an empty line before "class" it can find it.
>
> I see, from treesit-navigate-thing’s point of view, point is already at the
> beginning of a class, therefore the correct behavior is to go to the beg of
> the next class. Using ‘end is probably more appropriate here, but I know
> you must have good reasons to use ‘beg. How about using
> treesit-search-forward? Wait, am I the one that suggested
> treesit-navigate-thing to you, because it returns higher-leveled nodes
> first?

Indeed.

> In that case, maybe you can use treesit-thing-next to test if point is
> at the beginning of an outline header? That feels a bit easier to
> write and understand to me.

I don't see how treesit-thing-next could be used here since
quoting its doc:

  The returned node, if non-nil, must be after POS, i.e., its
  start >= POS.

> If you prefer the current patch I don’t have problem with it either.

Thanks, so now pushed.