summaryrefslogtreecommitdiff
path: root/doc/lispref/parsing.texi
diff options
context:
space:
mode:
authorYuan Fu <casouri@gmail.com>2022-11-15 20:29:07 -0800
committerYuan Fu <casouri@gmail.com>2022-11-16 14:40:37 -0800
commit306e49285a04c02f0a575a7d7b2f82eeb032c86b (patch)
tree4640e3aa8ed6e24422a54171a7e9032e12c2312f /doc/lispref/parsing.texi
parentd1ef0243eb6e7cd9720236eb0e900fe7163b3c2b (diff)
downloademacs-306e49285a04c02f0a575a7d7b2f82eeb032c86b.tar.gz
emacs-306e49285a04c02f0a575a7d7b2f82eeb032c86b.tar.bz2
emacs-306e49285a04c02f0a575a7d7b2f82eeb032c86b.zip
Add treesit-explore-mode
This mode is basically the tree-sitter playground[1] in Emacs: displays the syntax tree with the source side-by-side, kept in sync in real-time. [1] https://tree-sitter.github.io/tree-sitter/playground * doc/lispref/parsing.texi (Language Definitions): Mention in manual. * lisp/treesit.el (treesit--explorer-buffer) (treesit--explorer-source-buffer) (treesit--explorer-language) (treesit--explorer-refresh-timer) (treesit--explorer-highlight-overlay) (treesit--explorer-last-node): New variables. * lisp/treesit.el (treesit--explorer--nodes-to-highlight) (treesit--explorer-refresh) (treesit--explorer-post-command) (treesit--explorer-jump) (treesit--explorer-highlight-node) (treesit--explorer-draw-node): New functions. (treesit--explorer-tree-mode) (treesit-explore-mode): New modes.
Diffstat (limited to 'doc/lispref/parsing.texi')
-rw-r--r--doc/lispref/parsing.texi16
1 files changed, 16 insertions, 0 deletions
diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi
index 9fcf488da10..0f4a004ee90 100644
--- a/doc/lispref/parsing.texi
+++ b/doc/lispref/parsing.texi
@@ -223,6 +223,22 @@ assign @dfn{field names} to child nodes. For example, a
@end group
@end example
+@heading Exploring the syntax tree
+
+To aid understanding the syntax of a language and debugging, Emacs
+provides a ``explore'' mode, which displays the syntax tree of the
+source in the current buffer in real time. Emacs also comes with a
+``inspect mode'', which displays information of the nodes at point in
+the mode-line.
+
+@deffn Command treesit-explore-mode
+This mode pops up a window displaying the syntax tree of the source in
+the current buffer. Emacs highlights nodes in the syntax tree if
+their corresponding text in the source buffer is selected. Clicking
+on nodes in the syntax tree highlights the corresponding text in the
+source buffer.
+@end deffn
+
@deffn Command treesit-inspect-mode
This minor mode displays on the mode-line the node that @emph{starts}
at point. The mode-line will display