Commit 2fab1e33 authored by Chong Yidong's avatar Chong Yidong
Browse files

(Comparing Files): Note that diff uses the minibuffer, and

that the output is shown using Diff mode.
(Diff Mode): Explain what "patch" and "hunk" mean.  Document
diff-update-on-the-fly and diff-refine-hunk.
(File Archives): Add rar support.
parent 1a6e2954
...@@ -2580,19 +2580,23 @@ this, it runs the program specified by ...@@ -2580,19 +2580,23 @@ this, it runs the program specified by
@findex diff @findex diff
@vindex diff-switches @vindex diff-switches
The command @kbd{M-x diff} compares two files, displaying the The command @kbd{M-x diff} prompts for two file names, using the
differences in an Emacs buffer named @samp{*diff*}. It works by minibuffer, and displays the differences between the two files in a
running the @code{diff} program, using options taken from the variable buffer named @samp{*diff*}. This works by running the @command{diff}
@code{diff-switches}. The value of @code{diff-switches} should be a program, using options taken from the variable @code{diff-switches}.
string; the default is @code{"-c"} to specify a context diff. The value of @code{diff-switches} should be a string; the default is
@xref{Top,, Diff, diff, Comparing and Merging Files}, for more @code{"-c"} to specify a context diff. @xref{Top,, Diff, diff,
information about @command{diff} output formats. Comparing and Merging Files}, for more information about
@command{diff} output formats.
The output of the @code{diff} command is shown using a major mode
called Diff mode. @xref{Diff Mode}.
@findex diff-backup @findex diff-backup
The command @kbd{M-x diff-backup} compares a specified file with its most The command @kbd{M-x diff-backup} compares a specified file with its
recent backup. If you specify the name of a backup file, most recent backup. If you specify the name of a backup file,
@code{diff-backup} compares it with the source file that it is a backup @code{diff-backup} compares it with the source file that it is a
of. backup of. In all other respects, this behaves like @kbd{M-x diff}.
@findex compare-windows @findex compare-windows
The command @kbd{M-x compare-windows} compares the text in the The command @kbd{M-x compare-windows} compares the text in the
...@@ -2645,17 +2649,35 @@ merging files. ...@@ -2645,17 +2649,35 @@ merging files.
@findex diff-mode @findex diff-mode
@cindex patches, editing @cindex patches, editing
Diff mode is used for the output of @kbd{M-x diff}; it is also Diff mode is a major mode used for the output of @kbd{M-x diff} and
useful for editing patches and comparisons produced by the other similar commands, as well as the output of the @command{diff}
@command{diff} program. To select Diff mode manually, type @kbd{M-x program. This kind of output is called a @dfn{patch}, because it can
be passed to the @command{patch} command to automatically apply the
specified changes. To select Diff mode manually, type @kbd{M-x
diff-mode}. diff-mode}.
One general feature of Diff mode is that manual edits to the patch @cindex hunk, diff
automatically correct line numbers, including those in the hunk The changes specified in a patch are grouped into @dfn{hunks}, which
header, so that you can actually apply the edited patch. Diff mode are contiguous chunks of text that contain one or more changed lines.
treats each hunk location as an ``error message,'' so that you can use Hunks can also include unchanged lines to provide context for the
commands such as @kbd{C-x '} to visit the corresponding source changes. Each hunk is preceded by a @dfn{hunk header}, which
locations. It also provides the following commands to navigate, specifies the old and new line numbers at which the hunk occurs. Diff
mode highlights each hunk header, to distinguish it from the actual
contents of the hunk.
@vindex diff-update-on-the-fly
You can edit a Diff mode buffer like any other buffer. (If it is
read-only, you need to make it writable first. @xref{Misc Buffer}.)
Whenever you change a hunk, Diff mode attempts to automatically
correct the line numbers in the hunk headers, to ensure that the diff
remains ``correct''. To disable automatic line number correction,
change the variable @code{diff-update-on-the-fly} to @code{nil}.
Diff mode treats each hunk as an ``error message,'' similar to
Compilation mode. Thus, you can use commands such as @kbd{C-x '} to
visit the corresponding source locations. @xref{Compilation Mode}.
In addition, Diff mode provides the following commands to navigate,
manipulate and apply parts of patches: manipulate and apply parts of patches:
@table @kbd @table @kbd
...@@ -2691,6 +2713,12 @@ In a multi-file patch, kill the current file part. ...@@ -2691,6 +2713,12 @@ In a multi-file patch, kill the current file part.
Apply this hunk to its target file (@code{diff-apply-hunk}). With a Apply this hunk to its target file (@code{diff-apply-hunk}). With a
prefix argument of @kbd{C-u}, revert this hunk. prefix argument of @kbd{C-u}, revert this hunk.
@item C-c C-b
@findex diff-refine-hunk
Highlight the changes of the hunk at point with a finer granularity
(@code{diff-refine-hunk}). This allows you to see exactly which parts
of each changed line were actually changed.
@item C-c C-c @item C-c C-c
@findex diff-goto-source @findex diff-goto-source
Go to the source file and line corresponding to this hunk Go to the source file and line corresponding to this hunk
...@@ -2923,21 +2951,23 @@ requires the appropriate uncompression program. ...@@ -2923,21 +2951,23 @@ requires the appropriate uncompression program.
@cindex mode, archive @cindex mode, archive
@cindex @code{arc} @cindex @code{arc}
@cindex @code{jar} @cindex @code{jar}
@cindex @code{rar}
@cindex @code{zip} @cindex @code{zip}
@cindex @code{lzh} @cindex @code{lzh}
@cindex @code{zoo} @cindex @code{zoo}
@pindex arc @pindex arc
@pindex jar @pindex jar
@pindex zip @pindex zip
@pindex rar
@pindex lzh @pindex lzh
@pindex zoo @pindex zoo
@cindex Java class archives @cindex Java class archives
@cindex unzip archives @cindex unzip archives
A separate but similar Archive mode is used for archives produced by A separate but similar Archive mode is used for archives produced by
the programs @code{arc}, @code{jar}, @code{lzh}, @code{zip}, and the programs @code{arc}, @code{jar}, @code{lzh}, @code{zip},
@code{zoo}, which have extensions corresponding to the program names. @code{rar}, and @code{zoo}, which have extensions corresponding to the
Archive mode also works for those @code{exe} files that are program names. Archive mode also works for those @code{exe} files
self-extracting executables. that are self-extracting executables.
The key bindings of Archive mode are similar to those in Tar mode, The key bindings of Archive mode are similar to those in Tar mode,
with the addition of the @kbd{m} key which marks a file for subsequent with the addition of the @kbd{m} key which marks a file for subsequent
...@@ -2973,14 +3003,13 @@ syntax: ...@@ -2973,14 +3003,13 @@ syntax:
@end example @end example
@noindent @noindent
To carry out this request, Emacs uses either the FTP program or a To carry out this request, Emacs uses a remote-login program such as
remote-login program such as @command{ssh}, @command{rlogin}, or @command{ftp}, @command{ssh}, @command{rlogin}, or @command{telnet}.
@command{telnet}. You can always specify in the file name which You can always specify in the file name which method to use---for
method to use---for example, example, @file{/ftp:@var{user}@@@var{host}:@var{filename}} uses FTP,
@file{/ftp:@var{user}@@@var{host}:@var{filename}} uses FTP, whereas whereas @file{/ssh:@var{user}@@@var{host}:@var{filename}} uses
@file{/ssh:@var{user}@@@var{host}:@var{filename}} uses @command{ssh}. @command{ssh}. When you don't specify a method in the file name,
When you don't specify a method in the file name, Emacs chooses Emacs chooses the method as follows:
the method as follows:
@enumerate @enumerate
@item @item
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment