aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2008-10-21 23:10:45 +0000
committerChong Yidong2008-10-21 23:10:45 +0000
commit2fab1e336ce51ee8b35231358dcf8d39e17fc97f (patch)
treef132c057acd5fe9332cea72374f8d859bbc42282
parent1a6e29543090bd65b26c696522c61524e22275bb (diff)
downloademacs-2fab1e336ce51ee8b35231358dcf8d39e17fc97f.tar.gz
emacs-2fab1e336ce51ee8b35231358dcf8d39e17fc97f.zip
(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.
-rw-r--r--doc/emacs/files.texi93
1 files changed, 61 insertions, 32 deletions
diff --git a/doc/emacs/files.texi b/doc/emacs/files.texi
index 45d3d4a6e28..3ca80546a55 100644
--- a/doc/emacs/files.texi
+++ b/doc/emacs/files.texi
@@ -2580,19 +2580,23 @@ this, it runs the program specified by
2580 2580
2581@findex diff 2581@findex diff
2582@vindex diff-switches 2582@vindex diff-switches
2583 The command @kbd{M-x diff} compares two files, displaying the 2583 The command @kbd{M-x diff} prompts for two file names, using the
2584differences in an Emacs buffer named @samp{*diff*}. It works by 2584minibuffer, and displays the differences between the two files in a
2585running the @code{diff} program, using options taken from the variable 2585buffer named @samp{*diff*}. This works by running the @command{diff}
2586@code{diff-switches}. The value of @code{diff-switches} should be a 2586program, using options taken from the variable @code{diff-switches}.
2587string; the default is @code{"-c"} to specify a context diff. 2587The value of @code{diff-switches} should be a string; the default is
2588@xref{Top,, Diff, diff, Comparing and Merging Files}, for more 2588@code{"-c"} to specify a context diff. @xref{Top,, Diff, diff,
2589information about @command{diff} output formats. 2589Comparing and Merging Files}, for more information about
2590@command{diff} output formats.
2591
2592 The output of the @code{diff} command is shown using a major mode
2593called Diff mode. @xref{Diff Mode}.
2590 2594
2591@findex diff-backup 2595@findex diff-backup
2592 The command @kbd{M-x diff-backup} compares a specified file with its most 2596 The command @kbd{M-x diff-backup} compares a specified file with its
2593recent backup. If you specify the name of a backup file, 2597most recent backup. If you specify the name of a backup file,
2594@code{diff-backup} compares it with the source file that it is a backup 2598@code{diff-backup} compares it with the source file that it is a
2595of. 2599backup of. In all other respects, this behaves like @kbd{M-x diff}.
2596 2600
2597@findex compare-windows 2601@findex compare-windows
2598 The command @kbd{M-x compare-windows} compares the text in the 2602 The command @kbd{M-x compare-windows} compares the text in the
@@ -2645,17 +2649,35 @@ merging files.
2645@findex diff-mode 2649@findex diff-mode
2646@cindex patches, editing 2650@cindex patches, editing
2647 2651
2648 Diff mode is used for the output of @kbd{M-x diff}; it is also 2652 Diff mode is a major mode used for the output of @kbd{M-x diff} and
2649useful for editing patches and comparisons produced by the 2653other similar commands, as well as the output of the @command{diff}
2650@command{diff} program. To select Diff mode manually, type @kbd{M-x 2654program. This kind of output is called a @dfn{patch}, because it can
2655be passed to the @command{patch} command to automatically apply the
2656specified changes. To select Diff mode manually, type @kbd{M-x
2651diff-mode}. 2657diff-mode}.
2652 2658
2653 One general feature of Diff mode is that manual edits to the patch 2659@cindex hunk, diff
2654automatically correct line numbers, including those in the hunk 2660 The changes specified in a patch are grouped into @dfn{hunks}, which
2655header, so that you can actually apply the edited patch. Diff mode 2661are contiguous chunks of text that contain one or more changed lines.
2656treats each hunk location as an ``error message,'' so that you can use 2662Hunks can also include unchanged lines to provide context for the
2657commands such as @kbd{C-x '} to visit the corresponding source 2663changes. Each hunk is preceded by a @dfn{hunk header}, which
2658locations. It also provides the following commands to navigate, 2664specifies the old and new line numbers at which the hunk occurs. Diff
2665mode highlights each hunk header, to distinguish it from the actual
2666contents of the hunk.
2667
2668@vindex diff-update-on-the-fly
2669 You can edit a Diff mode buffer like any other buffer. (If it is
2670read-only, you need to make it writable first. @xref{Misc Buffer}.)
2671Whenever you change a hunk, Diff mode attempts to automatically
2672correct the line numbers in the hunk headers, to ensure that the diff
2673remains ``correct''. To disable automatic line number correction,
2674change the variable @code{diff-update-on-the-fly} to @code{nil}.
2675
2676 Diff mode treats each hunk as an ``error message,'' similar to
2677Compilation mode. Thus, you can use commands such as @kbd{C-x '} to
2678visit the corresponding source locations. @xref{Compilation Mode}.
2679
2680 In addition, Diff mode provides the following commands to navigate,
2659manipulate and apply parts of patches: 2681manipulate and apply parts of patches:
2660 2682
2661@table @kbd 2683@table @kbd
@@ -2691,6 +2713,12 @@ In a multi-file patch, kill the current file part.
2691Apply this hunk to its target file (@code{diff-apply-hunk}). With a 2713Apply this hunk to its target file (@code{diff-apply-hunk}). With a
2692prefix argument of @kbd{C-u}, revert this hunk. 2714prefix argument of @kbd{C-u}, revert this hunk.
2693 2715
2716@item C-c C-b
2717@findex diff-refine-hunk
2718Highlight the changes of the hunk at point with a finer granularity
2719(@code{diff-refine-hunk}). This allows you to see exactly which parts
2720of each changed line were actually changed.
2721
2694@item C-c C-c 2722@item C-c C-c
2695@findex diff-goto-source 2723@findex diff-goto-source
2696Go to the source file and line corresponding to this hunk 2724Go to the source file and line corresponding to this hunk
@@ -2923,21 +2951,23 @@ requires the appropriate uncompression program.
2923@cindex mode, archive 2951@cindex mode, archive
2924@cindex @code{arc} 2952@cindex @code{arc}
2925@cindex @code{jar} 2953@cindex @code{jar}
2954@cindex @code{rar}
2926@cindex @code{zip} 2955@cindex @code{zip}
2927@cindex @code{lzh} 2956@cindex @code{lzh}
2928@cindex @code{zoo} 2957@cindex @code{zoo}
2929@pindex arc 2958@pindex arc
2930@pindex jar 2959@pindex jar
2931@pindex zip 2960@pindex zip
2961@pindex rar
2932@pindex lzh 2962@pindex lzh
2933@pindex zoo 2963@pindex zoo
2934@cindex Java class archives 2964@cindex Java class archives
2935@cindex unzip archives 2965@cindex unzip archives
2936 A separate but similar Archive mode is used for archives produced by 2966 A separate but similar Archive mode is used for archives produced by
2937the programs @code{arc}, @code{jar}, @code{lzh}, @code{zip}, and 2967the programs @code{arc}, @code{jar}, @code{lzh}, @code{zip},
2938@code{zoo}, which have extensions corresponding to the program names. 2968@code{rar}, and @code{zoo}, which have extensions corresponding to the
2939Archive mode also works for those @code{exe} files that are 2969program names. Archive mode also works for those @code{exe} files
2940self-extracting executables. 2970that are self-extracting executables.
2941 2971
2942 The key bindings of Archive mode are similar to those in Tar mode, 2972 The key bindings of Archive mode are similar to those in Tar mode,
2943with the addition of the @kbd{m} key which marks a file for subsequent 2973with the addition of the @kbd{m} key which marks a file for subsequent
@@ -2973,14 +3003,13 @@ syntax:
2973@end example 3003@end example
2974 3004
2975@noindent 3005@noindent
2976To carry out this request, Emacs uses either the FTP program or a 3006To carry out this request, Emacs uses a remote-login program such as
2977remote-login program such as @command{ssh}, @command{rlogin}, or 3007@command{ftp}, @command{ssh}, @command{rlogin}, or @command{telnet}.
2978@command{telnet}. You can always specify in the file name which 3008You can always specify in the file name which method to use---for
2979method to use---for example, 3009example, @file{/ftp:@var{user}@@@var{host}:@var{filename}} uses FTP,
2980@file{/ftp:@var{user}@@@var{host}:@var{filename}} uses FTP, whereas 3010whereas @file{/ssh:@var{user}@@@var{host}:@var{filename}} uses
2981@file{/ssh:@var{user}@@@var{host}:@var{filename}} uses @command{ssh}. 3011@command{ssh}. When you don't specify a method in the file name,
2982When you don't specify a method in the file name, Emacs chooses 3012Emacs chooses the method as follows:
2983the method as follows:
2984 3013
2985@enumerate 3014@enumerate
2986@item 3015@item