Subject: Re: bug#63463: 29.0.90; Using python-ts-mode for single buffer should not alter global auto-mode-alist settings

From: Eli Zaretskii <[email-masked]>
Date: Fri, 12 May 2023 16:26:08 +0300

tags 63463 notabug wontfix
thanks

> From: Yikai Zhao <[email-masked]>
> 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.