How to enable automatic spell check by default?
emacs
Solution
I have the following in my init.el:
(add-hook 'text-mode-hook 'flyspell-mode)
(add-hook 'prog-mode-hook 'flyspell-prog-mode)
That covers my editing needs just fine.
Hooks are like 'events' or the observer pattern if you're used to OOP: they're lists of functions that get run at certain points. One of the main ways you customise Emacs is by adding your own functions to these hooks.
Most modes in Emacs call a hook when they're enabled. `prog-mode` is the mode from which programming modes are derived, so adding functions to `prog-mode-hook` customises all programming modes.
The best reference for this stuff is the built-in Emacs Lisp manual (`C-h r` or `M-x info-emacs-manual`). It has sections on Emacs Lisp programming, including a chapter on hooks.
Problem
I can't find what can be added to init file to enable automatic spell check by default. Automatic spell checking (Flyspell) can be enabled from menu -- may be there is a way to learn how menu entry work?