Subject: bug#75079: Window for treesit-explore

From: Yuan Fu <[email-masked]>
Date: Mon, 27 Jan 2025 17:48:05 -0800

> On Jan 22, 2025, at 11:40 PM, Juri Linkov <[email-masked]> wrote:
> 
> BTW, wouldn't it be nicer to display the treesit-explore window
> below the current buffer, this would keep the user's window layout:
> 
> diff --git a/lisp/treesit.el b/lisp/treesit.el
> index 8d86d142e3f..a22c335ae22 100644
> --- a/lisp/treesit.el
> +++ b/lisp/treesit.el
> @@ -4122,7 +4224,8 @@ treesit-explorer-switch-parser
>     (user-error "Not in `treesit-explore-mode'"))
>   (setq-local treesit--explorer-parser parser)
>   (display-buffer treesit--explorer-buffer
> -                  (cons nil '((inhibit-same-window . t))))
> +                  '(display-buffer-below-selected
> +                    (inhibit-same-window . t)))
>   (setq-local treesit--explorer-last-node nil)
>   (treesit--explorer-refresh))
> 
> @@ -4176,7 +4279,9 @@ treesit-explore
>   (interactive)
>   (if (and treesit-explore-mode
>            (buffer-live-p treesit--explorer-buffer))
> -      (display-buffer treesit--explorer-buffer '(nil (inhibit-same-window . t)))
> +      (display-buffer treesit--explorer-buffer
> +                      '(display-buffer-below-selected
> +                        (inhibit-same-window . t)))
>     (treesit-explore-mode)))

It’s hard to say what’s the ideal layout here. My personal preference is for the explorer window to show up in “the other window”. Since I usually have to side-by-side window, “the other window” will be on the left or right. And I’ll be sad if Emacs splits my window vertically to show a new window below.

IOW I think it’s best to use the “default” display behavior that user configured for and probably prefers.

Yuan