aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuan Fu2024-06-04 21:32:19 -0700
committerYuan Fu2024-06-04 21:46:22 -0700
commit636461686f1d36388d4523cbb10eb7ec3bbbd63e (patch)
tree5211e1678c9a85a32e8f1eb07ecf297b70b3fff2
parent2ee3edce3f5de55fc11997f522cbe2f00a4471fd (diff)
downloademacs-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.texi22
-rw-r--r--etc/NEWS6
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
1683parser will operate. This section describes functions for setting and 1683parser will operate. This section describes functions for setting and
1684getting ranges for a parser. 1684getting ranges for a parser.
1685 1685
1686@cindex primary parser
1687Generally 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
1690languages are ``embedded'' or ``guest'' parsers, which only work on part
1691of the buffer. The parse tree of the primary parser is usually used to
1692determine the ranges in which the embedded parsers operate.
1693
1694@vindex treesit-primary-parser
1695Major modes should set @var{treesit-primary-parser} to the primary
1696parser before calling @code{treesit-major-mode-setup}, so that Emacs can
1697configure the primary parser correctly for font-lock and other features.
1698
1686Lisp programs should call @code{treesit-update-ranges} to make sure 1699Lisp programs should call @code{treesit-update-ranges} to make sure
1687the ranges for each parser are correct before using parsers in a 1700the ranges for each parser are correct before using parsers in a
1688buffer, and call @code{treesit-language-at} to figure out the language 1701buffer, and call @code{treesit-language-at} to figure out the language
1689responsible for the text at some position. These two functions don't 1702responsible for the text at some position. These two functions don't
1690work by themselves, they need major modes to set 1703work 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.
1693These functions and variables are explained in more detail towards the 1706These functions and variables are explained in more detail towards the
1694end of the section. 1707end 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
diff --git a/etc/NEWS b/etc/NEWS
index 3220a3f16e4..922721f143c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2872,6 +2872,12 @@ only return parsers for that language. If TAG is given, only return
2872parsers with that tag. Note that passing nil as tag doesn't mean return 2872parsers with that tag. Note that passing nil as tag doesn't mean return
2873all parsers, but rather "all parsers with no tags". 2873all parsers, but rather "all parsers with no tags".
2874 2874
2875+++
2876*** New variable 'treesit-primary-parser'.
2877This variable should be set by multi-langauge major modes before calling
2878'treesit-major-mode-setup', in order for tree-sitter integration
2879functionalities 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