aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2025-06-05 10:30:44 +0300
committerEli Zaretskii2025-06-05 10:30:44 +0300
commitbcf005fa774194d434c68cc191566b58c297ca86 (patch)
treeefe2611242504140a8dfaf1c58e38333e8ea9080 /src
parent1903b0062b1688241d1485b3e460264e124ba757 (diff)
downloademacs-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.c22
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
5196The value should be an alist of (LANGUAGE . DEFINITIONS), where 5196The value should be defined by the major mode, and should be an alist
5197LANGUAGE is a language symbol, and DEFINITIONS is a list of 5197of the form (LANGUAGE . DEFINITIONS), where LANGUAGE is a language
5198symbol and DEFINITIONS is a list whose elements are of the form
5198 5199
5199 (THING PRED) 5200 (THING PRED)
5200 5201
5201THING is a symbol representing the thing, like `defun', `sexp', or 5202THING 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
5204for the major mode; PRED defines what kind of node can be qualified
5205as THING.
5203 5206
5204PRED can be a regexp string that matches the type of the node; it can 5207PRED can be a regexp string that matches the type of the node; it can
5205be a predicate function that takes the node as the sole argument and 5208be 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
5207cons (REGEXP . FN), which is a combination of a regexp and a predicate 5210cons (REGEXP . FN), which is a combination of a regexp and a predicate
5208function, and the node has to match both to qualify as the thing. 5211function, and the node has to match both to qualify as the thing.
5209 5212
5210PRED can also be recursively defined. It can be (or PRED...), meaning 5213PRED can also be recursively defined. It can be:
5211satisfying anyone of the inner PREDs qualifies the node; or (and
5212PRED...) meaning satisfying all of the inner PREDs qualifies the node;
5213or (not PRED), meaning not satisfying the inner PRED qualifies the node.
5214 5214
5215There 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
5219There are two pre-defined predicates, `named' and `anonymous'. They
5216match named nodes and anonymous nodes, respectively. 5220match named nodes and anonymous nodes, respectively.
5217 5221
5218Finally, PRED can refer to other THINGs defined in this list by using 5222Finally, PRED can refer to other THINGs defined in this list by using