diff options
| author | Yuan Fu | 2024-11-29 20:38:24 -0800 |
|---|---|---|
| committer | Yuan Fu | 2024-12-01 17:53:22 -0800 |
| commit | d0b918d8f3cc0779fa73b395b6384c8a04b0c0ba (patch) | |
| tree | 9091b2f54e0d6e39e33ac48adec6bc8bd8eeb559 | |
| parent | 1e44c63fcadeb89a9a9c9208f221970e6fcc774c (diff) | |
| download | emacs-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.texi | 4 | ||||
| -rw-r--r-- | lisp/treesit.el | 8 |
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 | |||
| 240 | real time. Emacs also comes with an ``inspect mode'', which displays | 240 | real time. Emacs also comes with an ``inspect mode'', which displays |
| 241 | information of the nodes at point in the mode-line. | 241 | information of the nodes at point in the mode-line. |
| 242 | 242 | ||
| 243 | @deffn Command treesit-explore-mode | 243 | @deffn Command treesit-explore |
| 244 | This mode pops up a window displaying the syntax tree of the source in | 244 | This command pops up a window displaying the syntax tree of the source in |
| 245 | the current buffer. Selecting text in the source buffer highlights | 245 | the current buffer. Selecting text in the source buffer highlights |
| 246 | the corresponding nodes in the syntax tree display. Clicking | 246 | the corresponding nodes in the syntax tree display. Clicking |
| 247 | on nodes in the syntax tree highlights the corresponding text in the | 247 | on 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 |