Closed jackson15j closed 1 year ago
What a wild bug! Before I get a chance to dig in, I see a few things we can try to narrow down the bug space.
First, when the bug is present, what's the value of major-mode-remap-alist? What we want to know is if it has (python-mode . python-ts-mode)
or p(python-ts-mode . python-mode)
.
Then, with the treesit-auto config commented out, use (require 'treesit-auto)
but don't enable global-treesit-auto-mode
, and:
After opening the markdown file, manually evaluate M-: (treesit-auto--maybe-install-grammar)
. This is the main "black magic" function and is usually where things break. If this is what causes the flip to python mode then that helps to know
(add-to-list 'major-mode-remap-alist '(python-mode . python-ts-mode))
, followed by opening the markdown file (or add the opposite cons cell, based on the answer to the previous section. It seems less likely that this is the culprit, but is the only other thing that this package modifies, so worth trying. If this is the problem, the bug is upstream in Emacs
If none of these reproduce the bug, I'll need to look more carefully, or get a minimum preproduction based on emacs -q
Sorry for the delay (and the fat fingers send - will edit the comment with details), had to keep my config stable for a few days. Right, testing against: treesit-auto-20230209.2222
:
major-mode-remap-alist
contents:
((python-mode . python-ts-mode)
...
(python-ts-mode . python-mode)
(markdown-ts-mode . markdown-mode)
(setq python-ts-mode-hook python-mode-hook)
from .emacs
changed the major-mode-remap-alist
contents to:
(...
(python-mode . python-ts-mode)
(markdown-ts-mode . markdown-mode)
python-mode
.python-mode
are not applied to python-ts-mode
.(python-ts-mode . python-mode)
in major-mode-remap-alist
?(python-ts-mode . python-mode)
. This pulls in all of my python-mode-hook
's on the markdown file.treesit-auto
directory, commented out package, but kept: (setq python-ts-mode-hook python-mode-hook)
.
python-mode
.major-mode-remap-alist
is nil
.Then, with the treesit-auto config commented out, use (require 'treesit-auto) but don't enable global-treesit-auto-mode, and:
1.After opening the markdown file, manually evaluate M-: (treesit-auto--maybe-install-grammar). This is the main "black magic" function and is usually where things break. If this is what causes the flip to python mode then that helps to know
I get:
Debugger entered--Lisp error: (wrong-type-argument treesit-auto-recipe nil)
treesit-auto--ready-p(markdown-mode)
treesit-auto--maybe-install-grammar()
eval-expression((treesit-auto--maybe-install-grammar) nil nil 127)
funcall-interactively(eval-expression (treesit-auto--maybe-install-grammar) nil nil 127)
command-execute(eval-expression)
- (add-to-list 'major-mode-remap-alist '(python-mode . python-ts-mode)), followed by opening the markdown file (or add the opposite cons cell, based on the answer to the previous section. It seems less likely that this is the culprit, but is the only other thing that this package modifies, so worth trying. If this is the problem, the bug is upstream in Emacs
Tried both ways of setting the python modes (on top of the above failure to install the grammar), but the markdown file still opens with markdown-mode
.
M-x emacs-version
is: GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.36, cairo version 1.17.6) of 2023-01-29
, so going to build the latest and see if there have been any outside fixes.
I've upgraded emacs to current latest (GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.36, cairo version 1.17.6) of 2023-02-10
) and that appears to have fixed this issue with the same version of treesit-auto
+ my current config.
Going to close it off. Thanks for the help and sorry for pointing the finger of blame in your direction :)
I'm still trying to dig into this with my messy config (https://github.com/jackson15j/dot_emacs), but I think there may be some interaction with
treesit-auto
,lsp
,projectile
that is changing the mode of non-python files to be set topython-mode
.The
auto-mode-alist
looks sane with no mixing ofpython-mode
to non-python files.Reproduction:
.emacs
&config.org
to home directory from: https://github.com/jackson15j/dot_emacs/tree/057d0b44cf31ac6351f48674d9228fa642935831rm -rf ~/.emacs.d
.emacs
.pyright
). Note: it is opened withpython-mode
.python-mode
instead ofmarkdown-mode
.Sorry for the rough reproduction steps. Happy to dig more if you can give me some advice.
Locally, I've commented out
treesit-auto
and nuked my~/.emacs.d
folder and now back to non-python files opening in the correct mode.