Skip to content

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

@blahgeek

Description

@blahgeek

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions