Closed jsmestad closed 2 years ago
So I notice that by default auto-mode-alist
has an entry ("\\.[sx]?html?\\(\\.[a-zA-Z_]+\\)?\\'" . mhtml-mode)
which is intended to open all *.html.*
files in mhtml-mode
. How are you configuring .html.eex
files to open in web-mode
? Is it another entry in auto-mode-alist
? Inspecting the full contents of auto-mode-alist
and their ordering (precedence is from top to bottom) could help determine what is going on.
I can't think off the top of my head why the reformatting operation could possibly cause the major mode to be switched. That seems like a probable bug.
I'll dig into that and see what I can come up with. Would it be a bug with web-mode
or this library?
It is hard to say without understanding what is going on---it could be either.
Sorry this took so long. I am using doom-emacs
if that helps track things down. Here is my current config and the value for auto-mode-alist
Looking through the ordering, the .l?eex
check is before the mhtml-mode
check so I would guess that is not it 🤷
Okay... so I installed Prettier and prettier-plugin-eex locally, added your auto-mode-alist
entry for .l?eex
files, created a file hello.html.eex
and pasted some sample code into it. When I open the file originally, it's web-mode, and remains as such after being reformatted. So maybe some other Emacs configuration interfering?
You could try this:
(advice-add #'mhtml-mode :override #'error) ; (advice-remove #'mhtml-mode #'error)
(setq debug-on-error t)
and then you might be able to get a stack trace when mhtml-mode
is activated. I'm not totally sure if this would work, but it could be a starting point.
Does https://github.com/raxod502/apheleia/commit/f865c165dac606187a66b2b25a57d5099b452120 fix this issue for you?
Although related, I'm not sure if my issue is exactly the same, so when it isn't I'll gladly re-open it as a new one.
My apheleia was freshly built from source yesterday (commit is f865c16
), and like OP I'm also using doom emacs.
Sometimes I have to switch major modes when editing a buffer (in my case I sometimes need to switch a .tsx file which gets automatically opened as typescript-tsx to typescript for some specific editings). While apheleia smoothly prettifies while staying on point, it also always switches back to the mode defined in the autoload alist after saving. Is this intentional behaviour, or is there some way to respect what major mode was active before saving?
If that happens, it's a bug. No extra code should be getting run when Apheleia formats.
Anything I can do to help debugging?
Hey @hermann-p, sorry for the delay! Just got back from vacation and catching up on email. Unfortunately there's not a lot of specific advice I can give on getting to the root of this problem. What I'd do is do into Apheleia and start inserting debugging statements, e.g. (message "stuff")
at various places in the code, which can help to establish what functions are being run and when. You also might have luck with M-x toggle-debug-on-error
and then inserting an (error "oh noes")
somewhere, which could trigger a stack trace that would tell you "how did we get to running this function?".
Going to give this another try shortly. I have not forgotten 👍
This thread is being closed automatically by Tidier because it is labeled with "waiting on response" and has not seen any activity for 90 days. But don't worry—if you have any information that might advance the discussion, leave a comment and I will be happy to reopen the thread :)
I am running adamzapasnik/prettier-plugin-eex on an
index.html.eex
file which is opened with a major mode ofweb-mode
. When I edit a file and hit save, the formatter runs great but I am switched intomhtml-mode
(HTML+) after the formatter is run.Is there some configuration I am missing? Happy to help debug if you can guide me on where/how to look.
Thanks for this great project btw 🍻 This is a great step forward in formatters for the emacs ecosystem