diff options
| author | Yuan Fu | 2024-07-26 22:33:17 -0700 |
|---|---|---|
| committer | Yuan Fu | 2024-07-30 17:09:57 -0700 |
| commit | e4cd26defc0e1a6deafbe4b2310ebdb3ffa4578f (patch) | |
| tree | d57a2a02c1f7b2c08ecd146738e4c8f949793c94 /doc | |
| parent | a2c439db687774f7b57959c39560993579c5d1bd (diff) | |
| download | emacs-e4cd26defc0e1a6deafbe4b2310ebdb3ffa4578f.tar.gz emacs-e4cd26defc0e1a6deafbe4b2310ebdb3ffa4578f.zip | |
"Separate" tree-sitter parser list for indirect buffers
When create a parser for the indirect buffer, set the buffer field of
the parser to the indirect buffer, but add the parser to the base
buffer's parser list. This way, all the parsers still get buffer
updates, but indirect buffer's parsers can have different narrowing than
the parsers of the base buffer.
When returning the parser list of a buffer, do filtering and only return
the parser for that buffer.
From user's POV, indirect buffers appear to have their own parser list.
* doc/lispref/parsing.texi (Using Parser): Remove the text describing
indirect buffer's special case.
* src/treesit.c (Ftreesit_parser_create): When create a parser for the
indirect buffer, set the buffer field of the parser to the indirect
buffer, but add the parser to the base buffer's parser list.
(Ftreesit_parser_list): Filter parser list, only return parsers for this
buffer.
xx
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/lispref/parsing.texi | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi index 65549505b1e..a3d2a5ac71c 100644 --- a/doc/lispref/parsing.texi +++ b/doc/lispref/parsing.texi | |||
| @@ -413,13 +413,6 @@ is non-@code{nil}, this function always creates a new parser. | |||
| 413 | 413 | ||
| 414 | @var{tag} can be any symbol except @code{t}, and defaults to | 414 | @var{tag} can be any symbol except @code{t}, and defaults to |
| 415 | @code{nil}. Different parsers can have the same tag. | 415 | @code{nil}. Different parsers can have the same tag. |
| 416 | |||
| 417 | If that buffer is an indirect buffer, its base buffer is used instead. | ||
| 418 | That is, indirect buffers use their base buffer's parsers. If the | ||
| 419 | base buffer is narrowed, an indirect buffer might not be able to | ||
| 420 | retrieve information of the portion of the buffer text that is | ||
| 421 | invisible in the base buffer. Lisp programs should widen as necessary | ||
| 422 | should they want to use a parser in an indirect buffer. | ||
| 423 | @end defun | 416 | @end defun |
| 424 | 417 | ||
| 425 | Given a parser, we can query information about it. | 418 | Given a parser, we can query information about it. |
| @@ -458,9 +451,7 @@ tree incrementally. | |||
| 458 | @defun treesit-parser-list &optional buffer language tag | 451 | @defun treesit-parser-list &optional buffer language tag |
| 459 | This function returns the parser list of @var{buffer}, filtered by | 452 | This function returns the parser list of @var{buffer}, filtered by |
| 460 | @var{language} and @var{tag}. If @var{buffer} is @code{nil} or | 453 | @var{language} and @var{tag}. If @var{buffer} is @code{nil} or |
| 461 | omitted, it defaults to the current buffer. If that buffer is an | 454 | omitted, it defaults to the current buffer. |
| 462 | indirect buffer, its base buffer is used instead. That is, indirect | ||
| 463 | buffers use their base buffer's parsers. | ||
| 464 | 455 | ||
| 465 | If @var{language} is non-@var{nil}, only include parsers for that | 456 | If @var{language} is non-@var{nil}, only include parsers for that |
| 466 | language, and only include parsers with @var{tag}. @var{tag} defaults | 457 | language, and only include parsers with @var{tag}. @var{tag} defaults |