root/trunk/man/ediff.texi

Revision 4220, 106.9 kB (checked in by miyoshi, 8 months ago)

Sync up with Emacs22.2.

Line 
1 \input texinfo                  @c -*-texinfo-*-
2 @c documentation for Ediff
3 @c Written by Michael Kifer
4
5 @comment %**start of header (This is for running Texinfo on a region.)
6
7 @comment Using ediff.info instead of ediff in setfilename breaks DOS.
8 @comment @setfilename ediff
9 @comment @setfilename ediff.info
10 @setfilename ../info/ediff
11
12 @settitle Ediff User's Manual
13 @synindex vr cp
14 @synindex fn cp
15 @synindex pg cp
16 @synindex ky cp
17
18 @iftex
19 @finalout
20 @end iftex
21 @c      @smallbook
22 @comment %**end of header (This is for running Texinfo on a region.)
23
24 @copying
25 This file documents Ediff, a comprehensive visual interface to Unix diff
26 and patch utilities.
27
28 Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
29 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
30
31 @quotation
32 Permission is granted to copy, distribute and/or modify this document
33 under the terms of the GNU Free Documentation License, Version 1.2 or
34 any later version published by the Free Software Foundation; with no
35 Invariant Sections, with the Front-Cover texts being ``A GNU
36 Manual'', and with the Back-Cover Texts as in (a) below.  A copy of the
37 license is included in the section entitled ``GNU Free Documentation
38 License'' in the Emacs manual.
39
40 (a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
41 this GNU Manual, like GNU software.  Copies published by the Free
42 Software Foundation raise funds for GNU development.''
43
44 This document is part of a collection distributed under the GNU Free
45 Documentation License.  If you want to distribute this document
46 separately from the collection, you can do so by adding a copy of the
47 license to the document, as described in section 6 of the license.
48 @end quotation
49 @end copying
50
51 @dircategory Emacs
52 @direntry
53 * Ediff: (ediff).       A visual interface for comparing and merging programs.
54 @end direntry
55
56 @titlepage
57 @title Ediff User's Manual
58 @sp 4
59 @subtitle Ediff version 2.81.1
60 @sp 1
61 @subtitle April 2007
62 @sp 5
63 @author Michael Kifer
64 @page
65
66 @vskip 0pt plus 1filll
67 @insertcopying
68 @end titlepage
69
70
71 @node Top, Introduction, (dir), (dir)
72
73
74 @menu
75 * Introduction::                About Ediff.
76 * Major Entry Points::          How to use Ediff.
77 * Session Commands::            Ediff commands used within a session.
78 * Registry of Ediff Sessions::  Keeping track of multiple Ediff sessions.
79 * Session Groups::              Comparing and merging directories.
80 * Remote and Compressed Files::  You may want to know about this.
81 * Customization::               How to make Ediff work the way YOU want.
82 * Credits::                     Thanks to those who helped.
83 * GNU Free Documentation License:: The license for this documentation.
84 * Index::
85 @end menu
86
87 @node Introduction, Major Entry Points, Top, Top
88 @chapter Introduction
89
90 @cindex Comparing files and buffers
91 @cindex Merging files and buffers
92 @cindex Patching files and buffers
93 @cindex Finding differences
94
95 Ediff provides a convenient way for simultaneous browsing through
96 the differences between a pair (or a triple) of files or buffers
97 (which are called @samp{variants} for our purposes).  The
98 files being compared, file-A, file-B, and file-C (if applicable) are
99 shown in separate windows (side by side, one above the another, or in
100 separate frames), and the differences are highlighted as you step
101 through them.  You can also copy difference regions from one buffer to
102 another (and recover old differences if you change your mind).
103
104 Another powerful feature is the ability to merge a pair of files into a
105 third buffer.  Merging with an ancestor file is also supported.
106 Furthermore, Ediff is equipped with directory-level capabilities that
107 allow the user to conveniently launch browsing or merging sessions on
108 groups of files in two (or three) different directories.
109
110 In addition, Ediff can apply a patch to a file and then let you step through
111 both files, the patched and the original one, simultaneously,
112 difference-by-difference.  You can even apply a patch right out of a mail
113 buffer, i.e., patches received by mail don't even have to be saved.  Since
114 Ediff lets you copy differences between variants, you can, in effect, apply
115 patches selectively (i.e., you can copy a difference region from
116 @file{file.orig} to @file{file}, thereby undoing any particular patch that
117 you don't like).
118
119 Ediff even understands multi-file patches and can apply them interactively!
120 (Ediff can recognize multi-file patches only if they are in the context
121 format or GNU unified format.  All other patches are treated as 1-file
122 patches.  Ediff is [hopefully] using the same algorithm as @code{patch} to
123 determine which files need to be patched.)
124
125 Ediff is aware of version control, which lets you compare
126 files with their older versions.  Ediff also works with remote and
127 compressed files, automatically ftp'ing them over and uncompressing them.
128 @xref{Remote and Compressed Files}, for details.
129
130 This package builds upon ideas borrowed from Emerge, and several of Ediff's
131 functions are adaptations from Emerge.  Although Ediff subsumes and greatly
132 extends Emerge, much of the functionality in Ediff is influenced by Emerge.
133 The architecture and the interface are, of course, drastically different.
134
135 @node Major Entry Points, Session Commands, Introduction, Top
136 @chapter Major Entry Points
137
138 When Ediff starts up, it displays a small control window, which accepts the
139 Ediff commands, and two or three windows displaying the files to be compared
140 or merged. The control window can be in its own small frame or it can be
141 part of a bigger frame that displays other buffers. In any case, it is
142 important that the control window be active (i.e., be the one receiving the
143 keystrokes) when you use Ediff. You can switch to other Emacs buffers at
144 will and even edit the files currently being compared with Ediff and then
145 switch back to Ediff at any time by activating the appropriate Emacs windows.
146
147 Ediff can be invoked interactively using the following functions, which can
148 be run either from the minibuffer or from the menu bar.  In the menu bar,
149 all Ediff's entry points belong to three submenus of the Tools menu:
150 Compare, Merge, and Apply Patch.
151
152 @table @code
153 @item ediff-files
154 @itemx ediff
155 @findex ediff-files
156 @findex ediff
157 Compare two files.
158
159 @item ediff-backup
160 @findex ediff-backup
161 Compare a file with its backup. If there are several numerical backups, use
162 the latest. If the file is itself a backup, then compare it with its
163 original.
164
165 @item ediff-buffers
166 @findex ediff-buffers
167 Compare two buffers.
168
169 @item ediff-files3
170 @itemx ediff3
171 @findex ediff-files3
172 @findex ediff3
173 Compare three files.
174
175 @item ediff-buffers3
176 @findex ediff-buffers3
177 Compare three buffers.
178
179 @item edirs
180 @itemx ediff-directories
181 @findex edirs
182 @findex ediff-directories
183  Compare files common to two directories.
184 @item edirs3
185 @itemx ediff-directories3
186 @findex edirs3
187 @findex ediff-directories3
188  Compare files common to three directories.
189 @item edir-revisions
190 @itemx ediff-directory-revisions
191 @findex ediff-directory-revisions
192 @findex edir-revisions
193  Compare versions of files in a given directory.  Ediff selects only the
194 files that are under version control.
195 @item edir-merge-revisions
196 @itemx ediff-merge-directory-revisions
197 @findex edir-merge-revisions
198 @findex ediff-merge-directory-revisions
199  Merge versions of files in a given directory.  Ediff selects only the
200 files that are under version control.
201 @item edir-merge-revisions-with-ancestor
202 @itemx ediff-merge-directory-revisions-with-ancestor
203 @findex edir-merge-revisions-with-ancestor
204 @findex ediff-merge-directory-revisions-with-ancestor
205  Merge versions of files in a given directory using other versions as
206 ancestors.  Ediff selects only the files that are under version control.
207
208 @item ediff-windows-wordwise
209 @findex ediff-windows-wordwise
210 Compare windows word-by-word.
211
212 @item ediff-windows-linewise
213 @findex ediff-windows-linewise
214 Compare windows line-by-line.
215
216 @item ediff-regions-wordwise
217 @findex ediff-regions-wordwise
218 Compare regions word-by-word.  The regions can come from the same buffer
219 and they can even overlap.  You will be asked to specify the buffers that
220 contain the regions, which you want to compare. For each buffer, you will
221 also be asked to mark the regions to be compared. Pay attention to the
222 messages that appear in the minibuffer.
223
224 @item ediff-regions-linewise
225 @findex ediff-regions-linewise
226 Similar to @code{ediff-windows-linewise}, but compares the regions
227 line-by-line. See @code{ediff-windows-linewise} for more details.
228
229 @item ediff-revision
230 @findex ediff-revision
231  Compare versions of the current buffer, if the buffer is visiting
232  a file under version control.
233
234 @item ediff-patch-file
235 @itemx epatch
236 @findex ediff-patch-file
237 @findex epatch
238
239 Patch a file or multiple files, then compare.  If the patch applies to just
240 one file, Ediff will invoke a regular comparison session.  If it is a
241 multi-file patch, then a session group interface will be used and the user
242 will be able to patch the files selectively.  @xref{Session Groups}, for
243 more details.
244
245 Since the patch might be in a buffer or a file, you will be asked which is
246 the case. To avoid this extra prompt, you can invoke this command with a
247 prefix argument.  With an odd prefix argument, Ediff assumes the patch
248 is in a file; with an even argument, a buffer is assumed.
249
250 Note that @code{ediff-patch-file} will actually use the @code{patch}
251 utility to change the original files on disk.  This is not that
252 dangerous, since you will always have the original contents of the file
253 saved in another file that has the extension @file{.orig}.
254 Furthermore, if the file is under version control, then you can always back
255 out to one of the previous versions (see the section on Version Control in
256 the Emacs manual).
257
258 @code{ediff-patch-file} is careful about versions control: if the file
259 to be patched is checked in, then Ediff will offer to check it out, because
260 failing to do so may result in the loss of the changes when the file is
261 checked out the next time.
262
263 If you don't intend to modify the file via the patch and just want to see
264 what the patch is all about (and decide later), then
265 @code{ediff-patch-buffer} might be a better choice.
266
267 @item ediff-patch-buffer
268 @itemx epatch-buffer
269 @findex ediff-patch-buffer
270 @findex epatch-buffer
271 Patch a buffer, then compare.  The buffer being patched and the file visited
272 by that buffer (if any) is @emph{not} modified.  The result of the patch
273 appears in some other buffer that has the name ending with @emph{_patched}.
274
275 This function would refuse to apply a multifile patch to a buffer.  Use
276 @code{ediff-patch-file} for that (and when you want the original file to be
277 modified by the @code{patch} utility).
278
279 Since the patch might be in a buffer or a file, you will be asked which is
280 the case. To avoid this extra prompt, you can invoke this command with a
281 prefix argument.  With an odd prefix argument, Ediff assumes the patch
282 is in a file; with an even argument, a buffer is assumed.
283
284 @item ediff-merge-files
285 @itemx ediff-merge
286 @findex ediff-merge-files
287 @findex ediff-merge
288 Merge two files.
289
290 @item ediff-merge-files-with-ancestor
291 @itemx ediff-merge-with-ancestor
292 @findex ediff-merge-files-with-ancestor
293 @findex ediff-merge-with-ancestor
294 Like @code{ediff-merge}, but with a third ancestor file.
295
296 @item ediff-merge-buffers
297 @findex ediff-merge-buffers
298 Merge two buffers.
299
300 @item ediff-merge-buffers-with-ancestor
301 @findex ediff-merge-buffers-with-ancestor
302 Same but with ancestor.
303
304
305 @item edirs-merge
306 @itemx ediff-merge-directories
307 @findex edirs-merge
308 @findex ediff-merge-directories
309  Merge files common to two directories.
310 @item edirs-merge-with-ancestor
311 @itemx ediff-merge-directories-with-ancestor
312 @findex edirs-merge-with-ancestor
313 @findex ediff-merge-directories-with-ancestor
314  Same but using files in a third directory as ancestors.
315  If a pair of files doesn't have an ancestor in the ancestor-directory, you
316  will still be able to merge them without the ancestor.
317
318 @item ediff-merge-revisions
319 @findex ediff-merge-revisions
320 Merge two versions of the file visited by the current buffer.
321
322 @item ediff-merge-revisions-with-ancestor
323 @findex ediff-merge-revisions-with-ancestor
324 Same but with ancestor.
325
326 @item ediff-documentation
327 @findex ediff-documentation
328 Brings up this manual.
329
330 @item ediff-show-registry
331 @itemx eregistry
332 Brings up Ediff session registry.  This feature enables you to quickly find
333 and restart active Ediff sessions.
334 @end table
335
336 @noindent
337 If you want Ediff to be loaded from the very beginning of your Emacs
338 session, you should put this line in your @file{~/.emacs} file:
339
340 @example
341 (require 'ediff)
342 @end example
343
344 @noindent
345 Otherwise, Ediff will be loaded automatically when you use one of the
346 above functions, either directly or through the menus.
347
348 When the above functions are invoked, the user is prompted for all the
349 necessary information---typically the files or buffers to compare, merge, or
350 patch.  Ediff tries to be smart about these prompts.  For instance, in
351 comparing/merging files, it will offer the visible buffers as defaults.  In
352 prompting for files, if the user enters a directory, the previously input
353 file name will be appended to that directory.  In addition, if the variable
354 @code{ediff-use-last-dir} is not @code{nil}, Ediff will offer
355 previously entered directories as defaults (which will be maintained
356 separately for each type of file, A, B, or C).
357 @vindex @code{ediff-use-last-dir}
358
359 All the above functions use the POSIX @code{diff} or @code{diff3} programs
360 to find differences between two files.  They process the @code{diff} output
361 and display it in a convenient form.  At present, Ediff understands only
362 the plain output from diff.  Options such as @samp{-c} are not supported,
363 nor is the format produced by incompatible file comparison programs such as
364 the VMS version of @code{diff}.
365
366 The functions @code{ediff-files}, @code{ediff-buffers},
367 @code{ediff-files3}, @code{ediff-buffers3} first display the coarse,
368 line-based difference regions, as reported by the @code{diff} program.  The
369 total number of difference regions and the current difference number are
370 always displayed in the mode line of the control window.
371
372 Since @code{diff} may report fairly large chunks of text as being different,
373 even though the difference may be localized to just a few words or even
374 to the white space or line breaks, Ediff further @emph{refines} the
375 regions to indicate which exact words differ.  If the only difference is
376 in the white space and line breaks, Ediff says so.
377
378 On a color display, fine differences are highlighted with color; on a
379 monochrome display, they are underlined.  @xref{Highlighting Difference
380 Regions}, for information on how to customize this.
381
382 The commands @code{ediff-windows-wordwise},
383 @code{ediff-windows-linewise}, @code{ediff-regions-wordwise} and
384 @code{ediff-regions-linewise} do comparison on parts of existing Emacs
385 buffers.  The commands @code{ediff-windows-wordwise} and
386 @code{ediff-regions-wordwise} are intended for relatively small segments
387 of buffers (e.g., up to 100 lines, depending on the speed of your machine),
388 as they perform comparison on the basis of words rather than lines.
389 (Word-wise comparison of large chunks of text can be slow.)
390
391 To compare large regions, use @code{ediff-regions-linewise}.  This
392 command displays differences much like @code{ediff-files} and
393 @code{ediff-buffers}.
394
395 The functions @code{ediff-patch-file} and @code{ediff-patch-buffer} apply a
396 patch to a file or a buffer and then run Ediff on the appropriate
397 files/buffers, displaying the difference regions.
398
399 The entry points @code{ediff-directories}, @code{ediff-merge-directories},
400 etc., provide a convenient interface for comparing and merging files in
401 different directories.  The user is presented with Dired-like interface from
402 which one can run a group of related Ediff sessions.
403
404 For files under version control, @code{ediff-revision} lets you compare
405 the file visited by the current buffer to one of its checked-in versions.
406 You can also compare two checked-in versions of the visited file.
407 Moreover, the functions @code{ediff-directory-revisions},
408 @code{ediff-merge-directory-revisions}, etc., let you run a group of
409 related Ediff sessions by taking a directory and comparing (or merging)
410 versions of files in that directory.
411
412 @node Session Commands, Registry of Ediff Sessions, Major Entry Points, Top
413 @chapter Session Commands
414
415 All Ediff commands are displayed in a Quick Help window, unless you type
416 @kbd{?} to shrink the window to just one line.  You can redisplay the help
417 window by typing @kbd{?} again.  The Quick Help commands are detailed below.
418
419 Many Ediff commands take numeric prefix arguments.  For instance, if you
420 type a number, say 3, and then @kbd{j} (@code{ediff-jump-to-difference}),
421 Ediff moves to the third difference region.  Typing 3 and then @kbd{a}
422 (@code{ediff-diff-to-diff}) copies the 3d difference region from variant A
423 to variant B.  Likewise, 4 followed by @kbd{ra} restores the 4th difference
424 region in buffer A (if it was previously written over via the command
425 @kbd{a}).
426
427 Some commands take negative prefix arguments as well.  For instance, typing
428 @kbd{-} and then @kbd{j} will make the last difference region
429 current.  Typing @kbd{-2} then @kbd{j} makes the penultimate difference
430 region current, etc.
431
432 Without the prefix argument, all commands operate on the currently
433 selected difference region.  You can make any difference region
434 current using the various commands explained below.
435
436 For some commands, the actual value of the prefix argument is
437 immaterial.  However, if supplied, the prefix argument may modify the
438 command (see @kbd{ga}, @kbd{gb}, and @kbd{gc}).
439
440 @menu
441 * Quick Help Commands::             Frequently used commands.
442 * Other Session Commands::          Commands that are not bound to keys.
443 @end menu
444
445 @node Quick Help Commands,Other Session Commands,,Session Commands
446 @section Quick Help Commands
447
448 @table @kbd
449 @item ?
450 @kindex ?
451 Toggles the Ediff Quick Help window ON and OFF.
452 @item G
453 @kindex G
454 Prepares a mail buffer for sending a praise or a curse to the Ediff maintainer.
455
456 @item E
457 @kindex E
458 Brings up the top node of this manual, where you can find further
459 information on the various Ediff functions and advanced issues, such as
460 customization, session groups, etc.
461
462 @item v
463 @kindex v
464 Scrolls up buffers A and B (and buffer C where appropriate) in a
465 coordinated fashion.
466 @item V
467 @kindex V
468 Scrolls the buffers down.
469
470 @item <
471 @kindex <
472 Scrolls the buffers to the left simultaneously.
473 @item >
474 @kindex >
475 Scrolls buffers to the right.
476
477 @item wd
478 @kindex wd
479 Saves the output from the diff utility, for further reference.
480
481 With prefix argument, saves the plain output from @code{diff} (see
482 @code{ediff-diff-program} and @code{ediff-diff-options}).  Without the
483 argument, it saves customized @code{diff} output (see
484 @code{ediff-custom-diff-program} and @code{ediff-custom-diff-options}), if
485 it is available.
486
487 @item wa
488 @kindex wa
489 Saves buffer A, if it was modified.
490 @item wb
491 @kindex wb
492 Saves buffer B, if it was modified.
493 @item wc
494 @kindex wc
495 Saves buffer C, if it was modified (if you are in a session that
496 compares three files simultaneously).
497
498 @item a
499 @kindex a
500 @emph{In comparison sessions:}
501 Copies the current difference region (or the region specified as the prefix
502 to this command) from buffer A to buffer B.
503 Ediff saves the old contents of buffer B's region; it can
504 be restored via the command @kbd{rb}, which see.
505
506 @emph{In merge sessions:}
507 Copies the current difference region (or the region specified as the prefix
508 to this command) from buffer A to the merge buffer.  The old contents of
509 this region in buffer C can be restored via the command @kbd{r}.
510
511 @item b
512 @kindex b
513 Works similarly, but copies the current difference region from buffer B to
514 buffer A (in @emph{comparison sessions}) or the merge buffer (in
515 @emph{merge sessions}).
516
517 Ediff saves the old contents of the difference region copied over; it can
518 be reinstated via the command @kbd{ra} in comparison sessions and
519 @kbd{r} in merge sessions.
520
521 @item ab
522 @kindex ab
523 Copies the current difference region (or the region specified as the prefix
524 to this command) from buffer A to buffer B.  This (and the next five)
525 command is enabled only in sessions that compare three files
526 simultaneously.  The old region in buffer B is saved and can be restored
527 via the command @kbd{rb}.
528 @item ac
529 @kindex ac
530 Copies the difference region from buffer A to buffer C.
531 The old region in buffer C is saved and can be restored via the command
532 @kbd{rc}.
533 @item ba
534 @kindex ba
535 Copies the difference region from buffer B to buffer A.
536 The old region in buffer A is saved and can be restored via the command
537 @kbd{ra}.
538 @item bc
539 @kindex bc
540 Copies the difference region from buffer B to buffer C.
541 The command @kbd{rc} undoes this.
542 @item ca
543 @kindex ca
544 Copies the difference region from buffer C to buffer A.
545 The command @kbd{ra} undoes this.
546 @item cb
547 @kindex cb
548 Copies the difference region from buffer C to buffer B.
549 The command @kbd{rb} undoes this.
550
551 @item p
552 @itemx DEL
553 @kindex p
554 @kindex DEL
555 Makes the previous difference region current.
556 @item n
557 @itemx SPC
558 @kindex n
559 @kindex SPC
560 Makes the next difference region current.
561
562 @item j
563 @itemx -j
564 @itemx Nj
565 @kindex j
566 Makes the very first difference region current.
567
568 @kbd{-j} makes the last region current.  Typing a number, N, and then `j'
569 makes the difference region N current.  Typing -N (a negative number) then
570 `j' makes current the region Last - N.
571
572 @item ga
573 @kindex ga
574 Makes current the difference region closest to the position of the point in
575 buffer A.
576
577 However, with a prefix argument, Ediff would position all variants
578 around the area indicated by the current point in buffer A: if
579 the point is inside a difference region, then the variants will be
580 positioned at this difference region.  If the point is not in any difference
581 region, then it is in an area where all variants agree with each other.  In
582 this case, the variants will be positioned so that each would display this
583 area (of agreement).
584 @item gb
585 @kindex gb
586 Makes current the difference region closest to the position of the point in
587 buffer B.
588
589 With a prefix argument, behaves like @kbd{ga}, but with respect to buffer B.
590 @item gc
591 @kindex gc
592 @emph{In merge sessions:}
593 makes current the difference region closest to the point in the merge buffer.
594
595 @emph{In 3-file comparison sessions:}
596 makes current the region closest to the point in buffer C.
597
598 With a prefix argument, behaves like @kbd{ga}, but with respect to buffer C.
599
600 @item !
601 @kindex !
602 Recomputes the difference regions, bringing them up to date.  This is often
603 needed because it is common to do all sorts of editing during Ediff
604 sessions, so after a while, the highlighted difference regions may no
605 longer reflect the actual differences among the buffers.
606
607 @item *
608 @kindex *
609 Forces refinement of the current difference region, which highlights the exact
610 words of disagreement among the buffers.  With a negative prefix argument,
611 unhighlights the current region.
612
613 Forceful refinement may be needed if Ediff encounters a difference region
614 that is larger than @code{ediff-auto-refine-limit}.  In this situation,
615 Ediff doesn't do automatic refinement in order to improve response time.
616 (Ediff doesn't auto-refine on dumb terminals as well, but @kbd{*} still
617 works there.  However, the only useful piece of information it can tell you
618 is whether or not the difference regions disagree only in the amount of
619 white space.)
620
621 This command is also useful when the highlighted fine differences are
622 no longer current, due to user editing.
623
624 @item m
625 @kindex m
626 Displays the current Ediff session in a frame as wide as the physical
627 display.  This is useful when comparing files side-by-side.  Typing `m' again
628 restores the original size of the frame.
629
630 @item |
631 @kindex |
632 Toggles the horizontal/vertical split of the Ediff display.  Horizontal
633 split is convenient when it is possible to compare files
634 side-by-side.  If the frame in which files are displayed is too narrow
635 and lines are cut off, typing @kbd{m} may help some.
636
637 @item @@
638 @kindex @@
639 Toggles auto-refinement of difference regions (i.e., automatic highlighting
640 of the exact words that differ among the variants).  Auto-refinement is
641 turned off on devices where Emacs doesn't support highlighting.
642
643 On slow machines, it may be advantageous to turn auto-refinement off.  The
644 user can always forcefully refine specific difference regions by typing
645 @kbd{*}.
646
647 @item h
648 @kindex h
649 Cycles between full highlighting, the mode where fine differences are not
650 highlighted (but computed), and the mode where highlighting is done with
651 @acronym{ASCII} strings.  The latter is not really recommended, unless on a dumb TTY.
652
653 @item r
654 @kindex r
655 Restores the old contents of the region in the merge buffer.
656 (If you copied a difference region from buffer A or B into the merge buffer
657 using the commands @kbd{a} or @kbd{b}, Ediff saves the old contents of the
658 region in case you change your mind.)
659
660 This command is enabled in merge sessions only.
661
662 @item ra
663 @kindex ra
664 Restores the old contents of the current difference region in buffer A,
665 which was previously saved when the user invoked one of these commands:
666 @kbd{b}, @kbd{ba}, @kbd{ca}, which see.  This command is enabled in
667 comparison sessions only.
668 @item rb
669 @kindex rb
670 Restores the old contents of the current difference region in buffer B,
671 which was previously saved when the user invoked one of these commands:
672 @kbd{a}, @kbd{ab}, @kbd{cb}, which see.  This command is enabled in
673 comparison sessions only.
674 @item rc
675 @kindex rc
676 Restores the old contents of the current difference region in buffer C,
677 which was previously saved when the user invoked one of these commands:
678 @kbd{ac}, @kbd{bc}, which see.  This command is enabled in 3-file
679 comparison sessions only.
680
681 @item ##
682 @kindex ##
683 Tell Ediff to skip over regions that disagree among themselves only in the
684 amount of white space and line breaks.
685
686 Even though such regions will be skipped over, you can still jump to any
687 one of them by typing the region number and then `j'.  Typing @kbd{##}
688 again puts Ediff back in the original state.
689
690 @item #c
691 @kindex #c
692 @vindex ediff-ignore-case-option
693 @vindex ediff-ignore-case-option3
694 @vindex ediff-ignore-case
695 Toggle case sensitivity in the diff program. All diffs are recomputed.
696 Case sensitivity is controlled by the variables
697 @code{ediff-ignore-case-option}, @code{ediff-ignore-case-option3},
698 and @code{ediff-ignore-case}, which are explained elsewhere.
699
700 @item #h
701 @itemx #f
702 @kindex #f
703 @kindex #h
704 Ediff works hard to ameliorate the effects of boredom in the workplace...
705
706 Quite often differences are due to identical replacements (e.g., the word
707 `foo' is replaced with the word `bar' everywhere).  If the number of regions
708 with such boring differences exceeds your tolerance threshold, you may be
709 tempted to tell Ediff to skip these regions altogether (you will still be able
710 to jump to them via the command @kbd{j}).  The above commands, @kbd{#h}
711 and @kbd{#f}, may well save your day!
712
713 @kbd{#h} prompts you to specify regular expressions for each
714 variant.  Difference regions where each variant's region matches the
715 corresponding regular expression will be skipped from then on.  (You can
716 also tell Ediff to skip regions where at least one variant matches its
717 regular expression.)
718
719 @kbd{#f} does dual job: it focuses on regions that match the corresponding
720 regular expressions.  All other regions will be skipped
721 over.  @xref{Selective Browsing}, for more.
722
723 @item A
724 @kindex A
725 Toggles the read-only property in buffer A.
726 If file A is under version control and is checked in, it is checked out
727 (with your permission).
728 @item B
729 @kindex B
730 Toggles the read-only property in buffer B.
731 If file B is under version control and is checked in, it is checked out.
732 @item C
733 @kindex C
734 Toggles the read-only property in buffer C (in 3-file comparison sessions).
735 If file C is under version control and is checked in, it is checked out.
736
737 @item ~
738 @kindex ~
739 Swaps the windows where buffers A and B are displayed.  If you are comparing
740 three buffers at once, then this command would rotate the windows among
741 buffers A, B, and C.
742
743 @item i
744 @kindex i
745 Displays all kinds of useful data about the current Ediff session.
746 @item D
747 @kindex D
748 Runs @code{ediff-custom-diff-program} on the variants and displays the
749 buffer containing the output.  This is useful when you must send the output
750 to your Mom.
751
752 With a prefix argument, displays the plain @code{diff} output.
753 @xref{Patch and Diff Programs}, for details.
754
755 @item R
756 @kindex R
757 Displays a list of currently active Ediff sessions---the Ediff Registry.
758 You can then restart any of these sessions by either clicking on a session
759 record or by putting the cursor over it and then typing the return key.
760
761 (Some poor souls leave so many active Ediff sessions around that they loose
762 track of them completely...  The `R' command is designed to save these
763 people from the recently discovered Ediff Proficiency Syndrome.)
764
765 Typing @kbd{R} brings up Ediff Registry only if it is typed into an Ediff
766 Control Panel.  If you don't have a control panel handy, type this in the
767 minibuffer: @kbd{M-x eregistry}.  @xref{Registry of Ediff Sessions}.
768
769 @item M
770 @kindex M
771 Shows the session group buffer that invoked the current Ediff session.
772 @xref{Session Groups}, for more information on session groups.
773
774 @item z
775 @kindex z
776 Suspends the current Ediff session.  (If you develop a condition known as
777 Repetitive Ediff Injury---a serious but curable illness---you must change
778 your current activity.  This command tries hard to hide all Ediff-related
779 buffers.)
780
781 The easiest way to resume a suspended Ediff session is through the registry
782 of active sessions.  @xref{Registry of Ediff Sessions}, for details.
783 @item q
784 @kindex q
785 Terminates this Ediff session.  With a prefix argument (e.g.,@kbd{1q}), asks
786 if you also want to delete the buffers of the variants.
787 Modified files and the results of merges are never deleted.
788
789 @item %
790 @kindex %
791 Toggles narrowing in Ediff buffers.  Ediff buffers may be narrowed if you
792 are comparing only parts of these buffers via the commands
793 @code{ediff-windows-*} and @code{ediff-regions-*}, which see.
794
795 @item C-l
796 @kindex C-l
797 Restores the usual Ediff window setup.  This is the quickest way to resume
798 an Ediff session, but it works only if the control panel of that session is
799 visible.
800
801 @item $$
802 @kindex $$
803 While merging with an ancestor file, Ediff is determined to reduce user's
804 wear and tear by saving him and her much of unproductive, repetitive
805 typing.  If it notices that, say, file A's difference region is identical to
806 the same difference region in the ancestor file, then the merge buffer will
807 automatically get the difference region taken from buffer B.  The rationale
808 is that this difference region in buffer A is as old as that in the
809 ancestor buffer, so the contents of that region in buffer B represents real
810 change.
811
812 You may want to ignore such `obvious' merges and concentrate on difference
813 regions where both files `clash' with the ancestor, since this means that
814 two different people have been changing this region independently and they
815 had different ideas on how to do this.
816
817 The above command does this for you by skipping the regions where only one
818 of the variants clashes with the ancestor but the other variant agrees with
819 it.  Typing @kbd{$$} again undoes this setting.
820
821 @item $*
822 @kindex $*
823 When merging files with large number of differences, it is sometimes
824 convenient to be able to skip the difference regions for which you already
825 decided which variant is most appropriate. Typing @kbd{$*} will accomplish
826 precisely this.
827
828 To be more precise, this toggles the check for whether the current merge is
829 identical to its default setting, as originally decided by Ediff.  For
830 instance, if Ediff is merging according to the `combined' policy, then the
831 merge region is skipped over if it is different from the combination of the
832 regions in buffers A and B.  (Warning: swapping buffers A and B will confuse
833 things in this respect.)  If the merge region is marked as `prefer-A' then
834 this region will be skipped if it differs from the current difference
835 region in buffer A, etc.
836
837 @item /
838 @kindex /
839 Displays the ancestor file during merges.
840 @item &
841 @kindex &
842 In some situations, such as when one of the files agrees with the ancestor file
843 on a difference region and the other doesn't, Ediff knows what to do: it copies
844 the current difference region from the second buffer into the merge buffer.
845
846 In other cases, the right course of action is not that clearcut, and Ediff
847 would use a default action.  The above command changes the default action.
848 The default action can be @samp{default-A} (choose the region from buffer
849 A), @samp{default-B} (choose the region from buffer B), or @samp{combined}
850 (combine the regions from the two buffers).
851 @xref{Merging and diff3}, for further details.
852
853 The command @kbd{&} also affects the regions in the merge buffers that have
854 @samp{default-A}, @samp{default-B}, or @samp{combined} status, provided
855 they weren't changed with respect to the original.  For instance, if such a
856 region has the status @samp{default-A} then changing the default action to
857 @samp{default-B} will also replace this merge-buffer's region with the
858 corresponding region from buffer B.
859
860 @item s
861 @kindex s
862 Causes the merge window shrink to its minimum size, thereby exposing as much
863 of the variant buffers as possible.  Typing `s' again restores
864 the original size of that window.
865
866 With a positive prefix argument, this command enlarges the merge window.
867 E.g., @kbd{4s} increases the size of the window by about 4 lines, if
868 possible.  With a negative numeric argument, the size of the merge window
869 shrinks by that many lines, if possible.  Thus, @kbd{-s} shrinks the window
870 by about 1 line and @kbd{-3s} by about 3 lines.
871
872 This command is intended only for temporary viewing; therefore, Ediff
873 restores window C to its original size whenever it makes any other change
874 in the window configuration.  However, redisplaying (@kbd{C-l}) or jumping
875 to another difference does not affect window C's size.
876
877 The split between the merge window and the variant windows is controlled by
878 the variable @code{ediff-merge-window-share}, which see.
879
880 @item +
881 @kindex +
882 Combines the difference regions from buffers A and B and copies the
883 result into the merge buffer.  @xref{Merging and diff3}, and the
884 variables @code{ediff-combine-diffs} and @code{ediff-combination-pattern}.
885
886
887 @item =
888 @kindex =
889 You may run into situations when a large chunk of text in one file has been
890 edited and then moved to a different place in another file.  In such a case,
891 these two chunks of text are unlikely to belong to the same difference
892 region, so the refinement feature of Ediff will not be able to tell you
893 what exactly differs inside these chunks.  Since eyeballing large pieces of
894 text is contrary to human nature, Ediff has a special command to help
895 reduce the risk of developing a cataract.
896
897 In other situations, the currently highlighted region might be big and you
898 might want to reconcile of them interactively.
899
900 All of this can be done with the above command, @kbd{=}, which
901 compares regions within Ediff buffers.  Typing @kbd{=} creates a
902 child Ediff session for comparing regions in buffers A, B, or
903 C as follows.
904
905 First, you will be asked whether you want to compare the fine differences
906 between the currently highlighted buffers on a word-by-word basis. If you
907 accept, a child Ediff session will start using the currently highlighted
908 regions. Ediff will let you step over the differences word-wise.
909
910 If you reject the offer, you will be asked to select regions of your choice.
911
912 @emph{If you are comparing 2 files or buffers:}
913 Ediff will ask you to select regions in buffers A and B.
914
915 @emph{If you are comparing 3 files or buffers simultaneously:} Ediff will
916 ask you to choose buffers and then select regions inside those buffers.
917
918 @emph{If you are merging files or buffers (with or without ancestor):}
919 Ediff will ask you to choose which buffer (A or B) to compare with the
920 merge buffer and then select regions in those buffers.
921
922 @end table
923
924 @node Other Session Commands,,Quick Help Commands,Session Commands
925 @section Other Session Commands
926
927 The following commands can be invoked from within any Ediff session,
928 although some of them are not bound to a key.
929
930 @table @code
931 @item eregistry
932 @itemx ediff-show-registry
933 @findex eregistry
934 @findex ediff-show-registry
935 This command brings up the registry of active Ediff sessions.  Ediff
936 registry is a device that can be used to resume any active Ediff session
937 (which may have been postponed because the user switched to some other
938 activity).  This command is also useful for switching between multiple
939 active Ediff sessions that are run at the same time.  The function
940 @code{eregistry} is an alias for @code{ediff-show-registry}.
941 @xref{Registry of Ediff Sessions}, for more information on this registry.
942
943 @item ediff-toggle-multiframe
944 @findex ediff-toggle-multiframe
945 Changes the display from the multi-frame mode (where the quick help window
946 is in a separate frame) to the single-frame mode (where all Ediff buffers
947 share the same frame), and vice versa.  See
948 @code{ediff-window-setup-function} for details on how to make either of
949 these modes the default one.
950
951 This function can also be invoked from the Menubar.  However, in some
952 cases, the change will take place only after you execute one of the Ediff
953 commands, such as going to the next difference or redisplaying.
954
955 @item ediff-toggle-use-toolbar
956 @findex ediff-toggle-use-toolbar
957 Available in XEmacs only.  The Ediff toolbar provides quick access to some
958 of the common Ediff functions.  This function toggles the display of the
959 toolbar.  If invoked from the menubar, the function may take sometimes
960 effect only after you execute an Ediff command, such as going to the next
961 difference.
962
963 @item ediff-use-toolbar-p
964 @vindex ediff-use-toolbar-p
965 The use of the toolbar can also be specified via the variable
966 @code{ediff-use-toolbar-p} (default is @code{t}).  This variable can be set
967 only in @file{.emacs} --- do @strong{not} change it interactively.  Use the
968 function @code{ediff-toggle-use-toolbar} instead.
969
970 @item ediff-revert-buffers-then-recompute-diffs
971 @findex ediff-revert-buffers-then-recompute-diffs
972 This command reverts the buffers you are comparing and recomputes their
973 differences.  It is useful when, after making changes, you decided to
974 make a fresh start, or if at some point you changed the files being
975 compared but want to discard any changes to comparison buffers that were
976 done since then.
977
978 This command normally asks for confirmation before reverting files.
979 With a prefix argument, it reverts files without asking.
980
981
982 @item ediff-profile
983 @findex ediff-profile
984 Ediff has an admittedly primitive (but useful) facility for profiling
985 Ediff's commands.  It is meant for Ediff maintenance---specifically, for
986 making it run faster.  The function @code{ediff-profile} toggles
987 profiling of ediff commands.
988 @end table
989
990 @node Registry of Ediff Sessions, Session Groups, Session Commands, Top
991 @chapter Registry of Ediff Sessions
992
993 Ediff maintains a registry of all its invocations that are
994 still @emph{active}.  This feature is very convenient for switching among
995 active Ediff sessions or for quickly restarting a suspended Ediff session.
996
997 The focal point of this activity is a buffer
998 called @emph{*Ediff Registry*}.  You can display this buffer by typing
999 @kbd{R} in any Ediff Control Buffer or Session Group Buffer
1000 (@pxref{Session Groups}), or by typing
1001 @kbd{M-x eregistry} into the Minibuffer.
1002 The latter would be the fastest way to bring up the registry
1003 buffer if no control or group buffer is displayed in any of the visible
1004 Emacs windows.
1005 If you are in a habit of running multiple long Ediff sessions and often need to
1006 suspend, resume, or switch between them, it may be a good idea to have the
1007 registry buffer permanently displayed in a separate, dedicated window.
1008
1009 The registry buffer has several convenient key bindings.
1010 For instance, clicking mouse button 2 or typing
1011 @kbd{RET} or @kbd{v} over any session record resumes that session.
1012 Session records in the registry buffer provide a fairly complete
1013 description of each session, so it is usually easy to identify the right
1014 session to resume.
1015
1016 Other useful commands are bound to @kbd{SPC} (next registry record)
1017 and @kbd{DEL} (previous registry record).  There are other commands as well,
1018 but you don't need to memorize them, since they are listed at the top of
1019 the registry buffer.
1020
1021 @node Session Groups, Remote and Compressed Files, Registry of Ediff Sessions, Top
1022 @chapter Session Groups
1023
1024 Several major entries of Ediff perform comparison and merging on
1025 directories.  On entering @code{ediff-directories},
1026 @code{ediff-directories3},
1027 @code{ediff-merge-directories},
1028 @code{ediff-merge-directories-with-ancestor},
1029 @code{ediff-directory-revisions},
1030 @code{ediff-merge-directory-revisions}, or
1031 @code{ediff-merge-directory-revisions-with-ancestor},
1032 the user is presented with a
1033 Dired-like buffer that lists files common to the directories involved along
1034 with their sizes.  (The list of common files can be further filtered through
1035 a regular expression, which the user is prompted for.)  We call this buffer
1036 @emph{Session Group Panel} because all Ediff sessions associated with the
1037 listed files will have this buffer as a common focal point.
1038
1039 Clicking button 2 or typing @kbd{RET} or @kbd{v} over a
1040 record describing files invokes Ediff in the appropriate mode on these
1041 files.  You can come back to the session group buffer associated with a
1042 particular invocation of Ediff by typing @kbd{M} in Ediff control buffer of
1043 that invocation.
1044
1045 Many commands are available in the session group buffer; some are
1046 applicable only to certain types of work.  The relevant commands are always
1047 listed at the top of each session group buffer, so there is no need to
1048 memorize them.
1049
1050 In directory comparison or merging, a session group panel displays only the
1051 files common to all directories involved.  The differences are kept in a
1052 separate @emph{directory difference buffer} and are conveniently displayed
1053 by typing @kbd{D} to the corresponding session group panel.  Thus, as an
1054 added benefit, Ediff can be used to compare the contents of up to three
1055 directories.
1056
1057 @cindex Directory difference buffer
1058 Sometimes it is desirable to copy some files from one directory to another
1059 without exiting Ediff. The @emph{directory difference buffer}, which is
1060 displayed by typing @kbd{D} as discussed above, can be used for this
1061 purpose. If a file is, say, in Ediff's Directory A, but is missing in
1062 Ediff's Directory B (Ediff will refuse to override existing files), then
1063 typing @kbd{C} or clicking mouse button 2 over that file (which must be
1064 displayed in directory difference buffer) will copy that file from
1065 Directory A to Directory B.
1066
1067 Session records in session group panels are also marked with @kbd{+}, for
1068 active sessions, and with @kbd{-}, for finished sessions.
1069
1070 Sometimes, it is convenient to exclude certain sessions from a group.
1071 Usually this happens when the user doesn't intend to run Ediff of certain
1072 files in the group, and the corresponding session records just add clutter
1073 to the session group buffer.  To help alleviate this problem, the user can
1074 type @kbd{h} to mark a session as a candidate for exclusion and @kbd{x} to
1075 actually hide the marked sessions.  There actions are reversible: with a
1076 prefix argument, @kbd{h} unmarks the session under the cursor, and @kbd{x}
1077 brings the hidden sessions into the view (@kbd{x} doesn't unmark them,
1078 though, so the user has to explicitly unmark the sessions of interest).
1079
1080 Group sessions also understand the command @kbd{m}, which marks sessions
1081 for future operations (other than hiding) on a group of sessions.  At present,
1082 the only such group-level operation is the creation of a multi-file patch.
1083
1084 @vindex ediff-autostore-merges
1085 For group sessions created to merge files, Ediff can store all merges
1086 automatically in a directory.  The user is asked to specify such directory
1087 if the value of @code{ediff-autostore-merges} is non-@code{nil}.  If the value is
1088 @code{nil}, nothing is done to the merge buffers---it will be the user's
1089 responsibility to save them.  If the value is @code{t}, the user will be
1090 asked where to save the merge buffers in all merge jobs, even those that do
1091 not originate from a session group.  It the value is neither @code{nil} nor
1092 @code{t}, the merge buffer is saved @emph{only} if this merge session was
1093 invoked from a session group.  This behavior is implemented in the function
1094 @code{ediff-maybe-save-and-delete-merge}, which is a hook in
1095 @code{ediff-quit-merge-hook}.  The user can supply a different hook, if
1096 necessary.
1097
1098 The variable @code{ediff-autostore-merges} is buffer-local, so it can be
1099 set on a per-buffer basis.  Therefore, use @code{setq-default} to change
1100 this variable globally.
1101
1102 @cindex Multi-file patches
1103 A multi-file patch is a concatenated output of several runs of the Unix
1104 @code{diff} command (some versions of @code{diff} let you create a
1105 multi-file patch in just one run).  Ediff facilitates creation of
1106 multi-file patches as follows.  If you are in a session group buffer
1107 created in response to @code{ediff-directories} or
1108 @code{ediff-directory-revisions}, you can mark (by typing @kbd{m}) the
1109 desired Ediff sessions and then type @kbd{P} to create a
1110 multi-file patch of those marked sessions.
1111 Ediff will then display a buffer containing the patch.
1112 The patch is generated by invoking @code{diff} on all marked individual
1113 sessions (represented by files) and session groups (represented by
1114 directories).  Ediff will also recursively descend into any @emph{unmarked}
1115 session group and will search for marked sessions there.  In this way, you
1116 can create multi-file patches that span file subtrees that grow out of
1117 any given directory.
1118
1119 In an @code{ediff-directories} session, it is enough to just mark the
1120 requisite sessions.  In @code{ediff-directory-revisions} revisions, the
1121 marked sessions must also be active, or else Ediff will refuse to produce a
1122 multi-file patch.  This is because, in the latter-style sessions, there are
1123 many ways to create diff output, and it is easier to handle by running
1124 Ediff on the inactive sessions.
1125
1126 Last, but not least, by typing @kbd{==}, you can quickly find out which
1127 sessions have identical entries, so you won't have to run Ediff on those
1128 sessions.  This, however, works only on local, uncompressed files.
1129 For compressed or remote files, this command won't report anything.
1130 Likewise, you can use @kbd{=h} to mark sessions with identical entries
1131 for hiding or, with @kbd{=m}, for further operations.
1132
1133 The comparison operations @kbd{==}, @kbd{=h}, and @kbd{=m} can recurse into
1134 subdirectories to see if they have identical contents (so the user will not
1135 need to descend into those subdirectories manually). These commands ask the
1136 user whether or not to do a recursive descent.
1137
1138
1139
1140 @node Remote and Compressed Files, Customization, Session Groups, Top
1141 @chapter Remote and Compressed Files
1142
1143 Ediff works with remote, compressed, and encrypted files.  Ediff
1144 supports @file{ange-ftp.el}, @file{jka-compr.el}, @file{uncompress.el}
1145 and @file{crypt++.el}, but it may work with other similar packages as
1146 well.  This means that you can compare files residing on another
1147 machine, or you can apply a patch to a file on another machine.  Even
1148 the patch itself can be a remote file!
1149
1150 When patching compressed or remote files, Ediff does not rename the source
1151 file (unlike what the @code{patch} utility would usually do).  Instead, the
1152 source file retains its name and the result of applying the patch is placed
1153 in a temporary file that has the suffix @file{_patched} attached.
1154 Generally, this applies to files that are handled using black magic, such
1155 as special file handlers (ange-ftp and some compression and encryption
1156 packages also use this method).
1157
1158 Regular files are treated by the @code{patch} utility in the usual manner,
1159 i.e., the original is renamed into @file{source-name.orig} and the result
1160 of the patch is placed into the file source-name (@file{_orig} is used
1161 on systems like VMS, DOS, etc.)
1162
1163 @node Customization, Credits, Remote and Compressed Files, Top
1164 @chapter Customization
1165
1166 Ediff has a rather self-explanatory interface, and in most cases you
1167 won't need to change anything.  However, should the need arise, there are
1168 extensive facilities for changing the default behavior.
1169
1170 Most of the customization can be done by setting various variables in the
1171 @file{.emacs} file.  Some customization (mostly window-related
1172 customization and faces) can be done by putting appropriate lines in
1173 @file{.Xdefaults}, @file{.xrdb}, or whatever X resource file is in use.
1174
1175 With respect to the latter, please note that the X resource
1176 for Ediff customization is `Ediff', @emph{not} `emacs'.
1177 @xref{Window and Frame Configuration},
1178 @xref{Highlighting Difference Regions}, for further details.  Please also
1179 refer to Emacs manual for the information on how to set Emacs X resources.
1180
1181 @menu
1182 * Hooks::                       Customization via the hooks.
1183 * Quick Help Customization::    How to customize Ediff's quick help feature.
1184 * Window and Frame Configuration::  Controlling the way Ediff displays things.
1185 * Selective Browsing::          Advanced browsing through difference regions.
1186 * Highlighting Difference Regions::  Controlling highlighting.
1187 * Narrowing::                   Comparing regions, windows, etc.
1188 * Refinement of Difference Regions::  How to control the refinement process.
1189 * Patch and Diff Programs::     Changing the utilities that compute differences
1190                                 and apply patches.
1191 * Merging and diff3::           How to customize Ediff in its Merge Mode.
1192 * Support for Version Control::  Changing the version control package.
1193                                  You are not likely to do that.
1194 * Customizing the Mode Line::   Changing the look of the mode line in Ediff.
1195 * Miscellaneous::&nb