What are some resources for learning to write a major mode for a programming language such as Haskell? I know such things exist but I would like to learn how to do it, it seems like a fun and interesting project.
Asked
Active
Viewed 2,925 times
8
-
1I would take a look at https://github.com/haskell/haskell-mode and try it out. Then I would modify it to suit my needs and learn a whole bunch of stuff in the process. You could reinvent the wheel, or instead work on something entirely new that does not yet exist. – lawlist Apr 06 '16 at 00:37
-
One should definitive start with `(define-derived-mode ...)`. With `(define-derived-mode my-mode prog-mode ...)` if there is nothing better. Just a comment. I know that this does not answer the question. – Tobias Apr 06 '16 at 07:16
1 Answers
9
There is a section of the Elisp manual specifically about this. I'd recommend that you start by reading that.
After that, I'd recommend that you look at the code for some simple major modes that come with Emacs. Emulating such code is a good way to start out, and to learn.
I'd also recommend that you read the parent section of that section, and other sibling sections (other subsections of the parent).
For example, you will see this in that parent node (Major Modes):
The standard GNU Emacs Lisp directory tree contains the code for several major modes, in files such as
text-mode.el
,texinfo.el
,lisp-mode.el
, andrmail.el
. You can study these libraries to see how modes are written.

Drew
- 75,699
- 9
- 109
- 225