; Fix vindexes in parsing.texi

* doc/lispref/parsing.texi (Tree-sitter major modes): Replace vindex
with cross-reference to modes.texi.  Add manual entry for
treesit-defun-type-regexp.
* lisp/treesit.el (treesit-defun-type-regexp): Use pred in docstring
since we use pred everywhere else.
This commit is contained in:
Yuan Fu 2022-12-26 01:39:02 -08:00
parent eb26872837
commit d90d7d15f2
No known key found for this signature in database
GPG key ID: 56E19BC57664A442
2 changed files with 16 additions and 8 deletions

View file

@ -1715,17 +1715,14 @@ This function activates some tree-sitter features for a major mode.
Currently, it sets up the following features: Currently, it sets up the following features:
@itemize @itemize
@vindex treesit-font-lock-settings
@item @item
If @code{treesit-font-lock-settings} is non-@code{nil}, it sets up If @code{treesit-font-lock-settings} (@pxref{Parser-based Font Lock})
fontification. is non-@code{nil}, it sets up fontification.
@vindex treesit-simple-indent-rules
@item @item
If @code{treesit-simple-indent-rules} is non-@code{nil}, it sets up If @code{treesit-simple-indent-rules} (@pxref{Parser-based Font Lock})
indentation. is non-@code{nil}, it sets up indentation.
@vindex treesit-defun-type-regexp
@item @item
If @code{treesit-defun-type-regexp} is non-@code{nil}, it sets up If @code{treesit-defun-type-regexp} is non-@code{nil}, it sets up
navigation functions for @code{beginning-of-defun} and navigation functions for @code{beginning-of-defun} and
@ -1782,6 +1779,17 @@ node is a defun node but doesn't have a name, or the node is
@code{nil}, it should return @code{nil}. @code{nil}, it should return @code{nil}.
@end defvar @end defvar
@defvar treesit-defun-type-regexp
This variable determines which nodes are considered defuns by Emacs.
It can be a regexp that matches the type of defun nodes.
Sometimes not all nodes matched by the regexp are valid defuns.
Therefore, this variable can also be a cons cell of the form
@w{(@var{regexp} . @var{pred})}, where @var{pred} should be a function
that takes a node as its argument, and returns @code{t} if the node is
valid defun, or @code{nil} if it is not valid.
@end defvar
@node Tree-sitter C API @node Tree-sitter C API
@section Tree-sitter C API Correspondence @section Tree-sitter C API Correspondence

View file

@ -1622,7 +1622,7 @@ For example, \"(function|class)_definition\".
Sometimes not all nodes matched by the regexp are valid defuns. Sometimes not all nodes matched by the regexp are valid defuns.
In that case, set this variable to a cons cell of the In that case, set this variable to a cons cell of the
form (REGEXP . FILTER), where FILTER is a function that takes a form (REGEXP . PRED), where PRED is a function that takes a
node (the matched node) and returns t if node is valid, or nil node (the matched node) and returns t if node is valid, or nil
for invalid node. for invalid node.