diff options
| author | Eli Zaretskii | 2022-12-01 17:25:28 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2022-12-01 17:25:28 +0200 |
| commit | a86ccb5f9dd4a5fe8e6af974d7f577e7b5d0a8d4 (patch) | |
| tree | 78bf36304c8699b329cc0936f74f11aa39e99828 /doc | |
| parent | 2d5cf7329e9af753651508cd13e03185a05f3f6a (diff) | |
| download | emacs-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.texi | 32 |
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 |
| 839 | If Emacs is compiled with tree-sitter, it can use the tree-sitter parser | 839 | If Emacs is compiled with tree-sitter, it can use the tree-sitter |
| 840 | information to move across syntax constructs. A major mode can set | 840 | parser information to move across syntax constructs. Since what |
| 841 | @code{treesit-defun-type-regexp} and get navigation functionality for | 841 | exactly is considered a defun varies between languages, a major mode |
| 842 | free, by using @code{treesit-beginning-of-defun} and | 842 | should set @code{treesit-defun-type-regexp} to determine that. Then |
| 843 | @code{treesit-end-of-defun}. | 843 | the 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 |
| 846 | The value of this variable is a regexp matching the node type of defun | 847 | The value of this variable is a regexp matching the node type of defun |
| 847 | nodes. (For ``node'', ``node type'', @pxref{Parsing Program Source}.) | 848 | nodes. (For ``node'' and ``node type'', @pxref{Parsing Program Source}.) |
| 848 | 849 | ||
| 849 | For example, @code{python-mode} sets this variable to a regexp that | 850 | For example, @code{python-mode} sets this variable to a regexp that |
| 850 | matches either @code{function_definition} or @code{class_definition}. | 851 | matches 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 |
| 854 | If this variable is non-@code{nil}, Emacs skips nested defun and | 855 | If this variable is non-@code{nil}, Emacs skips nested defuns, when it |
| 855 | prefers the top-level defun. | 856 | looks for beginning and end of a defun, and prefers to go to the |
| 857 | top-level defun instead. | ||
| 856 | 858 | ||
| 857 | In some languages, a defun could be nested in another one. Normally | 859 | In some languages, a defun could be nested in another one. By default, |
| 858 | Emacs stops at the first defun it encounters. If this variable's | 860 | Emacs stops at the first defun it encounters. But if this variable's |
| 859 | value is @code{t}, whenever Emacs finds a defun node, it tries to go | 861 | value is @code{t}, whenever Emacs finds a defun node, it tries to go |
| 860 | up the parse tree and find the top-level defun. | 862 | up the parse tree until it finds the top-level defun. |
| 861 | 863 | ||
| 862 | This variable can also be a list of cons cells of the form | 864 | This 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 |
| 864 | regexp matching tree-sitter node types. When Emacs finds a defun node | 866 | regexps matching tree-sitter node types. When Emacs finds a defun |
| 865 | whose type matches any of the @var{from} regexp in the list, Emacs | 867 | node whose type matches any of the @var{from} regexps in the list, it |
| 866 | then tries to go up the parse tree to find the top-level node matching | 868 | then tries to go up the parse tree until it finds a higher-level node |
| 867 | the corresponding @var{to} regexp. | 869 | matching the corresponding @var{to} regexp. |
| 868 | @end defvar | 870 | @end defvar |
| 869 | 871 | ||
| 870 | @node Skipping Characters | 872 | @node Skipping Characters |