2012-01-07 Chong Yidong <cyd@gnu.org>
+ * custom.texi (Hooks): Discuss how to disable minor modes.
+
+ * files.texi (Diff Mode): Discuss diff-auto-refine-mode
+ (Bug#10309).
+
* trouble.texi (Lossage): Refer to Bugs node for problems.
(DEL Does Not Delete): Don't use "usual erasure key" teminology.
(Screen Garbled): Don't refer to terminal "manufacturers".
Most major modes run one or more @dfn{mode hooks} as the last step
of initialization. Mode hooks are a convenient way to customize the
behavior of individual modes; they are always normal. For example,
-here's how to set up a hook to turn on Auto Fill mode when entering
-Text mode and other modes based on Text mode:
+here's how to set up a hook to turn on Auto Fill mode in Text mode and
+other modes based on Text mode:
@example
(add-hook 'text-mode-hook 'auto-fill-mode)
@end example
- Here is another example, showing how to use a hook to customize the
-indentation of C code. The hook function uses an anonymous lambda
-expression (@pxref{Lambda Expressions,,, elisp, The Emacs Lisp
-Reference Manual}).
+@noindent
+This works by calling @code{auto-fill-mode}, which enables the minor
+mode when no argument is supplied (@pxref{Minor Modes}). Next,
+suppose you don't want Auto Fill mode turned on in La@TeX{} mode,
+which is one of the modes based on Text mode. You can do this with
+the following additional line:
+
+@example
+(add-hook 'latex-mode-hook (lambda () (auto-fill-mode -1)))
+@end example
+
+@noindent
+Here we have used the special macro @code{lambda} to construct an
+anonymous function (@pxref{Lambda Expressions,,, elisp, The Emacs Lisp
+Reference Manual}), which calls @code{auto-fill-mode} with an argument
+of @code{-1} to disable the minor mode. Because La@TeX{} mode runs
+@code{latex-mode-hook} after running @code{text-mode-hook}, the result
+leaves Auto Fill mode disabled.
+
+ Here is a more complex example, showing how to use a hook to
+customize the indentation of C code:
@example
@group
@findex diff-hunk-next
Move to the next hunk-start (@code{diff-hunk-next}).
+@findex diff-auto-refine-mode
+@cindex mode, Diff Auto-Refine
+@cindex Diff Auto-Refine mode
+This command has a side effect: it @dfn{refines} the hunk you move to,
+highlighting its changes with better granularity. To disable this
+feature, type @kbd{M-x diff-auto-refine-mode} to toggle off the minor
+mode Diff Auto-Refine mode. To disable Diff Auto Refine mode by
+default, add this to your init file (@pxref{Hooks}):
+
+@example
+(add-hook 'diff-mode-hook
+ (lambda () (diff-auto-refine-hook -1)))
+@end example
+
@item M-p
@findex diff-hunk-prev
-Move to the previous hunk-start (@code{diff-hunk-prev}).
+Move to the previous hunk-start (@code{diff-hunk-prev}). Like
+@kbd{M-n}, this has the side-effect of refining the hunk you move to,
+unless you disable Diff Auto-Refine mode.
@item M-@}
@findex diff-file-next
patch syntax (@pxref{Useless Whitespace}).
@end table
-
@node Misc File Ops
@section Miscellaneous File Operations