From ce7b7e5af3ddb2863c0c4f6f7c91d1b6c205f1a0 Mon Sep 17 00:00:00 2001 From: Yuan Fu Date: Sun, 18 Dec 2022 14:11:54 -0800 Subject: Remove comment-start-skip preset in tree-sitter indentation engine Comment indentation should use a adaptive-fill-based indent, rather than comment-start-skip. Also remove manual description of removed variables in treesit.el and add documentation for n-p-gp upon request. * doc/lispref/modes.texi (Parser-based Indentation) * lisp/treesit.el (treesit-simple-indent-presets): Add n-p-gp, remove treesit-comment-start/end, remove comment-start-skip. * doc/lispref/parsing.texi (Tree-sitter major modes): Remove treesit-comment-start/end. --- doc/lispref/modes.texi | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'doc/lispref/modes.texi') diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 9ff9614a667..c44938f3929 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi @@ -4967,12 +4967,22 @@ first child where parent is @code{argument_list}, use (match nil "argument_list" nil nil 0 0) @end example +@item n-p-gp +Short for ``node-parent-grandparent'', this matcher is a function of 3 +arguments: @var{node-type}, @var{parent-type}, and +@var{grandparent-type}. It returns a function that is called with 3 +arguments: @var{node}, @var{parent}, and @var{bol}, and returns +non-@code{nil} if: (1) @var{node-type} matches @var{node}'s type, and +(2) @var{parent-type} matches @var{parent}'s type, and (3) +@var{grandparent-type} matches @var{parent}'s parent's type. If any +of @var{node-type}, @var{parent-type}, and @var{grandparent-type} is +@code{nil}, this function doesn't check for it. + @item comment-end This matcher is a function that is called with 3 arguments: @var{node}, @var{parent}, and @var{bol}, and returns non-@code{nil} if point is before a comment ending token. Comment ending tokens are -defined by regular expression @code{treesit-comment-end} -(@pxref{Tree-sitter major modes, treesit-comment-end}). +defined by regular expression @code{comment-end-skip} @item first-sibling This anchor is a function that is called with 3 arguments: @var{node}, @@ -5009,19 +5019,11 @@ This is useful as the beginning of the buffer is always at column 0. @item comment-start This anchor is a function that is called with 3 arguments: @var{node}, -@var{parent}, and @var{bol}, and returns the position right after the +@var{parent}, and @var{bol}, and returns the position after the comment-start token. Comment-start tokens are defined by regular -expression @code{treesit-comment-start} (@pxref{Tree-sitter major -modes, treesit-comment-start}). This function assumes @var{parent} is -the comment node. +expression @code{comment-start-skip}. This function assumes +@var{parent} is the comment node. -@item comment-start-skip -This anchor is a function that is called with 3 arguments: @var{node}, -@var{parent}, and @var{bol}, and returns the position after the -comment-start token and any whitespace characters following that -token. Comment-start tokens are defined by regular expression -@code{treesit-comment-start}. This function assumes @var{parent} is -the comment node. @end ftable @end defvar -- cgit v1.2.3