unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#60531: 29.0.50; Some fixes and suggestions for the docstrings of treesit-parent-while and treesit-parent-until
       [not found] <m1a62zgru8.fsf.ref@yahoo.es>
@ 2023-01-03 22:45 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
  2023-01-05  7:35   ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2023-01-03 22:45 UTC (permalink / raw)
  To: 60531


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.





^ permalink raw reply	[flat|nested] 2+ messages in thread

* bug#60531: 29.0.50; Some fixes and suggestions for the docstrings of treesit-parent-while and treesit-parent-until
  2023-01-03 22:45 ` bug#60531: 29.0.50; Some fixes and suggestions for the docstrings of treesit-parent-while and treesit-parent-until Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
@ 2023-01-05  7:35   ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2023-01-05  7:35 UTC (permalink / raw)
  To: Daniel Martín; +Cc: 60531-done

> 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" <bug-gnu-emacs@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.

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.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-05  7:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <m1a62zgru8.fsf.ref@yahoo.es>
2023-01-03 22:45 ` bug#60531: 29.0.50; Some fixes and suggestions for the docstrings of treesit-parent-while and treesit-parent-until Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-01-05  7:35   ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).