In emacs 29, when markdown-get-lang-mode selects a python-ts-mode for python, it would also enable it globally for all *.py files.
Steps to produce:
- Use emacs 29 with treesit support and python treesit library available
- Open some markdown file with python code block
- Open another xxx.py file
Expected behavior: The xxx.py file is opened with python-mode major mode (which is the default)
Actual behavior: The xxx.py file is opened with python-ts-mode.
The reason is that, in emacs 29, running python-ts-mode even for single buffer would modify auto-mode-alist globally: https://github.com/emacs-mirror/emacs/blob/ba2c76fa2bc3aabfda7d1d09cc5148f3f9d8e08e/lisp/progmodes/python.el#L6751
This is also true for almost all other treesit based major modes.
(I think this is a bug in the emacs core. I would file a bug report there too.)