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:

On AI writing in 2026

I use AI to write a little bit: I ask it for high level feedback on blog post drafts, make mechanical edits, and sometimes use it to brainstorm options for wording at a paragraph level. It’s unusual that I accept its wording or changes without modificatio…

via Home April 16, 2026

Some considerations on whether my job is evil

I. On an average weekend, only 1 in 20 Americans go to a party.

via Thing of Things April 14, 2026

Microfictions

A few microfictions, very much inspired by Quiet Pine Trees. I hope to add more over time. No LLMs.

via Evan Fields March 27, 2026

more     (via openring)