GNU bug report logs - #63463
29.0.90; Using python-ts-mode for single buffer should not alter global auto-mode-alist settings

Previous Next

Package: emacs;

Reported by: Yikai Zhao <yikai <at> z1k.dev>

Date: Fri, 12 May 2023 12:46:01 UTC

Severity: normal

Tags: notabug, wontfix

Found in version 29.0.90

Done: Stefan Kangas <stefankangas <at> gmail.com>

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 63463 in the body.
You can then email your comments to 63463 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 bug-gnu-emacs <at> gnu.org:
bug#63463; Package emacs. (Fri, 12 May 2023 12:46:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Yikai Zhao <yikai <at> z1k.dev>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 12 May 2023 12:46:01 GMT) Full text and rfc822 format available.

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

From: Yikai Zhao <yikai <at> z1k.dev>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.90; Using python-ts-mode for single buffer should not alter
 global auto-mode-alist settings
Date: Fri, 12 May 2023 20:45:18 +0800
Hi emacs devs,

So today, out of nowhere, I noticed that some of the *.py
buffers I opened are using `python-ts-mode` instead of the default
`python-mode`, also some of my configs are not working correctly because
of this (due to different hooks etc.). I was sure I didn't enable or configure
anything related to `python-ts-mode` so that's very strange.

After some debugging, it turns out that `markdown-mode` used
`python-ts-mode` when fontifying a python code block
(https://github.com/jrblevin/markdown-mode/commit/44ac8e4f96f03149f60cb182f8b3f1503f66f6d0),
and during that, `python-ts-mode` modified the global `auto-mode-alist`
settings so that all future *.py buffers I opened use that instead.

I believe this is a bug in emacs: using some treesit-based major mode
for single buffer should not automatically alter the global settings. I
don't think previously there's any other major modes doing that.

I understand that some may argue this behavior to be reasonable based
on the thought that,
"if the user chose to use treesit for one file, then it would be good to
use treesit automatically for all future files". This MAY be true, but
in my case, I didn't choose to use it by my own. It's some lisp code
down the rabbit hole that loads it without me even realized.

I fear that this kind of issue would become more common when: 1. more
distros build emacs with treesit support by default and ship with
treesit language libraries, 2. more emacs packages tries to use
treesit-based major modes internally

(I also submitted a bug report to `markdown-mode`:
https://github.com/jrblevin/markdown-mode/issues/761)

---

In GNU Emacs 29.0.90 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo
version 1.16.0, Xaw3d scroll bars)
Repository revision: emacs-29.0.90
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: Ubuntu 20.04.5 LTS

Configured using:
 'configure
 --prefix=/nix/store/4mgq52v87wxra7nqhvsspn3klp8c731m-emacs-unstable-29.0.90
 --disable-build-details --with-modules --with-x-toolkit=lucid
 --with-xft --with-cairo --with-native-compilation'




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#63463; Package emacs. (Fri, 12 May 2023 13:27:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Yikai Zhao <yikai <at> z1k.dev>
Cc: 63463 <at> debbugs.gnu.org
Subject: Re: bug#63463: 29.0.90;
 Using python-ts-mode for single buffer should not alter global
 auto-mode-alist settings
Date: Fri, 12 May 2023 16:26:08 +0300
tags 63463 notabug wontfix
thanks

> From: Yikai Zhao <yikai <at> z1k.dev>
> Date: Fri, 12 May 2023 20:45:18 +0800
> 
> So today, out of nowhere, I noticed that some of the *.py
> buffers I opened are using `python-ts-mode` instead of the default
> `python-mode`, also some of my configs are not working correctly because
> of this (due to different hooks etc.). I was sure I didn't enable or configure
> anything related to `python-ts-mode` so that's very strange.
> 
> After some debugging, it turns out that `markdown-mode` used
> `python-ts-mode` when fontifying a python code block
> (https://github.com/jrblevin/markdown-mode/commit/44ac8e4f96f03149f60cb182f8b3f1503f66f6d0),
> and during that, `python-ts-mode` modified the global `auto-mode-alist`
> settings so that all future *.py buffers I opened use that instead.
> 
> I believe this is a bug in emacs: using some treesit-based major mode
> for single buffer should not automatically alter the global settings. I
> don't think previously there's any other major modes doing that.

It is not a bug, it is the intended behavior that loading
python-ts-mode makes that mode the default for Python files.

However, the root cause of the issue you are describing seems to be
markdown-mode, which is not part of Emacs.  I don't understand well
enough why markdown-mode needs to load python-ts-mode, but in any
case, this issue should be solved in markdown-mode, I think.

> (I also submitted a bug report to `markdown-mode`:
> https://github.com/jrblevin/markdown-mode/issues/761)

Thanks; let's see what the markdown-mode's developers say about this.




Added tag(s) notabug and wontfix. Request was from Eli Zaretskii <eliz <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 12 May 2023 13:27:02 GMT) Full text and rfc822 format available.

Reply sent to Stefan Kangas <stefankangas <at> gmail.com>:
You have taken responsibility. (Sat, 02 Sep 2023 16:40:02 GMT) Full text and rfc822 format available.

Notification sent to Yikai Zhao <yikai <at> z1k.dev>:
bug acknowledged by developer. (Sat, 02 Sep 2023 16:40:02 GMT) Full text and rfc822 format available.

Message #15 received at 63463-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Yikai Zhao <yikai <at> z1k.dev>, 63463-done <at> debbugs.gnu.org
Subject: Re: bug#63463: 29.0.90; Using python-ts-mode for single buffer should
 not alter global auto-mode-alist settings
Date: Sat, 2 Sep 2023 09:39:20 -0700
Eli Zaretskii <eliz <at> gnu.org> writes:

> tags 63463 notabug wontfix
> thanks
>
>> From: Yikai Zhao <yikai <at> z1k.dev>
>> Date: Fri, 12 May 2023 20:45:18 +0800
>>
>> So today, out of nowhere, I noticed that some of the *.py
>> buffers I opened are using `python-ts-mode` instead of the default
>> `python-mode`, also some of my configs are not working correctly because
>> of this (due to different hooks etc.). I was sure I didn't enable or configure
>> anything related to `python-ts-mode` so that's very strange.
>>
>> After some debugging, it turns out that `markdown-mode` used
>> `python-ts-mode` when fontifying a python code block
>> (https://github.com/jrblevin/markdown-mode/commit/44ac8e4f96f03149f60cb182f8b3f1503f66f6d0),
>> and during that, `python-ts-mode` modified the global `auto-mode-alist`
>> settings so that all future *.py buffers I opened use that instead.
>>
>> I believe this is a bug in emacs: using some treesit-based major mode
>> for single buffer should not automatically alter the global settings. I
>> don't think previously there's any other major modes doing that.
>
> It is not a bug, it is the intended behavior that loading
> python-ts-mode makes that mode the default for Python files.
>
> However, the root cause of the issue you are describing seems to be
> markdown-mode, which is not part of Emacs.  I don't understand well
> enough why markdown-mode needs to load python-ts-mode, but in any
> case, this issue should be solved in markdown-mode, I think.
>
>> (I also submitted a bug report to `markdown-mode`:
>> https://github.com/jrblevin/markdown-mode/issues/761)
>
> Thanks; let's see what the markdown-mode's developers say about this.

I'm therefore closing this bug report.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 01 Oct 2023 11:24:23 GMT) Full text and rfc822 format available.

This bug report was last modified 208 days ago.

Previous Next


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