GNU bug report logs - #60880
30.0.50; tree-sitter `treesit-explore-mode' is buggy and does not behave properly

Previous Next

Package: emacs;

Reported by: Mickey Petersen <mickey <at> masteringemacs.org>

Date: Tue, 17 Jan 2023 13:50:02 UTC

Severity: normal

Found in version 30.0.50

To reply to this bug, email your comments to 60880 AT debbugs.gnu.org.

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

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


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#60880; Package emacs. (Tue, 17 Jan 2023 13:50:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Mickey Petersen <mickey <at> masteringemacs.org>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 17 Jan 2023 13:50:02 GMT) Full text and rfc822 format available.

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

From: Mickey Petersen <mickey <at> masteringemacs.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; tree-sitter `treesit-explore-mode' is buggy and does not
 behave properly
Date: Tue, 17 Jan 2023 13:44:21 +0000
A medley of issues here:

1. Executing `treesit-explore-mode' on a buffer with no valid grammar
support causes the minor mode (and playground buffer) to stick around and "load" anyway.

2. Bailing out of the grammar prompt does not, in actual fact, stop explore mode from proceeding. Instead it creates an empty buffer and it still engages the minor mode.

3. Killing the playground buffer does not remove the explore mode buffer.

4. treesit-explore-mode is stored against a buffer during `desktop-save' (and subsequently read with) `desktop-read'. Thus broken buffers or files inherit the explore mode. This is especially pernicious due to #1, #2, and #3.




In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.20, cairo version 1.16.0) of 2023-01-17 built on mickey-work
Repository revision: bb383a54910c3094e5d228e0af62bf70e36203ca
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: Ubuntu 20.04.3 LTS

Configured using:
 'configure --with-native-compilation --with-json --with-mailutils
 --without-compress-install --with-imagemagick CC=gcc-10'





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60880; Package emacs. (Thu, 19 Jan 2023 22:32:02 GMT) Full text and rfc822 format available.

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

From: Yuan Fu <casouri <at> gmail.com>
To: Mickey Petersen <mickey <at> masteringemacs.org>
Cc: 60880 <at> debbugs.gnu.org
Subject: Re: bug#60880: 30.0.50; tree-sitter `treesit-explore-mode' is buggy 
 and does not behave properly
Date: Thu, 19 Jan 2023 14:30:46 -0800
Mickey Petersen <mickey <at> masteringemacs.org> writes:

> A medley of issues here:
>
> 1. Executing `treesit-explore-mode' on a buffer with no valid grammar
> support causes the minor mode (and playground buffer) to stick around and "load" anyway.
>
> 2. Bailing out of the grammar prompt does not, in actual fact, stop
> explore mode from proceeding. Instead it creates an empty buffer and
> it still engages the minor mode.
>
> 3. Killing the playground buffer does not remove the explore mode buffer.
>
> 4. treesit-explore-mode is stored against a buffer during
> `desktop-save' (and subsequently read with) `desktop-read'. Thus
> broken buffers or files inherit the explore mode. This is especially
> pernicious due to #1, #2, and #3.

Ok, I fixed those problems. Now if the language is not available,
treesit-explore-mode raises an error instead of continuing, desktop-save
will not save the explorer buffer, and killing the source buffer also
kills the explorer buffer.

Invalid language doesn’t stop treesit-explore-mode from turning on, even
if it doesn’t create buffers, etc, since I think this is how minor modes
usually behave.

Yuan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60880; Package emacs. (Fri, 20 Jan 2023 07:03:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Yuan Fu <casouri <at> gmail.com>
Cc: 60880 <at> debbugs.gnu.org, mickey <at> masteringemacs.org
Subject: Re: bug#60880: 30.0.50;
 tree-sitter `treesit-explore-mode' is buggy and does not behave
 properly
Date: Fri, 20 Jan 2023 09:02:01 +0200
> Cc: 60880 <at> debbugs.gnu.org
> From: Yuan Fu <casouri <at> gmail.com>
> Date: Thu, 19 Jan 2023 14:30:46 -0800
> 
> 
> Mickey Petersen <mickey <at> masteringemacs.org> writes:
> 
> > A medley of issues here:
> >
> > 1. Executing `treesit-explore-mode' on a buffer with no valid grammar
> > support causes the minor mode (and playground buffer) to stick around and "load" anyway.
> >
> > 2. Bailing out of the grammar prompt does not, in actual fact, stop
> > explore mode from proceeding. Instead it creates an empty buffer and
> > it still engages the minor mode.
> >
> > 3. Killing the playground buffer does not remove the explore mode buffer.
> >
> > 4. treesit-explore-mode is stored against a buffer during
> > `desktop-save' (and subsequently read with) `desktop-read'. Thus
> > broken buffers or files inherit the explore mode. This is especially
> > pernicious due to #1, #2, and #3.
> 
> Ok, I fixed those problems. Now if the language is not available,
> treesit-explore-mode raises an error instead of continuing, desktop-save
> will not save the explorer buffer, and killing the source buffer also
> kills the explorer buffer.

I don't think the desktop-save part is correct: the test should be at
desktop-read time, not at desktop-save time.  Because the fact we had
the language available when we saved the desktop doesn't guarantee we
will have it available when restoring that desktop: it could be in a
different build of Emacs or even on a different machine.

I'm not sure I understand the problem which desktop-read has when
restoring desktop with buffers in treesit-explore-mode, but if the
problems are more than just warning messages, then desktop-read should
detect these problems, emit an echo-area message, and refrain from
restoring the mode.  Like it does with buffers that visited files
which are no longer there, for example.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60880; Package emacs. (Fri, 20 Jan 2023 08:21:01 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> linkov.net>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 60880 <at> debbugs.gnu.org, Yuan Fu <casouri <at> gmail.com>,
 mickey <at> masteringemacs.org
Subject: Re: bug#60880: 30.0.50; tree-sitter `treesit-explore-mode' is buggy
 and does not behave properly
Date: Fri, 20 Jan 2023 09:59:09 +0200
> I don't think the desktop-save part is correct: the test should be at
> desktop-read time, not at desktop-save time.  Because the fact we had
> the language available when we saved the desktop doesn't guarantee we
> will have it available when restoring that desktop: it could be in a
> different build of Emacs or even on a different machine.

When the buffer is not saved, then it will cause no problems when restoring.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60880; Package emacs. (Fri, 20 Jan 2023 09:12:02 GMT) Full text and rfc822 format available.

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

From: Mickey Petersen <mickey <at> masteringemacs.org>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 60880 <at> debbugs.gnu.org, Yuan Fu <casouri <at> gmail.com>
Subject: Re: bug#60880: 30.0.50; tree-sitter `treesit-explore-mode' is buggy
 and does not behave properly
Date: Fri, 20 Jan 2023 09:08:09 +0000
Eli Zaretskii <eliz <at> gnu.org> writes:

>> Cc: 60880 <at> debbugs.gnu.org
>> From: Yuan Fu <casouri <at> gmail.com>
>> Date: Thu, 19 Jan 2023 14:30:46 -0800
>>
>>
>> Mickey Petersen <mickey <at> masteringemacs.org> writes:
>>
>> > A medley of issues here:
>> >
>> > 1. Executing `treesit-explore-mode' on a buffer with no valid grammar
>> > support causes the minor mode (and playground buffer) to stick around and "load" anyway.
>> >
>> > 2. Bailing out of the grammar prompt does not, in actual fact, stop
>> > explore mode from proceeding. Instead it creates an empty buffer and
>> > it still engages the minor mode.
>> >
>> > 3. Killing the playground buffer does not remove the explore mode buffer.
>> >
>> > 4. treesit-explore-mode is stored against a buffer during
>> > `desktop-save' (and subsequently read with) `desktop-read'. Thus
>> > broken buffers or files inherit the explore mode. This is especially
>> > pernicious due to #1, #2, and #3.
>>
>> Ok, I fixed those problems. Now if the language is not available,
>> treesit-explore-mode raises an error instead of continuing, desktop-save
>> will not save the explorer buffer, and killing the source buffer also
>> kills the explorer buffer.
>
> I don't think the desktop-save part is correct: the test should be at
> desktop-read time, not at desktop-save time.  Because the fact we had
> the language available when we saved the desktop doesn't guarantee we
> will have it available when restoring that desktop: it could be in a
> different build of Emacs or even on a different machine.
>

> I'm not sure I understand the problem which desktop-read has when
> restoring desktop with buffers in treesit-explore-mode, but if the
> problems are more than just warning messages, then desktop-read should
> detect these problems, emit an echo-area message, and refrain from
> restoring the mode.  Like it does with buffers that visited files
> which are no longer there, for example.

Another problem is that it stops the loading process, pending manual
selection of the grammar you want explore mode to use. It would be
nice if we saved the previous choice -- when you made the choice to
begin with -- so that, upon read, it does not have to ask.

That way the desktop read experience is not interrupted by prompts
during Emacs startup.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#60880; Package emacs. (Fri, 20 Jan 2023 13:15:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Juri Linkov <juri <at> linkov.net>
Cc: 60880 <at> debbugs.gnu.org, casouri <at> gmail.com, mickey <at> masteringemacs.org
Subject: Re: bug#60880: 30.0.50; tree-sitter `treesit-explore-mode' is buggy
 and does not behave properly
Date: Fri, 20 Jan 2023 15:13:56 +0200
> From: Juri Linkov <juri <at> linkov.net>
> Cc: Yuan Fu <casouri <at> gmail.com>,  60880 <at> debbugs.gnu.org,
>   mickey <at> masteringemacs.org
> Date: Fri, 20 Jan 2023 09:59:09 +0200
> 
> > I don't think the desktop-save part is correct: the test should be at
> > desktop-read time, not at desktop-save time.  Because the fact we had
> > the language available when we saved the desktop doesn't guarantee we
> > will have it available when restoring that desktop: it could be in a
> > different build of Emacs or even on a different machine.
> 
> When the buffer is not saved, then it will cause no problems when restoring.

But users can expect the buffer to be saved and restored, when that
presents no problems.  We cannot unilaterally decide they cannot
expect such buffers with their modes being restored.




This bug report was last modified 2 years and 149 days ago.

Previous Next


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