MixedHTML Mode for Emacs |
April 19th, 2026 |
| emacs, tech |
Does not freeze, flash, or stutter, even on huge files on slow machines.
Does not get confused about whether a portion of a file is HTML vs CSS vs JS.
The initial insight was that how browsers decide what text is HTML vs
CSS vs JS is super simple: scanning for literal
<script> and <style> tags. I
pulled some tricky examples, described what I wanted, and then
iterated for about an hour until I had something that worked well.
Then I tried to use it to write something for real, ran into a few
other irritations, had Claude fix those, and now I have something I'm
enjoying a lot.
It's mildly faster than web-mode (and much simpler, and easier to install), and far faster than html-ts-mode. And unlike mhtml-mode it doesn't get confused by quotes.
The biggest drawback is that it doesn't do indentation; I may add that, but right now I'm happy with it the way it is.
I've skimmed the code, but haven't read it in detail, and definitely wouldn't say I understand it. The validation has been a mixture of asking Claude to review it and fix the bugs and warts it finds, making sure Claude has written tests, and using it enough to feel good about it. I do expect it has some bugs left: if you decide to use it and find a situation it handles poorly please let me know.
It's funny: I picked emacs two decades ago because I liked the idea of an editor that was so extensible that it was mostly written in its own extension language, and then never took advantage of this because it was too much work. But now it's not much work! Perhaps emacs will finally catch up to (and overtake) vim?
Comment via: facebook, lesswrong, mastodon, bluesky
