GNU bug report logs - #75079
Default parser for treesit-explore

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Wed, 25 Dec 2024 08:12:02 UTC

Severity: normal

Fixed in version 31.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 75079 in the body.
You can then email your comments to 75079 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to casouri <at> gmail.com, bug-gnu-emacs <at> gnu.org:
bug#75079; Package emacs. (Wed, 25 Dec 2024 08:12:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> linkov.net>:
New bug report received and forwarded. Copy sent to casouri <at> gmail.com, bug-gnu-emacs <at> gnu.org. (Wed, 25 Dec 2024 08:12:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: bug-gnu-emacs <at> gnu.org
Subject: Default parser for treesit-explore
Date: Wed, 25 Dec 2024 09:56:20 +0200
[Message part 1 (text/plain, inline)]
Currently loading the desktop is disrupted by the prompt
that asks for a parser name when treesit-explore-mode
was enabled in a buffer before.  The second part of the
following patch fixes this by omitting treesit-explore-mode.

But anyway it's very tedious to select the single parser
every time when enabling treesit-explore-mode.  So the
first part of this patch avoids this unnecessary selection:

[treesit-explorer-switch-parser.patch (text/x-diff, inline)]
diff --git a/lisp/treesit.el b/lisp/treesit.el
index 464b7e688be..5428e84fa5a 100644
--- a/lisp/treesit.el
+++ b/lisp/treesit.el
@@ -3911,8 +3911,10 @@ treesit-explorer-switch-parser
   (interactive
    (list (let* ((parser-alist
                  (treesit--explorer-generate-parser-alist))
-                (parser-name (completing-read
-                              "Parser: " (mapcar #'car parser-alist))))
+                (parser-name (if (= (length parser-alist) 1)
+                                 (car parser-alist)
+                               (completing-read
+                                "Parser: " (mapcar #'car parser-alist)))))
            (alist-get parser-name parser-alist
                       nil nil #'equal))))
   (unless treesit-explore-mode
@@ -3952,7 +3954,13 @@ treesit-explore-mode
           (unless (memq 'treesit--explorer-tree-mode
                         desktop-modes-not-to-save)
             (push 'treesit--explorer-tree-mode
-                  desktop-modes-not-to-save))))
+                  desktop-modes-not-to-save)))
+        ;; Tell `desktop-save' to not save minor mode.
+        (when (boundp 'desktop-minor-mode-table)
+          (unless (member '(treesit-explore-mode nil)
+                          desktop-minor-mode-table)
+            (push '(treesit-explore-mode nil)
+                  desktop-minor-mode-table))))
     ;; Turn off explore mode.
     (remove-hook 'post-command-hook
                  #'treesit--explorer-post-command t)

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75079; Package emacs. (Wed, 25 Dec 2024 08:39:02 GMT) Full text and rfc822 format available.

Message #8 received at 75079 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 75079 <at> debbugs.gnu.org
Subject: Re: bug#75079: Default parser for treesit-explore
Date: Wed, 25 Dec 2024 00:36:58 -0800

> On Dec 24, 2024, at 11:56 PM, Juri Linkov <juri <at> linkov.net> wrote:
> 
> Currently loading the desktop is disrupted by the prompt
> that asks for a parser name when treesit-explore-mode
> was enabled in a buffer before.  The second part of the
> following patch fixes this by omitting treesit-explore-mode.
> 
> But anyway it's very tedious to select the single parser
> every time when enabling treesit-explore-mode.  So the
> first part of this patch avoids this unnecessary selection:
> 
> diff --git a/lisp/treesit.el b/lisp/treesit.el
> index 464b7e688be..5428e84fa5a 100644
> --- a/lisp/treesit.el
> +++ b/lisp/treesit.el
> @@ -3911,8 +3911,10 @@ treesit-explorer-switch-parser
>   (interactive
>    (list (let* ((parser-alist
>                  (treesit--explorer-generate-parser-alist))
> -                (parser-name (completing-read
> -                              "Parser: " (mapcar #'car parser-alist))))
> +                (parser-name (if (= (length parser-alist) 1)
> +                                 (car parser-alist)
> +                               (completing-read
> +                                "Parser: " (mapcar #'car parser-alist)))))
>            (alist-get parser-name parser-alist
>                       nil nil #'equal))))
>   (unless treesit-explore-mode
> @@ -3952,7 +3954,13 @@ treesit-explore-mode
>           (unless (memq 'treesit--explorer-tree-mode
>                         desktop-modes-not-to-save)
>             (push 'treesit--explorer-tree-mode
> -                  desktop-modes-not-to-save))))
> +                  desktop-modes-not-to-save)))
> +        ;; Tell `desktop-save' to not save minor mode.
> +        (when (boundp 'desktop-minor-mode-table)
> +          (unless (member '(treesit-explore-mode nil)
> +                          desktop-minor-mode-table)
> +            (push '(treesit-explore-mode nil)
> +                  desktop-minor-mode-table))))
>     ;; Turn off explore mode.
>     (remove-hook 'post-command-hook
>                  #'treesit--explorer-post-command t)

Thanks Juri, have you applied the patch? If not, please feel free to do :-)

Yuan



Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75079; Package emacs. (Wed, 25 Dec 2024 12:40:01 GMT) Full text and rfc822 format available.

Message #11 received at 75079 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: casouri <at> gmail.com, 75079 <at> debbugs.gnu.org
Subject: Re: bug#75079: Default parser for treesit-explore
Date: Wed, 25 Dec 2024 14:39:05 +0200
> Cc: Yuan Fu <casouri <at> gmail.com>
> From: Juri Linkov <juri <at> linkov.net>
> Date: Wed, 25 Dec 2024 09:56:20 +0200
> 
> @@ -3952,7 +3954,13 @@ treesit-explore-mode
>            (unless (memq 'treesit--explorer-tree-mode
>                          desktop-modes-not-to-save)
>              (push 'treesit--explorer-tree-mode
> -                  desktop-modes-not-to-save))))
> +                  desktop-modes-not-to-save)))
> +        ;; Tell `desktop-save' to not save minor mode.
> +        (when (boundp 'desktop-minor-mode-table)
> +          (unless (member '(treesit-explore-mode nil)
> +                          desktop-minor-mode-table)
> +            (push '(treesit-explore-mode nil)
> +                  desktop-minor-mode-table))))

That comment should explain _why_ we don't want desktop-save to save
this minor mode.  Otherwise it just says what the code does, which is
not hard to understand by looking at the code.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75079; Package emacs. (Wed, 25 Dec 2024 17:56:02 GMT) Full text and rfc822 format available.

Message #14 received at 75079 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 75079 <at> debbugs.gnu.org
Subject: Re: bug#75079: Default parser for treesit-explore
Date: Wed, 25 Dec 2024 19:54:38 +0200
close 75079 31.0.50
thanks

>> On Dec 24, 2024, at 11:56 PM, Juri Linkov <juri <at> linkov.net> wrote:
>> 
>> Currently loading the desktop is disrupted by the prompt
>> that asks for a parser name when treesit-explore-mode
>> was enabled in a buffer before.  The second part of the
>> following patch fixes this by omitting treesit-explore-mode.
>> 
>> But anyway it's very tedious to select the single parser
>> every time when enabling treesit-explore-mode.  So the
>> first part of this patch avoids this unnecessary selection:
>
> Thanks Juri, have you applied the patch? If not, please feel free to do :-)

Now the patch is applied, after fulfilling Eli's request
to extend the comments. 




bug marked as fixed in version 31.0.50, send any further explanations to 75079 <at> debbugs.gnu.org and Juri Linkov <juri <at> linkov.net> Request was from Juri Linkov <juri <at> linkov.net> to control <at> debbugs.gnu.org. (Wed, 25 Dec 2024 17:56:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75079; Package emacs. (Wed, 25 Dec 2024 20:10:02 GMT) Full text and rfc822 format available.

Message #19 received at 75079 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 75079 <at> debbugs.gnu.org
Subject: Re: bug#75079: Default parser for treesit-explore
Date: Wed, 25 Dec 2024 12:08:33 -0800

> On Dec 25, 2024, at 9:54 AM, Juri Linkov <juri <at> linkov.net> wrote:
> 
> close 75079 31.0.50
> thanks
> 
>>> On Dec 24, 2024, at 11:56 PM, Juri Linkov <juri <at> linkov.net> wrote:
>>> 
>>> Currently loading the desktop is disrupted by the prompt
>>> that asks for a parser name when treesit-explore-mode
>>> was enabled in a buffer before.  The second part of the
>>> following patch fixes this by omitting treesit-explore-mode.
>>> 
>>> But anyway it's very tedious to select the single parser
>>> every time when enabling treesit-explore-mode.  So the
>>> first part of this patch avoids this unnecessary selection:
>> 
>> Thanks Juri, have you applied the patch? If not, please feel free to do :-)
> 
> Now the patch is applied, after fulfilling Eli's request
> to extend the comments. 

Thank you!





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75079; Package emacs. (Thu, 23 Jan 2025 07:42:02 GMT) Full text and rfc822 format available.

Message #22 received at 75079 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: 75079 <at> debbugs.gnu.org
Cc: Yuan Fu <casouri <at> gmail.com>
Subject: Re: bug#75079: Window for treesit-explore
Date: Thu, 23 Jan 2025 09:40:44 +0200
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)))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75079; Package emacs. (Tue, 28 Jan 2025 01:49:02 GMT) Full text and rfc822 format available.

Message #25 received at 75079 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: 75079 <at> debbugs.gnu.org
Subject: Re: bug#75079: Window for treesit-explore
Date: Mon, 27 Jan 2025 17:48:05 -0800

> On Jan 22, 2025, at 11:40 PM, Juri Linkov <juri <at> linkov.net> 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



bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 25 Feb 2025 12:24:14 GMT) Full text and rfc822 format available.

This bug report was last modified 173 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.