Writing an Emacs Major Mode

Wilfred Hughes has a nice post on writing a major mode for a new language. As Hughes demonstrates, it’s pretty easy to get started but there’s lots of details and nooks and crannies to worry about.

His post shows how to get started and points out enhancements that you’ll want to make as you grow the mode. A minimal implementation should have syntax highlighting and indentation. Fortunately, it’s pretty easy to get those working, especially if you use the SMIE engine to help with indentation1.

As you build out the mode, you’ll want to add things like completion, Eldoc, and Flycheck. Hughes’ post doesn’t tell you how to program these features but it does point you in the right direction. If you’re interested in writing a major mode for a language, this post is well worth reading.

Footnotes:

1

But be sure to follow the link in Hughes’ post to Steve Yegge’s musings on how hard indentation really is.

This entry was posted in General and tagged . Bookmark the permalink.