diff options
| author | Chong Yidong | 2008-10-21 23:10:45 +0000 |
|---|---|---|
| committer | Chong Yidong | 2008-10-21 23:10:45 +0000 |
| commit | 2fab1e336ce51ee8b35231358dcf8d39e17fc97f (patch) | |
| tree | f132c057acd5fe9332cea72374f8d859bbc42282 | |
| parent | 1a6e29543090bd65b26c696522c61524e22275bb (diff) | |
| download | emacs-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.texi | 93 |
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 |
| 2584 | differences in an Emacs buffer named @samp{*diff*}. It works by | 2584 | minibuffer, and displays the differences between the two files in a |
| 2585 | running the @code{diff} program, using options taken from the variable | 2585 | buffer named @samp{*diff*}. This works by running the @command{diff} |
| 2586 | @code{diff-switches}. The value of @code{diff-switches} should be a | 2586 | program, using options taken from the variable @code{diff-switches}. |
| 2587 | string; the default is @code{"-c"} to specify a context diff. | 2587 | The 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, |
| 2589 | information about @command{diff} output formats. | 2589 | Comparing 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 | ||
| 2593 | called 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 |
| 2593 | recent backup. If you specify the name of a backup file, | 2597 | most 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 |
| 2595 | of. | 2599 | backup 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 |
| 2649 | useful for editing patches and comparisons produced by the | 2653 | other similar commands, as well as the output of the @command{diff} |
| 2650 | @command{diff} program. To select Diff mode manually, type @kbd{M-x | 2654 | program. This kind of output is called a @dfn{patch}, because it can |
| 2655 | be passed to the @command{patch} command to automatically apply the | ||
| 2656 | specified changes. To select Diff mode manually, type @kbd{M-x | ||
| 2651 | diff-mode}. | 2657 | diff-mode}. |
| 2652 | 2658 | ||
| 2653 | One general feature of Diff mode is that manual edits to the patch | 2659 | @cindex hunk, diff |
| 2654 | automatically correct line numbers, including those in the hunk | 2660 | The changes specified in a patch are grouped into @dfn{hunks}, which |
| 2655 | header, so that you can actually apply the edited patch. Diff mode | 2661 | are contiguous chunks of text that contain one or more changed lines. |
| 2656 | treats each hunk location as an ``error message,'' so that you can use | 2662 | Hunks can also include unchanged lines to provide context for the |
| 2657 | commands such as @kbd{C-x '} to visit the corresponding source | 2663 | changes. Each hunk is preceded by a @dfn{hunk header}, which |
| 2658 | locations. It also provides the following commands to navigate, | 2664 | specifies the old and new line numbers at which the hunk occurs. Diff |
| 2665 | mode highlights each hunk header, to distinguish it from the actual | ||
| 2666 | contents 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 | ||
| 2670 | read-only, you need to make it writable first. @xref{Misc Buffer}.) | ||
| 2671 | Whenever you change a hunk, Diff mode attempts to automatically | ||
| 2672 | correct the line numbers in the hunk headers, to ensure that the diff | ||
| 2673 | remains ``correct''. To disable automatic line number correction, | ||
| 2674 | change the variable @code{diff-update-on-the-fly} to @code{nil}. | ||
| 2675 | |||
| 2676 | Diff mode treats each hunk as an ``error message,'' similar to | ||
| 2677 | Compilation mode. Thus, you can use commands such as @kbd{C-x '} to | ||
| 2678 | visit the corresponding source locations. @xref{Compilation Mode}. | ||
| 2679 | |||
| 2680 | In addition, Diff mode provides the following commands to navigate, | ||
| 2659 | manipulate and apply parts of patches: | 2681 | manipulate 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. | |||
| 2691 | Apply this hunk to its target file (@code{diff-apply-hunk}). With a | 2713 | Apply this hunk to its target file (@code{diff-apply-hunk}). With a |
| 2692 | prefix argument of @kbd{C-u}, revert this hunk. | 2714 | prefix argument of @kbd{C-u}, revert this hunk. |
| 2693 | 2715 | ||
| 2716 | @item C-c C-b | ||
| 2717 | @findex diff-refine-hunk | ||
| 2718 | Highlight the changes of the hunk at point with a finer granularity | ||
| 2719 | (@code{diff-refine-hunk}). This allows you to see exactly which parts | ||
| 2720 | of 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 |
| 2696 | Go to the source file and line corresponding to this hunk | 2724 | Go 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 |
| 2937 | the programs @code{arc}, @code{jar}, @code{lzh}, @code{zip}, and | 2967 | the 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 |
| 2939 | Archive mode also works for those @code{exe} files that are | 2969 | program names. Archive mode also works for those @code{exe} files |
| 2940 | self-extracting executables. | 2970 | that 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, |
| 2943 | with the addition of the @kbd{m} key which marks a file for subsequent | 2973 | with 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 |
| 2976 | To carry out this request, Emacs uses either the FTP program or a | 3006 | To carry out this request, Emacs uses a remote-login program such as |
| 2977 | remote-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 | 3008 | You can always specify in the file name which method to use---for |
| 2979 | method to use---for example, | 3009 | example, @file{/ftp:@var{user}@@@var{host}:@var{filename}} uses FTP, |
| 2980 | @file{/ftp:@var{user}@@@var{host}:@var{filename}} uses FTP, whereas | 3010 | whereas @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, |
| 2982 | When you don't specify a method in the file name, Emacs chooses | 3012 | Emacs chooses the method as follows: |
| 2983 | the method as follows: | ||
| 2984 | 3013 | ||
| 2985 | @enumerate | 3014 | @enumerate |
| 2986 | @item | 3015 | @item |