Question for the #emacs community:
I want to learn how to program my own emacs (major) modes. Is there any good ressource out there for this?
Question for the #emacs community:
I want to learn how to program my own emacs (major) modes. Is there any good ressource out there for this?
@PvN I don't know if it's in print any more, but https://www.oreilly.com/library/view/writing-gnu-emacs/9781449395056/ is great.
@PvN this page might serve as a quickstart: https://www.emacswiki.org/emacs/DerivedMode
@PvN The emacs lisp manual is a good place to start. I don't think you will need anything else.
@PvN (info "(elisp) Major Modes")
https://www.gnu.org/software/emacs/manual/html_node/elisp/Major-Modes.html
@PvN i learned just by the info manual, linked elsewhere in thread, and by looking at a few similar major modes to what i was doing. Theres not much to it as such, a mode declaration, a hook (optional), and a keymap mainly i guess.
«a mode declaration, a hook (optional), and a keymap mainly»
Mainly, yes.
Some modes need more: for example, redefining the notion of S-expressions for C-M-f, C-M-u, etc.
This may be counted outside the mode in the narrow sense, of course, since this usually involves writing some Emacs Lisp functions for said keymap.
Occasionally, character syntax classes need tweaking.
Etc.