diff options
| author | Yuan Fu | 2024-06-04 21:32:19 -0700 |
|---|---|---|
| committer | Yuan Fu | 2024-06-04 21:46:22 -0700 |
| commit | 636461686f1d36388d4523cbb10eb7ec3bbbd63e (patch) | |
| tree | 5211e1678c9a85a32e8f1eb07ecf297b70b3fff2 | |
| parent | 2ee3edce3f5de55fc11997f522cbe2f00a4471fd (diff) | |
| download | emacs-636461686f1d36388d4523cbb10eb7ec3bbbd63e.tar.gz emacs-636461686f1d36388d4523cbb10eb7ec3bbbd63e.zip | |
Add manual entry for treesit-primary-parser
* doc/lispref/parsing.texi (Multiple Languages): Add entry.
* etc/NEWS (Example): Add news.
| -rw-r--r-- | doc/lispref/parsing.texi | 22 | ||||
| -rw-r--r-- | etc/NEWS | 6 |
2 files changed, 26 insertions, 2 deletions
diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi index 645aad94a63..c8c2fe80c03 100644 --- a/doc/lispref/parsing.texi +++ b/doc/lispref/parsing.texi | |||
| @@ -1683,16 +1683,34 @@ instead to specify regions of buffer text (i.e., ranges) in which a | |||
| 1683 | parser will operate. This section describes functions for setting and | 1683 | parser will operate. This section describes functions for setting and |
| 1684 | getting ranges for a parser. | 1684 | getting ranges for a parser. |
| 1685 | 1685 | ||
| 1686 | @cindex primary parser | ||
| 1687 | Generally when there are multiple languages at play, there is a | ||
| 1688 | ``primary'', or ``host'' language. The parser for this language---the | ||
| 1689 | @dfn{primary parser}, parses the entire buffer. Parsers for other | ||
| 1690 | languages are ``embedded'' or ``guest'' parsers, which only work on part | ||
| 1691 | of the buffer. The parse tree of the primary parser is usually used to | ||
| 1692 | determine the ranges in which the embedded parsers operate. | ||
| 1693 | |||
| 1694 | @vindex treesit-primary-parser | ||
| 1695 | Major modes should set @var{treesit-primary-parser} to the primary | ||
| 1696 | parser before calling @code{treesit-major-mode-setup}, so that Emacs can | ||
| 1697 | configure the primary parser correctly for font-lock and other features. | ||
| 1698 | |||
| 1686 | Lisp programs should call @code{treesit-update-ranges} to make sure | 1699 | Lisp programs should call @code{treesit-update-ranges} to make sure |
| 1687 | the ranges for each parser are correct before using parsers in a | 1700 | the ranges for each parser are correct before using parsers in a |
| 1688 | buffer, and call @code{treesit-language-at} to figure out the language | 1701 | buffer, and call @code{treesit-language-at} to figure out the language |
| 1689 | responsible for the text at some position. These two functions don't | 1702 | responsible for the text at some position. These two functions don't |
| 1690 | work by themselves, they need major modes to set | 1703 | work by themselves, they need major modes to set |
| 1691 | @code{treesit-range-settings} and | 1704 | @var{treesit-range-settings} and |
| 1692 | @code{treesit-language-at-point-function}, which do the actual work. | 1705 | @var{treesit-language-at-point-function}, which do the actual work. |
| 1693 | These functions and variables are explained in more detail towards the | 1706 | These functions and variables are explained in more detail towards the |
| 1694 | end of the section. | 1707 | end of the section. |
| 1695 | 1708 | ||
| 1709 | @b{In short}, multi-language major modes should set | ||
| 1710 | @var{treesit-primary-parser}, @var{treesit-range-settings}, and | ||
| 1711 | @var{treesit-language-at-point-function} before calling | ||
| 1712 | @code{treesit-major-mode-setup}. | ||
| 1713 | |||
| 1696 | @heading Getting and setting ranges | 1714 | @heading Getting and setting ranges |
| 1697 | 1715 | ||
| 1698 | @defun treesit-parser-set-included-ranges parser ranges | 1716 | @defun treesit-parser-set-included-ranges parser ranges |
| @@ -2872,6 +2872,12 @@ only return parsers for that language. If TAG is given, only return | |||
| 2872 | parsers with that tag. Note that passing nil as tag doesn't mean return | 2872 | parsers with that tag. Note that passing nil as tag doesn't mean return |
| 2873 | all parsers, but rather "all parsers with no tags". | 2873 | all parsers, but rather "all parsers with no tags". |
| 2874 | 2874 | ||
| 2875 | +++ | ||
| 2876 | *** New variable 'treesit-primary-parser'. | ||
| 2877 | This variable should be set by multi-langauge major modes before calling | ||
| 2878 | 'treesit-major-mode-setup', in order for tree-sitter integration | ||
| 2879 | functionalities to operate correctly. | ||
| 2880 | |||
| 2875 | 2881 | ||
| 2876 | * Changes in Emacs 30.1 on Non-Free Operating Systems | 2882 | * Changes in Emacs 30.1 on Non-Free Operating Systems |
| 2877 | 2883 | ||