8

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.

2
  • 1
    I would take a look at 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 6, 2016 at 0: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 6, 2016 at 7:16

1 Answer 1

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, and rmail.el. You can study these libraries to see how modes are written.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.