Difference between revision 7 and current revision
Summary: Rollback to 2008-09-05 00:16 UTC
No diff available.Mode hooks make it so you can always set up a mode in a particular way.
For example, if you want to have AutoFillMode on by default in text mode, add this to your DotEmacs file:
(add-hook 'text-mode-hook 'turn-on-auto-fill)
That ones easy, because there’s a premade function for us, “turn-on-auto-fill.”
But only a very few are like that. For the rest, you’ll probably want to use LambdaFunctions?.
(add-hook 'text-mode-hook (lambda () (set-fill-column 72))) (add-hook 'text-mode-hook (lambda () (column-number-mode 1)))
How do you know what to put in place of ‘text-mode-hook’?
I’m not sure what will always work, but the following has worked for me:
See SaveLog for a simple example of using hooks.
See ManagingHookVariables for more sophisticated ways of adding hooks.
See ChangeHook to use ‘after-change-functions’ and ‘before-change-functions’ for evil hackery (electrifying user input).