Subject: bug#60531: closed (Re: bug#60531: 29.0.50; Some fixes and suggestions for the docstrings of treesit-parent-while and treesit-parent-until)

From: [email-masked] (GNU bug Tracking System)
Date: Thu, 05 Jan 2023 07:36:02 +0000

Your bug report

#60531: 29.0.50; Some fixes and suggestions for the docstrings of treesit-parent-while and treesit-parent-until

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
60531: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60531
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#60531: 29.0.50; Some fixes and suggestions for the docstrings of treesit-parent-while and treesit-parent-until
From: Eli Zaretskii <[email-masked]>
To: Daniel Martín <[email-masked]>
Cc: [email-masked]
Date: Thu, 05 Jan 2023 09:35:17 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

> Date: Tue, 03 Jan 2023 23:45:35 +0100
> From:  Daniel Martín via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> 
> The docstring of treesit-parent-while says:
> 
> Return the furthest parent of NODE that satisfies PRED.
> Return nil if none was found.  PRED should be a function that
> takes one argument, the parent node.
> 
> But, according to the source code, the first invocation of NODE passes
> NODE itself, not its parent:
> 
> (let ((last nil))
>     (while (and node (funcall pred node))
> 
> The same happens with the docstring of treesit-parent-until.

This is clearly a case of unnecessary details.  I made the doc string
say just "node".

> Another suggestion I have is that "the furthest parent of NODE" is a bit
> ambiguous (furthest from NODE or from the root?).  I think it would be
> more clear to say it will return the highest (ie. least deep) *ancestor*
> of NODE.  In 37.3 Retrieving Nodes, we introduce the concepts of
> "higher" and "lower" when explaining Tree-sitter nodes, so using this
> terminology consistently would avoid confusion.

Instead of changing a potentially confusing word to another
potentially confusing word, I decided to describe in more detail what
the functions do.

Subject: 29.0.50; Some fixes and suggestions for the docstrings of treesit-parent-while and treesit-parent-until
From: Daniel Martín <[email-masked]>
To: [email-masked]
Date: Tue, 03 Jan 2023 23:45:35 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

The docstring of treesit-parent-while says:

Return the furthest parent of NODE that satisfies PRED.
Return nil if none was found.  PRED should be a function that
takes one argument, the parent node.

But, according to the source code, the first invocation of NODE passes
NODE itself, not its parent:

(let ((last nil))
    (while (and node (funcall pred node))

The same happens with the docstring of treesit-parent-until.

Another suggestion I have is that "the furthest parent of NODE" is a bit
ambiguous (furthest from NODE or from the root?).  I think it would be
more clear to say it will return the highest (ie. least deep) *ancestor*
of NODE.  In 37.3 Retrieving Nodes, we introduce the concepts of
"higher" and "lower" when explaining Tree-sitter nodes, so using this
terminology consistently would avoid confusion.