jrblevin / markdown-mode

Emacs Markdown Mode
http://jblevins.org/projects/markdown-mode/
GNU General Public License v3.0
892 stars 163 forks source link

markdown-get-lang-mode would accidentally enable treesit major modes globally #761

Closed blahgeek closed 1 year ago

blahgeek commented 1 year ago

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:

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.)

blahgeek commented 1 year ago

Update: I reported this to emacs and got a reply: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63463 so apparently that behavior is intended and markdown-mode should not call treesit-based major modes.

syohex commented 1 year ago

How about https://github.com/jrblevin/markdown-mode/commit/f40808f7d1e012a885062ac6b2fa82e5e14d1e14 ? Load the language mode only if user sets it in auto-mode-alist.

blahgeek commented 1 year ago

Look good, thank you for your work!