Subject: Re: bug#62301: 29.0.60; treesit-parent-while should mention that the return value may include the initial node
From: Yuan Fu <[email-masked]>
To: [email-masked]
Cc: [email-masked]
Date: Tue, 21 Mar 2023 14:52:19 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

daanturo <[email-masked]> writes:

> For the current implementation of `treesit-parent-while`, it will return
> the initial argument NODE who satisfies PRED while its immediate parent
> doesn't. But the docstring, when mentioning return values, only said
> about "parent" but not the child itself.
>
> For example, finding the node closest to the root that covers only
> exactly one of its descendant.
>
> (-let* ((node (treesit-node-at (point))))
>   (treesit-parent-while
>    node
>    (lambda (nd)
>      (and (= (treesit-node-start nd) (treesit-node-start node))
>           (= (treesit-node-end nd) (treesit-node-end node))))))
>
>
> I don't think that's a bug as it's useful to include the child
> sometimes, as the example above, but I think the docstring should
> clarify more.

Thanks for the report! I updated the docstring as you suggested.

Yuan