aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorEli Zaretskii2022-12-01 17:25:28 +0200
committerEli Zaretskii2022-12-01 17:25:28 +0200
commita86ccb5f9dd4a5fe8e6af974d7f577e7b5d0a8d4 (patch)
tree78bf36304c8699b329cc0936f74f11aa39e99828 /doc
parent2d5cf7329e9af753651508cd13e03185a05f3f6a (diff)
downloademacs-a86ccb5f9dd4a5fe8e6af974d7f577e7b5d0a8d4.tar.gz
emacs-a86ccb5f9dd4a5fe8e6af974d7f577e7b5d0a8d4.zip
; Fix recently added treesit documentation
* lisp/treesit.el (treesit-defun-prefer-top-level): * doc/lispref/positions.texi (List Motion): Fix wording.
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/positions.texi32
1 files changed, 17 insertions, 15 deletions
diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi
index c065cc11e25..7acf2d052a8 100644
--- a/doc/lispref/positions.texi
+++ b/doc/lispref/positions.texi
@@ -836,35 +836,37 @@ of using its normal method.
836 836
837@findex treesit-beginning-of-defun 837@findex treesit-beginning-of-defun
838@findex treesit-end-of-defun 838@findex treesit-end-of-defun
839If Emacs is compiled with tree-sitter, it can use the tree-sitter parser 839If Emacs is compiled with tree-sitter, it can use the tree-sitter
840information to move across syntax constructs. A major mode can set 840parser information to move across syntax constructs. Since what
841@code{treesit-defun-type-regexp} and get navigation functionality for 841exactly is considered a defun varies between languages, a major mode
842free, by using @code{treesit-beginning-of-defun} and 842should set @code{treesit-defun-type-regexp} to determine that. Then
843@code{treesit-end-of-defun}. 843the mode can get navigation-by-defun functionality for free, by using
844@code{treesit-beginning-of-defun} and @code{treesit-end-of-defun}.
844 845
845@defvar treesit-defun-type-regexp 846@defvar treesit-defun-type-regexp
846The value of this variable is a regexp matching the node type of defun 847The value of this variable is a regexp matching the node type of defun
847nodes. (For ``node'', ``node type'', @pxref{Parsing Program Source}.) 848nodes. (For ``node'' and ``node type'', @pxref{Parsing Program Source}.)
848 849
849For example, @code{python-mode} sets this variable to a regexp that 850For example, @code{python-mode} sets this variable to a regexp that
850matches either @code{function_definition} or @code{class_definition}. 851matches either @code{function_definition} or @code{class_definition}.
851@end defvar 852@end defvar
852 853
853@defvar treesit-defun-prefer-top-level 854@defvar treesit-defun-prefer-top-level
854If this variable is non-@code{nil}, Emacs skips nested defun and 855If this variable is non-@code{nil}, Emacs skips nested defuns, when it
855prefers the top-level defun. 856looks for beginning and end of a defun, and prefers to go to the
857top-level defun instead.
856 858
857In some languages, a defun could be nested in another one. Normally 859In some languages, a defun could be nested in another one. By default,
858Emacs stops at the first defun it encounters. If this variable's 860Emacs stops at the first defun it encounters. But if this variable's
859value is @code{t}, whenever Emacs finds a defun node, it tries to go 861value is @code{t}, whenever Emacs finds a defun node, it tries to go
860up the parse tree and find the top-level defun. 862up the parse tree until it finds the top-level defun.
861 863
862This variable can also be a list of cons cells of the form 864This variable can also be a list of cons cells of the form
863@w{@code{(@var{from} . @var{to}))}}, where @var{from} and @var{to} are 865@w{@code{(@var{from} . @var{to}))}}, where @var{from} and @var{to} are
864regexp matching tree-sitter node types. When Emacs finds a defun node 866regexps matching tree-sitter node types. When Emacs finds a defun
865whose type matches any of the @var{from} regexp in the list, Emacs 867node whose type matches any of the @var{from} regexps in the list, it
866then tries to go up the parse tree to find the top-level node matching 868then tries to go up the parse tree until it finds a higher-level node
867the corresponding @var{to} regexp. 869matching the corresponding @var{to} regexp.
868@end defvar 870@end defvar
869 871
870@node Skipping Characters 872@node Skipping Characters