diff options
| author | Eli Zaretskii | 2025-02-28 09:12:05 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2025-02-28 09:12:05 +0200 |
| commit | 6ed119d3052ffebd20450ec0c7fb3abf863b3a49 (patch) | |
| tree | 01b6fdb5cdfeecebda3004861bb27d76a2f57948 /src | |
| parent | becdfb11a5b13bc773729236763e99e513806451 (diff) | |
| download | emacs-6ed119d3052ffebd20450ec0c7fb3abf863b3a49.tar.gz emacs-6ed119d3052ffebd20450ec0c7fb3abf863b3a49.zip | |
; Fix documentation of recent treesit changes
* src/treesit.c (Ftreesit_query_capture)
(Ftreesit_parser_embed_level, Ftreesit_parser_set_embed_level)
(Ftreesit_parser_set_parent_node):
* lisp/treesit.el (treesit-query-range)
(treesit-query-range-by-language, treesit-range-settings)
(treesit-range-rules, treesit--parser-at-level)
(treesit--update-ranges-non-local, treesit--update-ranges-local)
(treesit--update-range-1): Fix wording and typos in doc strings.
* doc/lispref/parsing.texi (Pattern Matching): Fix wording.
Diffstat (limited to 'src')
| -rw-r--r-- | src/treesit.c | 17 | ||||
| -rw-r--r-- | src/treesit.h | 15 |
2 files changed, 18 insertions, 14 deletions
diff --git a/src/treesit.c b/src/treesit.c index c8af17a5b8b..20c3626732a 100644 --- a/src/treesit.c +++ b/src/treesit.c | |||
| @@ -1827,8 +1827,8 @@ DEFUN ("treesit-parser-embed-level", | |||
| 1827 | 1827 | ||
| 1828 | The embed level can be either nil or a non-negative integer. A value of | 1828 | The embed level can be either nil or a non-negative integer. A value of |
| 1829 | nil means the parser isn't part of the embedded parser tree. The | 1829 | nil means the parser isn't part of the embedded parser tree. The |
| 1830 | primary parser has embed level 0, from it, each layer of embedded parser | 1830 | primary parser has embed level 0, and each additional layer of parser |
| 1831 | has +1 embed level. */) | 1831 | embedding increments the embed level by 1. */) |
| 1832 | (Lisp_Object parser) | 1832 | (Lisp_Object parser) |
| 1833 | { | 1833 | { |
| 1834 | treesit_check_parser (parser); | 1834 | treesit_check_parser (parser); |
| @@ -1839,7 +1839,9 @@ has +1 embed level. */) | |||
| 1839 | DEFUN ("treesit-parser-set-embed-level", | 1839 | DEFUN ("treesit-parser-set-embed-level", |
| 1840 | Ftreesit_parser_set_embed_level, Streesit_parser_set_embed_level, | 1840 | Ftreesit_parser_set_embed_level, Streesit_parser_set_embed_level, |
| 1841 | 2, 2, 0, | 1841 | 2, 2, 0, |
| 1842 | doc: /* Set the embed level for PARSER to LEVEL. */) | 1842 | doc: /* Set the embed level for PARSER to LEVEL. |
| 1843 | LEVEL can be nil, for a parser that is not part of an embedded parser | ||
| 1844 | tree; otherwise it must be a non-negative integer. */) | ||
| 1843 | (Lisp_Object parser, Lisp_Object level) | 1845 | (Lisp_Object parser, Lisp_Object level) |
| 1844 | { | 1846 | { |
| 1845 | treesit_check_parser (parser); | 1847 | treesit_check_parser (parser); |
| @@ -1859,7 +1861,7 @@ DEFUN ("treesit-parser-parent-node", | |||
| 1859 | 1, 1, 0, | 1861 | 1, 1, 0, |
| 1860 | doc: /* Return PARSER's parent node, if one exists. | 1862 | doc: /* Return PARSER's parent node, if one exists. |
| 1861 | 1863 | ||
| 1862 | Only embeded local parser can have parent node. When Emacs uses a node | 1864 | Only embeded local parsers can have parent node. When Emacs uses a node |
| 1863 | in the host parser to create this local parser, that node is considered | 1865 | in the host parser to create this local parser, that node is considered |
| 1864 | the parent node of the local parser. */) | 1866 | the parent node of the local parser. */) |
| 1865 | (Lisp_Object parser) | 1867 | (Lisp_Object parser) |
| @@ -1871,7 +1873,7 @@ the parent node of the local parser. */) | |||
| 1871 | DEFUN ("treesit-parser-set-parent-node", | 1873 | DEFUN ("treesit-parser-set-parent-node", |
| 1872 | Ftreesit_parser_set_parent_node, Streesit_parser_set_parent_node, | 1874 | Ftreesit_parser_set_parent_node, Streesit_parser_set_parent_node, |
| 1873 | 2, 2, 0, | 1875 | 2, 2, 0, |
| 1874 | doc: /* Return PARSER's parent node to NODE. */) | 1876 | doc: /* Make NODE be the parent node of PARSER. */) |
| 1875 | (Lisp_Object parser, Lisp_Object node) | 1877 | (Lisp_Object parser, Lisp_Object node) |
| 1876 | { | 1878 | { |
| 1877 | treesit_check_parser (parser); | 1879 | treesit_check_parser (parser); |
| @@ -3289,8 +3291,9 @@ in which the query is executed. Any matching node whose span overlaps | |||
| 3289 | with the region between BEG and END are captured, it doesn't have to | 3291 | with the region between BEG and END are captured, it doesn't have to |
| 3290 | be completely in the region. | 3292 | be completely in the region. |
| 3291 | 3293 | ||
| 3292 | If GROUPED is non-nil, group captures into matches and return a list of | 3294 | If GROUPED is non-nil, ther function groups the returned list of |
| 3293 | MATCH, where each MATH is a list of (CAPTURE_NAME . NODE). | 3295 | captures into matches and return a list of MATCH, where each MATCH is |
| 3296 | a list of the form (CAPTURE_NAME . NODE). | ||
| 3294 | 3297 | ||
| 3295 | If NODE-ONLY is non-nil, return nodes only, and don't include | 3298 | If NODE-ONLY is non-nil, return nodes only, and don't include |
| 3296 | CAPTURE_NAME. | 3299 | CAPTURE_NAME. |
diff --git a/src/treesit.h b/src/treesit.h index d19a0e76216..d4cfc47ee5d 100644 --- a/src/treesit.h +++ b/src/treesit.h | |||
| @@ -64,12 +64,13 @@ struct Lisp_TS_Parser | |||
| 64 | = 0, end_byte = UINT32_MAX). */ | 64 | = 0, end_byte = UINT32_MAX). */ |
| 65 | Lisp_Object last_set_ranges; | 65 | Lisp_Object last_set_ranges; |
| 66 | /* Parsers for embedded code blocks will have a non-zero embed level. | 66 | /* Parsers for embedded code blocks will have a non-zero embed level. |
| 67 | The primary parser has level 0, and each layer of embedded parser | 67 | The primary parser has level 0, and each additional layer of parser |
| 68 | gets +1 level. The embed level can be either a non-negative | 68 | embedding increments the leve by 1. The embed level can be either |
| 69 | integer or nil. Every parser created by treesit-parser-create | 69 | a non-negative integer or nil. Every parser created by |
| 70 | starts with a nil level. If the value is nil, that means the range | 70 | 'treesit-parser-create' starts with a nil level. If the value is |
| 71 | functions (treesit-update-ranges and friends) haven't touched this | 71 | nil, that means the range functions (treesit-update-ranges and |
| 72 | parser yet, and this parser isn't part of the embed parser tree. */ | 72 | friends) haven't touched this parser yet, and this parser isn't |
| 73 | part of the embed parser tree. */ | ||
| 73 | Lisp_Object embed_level; | 74 | Lisp_Object embed_level; |
| 74 | /* Some comments: Technically you could calculate embed_level by | 75 | /* Some comments: Technically you could calculate embed_level by |
| 75 | following parent_node, but parent_node might be outdated so it's a | 76 | following parent_node, but parent_node might be outdated so it's a |
| @@ -80,7 +81,7 @@ struct Lisp_TS_Parser | |||
| 80 | for a parser will be useful beyond this. And we can always convert | 81 | for a parser will be useful beyond this. And we can always convert |
| 81 | these to properties later, but not vice versa. */ | 82 | these to properties later, but not vice versa. */ |
| 82 | /* When an embedded parser is created, it's usually based on a node in | 83 | /* When an embedded parser is created, it's usually based on a node in |
| 83 | the host parser. This field saves that node so it possible to | 84 | the host parser. This field saves that node so it's possible to |
| 84 | climb up and out of the embedded parser into the host parser. Note | 85 | climb up and out of the embedded parser into the host parser. Note |
| 85 | that the range of the embedded parser doesn't have to match that of | 86 | that the range of the embedded parser doesn't have to match that of |
| 86 | the parent node. */ | 87 | the parent node. */ |