diff options
| author | Eli Zaretskii | 2025-06-05 10:30:44 +0300 |
|---|---|---|
| committer | Eli Zaretskii | 2025-06-05 10:30:44 +0300 |
| commit | bcf005fa774194d434c68cc191566b58c297ca86 (patch) | |
| tree | efe2611242504140a8dfaf1c58e38333e8ea9080 /src | |
| parent | 1903b0062b1688241d1485b3e460264e124ba757 (diff) | |
| download | emacs-bcf005fa774194d434c68cc191566b58c297ca86.tar.gz emacs-bcf005fa774194d434c68cc191566b58c297ca86.zip | |
Improve documentation of treesit "thing"
* src/treesit.c (syms_of_treesit):
* lisp/treesit.el (treesit-cycle-sexp-type):
(treesit-thing-at, treesit-thing-at-point): Doc fixes.
* doc/lispref/parsing.texi (User-defined Things): Improve
documentation of treesit "thing" and related functions; add
cross-references and indexing.
Diffstat (limited to 'src')
| -rw-r--r-- | src/treesit.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/treesit.c b/src/treesit.c index de74e41c89a..67dd2ee3a7a 100644 --- a/src/treesit.c +++ b/src/treesit.c | |||
| @@ -5193,13 +5193,16 @@ then in the system default locations for dynamic libraries, in that order. */); | |||
| 5193 | doc: | 5193 | doc: |
| 5194 | /* A list defining things. | 5194 | /* A list defining things. |
| 5195 | 5195 | ||
| 5196 | The value should be an alist of (LANGUAGE . DEFINITIONS), where | 5196 | The value should be defined by the major mode, and should be an alist |
| 5197 | LANGUAGE is a language symbol, and DEFINITIONS is a list of | 5197 | of the form (LANGUAGE . DEFINITIONS), where LANGUAGE is a language |
| 5198 | symbol and DEFINITIONS is a list whose elements are of the form | ||
| 5198 | 5199 | ||
| 5199 | (THING PRED) | 5200 | (THING PRED) |
| 5200 | 5201 | ||
| 5201 | THING is a symbol representing the thing, like `defun', `sexp', or | 5202 | THING is a symbol representing the thing, like `defun', `defclass', |
| 5202 | `sentence'; PRED defines what kind of node can be qualified as THING. | 5203 | `sexp', `sentence', `comment', or any other symbol that is meaningful |
| 5204 | for the major mode; PRED defines what kind of node can be qualified | ||
| 5205 | as THING. | ||
| 5203 | 5206 | ||
| 5204 | PRED can be a regexp string that matches the type of the node; it can | 5207 | PRED can be a regexp string that matches the type of the node; it can |
| 5205 | be a predicate function that takes the node as the sole argument and | 5208 | be a predicate function that takes the node as the sole argument and |
| @@ -5207,12 +5210,13 @@ returns t if the node is the thing, and nil otherwise; it can be a | |||
| 5207 | cons (REGEXP . FN), which is a combination of a regexp and a predicate | 5210 | cons (REGEXP . FN), which is a combination of a regexp and a predicate |
| 5208 | function, and the node has to match both to qualify as the thing. | 5211 | function, and the node has to match both to qualify as the thing. |
| 5209 | 5212 | ||
| 5210 | PRED can also be recursively defined. It can be (or PRED...), meaning | 5213 | PRED can also be recursively defined. It can be: |
| 5211 | satisfying anyone of the inner PREDs qualifies the node; or (and | ||
| 5212 | PRED...) meaning satisfying all of the inner PREDs qualifies the node; | ||
| 5213 | or (not PRED), meaning not satisfying the inner PRED qualifies the node. | ||
| 5214 | 5214 | ||
| 5215 | There are two pre-defined predicates, `named' and `anonymous`. They | 5215 | (or PRED...), meaning satisfying any of the inner PREDs qualifies the node; |
| 5216 | (and PRED...) meaning satisfying all of the inner PREDs qualifies the node; | ||
| 5217 | (not PRED), meaning not satisfying the inner PRED qualifies the node. | ||
| 5218 | |||
| 5219 | There are two pre-defined predicates, `named' and `anonymous'. They | ||
| 5216 | match named nodes and anonymous nodes, respectively. | 5220 | match named nodes and anonymous nodes, respectively. |
| 5217 | 5221 | ||
| 5218 | Finally, PRED can refer to other THINGs defined in this list by using | 5222 | Finally, PRED can refer to other THINGs defined in this list by using |