Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
blahgeek opened this issue May 12, 2023 · 3 comments
Closed

Comments

@blahgeek
Copy link

blahgeek commented May 12, 2023

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

@blahgeek
Copy link
Author

blahgeek commented May 12, 2023

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
Copy link
Collaborator

syohex commented May 13, 2023

How about f40808f ?
Load the language mode only if user sets it in auto-mode-alist.

@blahgeek
Copy link
Author

Look good, thank you for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants