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.
This commit is contained in:
Yuan Fu 2024-11-29 20:38:24 -08:00
parent 1e44c63fca
commit d0b918d8f3
No known key found for this signature in database
GPG key ID: 56E19BC57664A442
2 changed files with 10 additions and 2 deletions

View 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

View file

@ -3632,6 +3632,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