aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuan Fu2024-11-29 20:38:24 -0800
committerYuan Fu2024-12-01 17:53:22 -0800
commitd0b918d8f3cc0779fa73b395b6384c8a04b0c0ba (patch)
tree9091b2f54e0d6e39e33ac48adec6bc8bd8eeb559
parent1e44c63fcadeb89a9a9c9208f221970e6fcc774c (diff)
downloademacs-d0b918d8f3cc0779fa73b395b6384c8a04b0c0ba.tar.gz
emacs-d0b918d8f3cc0779fa73b395b6384c8a04b0c0ba.zip
Add treesit-explore command
* lisp/treesit.el (treesit-explore): New function. * doc/lispref/parsing.texi (Language Grammar): Advertize this command instead of the minor mode.
-rw-r--r--doc/lispref/parsing.texi4
-rw-r--r--lisp/treesit.el8
2 files changed, 10 insertions, 2 deletions
diff --git a/doc/lispref/parsing.texi b/doc/lispref/parsing.texi
index 9fe828d8512..5ef29f558ef 100644
--- a/doc/lispref/parsing.texi
+++ b/doc/lispref/parsing.texi
@@ -240,8 +240,8 @@ which displays the syntax tree of the source in the current buffer in
240real time. Emacs also comes with an ``inspect mode'', which displays 240real time. Emacs also comes with an ``inspect mode'', which displays
241information of the nodes at point in the mode-line. 241information of the nodes at point in the mode-line.
242 242
243@deffn Command treesit-explore-mode 243@deffn Command treesit-explore
244This mode pops up a window displaying the syntax tree of the source in 244This command pops up a window displaying the syntax tree of the source in
245the current buffer. Selecting text in the source buffer highlights 245the current buffer. Selecting text in the source buffer highlights
246the corresponding nodes in the syntax tree display. Clicking 246the corresponding nodes in the syntax tree display. Clicking
247on nodes in the syntax tree highlights the corresponding text in the 247on nodes in the syntax tree highlights the corresponding text in the
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 64b08857f4a..2dd556e55ab 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -3632,6 +3632,14 @@ window."
3632 #'treesit--explorer-kill-explorer-buffer t) 3632 #'treesit--explorer-kill-explorer-buffer t)
3633 (treesit--explorer-kill-explorer-buffer))) 3633 (treesit--explorer-kill-explorer-buffer)))
3634 3634
3635(defun treesit-explore ()
3636 "Show the explorer."
3637 (interactive)
3638 (if (and treesit-explore-mode
3639 (buffer-live-p treesit--explorer-buffer))
3640 (display-buffer treesit--explorer-buffer '(nil (inhibit-same-window . t)))
3641 (treesit-explore-mode)))
3642
3635;;; Install & build language grammar 3643;;; Install & build language grammar
3636 3644
3637(defvar treesit-language-source-alist nil 3645(defvar treesit-language-source-alist nil