diff options
| author | Eli Zaretskii | 2025-09-14 09:53:16 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2025-09-14 09:53:16 +0300 |
| commit | dd9f185bf68f6ded7841c50a69595f3eefb65b73 (patch) | |
| tree | 1a28b4636bcc947f3276bd7395277b92811c7281 | |
| parent | 0dd6e5f642f6705ad2f7f35bbd87415bb6ecc04f (diff) | |
| download | emacs-dd9f185bf68f6ded7841c50a69595f3eefb65b73.tar.gz emacs-dd9f185bf68f6ded7841c50a69595f3eefb65b73.zip | |
; Improve discoverability of tree-sitter related functionality
* doc/lispref/positions.texi (List Motion):
* doc/lispref/modes.texi (Major Mode Conventions, Major Modes)
(Parser-based Font Lock, Parser-based Indentation): Improve
indexing and cross-references to tree-sitter related stuff.
| -rw-r--r-- | doc/lispref/modes.texi | 11 | ||||
| -rw-r--r-- | doc/lispref/parsing.texi | 2 | ||||
| -rw-r--r-- | doc/lispref/positions.texi | 3 |
3 files changed, 13 insertions, 3 deletions
diff --git a/doc/lispref/modes.texi b/doc/lispref/modes.texi index 33c02aaabe3..0852a9ab8e1 100644 --- a/doc/lispref/modes.texi +++ b/doc/lispref/modes.texi | |||
| @@ -291,6 +291,9 @@ derivative of another mode, as it automatically enforces many coding | |||
| 291 | conventions for you. @xref{Basic Major Modes}, for common modes to | 291 | conventions for you. @xref{Basic Major Modes}, for common modes to |
| 292 | derive from. | 292 | derive from. |
| 293 | 293 | ||
| 294 | Writing major modes based on the tree-sitter library has some special | ||
| 295 | aspects and conventions; see @ref{Tree-sitter Major Modes}. | ||
| 296 | |||
| 294 | The standard GNU Emacs Lisp directory tree contains the code for | 297 | The standard GNU Emacs Lisp directory tree contains the code for |
| 295 | several major modes, in files such as @file{text-mode.el}, | 298 | several major modes, in files such as @file{text-mode.el}, |
| 296 | @file{texinfo.el}, @file{lisp-mode.el}, and @file{rmail.el}. You can | 299 | @file{texinfo.el}, @file{lisp-mode.el}, and @file{rmail.el}. You can |
| @@ -460,7 +463,8 @@ decides to use it. | |||
| 460 | The mode may have its own syntax table or may share one with other | 463 | The mode may have its own syntax table or may share one with other |
| 461 | related modes. If it has its own syntax table, it should store this in | 464 | related modes. If it has its own syntax table, it should store this in |
| 462 | a variable named @code{@var{modename}-mode-syntax-table}. @xref{Syntax | 465 | a variable named @code{@var{modename}-mode-syntax-table}. @xref{Syntax |
| 463 | Tables}. | 466 | Tables}. (Major modes based on the tree-sitter library use the parsers |
| 467 | provided by tree-sitter for this, @pxref{Parser-based Font Lock}.) | ||
| 464 | 468 | ||
| 465 | @item | 469 | @item |
| 466 | If the mode handles a language that has a syntax for comments, it should | 470 | If the mode handles a language that has a syntax for comments, it should |
| @@ -479,7 +483,8 @@ for the @var{system-flag} argument to @code{define-abbrev}. | |||
| 479 | @item | 483 | @item |
| 480 | The mode should specify how to do highlighting for Font Lock mode, by | 484 | The mode should specify how to do highlighting for Font Lock mode, by |
| 481 | setting up a buffer-local value for the variable | 485 | setting up a buffer-local value for the variable |
| 482 | @code{font-lock-defaults} (@pxref{Font Lock Mode}). | 486 | @code{font-lock-defaults} (@pxref{Font Lock Mode}). For a major mode |
| 487 | based on tree-sitter, see @ref{Parser-based Font Lock}. | ||
| 483 | 488 | ||
| 484 | @item | 489 | @item |
| 485 | Each face that the mode defines should, if possible, inherit from an | 490 | Each face that the mode defines should, if possible, inherit from an |
| @@ -4289,6 +4294,7 @@ reasonably fast. | |||
| 4289 | @node Parser-based Font Lock | 4294 | @node Parser-based Font Lock |
| 4290 | @subsection Parser-based Font Lock | 4295 | @subsection Parser-based Font Lock |
| 4291 | @cindex parser-based font-lock | 4296 | @cindex parser-based font-lock |
| 4297 | @cindex font-lock, using tree-sitter | ||
| 4292 | 4298 | ||
| 4293 | @c This node is written when the only parser Emacs has is tree-sitter; | 4299 | @c This node is written when the only parser Emacs has is tree-sitter; |
| 4294 | @c if in the future more parser are supported, this should be | 4300 | @c if in the future more parser are supported, this should be |
| @@ -5216,6 +5222,7 @@ to the file's local variables of the form: | |||
| 5216 | @node Parser-based Indentation | 5222 | @node Parser-based Indentation |
| 5217 | @subsection Parser-based Indentation | 5223 | @subsection Parser-based Indentation |
| 5218 | @cindex parser-based indentation | 5224 | @cindex parser-based indentation |
| 5225 | @cindex indentation, using tree-sitter | ||
| 5219 | 5226 | ||
| 5220 | @c This node is written when the only parser Emacs has is tree-sitter; | 5227 | @c This node is written when the only parser Emacs has is tree-sitter; |
| 5221 | @c if in the future more parsers are supported, this should be | 5228 | @c if in the future more parsers are supported, this should be |
diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi index 70626ea9bb4..5734fcf8094 100644 --- a/doc/lispref/parsing.texi +++ b/doc/lispref/parsing.texi | |||
| @@ -2287,7 +2287,7 @@ non-@code{nil}, it sets up indentation. | |||
| 2287 | @item | 2287 | @item |
| 2288 | If @code{treesit-defun-type-regexp} is non-@code{nil}, it sets up | 2288 | If @code{treesit-defun-type-regexp} is non-@code{nil}, it sets up |
| 2289 | navigation functions for @code{beginning-of-defun} and | 2289 | navigation functions for @code{beginning-of-defun} and |
| 2290 | @code{end-of-defun}. | 2290 | @code{end-of-defun}. @xref{List Motion}. |
| 2291 | 2291 | ||
| 2292 | @item | 2292 | @item |
| 2293 | If @code{treesit-defun-name-function} is non-@code{nil}, it sets up | 2293 | If @code{treesit-defun-name-function} is non-@code{nil}, it sets up |
diff --git a/doc/lispref/positions.texi b/doc/lispref/positions.texi index 60732e7e353..e25cfacd19f 100644 --- a/doc/lispref/positions.texi +++ b/doc/lispref/positions.texi | |||
| @@ -849,6 +849,8 @@ a defun. The function @code{end-of-defun} calls this function instead | |||
| 849 | of using its normal method. | 849 | of using its normal method. |
| 850 | @end defvar | 850 | @end defvar |
| 851 | 851 | ||
| 852 | @cindex motion using tree-sitter | ||
| 853 | @cindex navigation by defun, using tree-sitter | ||
| 852 | @findex treesit-beginning-of-defun | 854 | @findex treesit-beginning-of-defun |
| 853 | @findex treesit-end-of-defun | 855 | @findex treesit-end-of-defun |
| 854 | If Emacs is compiled with tree-sitter, it can use the tree-sitter | 856 | If Emacs is compiled with tree-sitter, it can use the tree-sitter |
| @@ -885,6 +887,7 @@ nested defuns. | |||
| 885 | @findex backward-sentence | 887 | @findex backward-sentence |
| 886 | @vindex forward-sentence-function | 888 | @vindex forward-sentence-function |
| 887 | @cindex sentence, in program source files | 889 | @cindex sentence, in program source files |
| 890 | @cindex navigation by sentence, using tree-sitter | ||
| 888 | The function that is the value of the variable | 891 | The function that is the value of the variable |
| 889 | @code{forward-sentence-function} determines how to move across syntax | 892 | @code{forward-sentence-function} determines how to move across syntax |
| 890 | constructs known as @dfn{sentences}. Major modes can assign their own | 893 | constructs known as @dfn{sentences}. Major modes can assign their own |