]> git.eshelyaron.com Git - emacs.git/commitdiff
Add treesit-explore command
authorYuan Fu <casouri@gmail.com>
Sat, 30 Nov 2024 04:38:24 +0000 (20:38 -0800)
committerEshel Yaron <me@eshelyaron.com>
Wed, 4 Dec 2024 17:02:51 +0000 (18:02 +0100)
* lisp/treesit.el (treesit-explore): New function.
* doc/lispref/parsing.texi (Language Grammar): Advertize this
command instead of the minor mode.

(cherry picked from commit d0b918d8f3cc0779fa73b395b6384c8a04b0c0ba)

doc/lispref/parsing.texi
lisp/treesit.el

index 9fe828d85121851ad6913f54ba6c403d43cefa26..5ef29f558ef8c13abe1ba20f8409f7bb8d038100 100644 (file)
@@ -240,8 +240,8 @@ which displays the syntax tree of the source in the current buffer in
 real time.  Emacs also comes with an ``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
+@deffn Command treesit-explore
+This command pops up a window displaying the syntax tree of the source in
 the current buffer.  Selecting text in the source buffer highlights
 the corresponding nodes in the syntax tree display.  Clicking
 on nodes in the syntax tree highlights the corresponding text in the
index be6df5a576b8bf29bd3af230c05edba7374762c0..1c57191fe53d4c5f70cefac1769700e95e232fae 100644 (file)
@@ -3624,6 +3624,14 @@ window."
                  #'treesit--explorer-kill-explorer-buffer t)
     (treesit--explorer-kill-explorer-buffer)))
 
+(defun treesit-explore ()
+  "Show the explorer."
+  (interactive)
+  (if (and treesit-explore-mode
+           (buffer-live-p treesit--explorer-buffer))
+      (display-buffer treesit--explorer-buffer '(nil (inhibit-same-window . t)))
+    (treesit-explore-mode)))
+
 ;;; Install & build language grammar
 
 (defvar treesit-language-source-alist nil