1 \input texinfo @c -*-texinfo-*-
2 @c documentation for Ediff
3 @c Written by Michael Kifer
5 @comment %**start of header (This is for running Texinfo on a region.)
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
12 @settitle Ediff User's Manual
19 * Ediff: (ediff). A visual interface for comparing and merging programs.
26 @comment %**end of header (This is for running Texinfo on a region.)
29 This file documents Ediff, a comprehensive visual interface to Unix diff
32 Permission is granted to make and distribute verbatim copies of this
33 manual provided the copyright notice and this permission notice are
34 preserved on all copies.
37 Permission is granted to process this file through TeX and print the
38 results, provided the printed document carries copying permission notice
39 identical to this one except for the removal of this paragraph (this
40 paragraph not being relevant to the printed manual).
47 @title Ediff User's Manual
49 @subtitle Ediff version 2.70
56 @vskip 0pt plus 1filll
58 Copyright @copyright{} 1995, 1996, 1997 Free Software Foundation, Inc.
60 Permission is granted to make and distribute verbatim copies of
61 this manual provided the copyright notice and this permission notice
62 are preserved on all copies.
67 @node Top, Introduction, (dir), (dir)
71 * Introduction:: About Ediff.
72 * Major Entry Points:: How to use Ediff.
73 * Session Commands:: Ediff commands used within a session.
74 * Registry of Ediff Sessions:: Keeping track of multiple Ediff sessions.
75 * Session Groups:: Comparing and merging directories.
76 * Remote and Compressed Files:: You may want to know about this.
77 * Customization:: How to make Ediff work the way YOU want.
78 * Credits:: Thanks to those who helped.
82 @node Introduction, Major Entry Points, Top, Top
85 @cindex Comparing files and buffers
86 @cindex Merging files and buffers
87 @cindex Patching files and buffers
88 @cindex Finding differences
90 Ediff provides a convenient way for simultaneous browsing through
91 the differences between a pair (or a triple) of files or buffers
92 (which are called @samp{variants} for our purposes). The
93 files being compared, file-A, file-B, and file-C (if applicable) are
94 shown in separate windows (side by side, one above the another, or in
95 separate frames), and the differences are highlighted as you step
96 through them. You can also copy difference regions from one buffer to
97 another (and recover old differences if you change your mind).
99 Another powerful feature is the ability to merge a pair of files into a
100 third buffer. Merging with an ancestor file is also supported.
101 Furthermore, Ediff is equipped with directory-level capabilities that
102 allow the user to conveniently launch browsing or merging sessions on
103 groups of files in two (or three) different directories.
105 In addition, Ediff can apply a patch to a file and then let you step though
106 both files, the patched and the original one, simultaneously,
107 difference-by-difference. You can even apply a patch right out of a mail
108 buffer, i.e., patches received by mail don't even have to be saved. Since
109 Ediff lets you copy differences between variants, you can, in effect, apply
110 patches selectively (i.e., you can copy a difference region from
111 @file{file.orig} to @file{file}, thereby undoing any particular patch that
114 Ediff even understands multi-file patches and can apply them interactively!
115 (Ediff can recognize multi-file patches only if they are in the context
116 format or GNU unified format. All other patches are treated as 1-file
117 patches. Ediff is [hopefully] using the same algorithm as @command{patch} to
118 determine which files need to be patched.)
120 Ediff is aware of version control, which lets you compare
121 files with their older versions. Ediff also works with remote and
122 compressed files, automatically ftp'ing them over and uncompressing them.
123 @xref{Remote and Compressed Files}, for details.
125 This package builds upon ideas borrowed from Emerge, and several of Ediff's
126 functions are adaptations from Emerge. Although Ediff subsumes and greatly
127 extends Emerge, much of the functionality in Ediff is influenced by Emerge.
128 The architecture and the interface are, of course, drastically different.
130 @node Major Entry Points, Session Commands, Introduction, Top
131 @chapter Major Entry Points
133 Ediff can be invoked interactively using the following functions, which can
134 be run either from the minibuffer or from the menu bar. In the menu bar,
135 all Ediff's entry points belong to three submenus of the Tools menu:
136 Compare, Merge, and Apply Patch.
146 @findex ediff-buffers
156 @findex ediff-buffers3
157 Compare three buffers.
160 @itemx ediff-directories
162 @findex ediff-directories
163 Compare files common to two directories.
165 @itemx ediff-directories3
167 @findex ediff-directories3
168 Compare files common to three directories.
170 @itemx ediff-directory-revisions
171 @findex ediff-directory-revisions
172 @findex edir-revisions
173 Compare versions of files in a given directory. Ediff selects only the
174 files that are under version control.
175 @item edir-merge-revisions
176 @itemx ediff-merge-directory-revisions
177 @findex edir-merge-revisions
178 @findex ediff-merge-directory-revisions
179 Merge versions of files in a given directory. Ediff selects only the
180 files that are under version control.
181 @item edir-merge-revisions-with-ancestor
182 @itemx ediff-merge-directory-revisions-with-ancestor
183 @findex edir-merge-revisions-with-ancestor
184 @findex ediff-merge-directory-revisions-with-ancestor
185 Merge versions of files in a given directory using other versions as
186 ancestors. Ediff selects only the files that are under version control.
188 @item ediff-windows-wordwise
189 @findex ediff-windows-wordwise
190 Compare windows word-by-word.
192 @item ediff-windows-linewise
193 @findex ediff-windows-linewise
194 Compare windows line-by-line.
196 @item ediff-regions-wordwise
197 @findex ediff-regions-wordwise
198 Compare regions word-by-word.
200 @item ediff-regions-linewise
201 @findex ediff-regions-linewise
202 Compare regions line-by-line.
205 @findex ediff-revision
206 Compare versions of the current buffer, if the buffer is visiting
207 a file under version control.
209 @item ediff-patch-file
211 @findex ediff-patch-file
214 Patch a file or multiple files, then compare. If the patch applies to just
215 one file, Ediff will invoke a regular comparison session. If it is a
216 multi-file patch, then a session group interface will be used and the user
217 will be able to patch the files selectively. @xref{Session Groups}, for
220 Since the patch might be in a buffer or a file, you will be asked which is
221 the case. To avoid this extra prompt, you can invoke this command with a
222 prefix argument. With an odd prefix argument, Ediff assumes the patch
223 is in a file; with an even argument, a buffer is assumed.
225 Note that @code{ediff-patch-file} will actually use the @command{patch}
226 utility to change the the original files on disk. This is not that
227 dangerous, since you will always have the original contents of the file
228 saved in another file that has the extension @file{.orig}.
229 Furthermore, if the file is under version control, then you can always back
230 out to one of the previous versions (see the section on Version Countrol in
233 @code{ediff-patch-file} is careful about versions control: if the file
234 to be patched is checked in, then Ediff will offer to check it out, because
235 failing to do so may result in the loss of the changes when the file is
236 checked out the next time.
238 If you don't intend to modify the file via the patch and just want to see
239 what the patch is all about (and decide later), then
240 @code{ediff-patch-buffer} might be a better choice.
242 @item ediff-patch-buffer
244 @findex ediff-patch-buffer
245 @findex epatch-buffer
246 Patch a buffer, then compare. The buffer being patched and the file visited
247 by that buffer (if any) is @emph{not} modified. The result of the patch
248 appears in some other buffer that has the name ending with @emph{_patched}.
250 This function would refuse to apply a multifile patch to a buffer. Use
251 @code{ediff-patch-file} for that (and when you want the original file to be
252 modified by the @command{patch} utility).
254 Since the patch might be in a buffer or a file, you will be asked which is
255 the case. To avoid this extra prompt, you can invoke this command with a
256 prefix argument. With an odd prefix argument, Ediff assumes the patch
257 is in a file; with an even argument, a buffer is assumed.
259 @item ediff-merge-files
261 @findex ediff-merge-files
265 @item ediff-merge-files-with-ancestor
266 @itemx ediff-merge-with-ancestor
267 @findex ediff-merge-files-with-ancestor
268 @findex ediff-merge-with-ancestor
269 Like @code{ediff-merge}, but with a third ancestor file.
271 @item ediff-merge-buffers
272 @findex ediff-merge-buffers
275 @item ediff-merge-buffers-with-ancestor
276 @findex ediff-merge-buffers-with-ancestor
277 Same but with ancestor.
281 @itemx ediff-merge-directories
283 @findex ediff-merge-directories
284 Merge files common to two directories.
285 @item edirs-merge-with-ancestor
286 @itemx ediff-merge-directories-with-ancestor
287 @findex edirs-merge-with-ancestor
288 @findex ediff-merge-directories-with-ancestor
289 Same but using files in a third directory as ancestors.
290 If a pair of files doesn't have an ancestor in the ancestor-directory, you
291 will still be able to merge them without the ancestor.
293 @item ediff-merge-revisions
294 @findex ediff-merge-revisions
295 Merge two versions of the file visited by the current buffer.
297 @item ediff-merge-revisions-with-ancestor
298 @findex ediff-merge-revisions-with-ancestor
299 Same but with ancestor.
301 @item ediff-documentation
302 @findex ediff-documentation
303 Brings up this manual.
305 @item ediff-show-registry
307 Brings up Ediff session registry. This feature enables you to quickly find
308 and restart active Ediff sessions.
312 If you want Ediff to be loaded from the very beginning of your Emacs
313 session, you should put this line in your @file{~/.emacs} file:
320 Otherwise, Ediff will be loaded automatically when you use one of the
321 above functions, either directly or through the menus.
323 When the above functions are invoked, the user is prompted for all the
324 necessary information---typically the files or buffers to compare, merge, or
325 patch. Ediff tries to be smart about these prompts. For instance, in
326 comparing/merging files, it will offer the visible buffers as defaults. In
327 prompting for files, if the user enters a directory, the previously input
328 file name will be appended to that directory. In addition, if the variable
329 @code{ediff-use-last-dir} is not @code{nil}, Ediff will offer
330 previously entered directories as defaults (which will be maintained
331 separately for each type of file, A, B, or C).
332 @vindex @code{ediff-use-last-dir}
334 All the above functions use the POSIX @code{diff} or @code{diff3} programs
335 to find differences between two files. They process the @code{diff} output
336 and display it in a convenient form. At present, Ediff understands only
337 the plain output from diff. Options such as @samp{-c} are not supported,
338 nor is the format produced by incompatible file comparison programs such as
339 the VMS version of @code{diff}.
341 The functions @code{ediff-files}, @code{ediff-buffers},
342 @code{ediff-files3}, @code{ediff-buffers3} first display the coarse,
343 line-based difference regions, as reported by the @command{diff} program. The
344 total number of difference regions and the current difference number are
345 always displayed in the mode line of the control window.
347 Since @code{diff} may report fairly large chunks of text as being different,
348 even though the difference may be localized to just a few words or even
349 to the white space or line breaks, Ediff further @emph{refines} the
350 regions to indicate which exact words differ. If the only difference is
351 in the white space and line breaks, Ediff says so.
353 On a color display, fine differences are highlighted with color; on a
354 monochrome display, they are underlined. @xref{Highlighting Difference
355 Regions}, for information on how to customize this.
357 The functions @code{ediff-windows-wordwise},
358 @code{ediff-windows-linewise}, @code{ediff-regions-wordwise} and
359 @code{ediff-regions-linewise} do comparison on parts of existing Emacs
360 buffers. Since @code{ediff-windows-wordwise} and
361 @code{ediff-regions-wordwise} are intended for relatively small segments
362 of buffers, comparison is done on the basis of words rather than lines.
363 No refinement is necessary in this case. These commands are recommended
364 only for relatively small regions (perhaps, up to 100 lines), because
365 these functions have a relatively slow startup.
367 To compare large regions, use @code{ediff-regions-linewise}. This
368 command displays differences much like @code{ediff-files} and
369 @code{ediff-buffers}.
371 The functions @code{ediff-patch-file} and @code{ediff-patch-buffer} apply a
372 patch to a file or a buffer and then run Ediff on the appropriate
373 files/buffers, displaying the difference regions.
375 The entry points @code{ediff-directories}, @code{ediff-merge-directories},
376 etc., provide a convenient interface for comparing and merging files in
377 different directories. The user is presented with Dired-like interface from
378 which one can run a group of related Ediff sessions.
380 For files under version control, @code{ediff-revision} lets you compare
381 the file visited by the current buffer to one of its checked-in versions.
382 You can also compare two checked-in versions of the visited file.
383 Moreover, the functions @code{ediff-directory-revisions},
384 @code{ediff-merge-directory-revisions}, etc., let you run a group of
385 related Ediff sessions by taking a directory and comparing (or merging)
386 versions of files in that directory.
388 @node Session Commands, Registry of Ediff Sessions, Major Entry Points, Top
389 @chapter Session Commands
391 All Ediff commands are displayed in a Quick Help window, unless you type
392 @kbd{?} to shrink the window to just one line. You can redisplay the help
393 window by typing @kbd{?} again. The Quick Help commands are detailed below.
395 Many Ediff commands take numeric prefix arguments. For instance, if you
396 type a number, say 3, and then @kbd{j} (@code{ediff-jump-to-difference}),
397 Ediff moves to the third difference region. Typing 3 and then @kbd{a}
398 (@code{ediff-diff-to-diff}) copies the 3d difference region from variant A
399 to variant B. Likewise, 4 followed by @kbd{ra} restores the 4th difference
400 region in buffer A (if it was previously written over via the command
403 Some commands take negative prefix arguments as well. For instance, typing
404 @kbd{-} and then @kbd{j} will make the last difference region
405 current. Typing @kbd{-2} then @kbd{j} makes the penultimate difference
408 Without the prefix argument, all commands operate on the currently
409 selected difference region. You can make any difference region
410 current using the various commands explained below.
412 For some commands, the actual value of the prefix argument is
413 immaterial. However, if supplied, the prefix argument may modify the
414 command (see @kbd{ga}, @kbd{gb}, and @kbd{gc}).
417 * Quick Help Commands:: Frequently used commands.
418 * Other Session Commands:: Commands that are not bound to keys.
421 @node Quick Help Commands,Other Session Commands,,Session Commands
422 @section Quick Help Commands
426 Toggles the Ediff Quick Help window ON and OFF.
428 Prepares a mail buffer for sending a praise or a curse to the Ediff maintainer.
431 Brings up the top node of this manual, where you can find further
432 information on the various Ediff functions and advanced issues, such as
433 customization, session groups, etc.
436 Scrolls up buffers A and B (and buffer C where appropriate) in a
439 Scrolls the buffers down.
442 Scrolls the buffers to the left simultaneously.
444 Scrolls buffers to the right.
447 Saves the output from the diff utility, for further reference.
449 With prefix argument, saves the plain output from @command{diff} (see
450 @code{ediff-diff-program} and @code{ediff-diff-options}). Without the
451 argument, it saves customized @command{diff} output (see
452 @code{ediff-custom-diff-program} and @code{ediff-custom-diff-options}), if
456 Saves buffer A, if it was modified.
458 Saves buffer B, if it was modified.
460 Saves buffer C, if it was modified (if you are in a session that
461 compares three files simultaneously).
464 @emph{In comparison sessions:}
465 Copies the current difference region (or the region specified as the prefix
466 to this command) from buffer A to buffer B.
467 Ediff saves the old contents of buffer B's region; it can
468 be restored via the command @kbd{rb}, which see.
470 @emph{In merge sessions:}
471 Copies the current difference region (or the region specified as the prefix
472 to this command) from buffer A to the merge buffer. The old contents of
473 this region in buffer C can be restored via the command @kbd{r}.
476 Works similarly, but copies the current difference region from buffer B to
477 buffer A (in @emph{comparison sessions}) or the merge buffer (in
478 @emph{merge sessions}).
480 Ediff saves the old contents of the difference region copied over; it can
481 be reinstated via the command @kbd{ra} in comparison sessions and
482 @kbd{r} in merge sessions.
485 Copies the current difference region (or the region specified as the prefix
486 to this command) from buffer A to buffer B. This (and the next five)
487 command is enabled only in sessions that compare three files
488 simultaneously. The old region in buffer B is saved and can be restored
489 via the command @kbd{rb}.
491 Copies the difference region from buffer A to buffer C.
492 The old region in buffer C is saved and can be restored via the command
495 Copies the difference region from buffer B to buffer A.
496 The old region in buffer A is saved and can be restored via the command
499 Copies the difference region from buffer B to buffer C.
500 The command @kbd{rc} undoes this.
502 Copies the difference region from buffer C to buffer A.
503 The command @kbd{ra} undoes this.
505 Copies the difference region from buffer C to buffer B.
506 The command @kbd{rb} undoes this.
510 Makes the previous difference region current.
513 Makes the next difference region current.
518 Makes the very first difference region current.
520 @kbd{-j} makes the last region current. Typing a number, N, and then `j'
521 makes the difference region N current. Typing -N (a negative number) then
522 `j' makes current the region Last - N.
525 Makes current the difference region closest to the position of the point in
528 However, with a prefix argument, Ediff would position all variants
529 around the area indicated by the current point in buffer A: if
530 the point is inside a difference region, then the variants will be
531 positioned at this difference region. If the point is not in any difference
532 region, then it is in an area where all variants agree with each other. In
533 this case, the variants will be positioned so that each would display this
536 Makes current the difference region closest to the position of the point in
539 With a prefix argument, behaves like @kbd{ga}, but with respect to buffer B.
541 @emph{In merge sessions:}
542 makes current the difference region closest to the point in the merge buffer.
544 @emph{In 3-file comparison sessions:}
545 makes current the region closest to the point in buffer C.
547 With a prefix argument, behaves like @kbd{ga}, but with respect to buffer C.
550 Recomputes the difference regions, bringing them up to date. This is often
551 needed because it is common to do all sorts of editing during Ediff
552 sessions, so after a while, the highlighted difference regions may no
553 longer reflect the actual differences among the buffers.
556 Forces refinement of the current difference region, which highlights the exact
557 words of disagreement among the buffers. With a negative prefix argument,
558 unhighlights the current region.
560 Forceful refinement may be needed if Ediff encounters a difference region
561 that is larger than @code{ediff-auto-refine-limit}. In this situation,
562 Ediff doesn't do automatic refinement in order to improve response time.
563 (Ediff doesn't auto-refine on dumb terminals as well, but @kbd{*} still
564 works there. However, the only useful piece of information it can tell you
565 is whether or not the difference regions disagree only in the amount of
568 This command is also useful when the highlighted fine differences are
569 no longer current, due to user editing.
572 Displays the current Ediff session in a frame as wide as the physical
573 display. This is useful when comparing files side-by-side. Typing `m' again
574 restores the original size of the frame.
577 Toggles the horizontal/vertical split of the Ediff display. Horizontal
578 split is convenient when it is possible to compare files
579 side-by-side. If the frame in which files are displayed is too narrow
580 and lines are cut off, typing @kbd{m} may help some.
583 Toggles auto-refinement of difference regions (i.e., automatic highlighting
584 of the exact words that differ among the variants). Auto-refinement is
585 turned off on devices where Emacs doesn't support highlighting.
587 On slow machines, it may be advantageous to turn auto-refinement off. The
588 user can always forcefully refine specific difference regions by typing
592 Cycles between full highlighting, the mode where fine differences are not
593 highlighted (but computed), and the mode where highlighting is done with
594 ASCII strings. The latter is not really recommended, unless on a dumb TTY.
597 Restores the old contents of the region in the merge buffer.
598 (If you copied a difference region from buffer A or B into the merge buffer
599 using the commands @kbd{a} or @kbd{b}, Ediff saves the old contents of the
600 region in case you change your mind.)
602 This command is enabled in merge sessions only.
605 Restores the old contents of the current difference region in buffer A,
606 which was previously saved when the user invoked one of these commands:
607 @kbd{b}, @kbd{ba}, @kbd{ca}, which see. This command is enabled in
608 comparison sessions only.
610 Restores the old contents of the current difference region in buffer B,
611 which was previously saved when the user invoked one of these commands:
612 @kbd{a}, @kbd{ab}, @kbd{cb}, which see. This command is enabled in
613 comparison sessions only.
615 Restores the old contents of the current difference region in buffer C,
616 which was previously saved when the user invoked one of these commands:
617 @kbd{ac}, @kbd{bc}, which see. This command is enabled in 3-file
618 comparison sessions only.
621 Tell Ediff to skip over regions that disagree among themselves only in the
622 amount of white space and line breaks.
624 Even though such regions will be skipped over, you can still jump to any
625 one of them by typing the region number and then `j'. Typing @kbd{##}
626 again puts Ediff back in the original state.
630 Ediff works hard to ameliorate the effects of boredom in the workplace...
632 Quite often differences are due to identical replacements (e.g., the word
633 `foo' is replaced with the word `bar' everywhere). If the number of regions
634 with such boring differences exceeds your tolerance threshold, you may be
635 tempted to tell Ediff to skip these regions altogether (you will still be able
636 to jump to them via the command @kbd{j}). The above commands, @kbd{#h}
637 and @kbd{#f}, may well save your day!
639 @kbd{#h} prompts you to specify regular expressions for each
640 variant. Difference regions where each variant's region matches the
641 corresponding regular expression will be skipped from then on. (You can
642 also tell Ediff to skip regions where at least one variant matches its
645 @kbd{#f} does dual job: it focuses on regions that match the corresponding
646 regular expressions. All other regions will be skipped
647 over. @xref{Selective Browsing}, for more.
650 Toggles the read-only property in buffer A.
651 If file A is under version control and is checked in, it is checked out
652 (with your permission).
654 Toggles the read-only property in buffer B.
655 If file B is under version control and is checked in, it is checked out.
657 Toggles the read-only property in buffer C (in 3-file comparison sessions).
658 If file C is under version control and is checked in, it is checked out.
661 Swaps the windows where buffers A and B are displayed. If you are comparing
662 three buffers at once, then this command would rotate the windows among
666 Displays all kinds of useful data about the current Ediff session.
668 Runs @code{ediff-custom-diff-program} on the variants and displays the
669 buffer containing the output. This is useful when you must send the output
672 With a prefix argument, displays the plain @command{diff} output.
673 @xref{Patch and Diff Programs}, for details.
676 Displays a list of currently active Ediff sessions---the Ediff Registry.
677 You can then restart any of these sessions by either clicking on a session
678 record or by putting the cursor over it and then typing the return key.
680 (Some poor souls leave so many active Ediff sessions around that they loose
681 track of them completely... The `R' command is designed to save these
682 people from the recently discovered Ediff Proficiency Syndrome.)
684 Typing @kbd{R} brings up Ediff Registry only if it is typed into an Ediff
685 Control Panel. If you don't have a control panel handy, type this in the
686 minibuffer: @kbd{M-x eregistry}. @xref{Registry of Ediff Sessions}.
689 Shows the session group buffer that invoked the current Ediff session.
690 @xref{Session Groups}, for more information on session groups.
693 Suspends the current Ediff session. (If you develop a condition known as
694 Repetitive Ediff Injury---a serious but curable illness---you must change
695 your current activity. This command tries hard to hide all Ediff-related
698 The easiest way to resume a suspended Ediff session is through the registry
699 of active sessions. @xref{Registry of Ediff Sessions}, for details.
701 Terminates this Ediff session. With a prefix argument (e.g.,@kbd{1q}), asks
702 if you also want to delete the buffers of the variants.
703 Modified files and the results of merges are never deleted.
706 Toggles narrowing in Ediff buffers. Ediff buffers may be narrowed if you
707 are comparing only parts of these buffers via the commands
708 @code{ediff-windows-*} and @code{ediff-regions-*}, which see.
711 Restores the usual Ediff window setup. This is the quickest way to resume
712 an Ediff session, but it works only if the control panel of that session is
716 While merging with an ancestor file, Ediff is determined to reduce user's
717 wear and tear by saving him and her much of unproductive, repetitive
718 typing. If it notices that, say, file A's difference region is identical to
719 the same difference region in the ancestor file, then the merge buffer will
720 automatically get the difference region taken from buffer B. The rationale
721 is that this difference region in buffer A is as old as that in the
722 ancestor buffer, so the contents of that region in buffer B represents real
725 You may want to ignore such `obvious' merges and concentrate on difference
726 regions where both files `clash' with the ancestor, since this means that
727 two different people have been changing this region independently and they
728 had different ideas on how to do this.
730 The above command does this for you by skipping the regions where only one
731 of the variants clashes with the ancestor but the other variant agrees with
732 it. Typing @kbd{$$} again undoes this setting.
735 When merging files with large number of differences, it is sometimes
736 convenient to be able to skip the difference regions for which you already
737 decided which variant is most appropriate. Typing @kbd{$*} will accomplish
740 To be more precise, this toggles the check for whether the current merge is
741 identical to its default setting, as originally decided by Ediff. For
742 instance, if Ediff is merging according to the `combined' policy, then the
743 merge region is skipped over if it is different from the combination of the
744 regions in buffers A and B. (Warning: swapping buffers A and B will confuse
745 things in this respect). If the merge region is marked as `prefer-A' then
746 this region will be skipped if it differs from the current difference
747 region in buffer A, etc.
750 Displays the ancestor file during merges.
752 In some situations, such as when one of the files agrees with the ancestor file
753 on a difference region and the other doesn't, Ediff knows what to do: it copies
754 the current difference region from the second buffer into the merge buffer.
756 In other cases, the right course of action is not that clearcut, and Ediff
757 would use a default action. The above command changes the default action.
758 The default action can be @samp{default-A} (choose the region from buffer
759 A), @samp{default-B} (choose the region from buffer B), or @samp{combined}
760 (combine the regions from the two buffers).
761 @xref{Merging and diff3}, for further details.
763 The command @kbd{&} also affects the regions in the merge buffers that have
764 @samp{default-A}, @samp{default-B}, or @samp{combined} status, provided
765 they weren't changed with respect to the original. For instance, if such a
766 region has the status @samp{default-A} then changing the default action to
767 @samp{default-B} will also replace this merge-buffer's region with the
768 corresponding region from buffer B.
771 Causes the merge window shrink to its minimum size, thereby exposing as much
772 of the variant buffers as possible. Typing `s' again restores
773 the original size of that window.
775 With a positive prefix argument, this command enlarges the merge window.
776 E.g., @kbd{4s} increases the size of the window by about 4 lines, if
777 possible. With a negative numeric argument, the size of the merge window
778 shrinks by that many lines, if possible. Thus, @kbd{-s} shrinks the window
779 by about 1 line and @kbd{-3s} by about 3 lines.
781 This command is intended only for temporary viewing; therefore, Ediff
782 restores window C to its original size whenever it makes any other change
783 in the window configuration. However, redisplaying (@kbd{C-l}) or jumping
784 to another difference does not affect window C's size.
786 The split between the merge window and the variant windows is controlled by
787 the variable @code{ediff-merge-window-share}, which see.
790 Combines the difference regions from buffers A and B and copies the
791 result into the merge buffer. @xref{Merging and diff3}, and the
792 variables @code{ediff-combine-diffs} and @code{ediff-combination-pattern}.
796 You may run into situations when a large chunk of text in one file has been
797 edited and then moved to a different place in another file. In such a case,
798 these two chunks of text are unlikely to belong to the same difference
799 region, so the refinement feature of Ediff will not be able to tell you
800 what exactly differs inside these chunks. Since eyeballing large pieces of
801 text is contrary to human nature, Ediff has a special command to help
802 reduce the risk of developing a cataract.
804 The above command compares regions within Ediff buffers. This creates a
805 child Ediff session for comparing current Emacs regions in buffers A, B, or
808 @emph{If you are comparing 2 files or buffers:}
809 Ediff would compare current Emacs regions in buffers A and B.
811 @emph{If you are comparing 3 files or buffers simultaneously:} Ediff would
812 compare the current Emacs regions in the buffers of your choice (you will
813 be asked which two of the three buffers to use).
815 @emph{If you are merging files or buffers (with or without ancestor):}
816 Ediff would take the current region in the merge buffer and compare
817 it to the current region in the buffer of your choice (A or B).
819 Highlighting set by the parent Ediff session is removed, to avoid interference
820 with highlighting of the child session. When done with the child session, type
821 @kbd{C-l} in the parent's control panel to restore the original highlighting.
823 If you temporarily switch to the parent session, parent highlighting will be
824 restored. If you then come back to the child session, you may want to remove
825 parent highlighting, so it won't interfere. Typing @kbd{h} may help here.
829 @node Other Session Commands,,Quick Help Commands,Session Commands
830 @section Other Session Commands
832 The following commands can be invoked from within any Ediff session,
833 although some of them are not bound to a key.
837 @itemx ediff-show-registry
839 @findex ediff-show-registry
840 This command brings up the registry of active Ediff sessions. Ediff
841 registry is a device that can be used to resume any active Ediff session
842 (which may have been postponed because the user switched to some other
843 activity). This command is also useful for switching between multiple
844 active Ediff sessions that are run at the same time. The function
845 @code{eregistry} is an alias for @code{ediff-show-registry}.
846 @xref{Registry of Ediff Sessions}, for more information on this registry.
848 @item ediff-toggle-multiframe
849 @findex ediff-toggle-multiframe
850 Changes the display from the multi-frame mode (where the quick help window
851 is in a separate frame) to the single-frame mode (where all Ediff buffers
852 share the same frame), and vice versa. See
853 @code{ediff-window-setup-function} for details on how to make either of
854 these modes the default one.
856 This function can also be invoked from the Menubar. However, in some
857 cases, the change will take place only after you execute one of the Ediff
858 commands, such as going to the next difference or redisplaying.
860 @item ediff-revert-buffers-then-recompute-diffs
861 @findex ediff-revert-buffers-then-recompute-diffs
862 This command reverts the buffers you are comparing and recomputes their
863 differences. It is useful when, after making changes, you decided to
864 make a fresh start, or if at some point you changed the files being
865 compared but want to discard any changes to comparison buffers that were
868 This command normally asks for confirmation before reverting files.
869 With a prefix argument, it reverts files without asking.
873 @findex ediff-profile
874 Ediff has an admittedly primitive (but useful) facility for profiling
875 Ediff's commands. It is meant for Ediff maintenance---specifically, for
876 making it run faster. The function @code{ediff-profile} toggles
877 profiling of ediff commands.
880 @node Registry of Ediff Sessions, Session Groups, Session Commands, Top
881 @chapter Registry of Ediff Sessions
883 Ediff maintains a registry of all its invocations that are
884 still @emph{active}. This feature is very convenient for switching among
885 active Ediff sessions or for quickly restarting a suspended Ediff session.
887 The focal point of this activity is a buffer
888 called @emph{*Ediff Registry*}. You can display this buffer by typing
889 @kbd{R} in any Ediff Control Buffer or Session Group Buffer
890 (@pxref{Session Groups}), or by typing
891 @kbd{M-x eregistry} into the Minibuffer.
892 The latter would be the fastest way to bring up the registry
893 buffer if no control or group buffer is displayed in any of the visible
895 If you are in a habit of running multiple long Ediff sessions and often need to
896 suspend, resume, or switch between them, it may be a good idea to have the
897 registry buffer permanently displayed in a separate, dedicated window.
899 The registry buffer has several convenient key bindings.
900 For instance, clicking mouse button 2 or typing
901 @kbd{RET} or @kbd{v} over any session record resumes that session.
902 Session records in the registry buffer provide a fairly complete
903 description of each session, so it is usually easy to identify the right
906 Other useful commands are bound to @kbd{SPC} (next registry record)
907 and @kbd{DEL} (previous registry record). There are other commands as well,
908 but you don't need to memorize them, since they are listed at the top of
911 @node Session Groups, Remote and Compressed Files, Registry of Ediff Sessions, Top
912 @chapter Session Groups
914 Several major entries of Ediff perform comparison and merging on
915 directories. On entering @code{ediff-directories},
916 @code{ediff-directories3},
917 @code{ediff-merge-directories},
918 @code{ediff-merge-directories-with-ancestor},
919 @code{ediff-directory-revisions},
920 @code{ediff-merge-directory-revisions}, or
921 @code{ediff-merge-directory-revisions-with-ancestor},
922 the user is presented with a
923 Dired-like buffer that lists files common to the directories involved along
924 with their sizes. (The list of common files can be further filtered through
925 a regular expression, which the user is prompted for.) We call this buffer
926 @emph{Session Group Panel} because all Ediff sessions associated with the
927 listed files will have this buffer as a common focal point.
929 Clicking button 2 or typing @kbd{RET} or @kbd{v} over a
930 record describing files invokes Ediff in the appropriate mode on these
931 files. You can come back to the session group buffer associated with a
932 particular invocation of Ediff by typing @kbd{M} in Ediff control buffer of
935 Many commands are available in the session group buffer; some are
936 applicable only to certain types of work. The relevant commands are always
937 listed at the top of each session group buffer, so there is no need to
940 In directory comparison or merging, a session group panel displays only the
941 files common to all directories involved. The differences are kept in a
942 separate buffer and are conveniently displayed by typing @kbd{D} to the
943 corresponding session group panel. Thus, as an added benefit, Ediff can be
944 used to compare the contents of up to three directories.
946 Session records in session group panels are also marked with @kbd{+}, for
947 active sessions, and with @kbd{-}, for finished sessions.
949 Sometimes, it is convenient to exclude certain sessions from a group.
950 Usually this happens when the user doesn't intend to run Ediff of certain
951 files in the group, and the corresponding session records just add clutter
952 to the session group buffer. To help alleviate this problem, the user can
953 type @kbd{h} to mark a session as a candidate for exclusion and @kbd{x} to
954 actually hide the marked sessions. There actions are reversible: with a
955 prefix argument, @kbd{h} unmarks the session under the cursor, and @kbd{x}
956 brings the hidden sessions into the view (@kbd{x} doesn't unmark them,
957 though, so the user has to explicitly unmark the sessions of interest).
959 Group sessions also understand the command @kbd{m}, which marks sessions
960 for future operations (other than hiding) on a group of sessions. At present,
961 the only such group-level operation is the creation of a multi-file patch.
963 @vindex ediff-autostore-merges
964 For group sessions created to merge files, Ediff can store all merges
965 automatically in a directory. The user is asked to specify such directory
966 if the value of @code{ediff-autostore-merges} is non-nil. If the value is
967 @code{nil}, nothing is done to the merge buffers---it will be the user's
968 responsibility to save them. If the value is @code{t}, the user will be
969 asked where to save the merge buffers in all merge jobs, even those that do
970 not originate from a session group. It the value is neither @code{nil} nor
971 @code{t}, the merge buffer is saved @emph{only} if this merge session was
972 invoked from a session group. This behavior is implemented in the function
973 @code{ediff-maybe-save-and-delete-merge}, which is a hook in
974 @code{ediff-quit-merge-hook}. The user can supply a different hook, if
977 The variable @code{ediff-autostore-merges} is buffer-local, so it can be
978 set on a per-buffer basis. Therefore, use @code{setq-default} to change
979 this variable globally.
981 @cindex Multi-file patches
982 A multi-file patch is a concatenated output of several runs of the Unix
983 @command{diff} command (some versions of @command{diff} let you create a
984 multi-file patch in just one run). Ediff facilitates creation of
985 multi-file patches as follows. If you are in a session group buffer
986 created in response to @code{ediff-directories} or
987 @code{ediff-directory-revisions}, you can mark (by typing @kbd{m}) the
988 desired Ediff sessions and then type @kbd{P} to create a
989 multi-file patch of those marked sessions.
990 Ediff will then display a buffer containing the patch.
991 The patch is generated by invoking @command{diff} on all marked individual
992 sessions (represented by files) and session groups (represented by
993 directories). Ediff will also recursively descend into any @emph{unmarked}
994 session group and will search for marked sessions there. In this way, you
995 can create multi-file patches that span file subtrees that grow out of
998 In an @code{ediff-directories} session, it is enough to just mark the
999 requisite sessions. In @code{ediff-directory-revisions} revisions, the
1000 marked sessions must also be active, or else Ediff will refuse to produce a
1001 multi-file patch. This is because, in the latter-style sessions, there are
1002 many ways to create diff output, and it is easier to handle by running
1003 Ediff on the inactive sessions.
1005 Last, but not least, by typing @kbd{=}, you can quickly find out which
1006 sessions have identical files, so you won't have to run Ediff on those
1007 sessions. This, however, works only on local, uncompressed files.
1008 For compressed or remote files, this command won't report anything.
1011 @node Remote and Compressed Files, Customization, Session Groups, Top
1012 @chapter Remote and Compressed Files
1014 Ediff works with remote, compressed, and encrypted files. Ediff
1015 supports @file{ange-ftp.el}, @file{jka-compr.el}, @file{uncompress.el}
1016 and @file{crypt++.el}, but it may work with other similar packages as
1017 well. This means that you can compare files residing on another
1018 machine, or you can apply a patch to a file on another machine. Even
1019 the patch itself can be a remote file!
1021 When patching compressed or remote files, Ediff does not rename the source
1022 file (unlike what the @code{patch} utility would usually do). Instead, the
1023 source file retains its name and the result of applying the patch is placed
1024 in a temporary file that has the suffix @file{_patched} attached.
1025 Generally, this applies to files that are handled using black magic, such
1026 as special file handlers (ange-ftp and some compression and encryption
1027 packages also use this method).
1029 Regular files are treated by the @code{patch} utility in the usual manner,
1030 i.e., the original is renamed into @file{source-name.orig} and the result
1031 of the patch is placed into the file source-name (@file{_orig} is used
1032 on systems like VMS, DOS, etc.)
1034 @node Customization, Credits, Remote and Compressed Files, Top
1035 @chapter Customization
1037 Ediff has a rather self-explanatory interface, and in most cases you
1038 won't need to change anything. However, should the need arise, there are
1039 extensive facilities for changing the default behavior.
1041 Most of the customization can be done by setting various variables in the
1042 @file{.emacs} file. Some customization (mostly window-related
1043 customization and faces) can be done by putting appropriate lines in
1044 @file{.Xdefaults}, @file{.xrdb}, or whatever X resource file is in use.
1046 With respect to the latter, please note that the X resource
1047 for Ediff customization is `Ediff', @emph{not} `emacs'.
1048 @xref{Window and Frame Configuration},
1049 @xref{Highlighting Difference Regions}, for further details. Please also
1050 refer to Emacs manual for the information on how to set Emacs X resources.
1053 * Hooks:: Customization via the hooks.
1054 * Quick Help Customization:: How to customize Ediff's quick help feature.
1055 * Window and Frame Configuration:: Controlling the way Ediff displays things.
1056 * Selective Browsing:: Advanced browsing through difference regions.
1057 * Highlighting Difference Regions:: Controlling highlighting.
1058 * Narrowing:: Comparing regions, windows, etc.
1059 * Refinement of Difference Regions:: How to control the refinement process.
1060 * Patch and Diff Programs:: Changing the utilities that compute differences
1062 * Merging and diff3:: How to customize Ediff in its Merge Mode.
1063 * Support for Version Control:: Changing the version control package.
1064 You are not likely to do that.
1065 * Customizing the Mode Line:: Changing the look of the mode line in Ediff.
1066 * Miscellaneous:: Other customization.
1067 * Notes on Heavy-duty Customization:: Customization for the gurus.
1070 @node Hooks, Quick Help Customization, Customization, Customization
1073 The bulk of customization can be done via the following hooks:
1076 @item ediff-load-hook
1077 @vindex ediff-load-hook
1078 This hook can be used to change defaults after Ediff is loaded.
1080 @item ediff-keymap-setup-hook
1081 @vindex ediff-keymap-setup-hook
1082 @vindex ediff-mode-map
1083 This hook can be used to alter bindings in Ediff's keymap,
1084 @code{ediff-mode-map}. These hooks are
1085 run right after the default bindings are set but before
1086 @code{ediff-load-hook}. The regular user needs not be concerned with this
1087 hook---it is provided for implementors of other Emacs packages built on top
1090 @item ediff-before-setup-windows-hook
1091 @itemx ediff-after-setup-windows-hook
1092 @vindex ediff-before-setup-windows-hook
1093 @vindex ediff-after-setup-windows-hook
1094 These two hooks are called before and after Ediff sets up its window
1095 configuration. Can be used to save the configuration that existed
1096 before Ediff starts or for whatever other purposes.
1098 @item ediff-suspend-hook
1099 @itemx ediff-quit-hook
1100 @vindex ediff-suspend-hook
1101 @vindex ediff-quit-hook
1102 These two hooks are run when you suspend or quit Ediff. They can be
1103 used to set desired window configurations, delete files Ediff didn't
1104 want to clean up after exiting, etc.
1106 By default, @code{ediff-quit-hook} holds one hook function,
1107 @code{ediff-cleanup-mess}, which cleans after Ediff, as appropriate in
1108 most cases. You probably won't want to change it, but you might
1109 want to add other hook functions.
1111 Keep in mind that hooks executing before @code{ediff-cleanup-mess} start
1112 in @code{ediff-control-buffer;} they should also leave
1113 @code{ediff-control-buffer} as the current buffer when they finish.
1114 Hooks that are executed after @code{ediff-cleanup-mess} should expect
1115 the current buffer be either buffer A or buffer B.
1116 @code{ediff-cleanup-mess} doesn't kill the buffers being compared or
1117 merged (see @code{ediff-cleanup-hook}, below).
1119 @item ediff-cleanup-hook
1120 @vindex ediff-cleanup-hook
1121 This hook is run just before @code{ediff-quit-hook}. This is a good
1122 place to do various cleanups, such as deleting the variant buffers.
1123 Ediff provides a function, @code{ediff-janitor}, as one such possible
1124 hook, which you can add to @code{ediff-cleanup-hook} with
1127 @findex ediff-janitor
1128 This function kills buffers A, B, and, possibly, C, if these buffers aren't
1129 modified. In merge jobs, buffer C is never deleted. However, the side
1130 effect of using this function is that you may not be able to compare the
1131 same buffer in two separate Ediff sessions: quitting one of them will
1132 delete this buffer in another session as well.
1134 @item ediff-quit-merge-hook
1135 @vindex ediff-quit-merge-hook
1136 @vindex ediff-autostore-merges
1137 @findex ediff-maybe-save-and-delete-merge
1138 This hook is called when Ediff quits a merge job. By default, the value is
1139 @code{ediff-maybe-save-and-delete-merge}, which is a function that attempts
1140 to save the merge buffer according to the value of
1141 @code{ediff-autostore-merges}, as described later.
1143 @item ediff-before-setup-control-frame-hook
1144 @itemx ediff-after-setup-control-frame-hook
1145 @vindex ediff-before-setup-control-frame-hook
1146 @vindex ediff-after-setup-control-frame-hook
1147 These two hooks run before and after Ediff sets up the control frame.
1148 They can be used to relocate Ediff control frame when Ediff runs in a
1149 multiframe mode (i.e., when the control buffer is in its own dedicated
1150 frame). Be aware that many variables that drive Ediff are local to
1151 Ediff Control Panel (@code{ediff-control-buffer}), which requires
1152 special care in writing these hooks. Take a look at
1153 @code{ediff-default-suspend-hook} and @code{ediff-default-quit-hook} to
1154 see what's involved.
1156 @item ediff-startup-hook
1157 @vindex ediff-startup-hook
1158 This hook is run at the end of Ediff startup.
1160 @item ediff-select-hook
1161 @vindex ediff-select-hook
1162 This hook is run after Ediff selects the next difference region.
1164 @item ediff-unselect-hook
1165 @vindex ediff-unselect-hook
1166 This hook is run after Ediff unselects the current difference region.
1168 @item ediff-prepare-buffer-hook
1169 @vindex ediff-prepare-buffer-hook
1170 This hook is run for each Ediff buffer (A, B, C) right after the buffer
1173 @item ediff-display-help-hook
1174 @vindex ediff-display-help-hook
1175 Ediff runs this hook each time after setting up the help message. It
1176 can be used to alter the help message for custom packages that run on
1179 @item ediff-mode-hook
1180 @vindex ediff-mode-hook
1181 This hook is run just after Ediff mode is set up in the control
1182 buffer. This is done before any Ediff window is created. You can use it to
1183 set local variables that alter the look of the display.
1185 @item ediff-registry-setup-hook
1186 @vindex ediff-registry-setup-hook
1187 Hooks run after setting up the registry for all active Ediff session.
1188 @xref{Session Groups}, for details.
1189 @item ediff-session-group-setup-hook
1190 @vindex ediff-session-group-setup-hook
1191 Hooks run after setting up a control panel for a group of related Ediff
1192 sessions. @xref{Session Groups}, for details.
1193 @item ediff-quit-session-group-hook
1194 @vindex ediff-quit-session-group-hook
1195 Hooks run just before exiting a session group.
1196 @item ediff-meta-buffer-keymap-setup-hook
1197 @vindex ediff-meta-buffer-keymap-setup-hook
1198 @vindex ediff-meta-buffer-map
1199 Hooks run just after setting up the @code{ediff-meta-buffer-map} --- the
1200 map that controls key bindings in the meta buffer. Since
1201 @code{ediff-meta-buffer-map} is a local variable, you can set different
1202 bindings for different kinds of meta buffers.
1205 @node Quick Help Customization, Window and Frame Configuration, Hooks, Customization
1206 @section Quick Help Customization
1207 @vindex ediff-use-long-help-message
1208 @vindex ediff-control-buffer
1209 @vindex ediff-startup-hook
1210 @vindex ediff-help-message
1212 Ediff provides quick help using its control panel window. Since this window
1213 takes a fair share of the screen real estate, you can toggle it off by
1214 typing @kbd{?}. The control window will then shrink to just one line and a
1215 mode line, displaying a short help message.
1217 The variable @code{ediff-use-long-help-message} tells Ediff whether
1218 you use the short message or the long one. By default, it
1219 is set to @code{nil}, meaning that the short message is used.
1220 Set this to @code{t}, if you want Ediff to use the long
1221 message by default. This property can always be changed interactively, by
1222 typing @kbd{?} into Ediff Control Buffer.
1224 If you want to change the appearance of the help message on a per-buffer
1225 basis, you must use @code{ediff-startup-hook} to change the value of
1226 the variable @code{ediff-help-message}, which is local to
1227 @code{ediff-control-buffer}.
1229 @node Window and Frame Configuration, Selective Browsing, Quick Help Customization, Customization
1230 @section Window and Frame Configuration
1232 On a non-windowing display, Ediff sets things up in one frame, splitting
1233 it between a small control window and the windows for buffers A, B, and C.
1234 The split between these windows can be horizontal or
1235 vertical, which can be changed interactively by typing @kbd{|} while the
1236 cursor is in the control window.
1238 On a window display, Ediff sets up a dedicated frame for Ediff Control
1239 Panel and then it chooses windows as follows: If one of the buffers
1240 is invisible, it is displayed in the currently selected frame. If
1241 a buffer is visible, it is displayed in the frame where it is visible.
1242 If, according to the above criteria, the two buffers fall into the same
1243 frame, then so be it---the frame will be shared by the two. The same
1244 algorithm works when you type @kbd{C-l} (@code{ediff-recenter}), @kbd{p}
1245 (@code{ediff-previous-difference}), @kbd{n}
1246 (@code{ediff-next-difference}), etc.
1248 The above behavior also depends on whether the current frame is splittable,
1249 dedicated, etc. Unfortunately, the margin of this book is too narrow to
1250 present the details of this remarkable algorithm.
1252 The upshot of all this is that you can compare buffers in one frame or
1253 in different frames. The former is done by default, while the latter can
1254 be achieved by arranging buffers A, B (and C, if applicable) to be seen in
1255 different frames. Ediff respects these arrangements, automatically
1256 adapting itself to the multi-frame mode.
1258 Ediff uses the following variables to set up its control panel
1259 (a.k.a.@: control buffer, a.k.a.@: quick help window):
1262 @item ediff-control-frame-parameters
1263 @vindex ediff-control-frame-parameters
1264 You can change or augment this variable including the font, color,
1265 etc. The X resource name of Ediff Control Panel frames is @samp{Ediff}. Under
1266 X-windows, you can use this name to set up preferences in your
1267 @file{~/.Xdefaults}, @file{~/.xrdb}, or whatever X resource file is in
1268 use. Usually this is preferable to changing
1269 @code{ediff-control-frame-parameters} directly. For instance, you can
1270 specify in @file{~/.Xdefaults} the color of the control frame
1271 using the resource @samp{Ediff*background}.
1273 In general, any X resource pertaining the control frame can be reached
1274 via the prefix @code{Ediff*}.
1276 @item ediff-control-frame-position-function
1277 @vindex ediff-control-frame-position-function
1278 The preferred way of specifying the position of the control frame is by
1279 setting the variable @code{ediff-control-frame-position-function} to an
1280 appropriate function.
1281 The default value of this variable is
1282 @code{ediff-make-frame-position}. This function places the control frame in
1283 the vicinity of the North-East corner of the frame displaying buffer A.
1285 @findex ediff-make-frame-position
1288 The following variables can be used to adjust the location produced by
1289 @code{ediff-make-frame-position} and for related customization.
1292 @item ediff-narrow-control-frame-leftward-shift
1293 @vindex ediff-narrow-control-frame-leftward-shift
1294 Specifies the number of characters for shifting
1295 the control frame from the rightmost edge of frame A when the control
1296 frame is displayed as a small window.
1298 @item ediff-wide-control-frame-rightward-shift
1299 @vindex ediff-wide-control-frame-rightward-shift
1300 Specifies the rightward shift of the control frame
1301 from the left edge of frame A when the control frame shows the full
1304 @item ediff-control-frame-upward-shift
1305 @vindex ediff-control-frame-upward-shift
1306 Specifies the number of pixels for the upward shift
1307 of the control frame.
1309 @item ediff-prefer-iconified-control-frame
1310 @vindex ediff-prefer-iconified-control-frame
1311 If this variable is @code{t}, the control frame becomes iconified
1312 automatically when you toggle the quick help message off. This saves
1313 valuable real estate on the screen. Toggling help back will deiconify
1316 To start Ediff with an iconified Control Panel, you should set this
1317 variable to @code{t} and @code{ediff-prefer-long-help-message} to
1318 @code{nil} (@pxref{Quick Help Customization}). This behavior is useful
1319 only if icons are allowed to accept keybord input (which depend on the
1320 window manager and other factors).
1323 @findex ediff-setup-windows
1324 To make more creative changes in the way Ediff sets up windows, you can
1325 rewrite the function @code{ediff-setup-windows}. However, we believe
1326 that detaching Ediff Control Panel from the rest and making it into a
1327 separate frame offers an important opportunity by allowing you to
1328 iconify that frame. The icon will usually accept all of the Ediff
1329 commands, but will free up valuable real estate on your screen (this may
1330 depend on your window manager, though).
1332 The following variable controls how windows are set up:
1335 @item ediff-window-setup-function
1336 @vindex ediff-window-setup-function
1337 The multiframe setup is done by the
1338 @code{ediff-setup-windows-multiframe} function, which is the default on
1339 windowing displays. The plain setup, one where all windows are always
1340 in one frame, is done by @code{ediff-setup-windows-plain}, which is the
1341 default on a non-windowing display (or in an xterm window). In fact,
1342 under Emacs, you can switch freely between these two setups by executing
1343 the command @code{ediff-toggle-multiframe} using the Minibuffer of the
1345 @findex ediff-setup-windows-multiframe
1346 @findex ediff-setup-windows-plain
1347 @findex ediff-toggle-multiframe
1349 If you don't like any of these setups, write your own function. See the
1350 documentation for @code{ediff-window-setup-function} for the basic
1351 guidelines. However, writing window setups is not easy, so you should
1352 first take a close look at @code{ediff-setup-windows-plain} and
1353 @code{ediff-setup-windows-multiframe}.
1356 You can run multiple Ediff sessions at once, by invoking Ediff several
1357 times without exiting previous Ediff sessions. Different sessions
1358 may even operate on the same pair of files.
1360 Each session has its own Ediff Control Panel and all the regarding a
1361 particular session is local to the associated control panel buffer. You
1362 can switch between sessions by suspending one session and then switching
1363 to another control panel. (Different control panel buffers are
1364 distinguished by a numerical suffix, e.g., @samp{Ediff Control Panel<3>}.)
1366 @node Selective Browsing, Highlighting Difference Regions, Window and Frame Configuration, Customization
1367 @section Selective Browsing
1369 Sometimes it is convenient to be able to step through only some difference
1370 regions, those that match certain regular expressions, and to ignore all
1371 others. On other occasions, you may want to ignore difference regions that
1372 match some regular expressions, and to look only at the rest.
1374 The commands @kbd{#f} and @kbd{#h} let you do precisely this.
1376 Typing @kbd{#f} lets you specify regular expressions that match difference
1377 regions you want to focus on.
1378 We shall call these regular expressions @var{regexp-A}, @var{regexp-B} and
1380 Ediff will then start stepping through only those difference regions
1381 where the region in buffer A matches @var{regexp-A} and/or the region in
1382 buffer B matches @var{regexp-B}, etc. Whether `and' or `or' will be used
1383 depends on how you respond to a question.
1385 When scanning difference regions for the aforesaid regular expressions,
1386 Ediff narrows the buffers to those regions. This means that you can use
1387 the expressions @kbd{\`} and @kbd{\'} to tie search to the beginning or end
1388 of the difference regions.
1390 On the other hand, typing @kbd{#h} lets you specify (hide) uninteresting
1391 regions. That is, if a difference region in buffer A matches
1392 @var{regexp-A}, the corresponding region in buffer B matches @var{regexp-B}
1393 and (if applicable) buffer C's region matches @var{regexp-C}, then the
1394 region will be ignored by the commands @kbd{n}/@key{SPC}
1395 (@code{ediff-next-difference}) and @kbd{p}/@key{DEL}
1396 (@code{ediff-previous-difference}) commands.
1398 Typing @kbd{#f} and @kbd{#h} toggles selective browsing on and off.
1400 Note that selective browsing affects only @code{ediff-next-difference}
1401 and @code{ediff-previous-difference}, i.e., the commands
1402 @kbd{n}/@key{SPC} and @kbd{p}/@key{DEL}. @kbd{#f} and @kbd{#h} do not
1403 change the position of the point in the buffers. And you can still jump
1404 directly (using @kbd{j}) to any numbered
1407 Users can supply their own functions to specify how Ediff should do
1408 selective browsing. To change the default Ediff function, add a function to
1409 @code{ediff-load-hook} which will do the following assignments:
1412 (setq ediff-hide-regexp-matches-function 'your-hide-function)
1413 (setq ediff-focus-on-regexp-matches-function 'your-focus-function)
1416 @strong{Useful hint}: To specify a regexp that matches everything, don't
1417 simply type @key{RET} in response to a prompt. Typing @key{RET} tells Ediff
1418 to accept the default value, which may not be what you want. Instead, you
1419 should enter something like @key{^} or @key{$}. These match every
1422 You can use the status command, @kbd{i}, to find out whether
1423 selective browsing is currently in effect.
1425 The regular expressions you specified are kept in the local variables
1426 @code{ediff-regexp-focus-A}, @code{ediff-regexp-focus-B},
1427 @code{ediff-regexp-focus-C}, @code{ediff-regexp-hide-A},
1428 @code{ediff-regexp-hide-B}, @code{ediff-regexp-hide-C}. Their default value
1429 is the empty string (i.e., nothing is hidden or focused on). To change the
1430 default, set these variables in @file{.emacs} using @code{setq-default}.
1432 In addition to the ability to ignore regions that match regular
1433 expressions, Ediff can be ordered to start skipping over certain
1434 ``uninteresting'' difference regions. This is controlled by the following
1438 @item ediff-ignore-similar-regions
1439 @vindex ediff-ignore-similar-regions
1440 If @code{t}, causes Ediff to skip over "uninteresting" difference regions,
1441 which are the regions where the variants differ only in the amount of the
1442 white space and newlines. This feature can be toggled on/off interactively,
1443 via the command @kbd{##}.
1446 @strong{Note:} In order for this feature to work, auto-refining of
1447 difference regions must be on, since otherwise Ediff won't know if there
1448 are fine differences between regions. On devices where Emacs can display
1449 faces, auto-refining is a default, but it is not turned on by default on
1450 text-only terminals. In that case, you must explicitly turn auto-refining
1451 on (such as, by typing @kbd{@@}).
1453 @strong{Reassurance:} If many such uninteresting regions appear in a row,
1454 Ediff may take a long time to skip over them because it has to compute fine
1455 differences of all intermediate regions. This delay does not indicate any
1458 @node Highlighting Difference Regions, Narrowing, Selective Browsing, Customization
1459 @section Highlighting Difference Regions
1461 The following variables control the way Ediff highlights difference
1465 @item ediff-before-flag-bol
1466 @itemx ediff-after-flag-eol
1467 @itemx ediff-before-flag-mol
1468 @itemx ediff-after-flag-mol
1469 @vindex ediff-before-flag-bol
1470 @vindex ediff-after-flag-eol
1471 @vindex ediff-before-flag-mol
1472 @vindex ediff-after-flag-mol
1473 These variables hold strings that Ediff uses to mark the beginning and the
1474 end of the differences found in files A, B, and C on devices where Emacs
1475 cannot display faces. Ediff uses different flags to highlight regions that
1476 begin/end at the beginning/end of a line or in a middle of a line.
1478 @item ediff-current-diff-face-A
1479 @itemx ediff-current-diff-face-B
1480 @itemx ediff-current-diff-face-C
1481 @vindex ediff-current-diff-face-A
1482 @vindex ediff-current-diff-face-B
1483 @vindex ediff-current-diff-face-C
1484 Ediff uses these faces to highlight current differences on devices where
1485 Emacs can display faces. These and subsequently described faces can be set
1486 either in @file{.emacs} or in @file{.Xdefaults}. The X resource for Ediff
1487 is @samp{Ediff}, @emph{not} @samp{emacs}. Please refer to Emacs manual for
1488 the information on how to set X resources.
1489 @item ediff-fine-diff-face-A
1490 @itemx ediff-fine-diff-face-B
1491 @itemx ediff-fine-diff-face-C
1492 @vindex ediff-fine-diff-face-A
1493 @vindex ediff-fine-diff-face-B
1494 @vindex ediff-fine-diff-face-C
1495 Ediff uses these faces to show the fine differences between the current
1496 differences regions in buffers A, B, and C, respectively.
1498 @item ediff-even-diff-face-A
1499 @itemx ediff-even-diff-face-B
1500 @itemx ediff-even-diff-face-C
1501 @itemx ediff-odd-diff-face-A
1502 @itemx ediff-odd-diff-face-B
1503 @itemx ediff-odd-diff-face-C
1504 @vindex ediff-even-diff-face-A
1505 @vindex ediff-even-diff-face-B
1506 @vindex ediff-even-diff-face-C
1507 @vindex ediff-odd-diff-face-A
1508 @vindex ediff-odd-diff-face-B
1509 @vindex ediff-odd-diff-face-C
1510 Non-current difference regions are displayed using these alternating
1511 faces. The odd and the even faces are actually identical on monochrome
1512 displays, because without colors options are limited.
1513 So, Ediff uses italics to highlight non-current differences.
1515 @item ediff-force-faces
1516 @vindex ediff-force-faces
1517 Ediff generally can detect when Emacs is running on a device where it can
1518 use highlighting with faces. However, if it fails to determine that faces
1519 can be used, the user can set this variable to @code{t} to make sure that
1520 Ediff uses faces to highlight differences.
1522 @item ediff-highlight-all-diffs
1523 @vindex ediff-highlight-all-diffs
1524 Indicates whether---on a windowind display---Ediff should highlight
1525 differences using inserted strings (as on text-only terminals) or using
1526 colors and highlighting. Normally, Ediff highlights all differences, but
1527 the selected difference is highlighted more visibly. One can cycle through
1528 various modes of highlighting by typing @kbd{h}. By default, Ediff starts
1529 in the mode where all difference regions are highlighted. If you prefer to
1530 start in the mode where unselected differences are not highlighted, you
1531 should set @code{ediff-highlight-all-diffs} to @code{nil}. Type @kbd{h} to
1532 restore highlighting for all differences.
1534 Ediff lets you switch between the two modes of highlighting. That is,
1535 you can switch interactively from highlighting using faces to
1536 highlighting using string flags, and back. Of course, switching has
1537 effect only under a windowing system. On a text-only terminal or in an
1538 xterm window, the only available option is highlighting with strings.
1542 If you want to change the default settings for @code{ediff-force-faces} and
1543 @code{ediff-highlight-all-diffs}, you must do it @strong{before} Ediff is
1546 You can also change the defaults for the faces used to highlight the
1547 difference regions. There are two ways to do this. The simplest and the
1548 preferred way is to use the customization widget accessible from the
1549 menubar. Ediff's customization group is located under "Tools", which in
1550 turn is under "Programming". The faces that are used to highlight
1551 difference regions are located in the "Highlighting" subgroup of the Ediff
1552 customization group.
1554 The second, much more arcane, method to change default faces is to include
1555 some Lisp code in @file{~/.emacs}. For instance,
1558 (setq ediff-current-diff-face-A
1559 (copy-face 'bold-italic 'ediff-current-diff-face-A))
1563 would use the pre-defined fase @code{bold-italic} to highlight the current
1564 difference region in buffer A (this face is not a good choice, by the way).
1566 If you are unhappy with just @emph{some} of the aspects of the default
1567 faces, you can modify them when Ediff is being loaded using
1568 @code{ediff-load-hook}. For instance:
1571 (add-hook 'ediff-load-hook
1573 (set-face-foreground
1574 ediff-current-diff-face-B "blue")
1575 (set-face-background
1576 ediff-current-diff-face-B "red")
1578 ediff-current-diff-face-B)))
1581 @strong{Note:} To set Ediff's faces, use only @code{copy-face} or
1582 @code{set/make-face-@dots{}} as shown above. Emacs' low-level
1583 face-manipulation functions should be avoided.
1585 @node Narrowing, Refinement of Difference Regions, Highlighting Difference Regions, Customization
1588 If buffers being compared are narrowed at the time of invocation of
1589 Ediff, @code{ediff-buffers} will preserve the narrowing range. However,
1590 if @code{ediff-files} is invoked on the files visited by these buffers,
1591 that would widen the buffers, since this command is defined to compare the
1594 Calling @code{ediff-regions-linewise} or @code{ediff-windows-linewise}, or
1595 the corresponding @samp{-wordwise} commands, narrows the variants to the
1596 particular regions being compared. The original accessible ranges are
1597 restored when you quit Ediff. During the command, you can toggle this
1598 narrowing on and off with the @kbd{%} command.
1600 These two variables control this narrowing behavior:
1603 @item ediff-start-narrowed
1604 @vindex ediff-start-narrowed
1605 If @code{t}, Ediff narrows the display to the appropriate range when it
1606 is invoked with an @samp{ediff-regions@dots{}} or
1607 @samp{ediff-windows@dots{}} command. If @code{nil}, these commands do
1608 not automatically narrow, but you can still toggle narrowing on and off
1611 @item ediff-quit-widened
1612 @vindex ediff-quit-widened
1613 Controls whether on quitting Ediff should restore the accessible range
1614 that existed before the current invocation.
1617 @node Refinement of Difference Regions, Patch and Diff Programs, Narrowing, Customization
1618 @section Refinement of Difference Regions
1620 Ediff has variables to control the way fine differences are
1621 highlighted. This feature gives you control over the process of refinement.
1622 Note that refinement ignores spaces, tabs, and newlines.
1625 @item ediff-auto-refine
1626 @vindex ediff-auto-refine
1627 This variable controls whether fine differences within regions are
1628 highlighted automatically (``auto-refining''). The default is yes
1631 On a slow machine, automatic refinement may be painful. In that case,
1632 you can turn auto-refining on or off interactively by typing
1633 @kbd{@@}. You can also turn off display of refining that has
1636 When auto-refining is off, fine differences are shown only for regions
1637 for which these differences have been computed and saved before. If
1638 auto-refining and display of refining are both turned off, fine
1639 differences are not shown at all.
1641 Typing @kbd{*} computes and displays fine differences for the current
1642 difference region, regardless of whether auto-refining is turned on.
1644 @item ediff-auto-refine-limit
1645 @vindex ediff-auto-refine-limit
1646 If auto-refining is on, this variable limits the size of the regions to
1647 be auto-refined. This guards against the possible slowdown that may be
1648 caused by extraordinary large difference regions.
1650 You can always refine the current region by typing @kbd{*}.
1652 @item ediff-forward-word-function
1653 @vindex ediff-forward-word-function
1654 This variable controls how fine differences are computed. The
1655 value must be a Lisp function that determines how the current difference
1656 region should be split into words.
1658 @vindex ediff-diff-program
1659 @vindex ediff-forward-word-function
1660 @findex ediff-forward-word
1661 Fine differences are computed by first splitting the current difference
1662 region into words and then passing the result to
1663 @code{ediff-diff-program}. For the default forward word function (which is
1664 @code{ediff-forward-word}), a word is a string consisting of letters,
1665 @samp{-}, or @samp{_}; a string of punctuation symbols; a string of digits,
1666 or a string consisting of symbols that are neither space, nor a letter.
1668 This default behavior is controlled by four variables: @code{ediff-word-1},
1669 ..., @code{ediff-word-4}. See the on-line documentation for these variables
1670 and for the function @code{ediff-forward-word} for an explanation of how to
1671 modify these variables.
1672 @vindex ediff-word-1
1673 @vindex ediff-word-2
1674 @vindex ediff-word-3
1675 @vindex ediff-word-4
1678 Sometimes, when a region has too many differences between the variants,
1679 highlighting of fine differences is inconvenient, especially on
1680 color displays. If that is the case, type @kbd{*} with a negative
1681 prefix argument. This unhighlights fine differences for the current
1684 To unhighlight fine differences in all difference regions, use the
1685 command @kbd{@@}. Repeated typing of this key cycles through three
1686 different states: auto-refining, no-auto-refining, and no-highlighting
1687 of fine differences.
1689 @node Patch and Diff Programs, Merging and diff3, Refinement of Difference Regions, Customization
1690 @section Patch and Diff Programs
1692 This section describes variables that specify the programs to be used for
1693 applying patches and for computing the main difference regions (not the
1694 fine difference regions):
1697 @item ediff-diff-program
1698 @itemx ediff-diff3-program
1699 @vindex ediff-patch-program
1700 @vindex ediff-diff-program
1701 @vindex ediff-diff3-program
1702 These variables specify the programs to use to produce differences
1705 @item ediff-diff-options
1706 @itemx ediff-diff3-options
1707 @vindex ediff-patch-options
1708 @vindex ediff-diff-options
1709 @vindex ediff-diff3-options
1710 These variables specify the options to pass to the above utilities.
1712 In @code{ediff-diff-options}, it may be useful to specify options
1713 such as @samp{-w} that ignore certain kinds of changes. However,
1714 Ediff does not let you use the option @samp{-c}, as it doesn't recognize this
1717 @item ediff-patch-program
1718 The program to use to apply patches. Since there are certain
1719 incompatibilities between the different versions of the patch program, the
1720 best way to stay out of trouble is to use a GNU-compatible version.
1721 Otherwise, you may have to tune the values of the variables
1722 @code{ediff-patch-options}, @code{ediff-backup-specs}, and
1723 @code{ediff-backup-extension} as described below.
1724 @item ediff-patch-options
1725 Options to pass to @code{ediff-patch-program}.
1727 Note: the `-b' and `-z' options should be specified in
1728 `ediff-backup-specs', not in @code{ediff-patch-options}.
1730 It is recommended to pass the `-f' option to the patch program, so it won't
1731 ask questions. However, some implementations don't accept this option, in
1732 which case the default value of this variable should be changed.
1734 @item ediff-backup-extension
1735 Backup extension used by the patch program. Must be specified, even if
1736 @code{ediff-backup-specs} is given.
1737 @item ediff-backup-specs
1738 Backup directives to pass to the patch program.
1739 Ediff requires that the old version of the file (before applying the patch)
1740 is saved in a file named @file{the-patch-file.extension}. Usually
1741 `extension' is `.orig', but this can be changed by the user, and may also be
1742 system-dependent. Therefore, Ediff needs to know the backup extension used
1743 by the patch program.
1745 Some versions of the patch program let the user specify `-b backup-extension'.
1746 Other versions only permit `-b', which (usually) assumes the extension `.orig'.
1747 Yet others force you to use `-z<backup-extension>'.
1749 Note that both `ediff-backup-extension' and `ediff-backup-specs' must be
1750 properly set. If your patch program takes the option `-b', but not
1751 `-b extension', the variable `ediff-backup-extension' must still
1752 be set so Ediff will know which extension to use.
1754 @item ediff-custom-diff-program
1755 @itemx ediff-custom-diff-options
1756 @vindex ediff-custom-diff-program
1757 @vindex ediff-custom-diff-options
1758 @findex ediff-save-buffer
1759 Because Ediff limits the options you may want to pass to the @code{diff}
1760 program, it partially makes up for this drawback by letting you save the
1761 output from @code{diff} in your preferred format, which is specified via
1762 the above two variables.
1764 The output generated by @code{ediff-custom-diff-program} (which doesn't
1765 even have to be a standard-style @command{diff}!)@: is not used by Ediff. It is
1766 provided exclusively so that you can
1768 it later, send it over email, etc. For instance, after reviewing the
1769 differences, you may want to send context differences to a colleague.
1770 Since Ediff ignores the @samp{-c} option in
1771 @code{ediff-diff-program}, you would have to run @code{diff -c} separately
1772 just to produce the list of differences. Fortunately,
1773 @code{ediff-custom-diff-program} and @code{ediff-custom-diff-options}
1774 eliminate this nuisance by keeping a copy of a difference list in the
1775 desired format in a buffer that can be displayed via the command @kbd{D}.
1777 @item ediff-patch-default-directory
1778 @vindex ediff-patch-default-directory
1779 Specifies the default directory to look for patches.
1784 @strong{Warning:} Ediff does not support the output format of VMS
1785 @code{diff}. Instead, make sure you are using some implementation of POSIX
1786 @code{diff}, such as @code{gnudiff}.
1788 @node Merging and diff3, Support for Version Control, Patch and Diff Programs, Customization
1789 @section Merging and diff3
1791 Ediff supports three-way comparison via the functions @code{ediff-files3} and
1792 @code{ediff-buffers3}. The interface is the same as for two-way comparison.
1793 In three-way comparison and merging, Ediff reports if any two difference
1794 regions are identical. For instance, if the current region in buffer A
1795 is the same as the region in buffer C, then the mode line of buffer A will
1796 display @samp{[=diff(C)]} and the mode line of buffer C will display
1799 Merging is done according to the following algorithm.
1801 If a difference region in one of the buffers, say B, differs from the ancestor
1802 file while the region in the other buffer, A, doesn't, then the merge buffer,
1803 C, gets B's region. Similarly when buffer A's region differs from
1804 the ancestor and B's doesn't, A's region is used.
1806 @vindex ediff-default-variant
1807 If both regions in buffers A and B differ from the ancestor file, Ediff
1808 chooses the region according to the value of the variable
1809 @code{ediff-default-variant}. If its value is @code{default-A} then A's
1810 region is chosen. If it is @code{default-B} then B's region is chosen.
1811 If it is @code{combined} then the region in buffer C will look like
1814 @comment Use @set to avoid triggering merge conflict detectors like CVS.
1815 @set seven-left <<<<<<<
1816 @set seven-right >>>>>>>
1818 @value{seven-left} variant A
1819 the difference region from buffer A
1820 @value{seven-right} variant B
1821 the difference region from buffer B
1823 the difference region from the ancestor buffer, if available
1827 The above is the default template for the combined region. The user can
1828 customize this template using the variable
1829 @code{ediff-combination-pattern}.
1831 @vindex ediff-combination-pattern
1832 The variable @code{ediff-combination-pattern} specifies the template that
1833 determines how the combined merged region looks like. The template is
1834 represented as a list of the form @code{(STRING1 Symbol1 STRING2 Symbol2
1835 STRING3 Symbol3 STRING4)}. The symbols here must be atoms of the form
1836 @code{A}, @code{B}, or @code{Ancestor}. They determine the order in which
1837 the corresponding difference regions (from buffers A, B, and the ancestor
1838 buffer) are displayed in the merged region of buffer C. The strings in the
1839 template determine the text that separates the aforesaid regions. The
1843 ("@value{seven-left} variant A" A "@value{seven-right} variant B" B "####### Ancestor" Ancestor "======= end")
1846 and the corresponding combined region is shown above. The order in which
1847 the regions are shown (and the separator strings) can be changed by
1848 changing the above template. It is even possible to add or delete region
1849 specifiers in this template (although the only possibly useful such
1850 modification seems to be the deletion of the ancestor).
1852 In addition to the state of the difference, Ediff displays the state of the
1853 merge for each region. If a difference came from buffer A by default
1854 (because both regions A and B were different from the ancestor and
1855 @code{ediff-default-variant} was set to @code{default-A}) then
1856 @samp{[=diff(A) default-A]} is displayed in the mode line. If the
1857 difference in buffer C came, say, from buffer B because the difference
1858 region in that buffer differs from the ancestor, but the region in buffer A
1859 does not (if merging with an ancestor) then @samp{[=diff(B) prefer-B]} is
1860 displayed. The indicators default-A/B and prefer-A/B are inspired by
1861 Emerge and have the same meaning.
1863 Another indicator of the state of merge is @samp{combined}. It appears
1864 with any difference region in buffer C that was obtained by combining
1865 the difference regions in buffers A and B as explained above.
1867 In addition to the state of merge and state of difference indicators, while
1868 merging with an ancestor file or buffer, Ediff informs the user when the
1869 current difference region in the (normally invisible) ancestor buffer is
1870 empty via the @emph{AncestorEmpty} indicator. This helps determine if the
1871 changes made to the original in variants A and B represent pure insertion
1872 or deletion of text: if the mode line shows @emph{AncestorEmpty} and the
1873 corresponding region in buffers A or B is not empty, this means that new
1874 text was inserted. If this indicator is not present and the difference
1875 regions in buffers A or B are non-empty, this means that text was
1876 modified. Otherwise, the original text was deleted.
1878 Although the ancestor buffer is normally invisible, Ediff maintains
1879 difference regions there and advances the current difference region
1880 accordingly. All highlighting of difference regions is provided in the
1881 ancestor buffer, except for the fine differences. Therefore, if desired, the
1882 user can put the ancestor buffer in a separate frame and watch it
1883 there. However, on a TTY, only one frame can be visible at any given time,
1884 and Ediff doesn't support any single-frame window configuration where all
1885 buffers, including the ancestor buffer, would be visible. However, the
1886 ancestor buffer can be displayed by typing @kbd{/} to the control
1887 window. (Type @kbd{C-l} to hide it again.)
1889 Note that the state-of-difference indicators @samp{=diff(A)} and
1890 @samp{=diff(B)} above are not redundant, even in the presence of a
1891 state-of-merge indicator. In fact, the two serve different purposes.
1893 For instance, if the mode line displays @samp{=diff(B) prefer(B)} and
1894 you copy a difference region from buffer A to buffer C then
1895 @samp{=diff(B)} will change to @samp{diff-A} and the mode line will
1896 display @samp{=diff(A) prefer-B}. This indicates that the difference
1897 region in buffer C is identical to that in buffer A, but originally
1898 buffer C's region came from buffer B. This is useful to know because
1899 you can recover the original difference region in buffer C by typing
1903 Ediff never changes the state-of-merge indicator, except in response to
1904 the @kbd{!} command (see below), in which case the indicator is lost.
1905 On the other hand, the state-of-difference indicator is changed
1906 automatically by the copying/recovery commands, @kbd{a}, @kbd{b}, @kbd{r},
1909 The @kbd{!} command loses the information about origins of the regions
1910 in the merge buffer (default-A, prefer-B, or combined). This is because
1911 recomputing differences in this case means running @code{diff3} on
1912 buffers A, B, and the merge buffer, not on the ancestor buffer. (It
1913 makes no sense to recompute differences using the ancestor file, since
1914 in the merging mode Ediff assumes that you have not edited buffers A and
1915 B, but that you may have edited buffer C, and these changes are to be
1916 preserved.) Since some difference regions may disappear as a result of
1917 editing buffer C and others may arise, there is generally no simple way
1918 to tell where the various regions in the merge buffer came from.
1920 In three-way comparison, Ediff tries to disregard regions that consist
1921 entirely of white space. For instance, if, say, the current region in
1922 buffer A consists of the white space only (or if it is empty), Ediff will
1923 not take it into account for the purpose of computing fine differences. The
1924 result is that Ediff can provide a better visual information regarding the
1925 actual fine differences in the non-white regions in buffers B and
1926 C. Moreover, if the regions in buffers B and C differ in the white space
1927 only, then a message to this effect will be displayed.
1929 @vindex ediff-merge-window-share
1930 In the merge mode, the share of the split between window C (the window
1931 displaying the merge-buffer) and the windows displaying buffers A and B
1932 is controlled by the variable @code{ediff-merge-window-share}. Its
1933 default value is 0.5. To make the merge-buffer window smaller, reduce
1936 We don't recommend increasing the size of the merge-window to more than
1937 half the frame (i.e., to increase the value of
1938 @code{ediff-merge-window-share}) to more than 0.5, since it would be
1939 hard to see the contents of buffers A and B.
1941 You can temporarily shrink the merge window to just one line by
1942 typing @kbd{s}. This change is temporary, until Ediff finds a reason to
1943 redraw the screen. Typing @kbd{s} again restores the original window size.
1945 With a positive prefix argument, the @kbd{s} command will make the merge
1946 window slightly taller. This change is persistent. With `@kbd{-}' or
1947 with a negative prefix argument, the command @kbd{s} makes the merge
1948 window slightly shorter. This change also persistent.
1950 @vindex ediff-show-clashes-only
1951 Ediff lets you automatically ignore the regions where only one of the
1952 buffers A and B disagrees with the ancestor. To do this, set the
1953 variable @code{ediff-show-clashes-only} to non-@code{nil}.
1955 You can toggle this feature interactively by typing @kbd{$$}.
1957 Note that this variable affects only the show next/previous difference
1958 commands. You can still jump directly to any difference region directly
1959 using the command @kbd{j} (with a prefix argument specifying the difference
1962 @vindex ediff-autostore-merges
1963 @vindex ediff-quit-merge-hook
1964 @findex ediff-maybe-save-and-delete-merge
1965 The variable @code{ediff-autostore-merges} controls what happens to the
1966 merge buffer when Ediff quits. If the value is @code{nil}, nothing is done
1967 to the merge buffer---it will be the user's responsibility to save it.
1968 If the value is @code{t}, the user will be asked where to save the buffer
1969 and whether to delete it afterwards. It the value is neither @code{nil} nor
1970 @code{t}, the merge buffer is saved @emph{only} if this merge session was
1971 invoked from a group of related Ediff session, such as those that result
1972 from @code{ediff-merge-directories},
1973 @code{ediff-merge-directory-revisions}, etc.
1974 @xref{Session Groups}. This behavior is implemented in the function
1975 @code{ediff-maybe-save-and-delete-merge}, which is a hook in
1976 @code{ediff-quit-merge-hook}. The user can supply a different hook, if
1979 The variable @code{ediff-autostore-merges} is buffer-local, so it can be
1980 set in a per-buffer manner. Therefore, use @code{setq-default} to globally
1981 change this variable.
1983 @vindex ediff-merge-filename-prefix
1984 When merge buffers are saved automatically as directed by
1985 @code{ediff-autostore-merges}, Ediff attaches a prefix to each file, as
1986 specified by the variable @code{ediff-merge-filename-prefix}. The default
1987 is @code{merge_}, but this can be changed by the user.
1989 @node Support for Version Control, Customizing the Mode Line, Merging and diff3, Customization
1990 @section Support for Version Control
1993 Ediff supports version control and lets you compare versions of files
1994 visited by Emacs buffers via the function @code{ediff-revision}. This
1995 feature is controlled by the following variables:
1998 @item ediff-version-control-package
1999 @vindex ediff-version-control-package
2000 A symbol. The default is @samp{vc}.
2002 If you are like most Emacs users, Ediff will use VC as the version control
2003 package. This is the standard Emacs interface to RCS, CVS, and SCCS.
2005 However, if your needs are better served by other interfaces, you will
2006 have to tell Ediff which version control package you are using, e.g.,
2008 (setq ediff-version-control-package 'rcs)
2011 Apart from the standard @file{vc.el}, Ediff supports three other interfaces
2013 @file{rcs.el}, @file{pcl-cvs.el}, and @file{generic-sc.el}.
2014 The package @file{rcs.el} is written by Sebastian Kremer
2015 <sk@@thp.Uni-Koeln.DE> and is available as
2017 @file{ftp.cs.buffalo.edu:pub/Emacs/rcs.tar.Z}
2018 @file{ftp.uni-koeln.de:/pub/gnu/emacs/rcs.tar.Z}
2020 @pindex @file{vc.el}
2021 @pindex @file{rcs.el}
2022 @pindex @file{pcl-cvs.el}
2023 @pindex @file{generic-sc.el}
2026 Ediff's interface to the above packages allows the user to compare the
2027 versions of the current buffer or to merge them (with or without an
2028 ancestor-version). These operations can also be performed on directories
2029 containing files under version control.
2031 In case of @file{pcl-cvs.el}, Ediff can also be invoked via the function
2032 @code{run-ediff-from-cvs-buffer}---see the documentation string for this
2035 @node Customizing the Mode Line, Miscellaneous, Support for Version Control, Customization
2036 @section Customizing the Mode Line
2038 When Ediff is running, the mode line of @samp{Ediff Control Panel}
2039 buffer shows the current difference number and the total number of
2040 difference regions in the two files.
2042 The mode line of the buffers being compared displays the type of the
2043 buffer (@samp{A:}, @samp{B:}, or @samp{C:}) and (usually) the file name.
2044 Ediff tries to be intelligent in choosing the mode line buffer
2045 identification. In particular, it works well with the
2046 @file{uniquify.el} and @file{mode-line.el} packages (which improve on
2047 the default way in which Emacs displays buffer identification). If you
2048 don't like the way Ediff changes the mode line, you can use
2049 @code{ediff-prepare-buffer-hook} to modify the mode line.
2050 @vindex ediff-prepare-buffer-hook
2051 @pindex @file{uniquify.el}
2052 @pindex @file{mode-line.el}
2054 @node Miscellaneous, Notes on Heavy-duty Customization, Customizing the Mode Line, Customization
2055 @section Miscellaneous
2057 Here are a few other variables for customizing Ediff:
2060 @item ediff-split-window-function
2061 @vindex ediff-split-window-function
2062 Controls the way you want the window be split between file-A and file-B
2063 (and file-C, if applicable). It defaults to the vertical split
2064 (@code{split-window-vertically}, but you can set it to
2065 @code{split-window-horizontally}, if you so wish.
2066 Ediff also lets you switch from vertical to horizontal split and back
2069 Note that if Ediff detects that all the buffers it compares are displayed in
2070 separate frames, it assumes that the user wants them to be so displayed
2071 and stops splitting windows. Instead, it arranges for each buffer to
2072 be displayed in a separate frame. You can switch to the one-frame mode
2073 by hiding one of the buffers A/B/C.
2075 You can also swap the windows where buffers are displayed by typing
2078 @item ediff-merge-split-window-function
2079 @vindex ediff-merge-split-window-function
2080 Controls how windows are
2081 split between buffers A and B in the merge mode.
2082 This variable is like @code{ediff-split-window-function}, but it defaults
2083 to @code{split-window-horizontally} instead of
2084 @code{split-window-vertically}.
2086 @item ediff-make-wide-display-function
2087 @vindex ediff-make-wide-display-function
2088 The value is a function to be called to widen the frame for displaying
2089 the Ediff buffers. See the on-line documentation for
2090 @code{ediff-make-wide-display-function} for details. It is also
2091 recommended to look into the source of the default function
2092 @code{ediff-make-wide-display}.
2094 You can toggle wide/regular display by typing @kbd{m}. In the wide
2095 display mode, buffers A, B (and C, when applicable) are displayed in a
2096 single frame that is as wide as the entire workstation screen. This is
2097 useful when files are compared side-by-side. By default, the display is
2098 widened without changing its height.
2100 @item ediff-use-last-dir
2101 @vindex ediff-use-last-dir
2102 Controls the way Ediff presents the
2103 default directory when it prompts the user for files to compare. If
2105 Ediff uses the default directory of the current buffer when it
2106 prompts the user for file names. Otherwise, it will use the
2107 directories it had previously used for files A, B, or C, respectively.
2109 @item ediff-no-emacs-help-in-control-buffer
2110 @vindex ediff-no-emacs-help-in-control-buffer
2111 If @code{t}, makes @kbd{C-h}
2112 behave like the @key{DEL} key, i.e., it will move you back to the previous
2113 difference rather than invoking help. This is useful when, in an xterm
2114 window or a text-only terminal, the Backspace key is bound to @kbd{C-h} and is
2115 positioned more conveniently than the @key{DEL} key.
2117 @item ediff-toggle-read-only-function
2118 @vindex ediff-toggle-read-only-function
2119 This variable's value is a function that Ediff uses to toggle
2120 the read-only property in its buffers.
2122 The default function that Ediff uses simply toggles the read-only property,
2123 unless the file is under version control. For a checked-in file under
2124 version control, Ediff first tries to check the file out.
2126 @item ediff-make-buffers-readonly-at-startup nil
2127 @vindex ediff-make-buffers-readonly-at-startup
2128 If t, all variant buffers are made read-only at Ediff startup.
2130 @item ediff-keep-variants
2131 @vindex @code{ediff-keep-variants}
2132 The default is @code{t}, meaning that the buffers being compared or merged will
2133 be preserved when Ediff quits. Setting this to @code{nil} causes Ediff to
2134 offer the user a chance to delete these buffers (if they are not modified).
2135 Supplying a prefix argument to the quit command (@code{q}) temporarily
2136 reverses the meaning of this variable. This is convenient when the user
2137 prefers one of the behaviors most of the time, but occasionally needs the
2140 However, Ediff temporarily resets this variable to @code{t} if it is
2141 invoked via one of the "buffer" jobs, such as @code{ediff-buffers}.
2142 This is because it is all too easy to loose day's work otherwise.
2143 Besides, in a "buffer" job, the variant buffers have already been loaded
2144 prior to starting Ediff, so Ediff just preserves status quo here.
2146 Using @code{ediff-cleanup-hook}, one can make Ediff delete the variants
2147 unconditionally (e.g., by making @code{ediff-janitor} into one of these hooks).
2148 @item ediff-grab-mouse
2149 @vindex @code{ediff-grab-mouse}
2150 Default is @code{t}. Normally, Ediff grabs mouse and puts it in its
2151 control frame. This is useful since the user can be sure that when he
2152 needs to type an Ediff command the focus will be in an appropriate Ediff's
2153 frame. However, some users prefer to move the mouse by themselves. The
2154 above variable, if set to @code{maybe}, will prevent Ediff from grabbing
2155 the mouse in many situations, usually after commands that may take more
2156 time than usual. In other situation, Ediff will continue grabbing the mouse
2157 and putting it where it believes is appropriate. If the value is
2158 @code{nil}, then mouse is entirely user's responsibility.
2159 Try different settings and see which one is for you.
2163 @node Notes on Heavy-duty Customization, , Miscellaneous, Customization
2164 @section Notes on Heavy-duty Customization
2166 Some users need to customize Ediff in rather sophisticated ways, which
2167 requires different defaults for different kinds of files (e.g., SGML,
2168 etc.). Ediff supports this kind of customization in several ways. First,
2169 most customization variables are buffer-local. Those that aren't are
2170 usually accessible from within Ediff Control Panel, so one can make them
2171 local to the panel by calling make-local-variable from within
2172 @code{ediff-startup-hook}.
2174 Second, the function @code{ediff-setup} accepts an optional sixth
2175 argument which has the form @code{((@var{var-name-1} .@: @var{val-1})
2176 (@var{var-name-2} .@: @var{val-2}) @dots{})}. The function
2177 @code{ediff-setup} sets the variables in the list to the respective
2178 values, locally in the Ediff control buffer. This is an easy way to
2179 throw in custom variables (which usually should be buffer-local) that
2180 can then be tested in various hooks.
2182 Make sure the variable @code{ediff-job-name} and @code{ediff-word-mode} are set
2183 properly in this case, as some things in Ediff depend on this.
2185 Finally, if you want custom-tailored help messages, you can set the
2186 variables @code{ediff-brief-help-message-function} and
2187 @code{ediff-long-help-message-function}
2188 to functions that return help strings.
2189 @vindex ediff-startup-hook
2191 @vindex ediff-job-name
2192 @vindex ediff-word-mode
2193 @vindex ediff-brief-help-message-function
2194 @vindex ediff-long-help-message-function
2196 When customizing Ediff, some other variables are useful, although they are
2197 not user-definable. They are local to the Ediff control buffer, so this
2198 buffer must be current when you access these variables. The control buffer
2199 is accessible via the variable @code{ediff-control-buffer}, which is also
2200 local to that buffer. It is usually used for checking if the current buffer
2201 is also the control buffer.
2203 Other variables of interest are:
2205 @item ediff-buffer-A
2206 The first of the data buffers being compared.
2208 @item ediff-buffer-B
2209 The second of the data buffers being compared.
2211 @item ediff-buffer-C
2212 In three-way comparisons, this is the third buffer being compared.
2213 In merging, this is the merge buffer.
2214 In two-way comparison, this variable is nil.
2216 @item ediff-window-A
2217 The window displaying buffer A. If buffer A is not visible, this variable
2218 is nil or it may be a dead window.
2220 @item ediff-window-B
2221 The window displaying buffer B.
2223 @item ediff-window-C
2224 The window displaying buffer C, if any.
2226 @item ediff-control-frame
2227 A dedicated frame displaying the control buffer, if it exists.
2228 It is non-nil only if Ediff uses the multiframe display, i.e., when the
2229 control buffer is in its own frame.
2232 @node Credits, Index, Customization, Top
2235 Ediff was written by Michael Kifer <kifer@@cs.sunysb.edu>. It was inspired
2236 by emerge.el written by Dale R.@: Worley <drw@@math.mit.edu>. An idea due to
2237 Boris Goldowsky <boris@@cs.rochester.edu> made it possible to highlight
2238 fine differences in Ediff buffers. Alastair Burt <burt@@dfki.uni-kl.de>
2239 ported Ediff to XEmacs, Eric Freudenthal <freudent@@jan.ultra.nyu.edu>
2240 made it work with VC, Marc Paquette <marcpa@@cam.org> wrote the
2241 toolbar support package for Ediff, and Hrvoje Niksic <hniksic@@xemacs.org>
2242 adapted it to the Emacs customization package.
2244 Many people provided help with bug reports, patches, and advice.
2245 Without them, Ediff would not be nearly as useful as it is today.
2246 Here is a full list of contributors (I hope I didn't miss anyone):
2249 Adrian Aichner (aichner@@ecf.teradyne.com),
2250 Steve Baur (steve@@xemacs.org),
2251 Neal Becker (neal@@ctd.comsat.com),
2252 E.@: Jay Berkenbilt (ejb@@ql.org),
2253 Alastair Burt (burt@@dfki.uni-kl.de),
2254 Paul Bibilo (peb@@delcam.co.uk),
2255 Kevin Broadey (KevinB@@bartley.demon.co.uk),
2256 Harald Boegeholz (hwb@@machnix.mathematik.uni-stuttgart.de),
2257 Bradley A.@: Bosch (brad@@lachman.com),
2258 Michael D.@: Carney (carney@@ltx-tr.com),
2259 Jin S.@: Choi (jin@@atype.com),
2260 Scott Cummings (cummings@@adc.com),
2261 Albert Dvornik (bert@@mit.edu),
2262 Eric Eide (eeide@@asylum.cs.utah.edu),
2263 Paul Eggert (eggert@@twinsun.com),
2264 Urban Engberg (ue@@cci.dk),
2265 Kevin Esler (esler@@ch.hp.com),
2266 Robert Estes (estes@@ece.ucdavis.edu),
2267 Jay Finger (jayf@@microsoft.com),
2268 Xavier Fornari (xavier@@europe.cma.fr),
2269 Eric Freudenthal (freudent@@jan.ultra.nyu.edu),
2270 Job Ganzevoort (Job.Ganzevoort@@cwi.nl),
2271 Boris Goldowsky (boris@@cs.rochester.edu),
2272 Allan Gottlieb (gottlieb@@allan.ultra.nyu.edu),
2273 Aaron Gross (aaron@@bfr.co.il),
2274 Thorbjoern Hansen (thorbjoern.hansen@@mchp.siemens.de),
2275 Xiaoli Huang (hxl@@epic.com),
2276 Andreas Jaeger (aj@@suse.de),
2277 Lars Magne Ingebrigtsen (larsi@@ifi.uio.no),
2278 Larry Gouge (larry@@itginc.com),
2279 Karl Heuer (kwzh@@gnu.org),
2280 (irvine@@lks.csi.com),
2281 (jaffe@@chipmunk.cita.utoronto.ca),
2282 David Karr (dkarr@@nmo.gtegsc.com),
2283 Norbert Kiesel (norbert@@i3.informatik.rwth-aachen.de),
2284 Sam Steingold (sds@@goems.com),
2285 Leigh L Klotz (klotz@@adoc.xerox.com),
2286 Fritz Knabe (Fritz.Knabe@@ecrc.de),
2287 Heinz Knutzen (hk@@informatik.uni-kiel.d400.de),
2288 Andrew Koenig (ark@@research.att.com),
2289 Ken Laprade (laprade@@dw3f.ess.harris.com),
2290 Will C Lauer (wcl@@cadre.com),
2291 Richard Levitte (levitte@@e.kth.se),
2292 Mike Long (mike.long@@analog.com),
2293 Martin Maechler (maechler@@stat.math.ethz.ch),
2294 Simon Marshall (simon@@gnu.org),
2295 Richard Mlynarik (mly@@adoc.xerox.com),
2296 Chris Murphy (murphycm@@sun.aston.ac.uk),
2297 Erik Naggum (erik@@naggum.no),
2298 Eyvind Ness (Eyvind.Ness@@hrp.no),
2299 Ray Nickson (nickson@@cs.uq.oz.au),
2300 David Petchey (petchey_david@@jpmorgan.com),
2301 Benjamin Pierce (benjamin.pierce@@cl.cam.ac.uk),
2302 Francois Pinard (pinard@@iro.umontreal.ca),
2303 Tibor Polgar (tlp00@@spg.amdahl.com),
2304 David Prince (dave0d@@fegs.co.uk),
2305 Paul Raines (raines@@slac.stanford.edu),
2306 Bill Richter (richter@@math.nwu.edu),
2307 C.S.@: Roberson (roberson@@aur.alcatel.com),
2308 Kevin Rodgers (kevin.rodgers@@ihs.com),
2309 Sandy Rutherford (sandy@@ibm550.sissa.it),
2310 Heribert Schuetz (schuetz@@ecrc.de),
2311 Andy Scott (ascott@@pcocd2.intel.com),
2312 Axel Seibert (axel@@tumbolia.ppp.informatik.uni-muenchen.de),
2313 Scott O.@: Sherman (Scott.Sherman@@mci.com),
2314 Richard Stallman (rms@@gnu.org),
2315 Richard Stanton (stanton@@haas.berkeley.edu),
2316 Ake Stenhoff (etxaksf@@aom.ericsson.se),
2317 Stig (stig@@hackvan.com),
2318 Peter Stout (Peter_Stout@@cs.cmu.edu),
2319 Chuck Thompson (cthomp@@cs.uiuc.edu),
2320 Ray Tomlinson (tomlinso@@bbn.com),
2321 Raymond Toy (toy@@rtp.ericsson.se),
2322 Jan Vroonhof (vroonhof@@math.ethz.ch),
2323 Philippe Waroquiers (philippe.waroquiers@@eurocontrol.be),
2324 Klaus Weber (gizmo@@zork.north.de),
2325 Ben Wing (ben@@xemacs.org),
2326 Ilya Zakharevich (ilya@@math.ohio-state.edu),
2327 Eli Zaretskii (eliz@@is.elta.co.il)
2330 @node Index, , Credits, Top
2334 @setchapternewpage odd