When editing Markdown files (.md, .mdwn, etc.) and Mediawiki files (.mw), I almost always need to have flyspell-mode loaded. How to have that automatically happen via configuration?
Put this in your .emacs:
(add-hook 'markdown-mode-hook 'flyspell-mode)
It will enable flyspell-mode whenever markdown-mode is entered; i.e. when you open markdown files.
There are two answers recommending adding
flyspell-mode as a
markdown-mode-hook function. Perhaps the problem is that
flyspell-mode is a toggle. There is also
turn-on-flyspell, defined like so:
(defun turn-on-flyspell () "Unconditionally turn on Flyspell mode." (flyspell-mode 1))
This is a built-in function which accomplishes the same thing as in marcanuy's answer.
So, this should do what you want, unconditionally:
(add-hook 'markdown-mode-hook 'turn-on-flyspell) (add-hook 'mediawiki-mode-hook 'turn-on-flyspell)
Base on Trebuchette's answer:
(add-hook 'markdown-mode-hook 'flyspell-mode) (add-hook 'mediawiki-mode-hook 'flyspell-mode)
But if you want to turn on
flyspell-mode while editing text files in various major-modes, you can just use:
(add-hook 'text-mode-hook 'flyspell-mode)
this will works because
mediawiki-mode are base on
text-mode. Analogously, we use
prog-mode-hook to setup common programming environment.
I was looking for the same and finally found a solution that works:
(dolist (hook '(markdown-mode-hook)) (add-hook hook (lambda () (flyspell-mode 1))))
Tested in GNU Emacs 25.1
Not tested this but should also work for other modes like mediawiki:
(dolist (hook '(markdown-mode-hook mediawiki-mode-hook)) (add-hook hook (lambda () (flyspell-mode 1))))