Next: Misc File Ops, Previous: Comparing Files, Up: Files
Diff mode is used for the output of M-x diff; it is also useful for editing patches and comparisons produced by the diff program. To select Diff mode manually, type M-x diff-mode.
One general feature of Diff mode is that manual edits to the patch automatically correct line numbers, including those in the hunk header, so that you can actually apply the edited patch. Diff mode treats each hunk location as an “error message,” so that you can use commands such as C-x ' to visit the corresponding source locations. It also provides the following commands to navigate, manipulate and apply parts of patches:
diff-hunk-next).
diff-hunk-prev).
diff-file-next).
diff-file-prev).
diff-hunk-kill).
diff-file-kill).
diff-apply-hunk). With a
prefix argument of C-u, revert this hunk.
diff-goto-source).
diff-ediff-patch).
See Ediff.
diff-restrict-view).
See Narrowing. With a prefix argument of C-u, restrict the
view to the current patch of a multiple file patch. To widen again,
use C-x n w.
diff-reverse-direction).
diff-split-hunk). This is for
manually editing patches, and only works with the unified diff format.
diff-context->unified). With a prefix argument, convert
unified format to context format. In Transient Mark mode, when the
mark is active, this command operates only on the region.
diff-refine-hunk).
C-x 4 a in Diff mode operates on behalf of the target file, but gets the function name from the patch itself. See Change Log. This is useful for making log entries for functions that are deleted by the patch.