MixedHTML Mode for Emacs

April 19th, 2026
emacs, tech
I made a new major mode for emacs: mixed-html-mode. Or, really, Claude Code made one at my direction. It does syntax highlighting in HTML files with inline CSS and JS. I had two goals, which weren't met by any mode I could find:

  1. Does not freeze, flash, or stutter, even on huge files on slow machines.

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

Recent posts on blogs I like:

Thing of Things AI use policy

dynomight recently wrote an article calling for bloggers to state publicly whether and how they use AI

via Thing of Things July 6, 2026

Agentic test processes, LLM benchmarks, and other notes on agentic coding from Galapagos Island

I've been using AI fairly heavily since last November and the whole thing is a funny experience. An agent will do something that, if a human did it, you'd immediately fire them. My reaction, of course, is to act as if this is great and spin up a t…

via Posts on July 3, 2026

Variable fonts aren't universally supported

I make a lot of webpages. I also use Lockdown Mode on iOS and MacOS for a bit of extra security. Sometimes I realize that I forgot to test on Safari and it looks like crap, or I test and don’t notice that there’s been a problem for months (as was the case…

via Home June 27, 2026

more     (via openring)