Delete some autoloads that are now in menu-bar.el.
[bpt/emacs.git] / lisp / ediff.el
1 ;;; ediff.el --- a comprehensive visual interface to diff & patch
2 ;;; Copyright (C) 1994 Free Software Foundation, Inc.
3
4 ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
5 ;; Created: February 2, 1994
6 ;; Keywords: comparing, merging, patching, version control.
7
8 (defconst ediff-version "2.19" "The current version of Ediff")
9 (defconst ediff-date "March 14, 1995" "Date of last update")
10
11 ;; LCD Archive Entry:
12 ;; ediff|Michael Kifer|kifer@cs.sunysb.edu|
13 ;; A comprehensive visual interface to diff and patch|
14 ;; 14-March-95|2.19|~/packages/ediff.shar.Z|
15
16
17 ;; This file is part of GNU Emacs.
18
19 ;; GNU Emacs is free software; you can redistribute it and/or modify
20 ;; it under the terms of the GNU General Public License as published by
21 ;; the Free Software Foundation; either version 2, or (at your option)
22 ;; any later version.
23
24 ;; GNU Emacs is distributed in the hope that it will be useful,
25 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
26 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 ;; GNU General Public License for more details.
28
29 ;; You should have received a copy of the GNU General Public License
30 ;; along with GNU Emacs; see the file COPYING. If not, write to
31 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
32
33 ;;; Commentary:
34 ;; ----------
35
36 ;; Never read that diff output again!
37 ;; Apply patch selectively, like a pro!
38 ;; Merge with ease!
39
40 ;; This package provides a convenient way of simultaneous browsing through
41 ;; the differences between a pair (or a tripple) of files or buffers. The
42 ;; files being compared, file-A, file-B, and file-C (if applicable) are
43 ;; shown in separate windows (side by side, one above the another, or in
44 ;; separate frames), and the differences are highlighted as you step
45 ;; through them. You can also copy difference regions from one buffer to
46 ;; another (and recover old differences if you change your mind).
47
48 ;; In addition, Ediff can apply a patch to a file and then let you step
49 ;; though both files, the patched and the original one, simultaneously,
50 ;; difference-by-difference. You can even apply a patch right out of a
51 ;; mail buffer, i.e., patches received by mail don't even have to be saved.
52 ;; Since Ediff lets you copy differences between buffers, you can, in
53 ;; effect, apply patches selectively (i.e., you can copy a difference
54 ;; region from file_orig to file, thereby undoing any particular patch that
55 ;; you don't like).
56
57 ;; This package builds upon the ideas borrowed from emerge.el and
58 ;; several Ediff's functions are adaptations from emerge.el.
59 ;; Much of the functionality of Ediff is also influenced by emerge.el.
60
61 ;; The present version of Ediff supersedes Emerge. It provides a superior
62 ;; user interface and has many features not found in Emerge. In particular,
63 ;; it can do patching and 2-way and 3-way file comparison in addition to
64 ;; merging.
65
66 ;; Ediff is aware of version control, which lets the user compare
67 ;; files with their older versions. Ediff can also work with remote and
68 ;; compressed files. Details are given below.
69
70
71 ;;; Remarks:
72 ;; -------
73
74 ;; 1. Ediff is heavily dependent on the new features of Emacs 19.
75 ;; It won't run under Emacs 18 at all.
76 ;; 2. If running XEmacs, Ediff requires at least version 19.9.
77 ;; 3. The function ediff-revision requires the version of vc.el that comes
78 ;; with Emacs 19.22 and XEmacs 19.10 and later, or rcs.el version 1.67
79 ;; or later. See "Version control support", below.
80
81
82 ;;; Installation and use:
83 ;; ---------------------
84
85 ;; The user can invoke Ediff interactively using the following functions:
86 ;;
87 ;; ediff-files - compare two files
88 ;; ediff - alias for ediff-files
89 ;; ediff-buffers - compare two buffers
90 ;;
91 ;; ediff-files3 - compare three files
92 ;; ediff3 - alias for ediff-files3
93 ;; ediff-buffers3 - compare three buffers
94 ;;
95 ;; ediff-windows - compare windows
96 ;; ediff-small-regions - compare small regions
97 ;; ediff-large-regions - compare large regions
98 ;;
99 ;; ediff-revision - compare buffer & version
100 ;;
101 ;; ediff-patch-file - patch file then compare
102 ;; epatch - alias for ediff-patch-file
103 ;; ediff-patch-buffer - patch buffer then compare
104 ;; epatch-buffer - alias for ediff-patch-buffer
105 ;;
106 ;; ediff-merge-files - merge two files
107 ;; ediff-merge - alias for ediff-merge-files
108 ;; ediff-merge-files-with-ancestor - same but with ancestor
109 ;; ediff-merge-with-ancestor - alias for the above
110 ;; ediff-merge-buffers - merge two buffers
111 ;; ediff-merge-buffers-with-ancestor - same but with ancestor
112 ;; ediff-merge-revisions - same but with ancestor
113 ;; ediff-merge-revisions-with-ancestor - same but with ancestor
114 ;;
115 ;;
116 ;;
117 ;; To use Ediff, put this in your .emacs file:
118 ;;
119 ;; (autoload 'ediff-buffers "ediff" "Visual interface to diff" t)
120 ;; (autoload 'ediff "ediff" "Visual interface to diff" t)
121 ;; (autoload 'ediff-files "ediff" "Visual interface to diff" t)
122 ;; (autoload 'ediff-buffers3 "ediff" "Visual interface to diff" t)
123 ;; (autoload 'ediff3 "ediff3" "Visual interface to diff" t)
124 ;; (autoload 'ediff-files3 "ediff" "Visual interface to diff" t)
125 ;; (autoload 'ediff-merge "ediff" "Visual interface to diff" t)
126 ;; (autoload 'ediff-merge-files "ediff" "Visual interface to diff" t)
127 ;; (autoload 'ediff-merge-files-with-ancestor "ediff"
128 ;; "Visual interface to diff" t)
129 ;; (autoload 'ediff-merge-with-ancestor "ediff" "Visual interface to diff" t)
130 ;; (autoload 'ediff-merge-buffers "ediff" "Visual interface to diff" t)
131 ;; (autoload 'ediff-merge-buffers-with-ancestor "ediff"
132 ;; "Visual interface to diff" t)
133 ;; (autoload 'ediff-merge-revisions "ediff" "Visual interface to diff" t)
134 ;; (autoload 'ediff-merge-revisions-with-ancestor "ediff"
135 ;; "Visual interface to diff" t)
136 ;; (autoload 'ediff-windows "ediff" "Visual interface to diff" t)
137 ;; (autoload 'ediff-small-regions "ediff" "Visual interface to diff" t)
138 ;; (autoload 'ediff-large-regions "ediff" "Visual interface to diff" t)
139 ;; (autoload 'epatch "ediff" "Visual interface to patch" t)
140 ;; (autoload 'ediff-patch-file "ediff" "Visual interface to patch" t)
141 ;; (autoload 'ediff-patch-buffer "ediff" "Visual interface to patch" t)
142 ;; (autoload 'epatch-buffer "ediff" "Visual interface to patch" t)
143 ;; (autoload 'ediff-revision "ediff"
144 ;; "Interface to diff & version control" t)
145 ;;
146 ;;
147 ;; If you want Ediff to be loaded from the very beginning, you should have
148 ;;
149 ;; (require 'ediff)
150 ;;
151 ;; in your .emacs file. This way it is also easier to figure out changes
152 ;; to the default Ediff setting, if such changes become necessary --- see
153 ;; Customization.
154 ;;
155 ;; All the above functions use the diff program to find different
156 ;; regions. They process diff output and display it to the user in a
157 ;; convenient form.
158 ;;
159 ;; The functions ediff-files, ediff-buffers, ediff-files3, ediff-buffers3
160 ;; first display the coarse, line-based difference regions, as commonly
161 ;; found by the diff program.
162 ;; Since diff may report fairly large chunks of text as being
163 ;; different even though the difference may be contained in a few words or
164 ;; even in the white space or line breaks, Ediff will further refine the
165 ;; regions to indicate which exact words differ. If the only difference is
166 ;; in the white space and line breaks, Ediff will say so.
167 ;;
168 ;; The functions ediff-windows, ediff-small-regions and ediff-large-regions
169 ;; do comparison on parts of buffers (which must already exist).
170 ;; Since ediff-windows and ediff-small-regions are intended for relatively
171 ;; small segments of the buffers, comparison is done on the
172 ;; word-basis rather than line basis. No refinement is necessary in this
173 ;; case. This technique is effective only for relatively small
174 ;; regions (perhaps, up to 100 lines), as these functions have a relatively
175 ;; slow startup.
176 ;; To compare large regions, use ediff-large-regions. In this mode, Ediff
177 ;; displays differences as it would if invoked via ediff-files or
178 ;; ediff-buffers.
179 ;;
180 ;; The functions ediff-patch-file and ediff-patch-buffer apply a patch
181 ;; to a file or a buffer and then run Ediff on these buffers, displaying
182 ;; the difference regions.
183 ;;
184 ;; Finally, for files under version control, ediff-revisions will compare a
185 ;; file to one of its versions.
186
187 ;;; Compilation
188 ;; -----------
189 ;;
190 ;; When you byte-compile Ediff, you will get some warnings about functions
191 ;; being undefined. These can be safely ignored.
192 ;;
193
194 ;;; Customization:
195 ;; --------------
196
197 ;; Hooks:
198 ;; -----
199 ;; If you don't like the default setting, you can change it through the
200 ;; various variables and hooks. In particular, the following hooks are
201 ;; available:
202
203 ;; ediff-load-hooks
204 ;; ediff-keymap-setup-hooks
205 ;; ediff-before-setup-windows-hooks
206 ;; ediff-after-setup-windows-hooks
207 ;; ediff-before-setup-control-frame-hooks
208 ;; ediff-after-setup-control-frame-hooks
209 ;; ediff-startup-hooks
210 ;; ediff-select-hooks
211 ;; ediff-unselect-hooks
212 ;; ediff-suspend-hooks
213 ;; ediff-quit-hooks
214 ;; ediff-prepare-buffer-hooks
215 ;; ediff-display-help-hooks
216
217 ;; The hooks in ediff-load-hooks can be used to change defaults after Ediff
218 ;; is loaded. The hooks in ediff-keymap-setup-hooks can be used to alter
219 ;; bindings in Ediff's keymap. These hooks are called right after the
220 ;; default bindings are set.
221 ;;
222 ;; The hooks in ediff-before/after-setup-windows-hooks,
223 ;; ediff-suspend-hooks, and ediff-quit-hooks can be used to save and then
224 ;; restore whatever window configuration you want.
225
226 ;; Note that, by default, ediff-quit-hooks is set to a function,
227 ;; ediff-cleanup-mess, which cleans after Ediff, as appropriate in most
228 ;; cases. It is rather unlikely that the user will want to change
229 ;; it. However, the user may want add other hooks to ediff-quit-hooks,
230 ;; either before or after ediff-cleanup-mess (see the documentation for
231 ;; add-hook on how to do this). One should be aware that hooks executing
232 ;; before ediff-cleanup-mess start in ediff-control-buffer; they should
233 ;; also leave ediff-control-buffer as the current buffer. Hooks that are
234 ;; executed after ediff-cleanup-mess will have either buffer A or buffer B
235 ;; as the current buffer.
236
237 ;; If you are using packages such as mode-line.el to alter
238 ;; the buffer identification field in the mode line, you may have to
239 ;; restore this field after exiting Ediff by calling an appropriate
240 ;; function from a hook in ediff-quit-hooks (in case of mode-line.el, the
241 ;; function to call would be mode-line-abbreviate-buffer-identification).
242 ;; This should be done from a hook that runs before ediff-default-quit-hook,
243 ;; since such hooks run from within ediff-control-buffer, where buffers
244 ;; A, B, and C can be accessed via the variables ediff-buffer-A,
245 ;; ediff-buffer-B, ediff-buffer-C.
246
247 ;; The hooks ediff-before/after-setup-control-frame-hooks can be used to
248 ;; change how and where Ediff Control Panel is displayed, when it is
249 ;; displayed in a separate frame.
250
251 ;; However, be aware that many variables that drive Ediff are local to
252 ;; Ediff Control Panel, which requires special care in writing these hooks.
253 ;; Take a look at ediff-default-suspend-hook and ediff-default-quit-hook to
254 ;; see what's involved.
255
256 ;; The hooks in ediff-prepare-buffer-hooks are executed for each Ediff
257 ;; buffer (A, B, C) right after these buffers are arranged. Ediff runs the
258 ;; hooks in ediff-display-help-hooks each time after setting up the help
259 ;; message. Finally, ediff-mode-hooks are run just after ediff-mode is set
260 ;; up in the control buffer. This is done before any windows or frames are
261 ;; created. One can use it to set local variables that determine the
262 ;; look of the display.
263
264 ;; Quick help:
265 ;; ----------
266 ;;
267 ;; Ediff provides quick help using its control panel window. Since this
268 ;; window takes a fair share of the screen real estate, you can toggle it
269 ;; off by hitting `?'. The control window will then shrink to just one
270 ;; line and a mode line, displaying a short help message. The variable
271 ;;
272 ;; ediff-prefer-long-help-message
273 ;;
274 ;; Tells Ediff whether the user wants the short message initially or the
275 ;; long one. By default, it is set to nil, meaning that the short message
276 ;; will be shown on startup. Set this to t, if you want the long message
277 ;; initially.
278 ;; If you want to change the appearance of the help message on a
279 ;; per-buffer basis, you must use ediff-startup-hooks to change the value
280 ;; of ediff-help-message, which is a variable local to ediff-control-buffer.
281
282 ;; Window and frame configuration:
283 ;; -------------------------------
284
285 ;; In a non-windowing display, Ediff sets things up in one frame, splitting
286 ;; it between a small control window and the windows for file-A, file-B,
287 ;; and file-C. The split between these latter windows can be horizontal or
288 ;; vertical, which can be changed interactively by hitting `|' while the
289 ;; cursor is in the control window.
290 ;;
291 ;; On a window display, Ediff sets up a dedicated frame for Ediff Control
292 ;; Panel and then it would choose windows as follows: If one of the buffers
293 ;; is invisible, it will be displayed in the currently selected frame. If
294 ;; a buffer is visible, it will be displayed in the frame it is visible.
295 ;; If, according to the above criteria, the two buffers fall into the same
296 ;; frame, then be it---the frame will be shared by the two. The same
297 ;; algorithm works when you hit `C-l' (ediff-recenter), `p'
298 ;; (ediff-previous-difference), `n', etc.
299 ;;
300 ;; Thus, you can compare files in one frame or in different frames.
301 ;; The former is done by default, while the latter can be achieved by
302 ;; arranging files A, B (and C, if applicable) to be seen in different
303 ;; frames. Ediff respects these arrangements, automatically adapting
304 ;; itself to the multi-frame mode.
305
306 ;; Ediff uses the variables
307 ;;
308 ;; ediff-control-frame-parameters
309 ;; ediff-control-frame-position-function
310 ;;
311 ;; to set up its control panels. The user can change or augment
312 ;; ediff-control-frame-parameters including the font, color, etc. The X
313 ;; resource name of Ediff Control Panel frames is `Ediff'. Under X-windows,
314 ;; you can use this name to set up preferences in your ~/.Xdefaults
315 ;; (~/.xrdb, or whatever is in use). Usually this is preferable to changing
316 ;; ediff-control-frame-parameters directly. For instance, you can specify
317 ;; in ~/.Xdefaults where the control frame is to be sitting on the screen
318 ;; using the resource
319 ;;
320 ;; Ediff*geometry
321 ;;
322 ;; In general, any X resource pertaining the control frame can be reached
323 ;; via the prefix `Ediff*'.
324 ;;
325 ;; The prefered way of specifying the position of the control frame is by
326 ;; setting the variable ediff-control-frame-position-function to be a
327 ;; function to be called in order to determine the desired location for the
328 ;; control frame. The default value of this variable is
329 ;; `ediff-make-frame-position'. This function places the control frame in
330 ;; the vicinity of the North-East corner of the frame displaying buffer A.
331 ;; A pair of variables,
332 ;;
333 ;; ediff-narrow-control-frame-leftward-shift
334 ;; ediff-wide-control-frame-rightward-shift
335 ;; ediff-control-frame-upward-shift
336 ;;
337 ;; can be used to adjust the location produced by ediff-make-frame-position.
338 ;; The first variable specifies the number of characters for shifting
339 ;; the control frame from the rightmost edge of frame A when the control
340 ;; frame is displayed as a small window.
341 ;; The second variable specifies the rightward shift of the control frame
342 ;; from the left edge of frame A when the control frame shows the full
343 ;; menu of options.
344 ;; The third variable specifies the number of pixels for the upward shift
345 ;; of the control frame.
346 ;;
347 ;; If you truly and absolutely dislike the way Ediff sets up windows and if
348 ;; you can't customize this via frame parameters, the last resort is to
349 ;; rewrite the function `ediff-setup-windows'. However, we believe that
350 ;; detaching Ediff Control Panel from the rest and making it into a
351 ;; separate frame offers an important opportunity by allowing you to
352 ;; iconify that frame. Under Emacs, the icon will usually accept all of the
353 ;; Ediff commands, but will free up valuable real estate on your screen
354 ;; (this may depend on the window manager, though). Iconifying won't do any
355 ;; good under XEmacs since XEmacs icons do not seem to be sensitive to
356 ;; keyboard input. The saving grace is that, even if not iconified, the
357 ;; control frame is very small, smaller than some icons, so it doesn't take
358 ;; much space in any case.
359 ;;
360 ;; The variable
361 ;;
362 ;; ediff-prefer-iconified-control-frame
363 ;;
364 ;; if t, will cause the control frame to become iconified automatically when
365 ;; the help message is toggled off. This saves valuable real estate on the
366 ;; screen. Toggling help back will deiconify the control frame.
367 ;;
368 ;; To start ediff with an iconified Control Panel, you should set the above
369 ;; to t and ediff-prefer-long-help-message to nil.
370
371 ;; The variable
372 ;;
373 ;; ediff-window-setup-function
374 ;;
375 ;; Controls the way windows are setup. The above multiframe setup is
376 ;; achieved via ediff-setup-windows-multiframe function, which is a default
377 ;; on windowing displays (except for XEmacs 19.10 and earlier, which has a
378 ;; bug that breaks the multiframe display). The plain setup, one where all
379 ;; windows are always in one frame, is done via ediff-setup-windows-plain,
380 ;; which is the default on a non-windowing display (or in an xterm window).
381 ;; In fact, under Emacs, you can switch freely between these two setups by
382 ;; executing the command `ediff-toggle-multiframe'. However, don't try to
383 ;; do it under XEmacs, as it gets thoroughly confused if you switch from
384 ;; multiframe setup to plain setup within the same Ediff session.
385
386 ;; If you don't like either of these setups, write your own function. See
387 ;; the documentation for ediff-window-setup-function for the basic
388 ;; guidelines. However, writing window setups is not easy, so, before
389 ;; embarking on this job, you may want to take a close look at
390 ;; ediff-setup-windows-plain and ediff-setup-windows-multiframe.
391
392 ;; The user can run multiple Ediff sessions at once, by invoking it several
393 ;; times without exiting the previous Ediff sessions. Different sessions
394 ;; may even operate on the same pair of files. So, in principle, it is
395 ;; possible to do, say, pairwise comparison of three (or more) different
396 ;; files. Each session would have its own Ediff Control Panel and all the
397 ;; regarding a particular session is local to the associated control panel
398 ;; buffer. You can switch between sessions by suspending one session and
399 ;; then switching to another control panel. (Different control panel
400 ;; buffers are distinguished by a numerical suffix, e.g., Ediff Control
401 ;; Panel<3>.) Thus, if you would like to compare three files pairwise,
402 ;; you can do this by preparing three different frames, each with its data
403 ;; buffer to be compared. (No, I am not saying that such a 3way
404 ;; comparison is very easy to do.)
405 ;;
406 ;; If you need to conduct multiple Ediff sessions on the same file, one
407 ;; thing should be kept in mind: each time you invoke Ediff on a buffer that
408 ;; already participates in another Ediff session, that buffer should not
409 ;; have any ASCII Ediff flags in it. (Highlighting with faces is OK.) If
410 ;; flags are not removed, difference overlays won't be set correctly
411 ;; for the second invocation of Ediff. The simplest way to remove ASCII
412 ;; flags from an Ediff buffer is to hit `h' and thus switch to highlighting
413 ;; with faces (unhighlighting on a dumb terminal).
414
415 ;; Remote and Compressed Files
416 ;; ---------------------------
417
418 ;; Ediff will work with remote, compressed, and encrypted files. Ediff
419 ;; supports ange-ftp.el, jka-compr.el, uncompress.el and crypt++.el, but
420 ;; it may work with other similar packages as well. This
421 ;; means that you can compare files residing on another machine, or you
422 ;; can apply a patch to a file on another machine (even the patch itself
423 ;; can be a remote file!).
424 ;;
425 ;; When patching compressed or remote files, Ediff doesn't rename the
426 ;; source file into source-file-name_orig (unlike what `patch' would
427 ;; usually do). Instead, the source file retains its name and the result
428 ;; of applying the patch is placed in a temporary file that has the suffix
429 ;; `_patched'. Generally, this applies to files that are handled using
430 ;; black magic, such as special file handlers (ange-ftp and some
431 ;; compression and encryption packages all use this method).
432 ;;
433 ;; Regular files are treated by `patch' in the usual manner, i.e., the
434 ;; original is renamed into source-name_orig and the result of the patch
435 ;; is placed into the file source-name. (Ediff uses `_orig' instead of
436 ;; the usual `.orig' for compatibility with systems like VMS.)
437
438 ;;
439 ;; Selective browsing: Control over stepping through difference regions
440 ;; --------------------------------------------------------------------
441 ;;
442 ;; Sometimes it is convenient to be able to step through only some
443 ;; difference regions, those that satisfy certain conditions and to ignore
444 ;; all others. The commands `#f' and `#h' let the user specify regular
445 ;; expressions to control the way Ediff skips to the next or previous
446 ;; difference. Typing `#f' lets one specify of regular expressions,
447 ;; regexp-A, regexp-B, and regexp-C.
448 ;; Ediff will then start stepping only through those difference regions where
449 ;; the region in buffer A matches regexp-A and/or the region in buffer B
450 ;; matches regexp-B, etc. Whether `and' or `or' should be used depends on
451 ;; how the user responds to a prompt.
452 ;; Similarly, using `#h', one specifies expressions that match difference
453 ;; regions to be ignored while stepping through the differences. That is, if
454 ;; the buffer A part matches regexp-A, the buffer B part matches regexp B
455 ;; and (if applicable) buffer-C part matches regexp-C, then the region will
456 ;; be ignored by ediff-next-difference and ediff-previous-difference commands.
457 ;;
458 ;; Hitting `#f' and `#h' toggles this feature on/off.
459 ;;
460 ;; Note that selective browsing affects only ediff-next-difference and
461 ;; ediff-previous-difference, i.e., the commands invoked by typing n/SPC
462 ;; and p/DEL. You can still jump directly (using `j' or `ga/gb/gc') to any
463 ;; numbered difference. Also, it should be understood, that #f and #h do
464 ;; not change the position of the point in the buffers. The effect of these
465 ;; commands is seen only when the user types `n' or `p', i.e., when
466 ;; Ediff is told to jump to the next or previous difference.
467 ;;
468 ;; Users can supply their own functions that specify how Ediff should do
469 ;; selective browsing. To change the default Ediff function, add a function to
470 ;; ediff-load-hooks which will do the following assignments:
471 ;;
472 ;; (fset ediff-hide-regexp-matches 'your-hide-function)
473 ;; (fset ediff-focus-on-regexp-matches 'your-focus-function)
474 ;;
475 ;; Useful hints: To specify a regexp that matches everything, don't simply
476 ;; type RET in response to a prompt. Typing RET tells Ediff to accept the
477 ;; default value, which may not be what you want. Instead, one should enter
478 ;; something like `^' or `$' --- which would match every line.
479 ;;
480 ;; If the user doesn't remember if selective browsing is in effect and
481 ;; which regexps are being used, the status command, `i', will supply
482 ;; the requisite information.
483 ;;
484 ;; In addition to the ability to ignore regions that match regular
485 ;; expressions, Ediff can be ordered to start skipping over certain
486 ;; `inessential' regions. This is controlled by the variable
487 ;;
488 ;; ediff-ignore-similar-regions
489 ;;
490 ;; which, if set to t, will cause Ediff to skip over difference regions
491 ;; that has been found similar, i.e., where the only differences are those
492 ;; in the white space and newlines.
493 ;;
494 ;; Note: In order for this feature to work, auto-refining of difference
495 ;; regions must be on, since otherwise Ediff won't know if there are no
496 ;; fine differences between regions. Under X, auto-refining is a default,
497 ;; but it is nixed on a dumb terminal or in an Xterm window. Therefore, in
498 ;; a non-windowing environment, the user must explicitly turn
499 ;; auto-refining on (e.g., by typing `@').
500 ;;
501 ;; CAUTION: If many inessential regions appear in a row, Ediff may take a
502 ;; long time to jump to the next region because it has to compute fine
503 ;; differences of all intermediate regions.
504 ;;
505 ;;
506 ;; Highlighting difference regions
507 ;; -------------------------------
508 ;; The second group of Ediff variables that could be changed, if you so
509 ;; wish, is:
510 ;;
511 ;; ediff-before-flag-bol
512 ;; ediff-after-flag-eol
513 ;; ediff-before-flag-mol
514 ;; ediff-after-flag-mol
515 ;;
516 ;; ediff-current-diff-face-A
517 ;; ediff-current-diff-face-B
518 ;; ediff-current-diff-face-C
519 ;; ediff-fine-diff-face-A
520 ;; ediff-fine-diff-face-B
521 ;; ediff-fine-diff-face-C
522 ;; ediff-even-diff-face-A
523 ;; ediff-even-diff-face-B
524 ;; ediff-even-diff-face-C
525 ;; ediff-odd-diff-face-A
526 ;; ediff-odd-diff-face-B
527 ;; ediff-odd-diff-face-C
528 ;
529 ;; The first four are ASCII strings that mark the beginning and the end of
530 ;; the differences found in files A, B, and C. Ediff uses different flags
531 ;; to highlight regions that begin/end at the beginning of a line or in a
532 ;; middle of a line.
533
534 ;; The rest are the faces used to highlight text on X displays. On X
535 ;; displays, Ediff uses ediff-current-diff-face-A/B/C to highlight the
536 ;; current difference region.
537 ;;
538 ;; The faces ediff-fine-diff-face-A/B/C
539 ;; are used to show the fine differences between the current differences
540 ;; regions in buffers A, B, and C, respectively.
541 ;;
542 ;; Non-current difference regions are displayed in alternating
543 ;; faces: ediff-even/odd-diff-face-A/B/C. The odd and the even
544 ;; faces are actually identical on monochrome displays, because it is
545 ;; rather poor in what you can do on such a display. So, I chose to use
546 ;; italics to highlight other differences. Any ideas would be welcome.
547 ;; There are two ways to change the default setting for highlighting faces:
548 ;; either change the variables, as in
549 ;;
550 ;; (setq ediff-current-diff-face-A 'bold-italic)
551 ;;
552 ;; or
553 ;;
554 ;; (setq ediff-current-diff-face-A
555 ;; (copy-face 'bold-italic 'ediff-current-diff-face-A))
556 ;;
557 ;; or by selectively modifying the defaults:
558 ;;
559 ;; (add-hook 'ediff-load-hooks
560 ;; (function (lambda ()
561 ;; (set-face-foreground ediff-current-diff-face-B "blue")
562 ;; (set-face-background ediff-current-diff-face-B "red")
563 ;; (make-face-italic ediff-current-diff-face-B))))
564 ;;
565 ;; You may also want to take a look at how the above faces are defined in
566 ;; Ediff.
567 ;;
568 ;; Note: it is not recommended to use `internal-get-face' (or `get-face' in
569 ;; XEmacs) when defining faces for Ediff, since this may cause
570 ;; problems when there are several frames with different font sizes.
571 ;; Instead, use copy-face or set/make-face-* as shown above.
572 ;;
573 ;; The last variable in this group,
574 ;;
575 ;; ediff-highlight-all-diffs
576 ;;
577 ;; indicates whether---on a window system---the user wants differences to be
578 ;; marked using ASCII strings (like on a dumb terminal) or using colors and
579 ;; highlighting. Normally, Ediff highlights all differences, but the selected
580 ;; difference is highlighted more visibly. One can cycle through various
581 ;; modes of highlighting by hitting `h'. By default, Ediff starts in the
582 ;; mode where all difference regions are highlighted. If you prefer to
583 ;; start in the mode where unselected differences are not highlighted, you
584 ;; should set ediff-highlight-all-diffs to nil.
585 ;; You will still be able to turn on highlighting of all differences by
586 ;; hitting `h'.
587 ;;
588 ;; If you want to change the above variables, they must be set
589 ;; BEFORE Ediff is loaded.
590 ;;
591 ;; Note: Ediff lets you switch between the two types of highlighting. That
592 ;; is you can switch, interactively, from highlighting using faces to
593 ;; highlighting using ASCII flags, and back. Of course, toggling has
594 ;; effect only on a window system. On a dumb terminal or in an xterm
595 ;; window, the only available option is highlighting with ASCII flags.
596 ;;
597 ;; Selective display
598 ;; -----------------
599 ;; If buffers being compared are narrowed at the time of invocation of Ediff,
600 ;; ediff-buffers will preserve the narrowing range. However, if ediff-files
601 ;; is invoked on the files visited by these buffers, narrowing will be
602 ;; turned off, since we assume that the user wants to compare the entire files.
603 ;;
604 ;; Invocation of ediff-small/large-regions and ediff-windows will cause
605 ;; Ediff to set new narrowing ranges. However, the old ranges are preserved
606 ;; and will be returned to after quitting or by hitting `%'.
607 ;;
608 ;; Two variables control the behavior of ediff-windows,
609 ;; ediff-small-regions, and ediff-large-regions with respect to narrowing:
610 ;;
611 ;; ediff-start-narrowed
612 ;; ediff-quit-widened
613 ;;
614 ;; If ediff-start-narrowed is t, then Ediff will narrow display to the
615 ;; appropriate range if it is invoked as ediff-windows or
616 ;; ediff-small/large-regions.
617 ;; If it is nil, then narrowing will not take place. However, the user can
618 ;; still toggle narrowing on and off by typing `%'.
619 ;; Similarly, ediff-quit-widened controls whether Ediff should restore
620 ;; the visibility range that existed before the current invocation.
621 ;;
622 ;;
623 ;; Refinement of difference regions
624 ;; --------------------------------
625 ;; Ediff has variables that control the way fine differences are
626 ;; highlighted. This feature lets the user highlight the exact words that
627 ;; make the difference regions in comparison buffers different. This process
628 ;; ignores spaces, tabs, and newlines.
629 ;;
630 ;; ediff-auto-refine
631 ;; ediff-auto-refine-limit
632 ;;
633 ;; By default, `ediff-auto-refine' is `on', which means that fine differences
634 ;; within regions will be highlighted automatically. On a slow system, this
635 ;; feature may be undesirable. In any case, the user can always toggle
636 ;; auto-refining on/off/nix by hitting `@'. When auto-refining is off, fine
637 ;; differences will be shown only for regions for which these differences
638 ;; have been computed and saved before. If auto-refining is nixed, fine
639 ;; differences will not be shown at all. Hitting `*' will compute and
640 ;; display fine differences for the current difference region regardless of
641 ;; whether auto-refining is on, off, or nixed.
642 ;; If auto-refining is on, the variable `ediff-auto-refine-limit' limits
643 ;; the size of the regions to be auto-refined. This variable guards against
644 ;; possible slow-down that may be caused by an extraordinary large
645 ;; difference region.
646 ;;
647 ;; However, the user can always force region refining by typing `*'.
648 ;;
649 ;; Sometimes, when a difference region has too many differences between the
650 ;; variants, highlighting of fine differences stands in the way, especially
651 ;; on color displays. If that is the case, the user can invoke `*' with a
652 ;; negative prefix argument, which would unhighlight fine diffs for the
653 ;; current region.
654 ;;
655 ;; To unhighlight fine differences in all diff regions, use the command
656 ;; `@'. Repeated typing of this key cycles through three different states:
657 ;; auto-refining, no-auto-refining, and unhighlighting of all fine
658 ;; differences.
659 ;;
660 ;; The variable
661 ;;
662 ;; ediff-forward-word-function
663 ;;
664 ;; allows the user to control how fine differences are computed.
665 ;; The value must be a lisp function that determines how the
666 ;; current difference region should be split into words.
667 ;;
668 ;; Fine diferences are computed by first splitting the current difference
669 ;; region into words and then passing this along to
670 ;; `ediff-diff-program'. For the default ediff-forward-word-function,
671 ;; `ediff-forward-word', a word is a string consisting of letters, `-', or
672 ;; `_', a string of punctuation symbols, a string of digits, or a string
673 ;; consisting of symbols that are neither space, nor a letter.
674 ;;
675 ;; Patch and diff programs
676 ;; -----------------------
677 ;; The next group of variables determines the programs to be used for
678 ;; applying patches and for computing the main difference regions (not the
679 ;; fine difference regions):
680 ;;
681 ;; ediff-patch-program
682 ;; ediff-patch-options
683 ;; ediff-diff-program
684 ;; ediff-diff-options
685 ;; ediff-diff3-program
686 ;; ediff-diff3-options
687 ;;
688 ;; Warning about VMS: The output from VMS DIFF is not yet supported.
689 ;; Instead, make sure some implementation of Unix diff on VMS is used.
690 ;;
691 ;; These specify the functions that produce differences and do patching.
692 ;; The *-options variables specify which options to pass to these programs.
693 ;; It is unlikely that you would want to change these.
694 ;; However, sometimes you may want to tell diff to ignore spaces and
695 ;; such. Use the option '-w' for that.
696 ;; Diff has several other useful options (type 'man diff' to find out).
697 ;;
698 ;; However, Ediff doesn't let you use the option '-c', as it doesn't
699 ;; recognize this format yet. However, if you need to save the output from
700 ;; diff in a special form, Ediff lets you specify ``custom'' diff format
701 ;; using the following two variables:
702 ;;
703 ;; ediff-custom-diff-program
704 ;; ediff-custom-diff-options
705 ;;
706 ;; The output generated by ediff-custom-diff-program (which doesn't even
707 ;; have to be a Unix-style diff!) is not used by Ediff, except that you can
708 ;; save if using ediff-save-buffer function (normally bound to `wd' key
709 ;; sequence).
710 ;; However, Ediff is not the preferred way of producing diff output in
711 ;; Emacs, unless you also intend to use Ediff to browse through the diff'ed
712 ;; files. This is because diff.el (M-x diff), which also comes with Emacs,
713 ;; is much faster in yielding the output of diff, while Ediff consumes many
714 ;; resources.
715
716 ;; Support for diff3 and merging
717 ;; -----------------------------
718
719 ;; Ediff supports 3way comparison via the functions `ediff-files3' and
720 ;; `ediff-buffers3'. The interface is the same as for 2-way comparison.
721 ;; In 3-way comparison and merging, Ediff indicates if any two difference
722 ;; regions are identical. For instance, if the current region in buffer A
723 ;; is the same as the region in buffer C, then the mode line of buffer A will
724 ;; display [=diff(C)] and the mode line of buffer C will display [=diff(A)].
725 ;;
726 ;; Merging is done according to the following algorithm.
727 ;;
728 ;; If a diff region in one of the buffers, say B, differs from the ancestor
729 ;; while the region in the other buffer, A, doesn't, then the merge buffer,
730 ;; C, gets the B's region. Similarly when buffer A's region differs from
731 ;; the ancestor and B's doesn't.
732 ;;
733 ;; If both regions, A and B, differ from the ancestor, then Ediff chooses
734 ;; according to the value of
735 ;;
736 ;; ediff-default-variant
737 ;;
738 ;; If the value is `default-A' then A's region is chosen. If it is
739 ;; `default-B' then B's region is chosen. If the value of the above
740 ;; variable is `combined' then the region in buffer C will look like this:
741 ;;
742 ;; #ifdef NEW /* variant A */
743 ;; diff region from buffer A
744 ;; #else /* variant B */
745 ;; diff region from buffer B
746 ;; #endif /* NEW */
747 ;;
748 ;; The actual strings that separate the regions copied from bufer A and B
749 ;; are controled by the variable
750 ;;
751 ;; ediff-combination-pattern
752 ;;
753 ;; which must be a list of three strings.
754 ;;
755 ;; In addition to the state of the difference, during merging Ediff
756 ;; displays the state of the merge for each region. If a difference came
757 ;; from buffer A by default (because both regions A and B were different
758 ;; from the ancestor and ediff-default-variant was set to `default-A')
759 ;; then [=diff(A) default-A] is displayed in the mode line. If the
760 ;; difference in buffer C came, say, from buffer B because the diff region
761 ;; in that buffer differs from the ancestor, but the region in buffer A
762 ;; doesn't (if merging with an ancestor) then [=diff(B) prefer-B] is
763 ;; displayed. The indicators default-A/B and prefer-A/B are inspired by
764 ;; emerge.el and have the same meaning.
765 ;;
766 ;; Another indicator of the state of merge is `combined'. It appears
767 ;; with any difference region in buffer C that was obtained by combining
768 ;; the difference regions in buffers A and B as explained above.
769 ;;
770 ;; Note that the state-of-difference indicators `=diff(A)' and `=diff(B)'
771 ;; above are not redundant, even in the present of a state-of-merge
772 ;; indicator, as the two serve different purposes. For instance, if the
773 ;; mode line displays [=diff(B) prefer(B)] and you copy a diff region from
774 ;; buffer A to buffer C then `=diff(B)' will change to `diff-A' and the
775 ;; mode line will display [=diff(A) prefer-B].
776 ;; This indicates that the difference region in buffer C is identical to
777 ;; that in buffer A, but originally buffer C's region came from buffer B.
778 ;; This is useful to know because the original diff region in buffer C can
779 ;; be recovered by typing `r'.
780 ;;
781 ;; Ediff never changes the state-of-merge indicator, except as a result of
782 ;; the `!' command (see below), in which case the indicator is lost.
783 ;; On the other hand, the state-of-difference indicator is changed
784 ;; automatically by the copying/recovery commands, `a', `b', `r', `+'.
785 ;;
786 ;; If Ediff is asked to recompute differences via the command `!', the
787 ;; information about origins of the regions in the merge buffer (default-A,
788 ;; prefer-B, or combined) will be lost. This is because recomputing
789 ;; differences in this case means running diff3 on buffers A, B, and the
790 ;; merge buffer, not on the ancestor buffer. (It makes no sense to
791 ;; recompute differences with the ancestor, since Ediff assumes that the user
792 ;; doesn't edit buffers A and B, but he may have edited buffer C, and these
793 ;; changes are to be preserved.) Since some difference regions
794 ;; may disappear as a result of editing in buffer C and others may arise,
795 ;; there is generally no simple way to tell where the various regions
796 ;; in the merge buffer came from.
797 ;;
798 ;; In 3-way comparison, Ediff tries to disregard regions consisting of
799 ;; white space only as much as possible. For instance, if, say, the current
800 ;; region in buffer A consists of the white space only (or if it is empty),
801 ;; Ediff will not take it into account for the purpose of computing fine
802 ;; differences. The result is that Ediff can provide more visual
803 ;; information regarding the actual fine differences in the non-white
804 ;; regions B and C. Moreover, if the regions in buffers B and C differ in
805 ;; the white space only, then a message to this effect will be displayed.
806 ;;
807 ;; In merging, the variable
808 ;;
809 ;; ediff-merge-window-share
810 ;;
811 ;; controls the split between window C (the window for the merge-buffer)
812 ;; and the windows for buffers A and B. The default is 0.5. To make the
813 ;; merge-buffer window smaller, reduce this amount. It is not recommended
814 ;; to increase the size of the merge-window to more than half the frame
815 ;; (i.e., to increase the default value of ediff-merge-window-share),
816 ;; since it is then hard to see the contents of buffers A and B.
817 ;;
818 ;; The user can temporarily shrink the merge window to just one line by
819 ;; typing `s'. This change is temporary, until Ediff finds a reason to
820 ;; redraw the screen. Typing `s' again will restore the original window size.
821 ;;
822 ;; With a positive prefix argument, this command will make the merge window
823 ;; slightly taller. This change will hold throughout the current Ediff
824 ;; session. With `-' or a negative prefix argument, the command `s' makes
825 ;; the merge window slightly shorter. This change also holds through the
826 ;; entire current Ediff session.
827 ;;
828 ;; Ediff lets the user automatically skip regions where one of the buffer's
829 ;; regions is prefered because it disagrees with the ancestor, while the
830 ;; other buffer agrees with the ancestor. In this case, Ediff displays only
831 ;; the difference regions where the changes made to the original clash with
832 ;; each other. The variable that controls this behavior is
833 ;;
834 ;; ediff-show-clashes-only
835 ;;
836 ;; The value of this variable can be toggled interactively, by typing `$'.
837 ;; Note that this variable controls only how Ediff chooses the
838 ;; next/previous difference to show. The user can still jump directly to
839 ;; any difference using the command `j' (with prefix argument specifying
840 ;; the difference number).
841
842 ;; Version control support
843 ;; -----------------------
844 ;; Ediff supports version control via vc.el (in the standard
845 ;; distribution of Emacs 19) and rcs.el. The latter is a package written by
846 ;; Sebastian Kremer <sk@thp.Uni-Koeln.DE>, which is available in
847 ;;
848 ;; ftp.cs.buffalo.edu:pub/Emacs/rcs.tar.Z
849 ;; ftp.uni-koeln.de:/pub/gnu/emacs/rcs.tar.Z
850 ;;
851 ;; To specify which version control package you are using, set the variable
852 ;; ediff-version-control-package, e.g.,
853 ;; (setq ediff-version-control-package 'rcs)
854 ;; The default, is `vc'.
855 ;; Note: both packages provide access to RCS, but only vc.el comes standard
856 ;; with Emacs and XEmacs.
857 ;; For files under revision control, one key (usually `=') is bound to the
858 ;; function ediff-revision, which runs Ediff on the current buffer and one
859 ;; of its versions. Use the variable
860 ;;
861 ;; ediff-revision-key
862 ;;
863 ;; if you want to change this binding, e.g., (setq ediff-revision-key "\C-cD")
864
865 ;;
866 ;; Mode line
867 ;; ---------
868 ;;
869 ;; When Ediff is running, the mode line of Ediff Control Panel buffer
870 ;; displays the current difference being displayed and the total number of
871 ;; difference regions in the two files.
872 ;;
873 ;; The mode line of the buffers being compared displays the type of the
874 ;; buffer (`A:' or `B:') and (usually) the file name. Ediff is trying to be
875 ;; intelligent in choosing mode line buffer identification. In particular,
876 ;; it works well with uniquify.el and mode-line.el packages (which improve
877 ;; on the default way in which Emacs displays buffer identification).
878 ;; If you don't like the way Ediff identifies its buffers, there is always
879 ;; ediff-prepare-buffer-hooks, which can be used to modify the mode line.
880 ;;
881 ;; Miscellaneous
882 ;; -------------
883 ;; The last batch of variables that can be modified is
884 ;;
885 ;; ediff-split-window-function
886 ;; ediff-merge-split-window-function
887 ;; ediff-make-wide-display-function
888 ;; ediff-use-last-dir
889 ;; ediff-no-emacs-help-in-control-buffer
890 ;; ediff-toggle-read-only-function
891
892 ;; ediff-split-window-function controls the way you want the window be
893 ;; split between file-A and file-B (and file-C, if applicable). It
894 ;; defaults to vertical split, but you can set it to
895 ;; split-window-horizontally, if you want.
896 ;; The variable ediff-merge-split-window-function controls how windows are
897 ;; split between buffers A and B in merging jobs.
898
899 ;; Ediff lets you toggle the way
900 ;; windows are split, so you can try different settings interactively.
901 ;; Note: if file-A and file-B (and file-C, if applicable) are in different
902 ;; frames, windows are not split, regardless of the value
903 ;; ediff-split-window-function. Instead, other windows on these frames are
904 ;; deleted and Ediff starts displaying file-A/B/C using these
905 ;; frames, one file per frame. You can then switch to one-frame mode
906 ;; simply by hiding one of the buffers A/B/C.
907 ;;
908 ;; Note that if Ediff detects that the two buffers it compares are residing in
909 ;; separate frames, it assumes that the user wants them to be so displayed
910 ;; and stops splitting windows. Instead, it will arrange each buffer to
911 ;; occupy its own frame (possibly shared with Ediff's help window).
912 ;;
913 ;; The user can swap the windows in which buffers are displayed by typing `~'.
914 ;; Furthermore, the user can toggle wide/regular display by typing
915 ;; `m'. This is particularly useful when files are compared side-by-side.
916 ;; By default, the display is widened without changing its height. However,
917 ;; the user can set the variable
918 ;;
919 ;; ediff-make-wide-display-function
920 ;;
921 ;; to contain the name of a function to be called to widen the frame in
922 ;; which to display the buffers. See the documentation string for
923 ;; `ediff-make-wide-display-function' for details. It is also recommended
924 ;; to look into how the default function, `ediff-make-wide-display' is
925 ;; written.
926 ;;
927 ;;
928 ;; The variable ediff-use-last-dir controls the way Ediff presents the
929 ;; default directory when it prompts the user for files to compare. If nil,
930 ;; Ediff will use the default directory of the current buffer when it
931 ;; prompts the user for file names. Otherwise, it will use the
932 ;; directories it had previously used for file-A/B/C.
933 ;;
934 ;; The variable ediff-no-emacs-help-in-control-buffer, if set to t, makes C-h
935 ;; behave like the DEL key, i.e., it will move you back to the previous
936 ;; difference rather than invoking help. This is useful when, in an xterm
937 ;; window or on a dumb terminal, the Backspace key is bound to C-h and is
938 ;; positioned more conveniently than the DEL key.
939 ;;
940 ;; The variable ediff-toggle-read-only-function can be used to change the
941 ;; way Ediff toggles the read-only property in its buffers.
942 ;; By default, Ediff uses toggle-read-only. For files under version
943 ;; control, Ediff first tries to check the files out.
944
945
946 ;;; Commands
947 ;; --------
948
949 ;; All Ediff commands are displayed in a help window, unless you hit '?' to
950 ;; shrink it to just one line. You can redisplay the help window by hitting
951 ;; '?' again.
952 ;;
953 ;; Many Ediff commands take numeric prefix arguments. For instance, if you
954 ;; hit a number, N, and then `j' (ediff-jump-to-difference), Ediff will
955 ;; take you to Nth difference. Hitting a number, N, and then `ab'
956 ;; (ediff-diff-to-diff) will copy Nth difference from buffer A to buffer B.
957 ;; Hitting `ba' does copying in the other direction. Likewise, `ca' would
958 ;; copy from buffer C to buffer A (if buffer C exists, of course).
959 ;; Likewise, a number, N, followed by `ra' will restore the Nth difference
960 ;; region in buffer A (if it was previously saved as a result of copying
961 ;; from buffer B to A).
962 ;;
963 ;; Without the prefix argument, all commands operate on the current
964 ;; difference region.
965 ;;
966 ;; The total number of differences and the current difference number are
967 ;; always displayed in the mode line of the control window.
968 ;;
969 ;; If, after making changes to buffers A, B, or C, you decide to save them,
970 ;; it is recommended to use `ediff-save-buffer', which is bound to `wa', `wb',
971 ;; and `wc' (`wa will save buffer A, `wb' saves buffer B, etc.).
972 ;;
973 ;; Typing `wd' saves the diff output in a file.
974
975 ;; The command `s' is used only for merging. It allows the user to shrink
976 ;; window C to its minimal size, thereby exposing as much of buffers A and
977 ;; B as possible.
978 ;; This command is intended only for temporary viewing. Therefore, Ediff
979 ;; will restore the original window size for buffer C whenever window
980 ;; configuration is changed by the user (on toggling help, split,
981 ;; etc.). However, recentering and jumping to a difference doesn't affect
982 ;; window C. Typing `s' again restores the original size of the merge
983 ;; window.
984 ;;
985 ;; With a positive prefix argument, the command `s' makes the merge
986 ;; window, window C, slightly taller. With `-' or a negative prefix
987 ;; argument, `s' makes window C slightly shorter.
988 ;;
989 ;; While browsing through differences in the merge mode, one may discover
990 ;; that the default variant was chosen inappropriately, which means that
991 ;; the user will have to do a lot of copying manually. To facilitate this,
992 ;; there is a command, bound to `&', which will cause Ediff to start
993 ;; merging anew beginning with the current difference and using the
994 ;; alternative default variant (the user is asked to type in the new
995 ;; default for merging, which can be either `default-A', `default-B', or
996 ;; `combined'.
997 ;;
998 ;; Such repeated merging affects only difference regions that have
999 ;; default-A/B status, and only if they were not changed with respect to
1000 ;; their originals.
1001 ;;
1002 ;; Another command that is used for merging only is `+'. Its effect is to
1003 ;; combine the current difference regions of buffers A and B and put the
1004 ;; combination into the merge buffer. See `ediff-combine-diffs' and
1005 ;; `ediff-combination-pattern' for details.
1006 ;;
1007 ;; There is also one command the is not bound to any key:
1008 ;;
1009 ;; ediff-revert-buffers-then-recompute-diffs
1010 ;;
1011 ;; It is useful when, after making changes, you decided to make a fresh
1012 ;; start, or if at some point you changed the files being compared but want
1013 ;; to discard any changes to comparison buffers that were done since then.
1014 ;; This command will ask for confirmation before reverting files. With a
1015 ;; prefix argument, it will revert files without asking.
1016
1017 ;;; Heavy-duty customization:
1018 ;; -------------------------
1019
1020 ;; Some users need to customize Ediff in rather sophisticated ways, which
1021 ;; requires different defaults for different kinds of files (e.g., SGML, etc.).
1022 ;; Ediff supports this kind of customization is several ways.
1023 ;; First, most customization variables are buffer-local. Those that aren't
1024 ;; are usually accessible from within Ediff Control Panel, so one can make
1025 ;; thel local to the panel by calling make-local-variable from within
1026 ;; ediff-startup-hooks.
1027 ;; Second, there is now a new optional (6-th) argument to ediff-setup,
1028 ;; which has the form ( (var-name-1 . val-1) (var-name-2 . val-2) ...).
1029 ;; The function ediff-setup will set the variables on the list to the
1030 ;; respective values in the ediff control buffer. This is an easy way to
1031 ;; throw in custom variables (which usually should be buffer-local) that
1032 ;; can then be tested in various hooks.
1033 ;; Make sure the variable ediff-job-name and ediff-word-mode are set
1034 ;; properly in this case, as some things in Ediff depend on this.
1035 ;; Finally, if custom-tailored help messages are desired, Ediff has
1036 ;; ediff-brief-help-message-custom and ediff-long-help-message-custom,
1037 ;; which are local variables that can be either set to
1038 ;; a function that returns a string.
1039
1040
1041 ;;; Bugs:
1042 ;; -----
1043
1044 ;; 1. The undo command doesn't restore deleted regions well. That is, if
1045 ;; you delete all characters in a difference region and then invoke
1046 ;; `undo', the reinstated text will most likely be inserted outside of
1047 ;; what Ediff thinks is the current difference region. (This problem
1048 ;; doesn't seem to exist with XEmacs.)
1049 ;;
1050 ;; If at any point you feel that difference regions are no longer correct,
1051 ;; you can hit '!' to recompute the differences.
1052
1053 ;; 2. Emacs 19.xx, where xx < 23, has several bugs related to overlays and
1054 ;; faces. Somethimes, these may cause highlighting of the refinements or
1055 ;; of the unselected differences to disappear. Hitting `!' will bring them
1056 ;; back. In version 19.23 and later, these problems no longer occur.
1057
1058 ;; 3. On a monochrome display, the repertoire of faces with which to
1059 ;; highlight fine differences is limited. By default, Ediff is using
1060 ;; underlining. However, if the region is already underlied by some other
1061 ;; overlays, there is no simple way to temporarily remove that residual
1062 ;; underlining. This problem occurs when a buffer is highlighted with
1063 ;; hilit19.el or font-lock.el packages. If this residual highlighting gets
1064 ;; in the way, you can do the following. Both font-lock.el and hilit19.el
1065 ;; provide commands for unhighlighting buffers. You can either place these
1066 ;; commands in `ediff-prepare-buffer-hooks' (which will unhighlight every
1067 ;; buffer used by Ediff) or you can execute them interactively, at any time
1068 ;; and on any buffer.
1069
1070 ;; 4. In XEmacs (statically linked with Motif libraries), emerge.el
1071 ;; and hence Ediff won't start, unless you set (setq scrollbar-width 0).
1072 ;; This is a Motif-related bug, I was told.
1073
1074 ;; 5. XEmacs 19.11 (and, probably, earlier versions) has trouble
1075 ;; positioning the point withing Ediff buffers on Ediff's startup.
1076 ;; This doesn't get in the way, though, since when the user start looking
1077 ;; at the diff regions, they are positioned correctly. It seems that
1078 ;; XEmacs doesn't have enough time to redisplay windows---it does this
1079 ;; correctly when it is told to redisplay (sit-for 0).
1080
1081 ;; 6. It seems that XEmacs icons are insensitive to keyboard events. This
1082 ;; deprives XEmacs users from being able to iconify Ediff's control panel,
1083 ;; thereby saving space onthe screen. Also, it seems that XEmacs doesn't
1084 ;; let one create minibuffer-less frames, which leaves Ediff control Panel
1085 ;; with a useless minibuffer. The "unsplittable" property is also ignored
1086 ;; in XEmacs, some further minor annoyances are possible.
1087
1088 ;; 7. XEmacs (19.11 and below) doesn't let one create minibufferless
1089 ;; frames. This causes the problem that messages are displayed in a small
1090 ;; control frame window, when help is toggled off. Ediff overcomes this by
1091 ;; setting synchronize-minibuffers to t, which causes all messages to be
1092 ;; displayed in all minibuffers. If you detest this, set
1093 ;; synchronize-minibuffers to nil after quitting Ediff.
1094
1095
1096 ;;; Change Log:
1097 ;; ----------
1098
1099 ;; Thu Feb 3, 1994
1100
1101 ;; Fixed a bug in ediff-setup-windows that caused control window to
1102 ;; appear in a wrong place when split-window-keep-point is nil
1103 ;; (Thanks to Kevin Broadey <KevinB@bartley.demon.co.uk>.)
1104 ;;
1105 ;; Added mechanism for using faces instead of before/after flags. This
1106 ;; looks much better on an X display, especially on a color one.
1107 ;; (Thanks to Boris Goldowsky <boris@cs.rochester.edu> for the code
1108 ;; that led to ediff-highlight-diff.
1109 ;; Also, thanks to Kevin Esler <esler@ch.hp.com> for suggestions
1110 ;; regarding highlighting differences on X displays.)
1111 ;;
1112 ;; Added functions to apply patches.
1113 ;; (Thanks to Kevin Broadey <KevinB@bartley.demon.co.uk> for this
1114 ;; suggestion.)
1115
1116 ;; Fri Feb 4, 1994
1117
1118 ;; Added mechanism for toggling vertical/horizontal window split.
1119 ;; (Inspired by a suggestion from Allan Gottlieb
1120 ;; <gottlieb@allan.ultra.nyu.edu> -- thanks.)
1121 ;;
1122 ;; Added mechanism for toggling between highlighting using faces and
1123 ;; highlighting using ASCII flags.
1124 ;;
1125 ;; Fixed a problem with undo. Now, Ediff has smartened up and doesn't
1126 ;; keep undo info on ASCII flags inserted in buffer-A and buffer-B.
1127 ;; So, if you edit the files while browsing through them, undo behaves
1128 ;; as you would expect, i.e., faces/flags don't get in the way.
1129
1130 ;; Sun Feb 6, 1994
1131
1132 ;; Added horizontal scrolling. Added ediff-position-region to ensure
1133 ;; that difference regions in buffer-A and buffer-B are aligned with
1134 ;; each other. Disabled ediff-toggle-split when buffers are displayed
1135 ;; in different frames.
1136 ;;
1137 ;; Added toggle-window help (Suggested by Boris Goldowsky
1138 ;; <boris@cs.rochester.edu>.)
1139 ;; Added functions to copy differences from one buffer to another and to
1140 ;; recover old differences.
1141 ;; Added prefix arguments to ediff-next-difference and
1142 ;; ediff-previous-difference.
1143
1144 ;; Tue Feb 8, 1994
1145
1146 ;; Replaced text properties with overlays. Fixed ediff-setup-windows.
1147 ;; Added ediff-save-buffer to local-write-file-hooks to prevent user
1148 ;; from saving corrupted states. (Thanks to <boris@cs.rochester.edu>
1149 ;; for suggestion.) Instead, Ediff now has a pair of functions for
1150 ;; safe saving of buffers.
1151 ;; Changed ediff-read-file-name to be more intuitive on ediff-files.
1152 ;; Added ediff-prepare-buffer-hooks. (Thanks to Kevin Esler
1153 ;; <esler@ch.hp.com> for the idea.)
1154 ;;
1155 ;; Cleanups in ediff-patch-file. Protected ediff-copy-diff against
1156 ;; a bug that Emacs has in kill-region.
1157 ;;
1158 ;; Added support for Lemacs. (Thanks to Alastair Burt
1159 ;; <burt@dfki.uni-kl.de> for coercing Ediff into working under Lemacs.)
1160 ;; Added ediff-kill-buffer-carefully and other suggestions by Boris
1161 ;; Goldowsky <boris@cs.rochester.edu>.
1162 ;; Refined the protection against interference with highlighting caused
1163 ;; by Hilit19. Added the variable ediff-third-party-highlighting.
1164 ;; Added mechanisn for unhighlighting regions highlighted with Hilit19
1165 ;; before hightlighting them with Ediff's overlays. (And for
1166 ;; rehighlighting them with Hilit19, when the current difference moves on.)
1167
1168 ;; Sun Feb 13, 1994
1169
1170 ;; Added ediff-place-flags-in-buffer and ediff-remote-exit, which are
1171 ;; modifications of Emerge's similar functions. The difference is that
1172 ;; in Ediff they make ediff-before-flag and ediff-after-flag into
1173 ;; read-only regions, so the user can't change them by mistake.
1174 ;;
1175 ;; Adopted a suggestion by Boris Goldowsky <boris@cs.rochester.edu>
1176 ;; that led to a more elegant treatment of faces.
1177 ;;
1178 ;; Added protection against interference with Font-Lock highlighting
1179 ;; similar to that of Hilit19's protection.
1180
1181 ;; Tue Feb 15, 1994
1182
1183 ;; Deleted spurious (auto-save-mode 1) in ediff-control-buffer, which
1184 ;; was causing this buffer to be auto-saved for no good reason.
1185 ;; Added read-only protection to ediff-before/after-flags in Lemacs.
1186 ;; (Thanks to Alastair Burt <burt@dfki.uni-kl.de> for help in testing.)
1187 ;;
1188 ;; Further fixes in the XEmacs part. Changed highlighted region in
1189 ;; ediff-highlight-diff so that an extra character will be highlighted
1190 ;; only if a difference is empty (thereby allowing the user to see where an
1191 ;; insertion or a deletion has taken place).
1192 ;;
1193 ;; Simplified interaction with other highlighting packages by giving
1194 ;; Ediff overlays the highest priority. (Taking a cue from
1195 ;; ediff-highlight-diff-lemacs written by Alastair Burt
1196 ;; <burt@dfki.uni-kl.de>.) Zapped ediff-third-party-highlighting
1197 ;; variable and hooks that were previously used to
1198 ;; unhighlight/rehighlight buffers when hilit19/font-lock are on.
1199
1200 ;; Fri Feb 18, 1994
1201
1202 ;; Added a bit more sophistication to ediff-read-file-name. Now,
1203 ;; ediff-files remembers both, the file-A and the file-B directories.
1204 ;; They are offered as defaults when ediff-use-last-dir is set to t.
1205
1206 ;; Fri Feb 22, 1994
1207
1208 ;; Added ediff-before-change-guard to remove ASCII highlighting when
1209 ;; the user attempts to change buffer-A/B. This is needed because
1210 ;; otherwise the undo info may become screwed up in those buffers.
1211 ;; Hitting `h' (ediff-toggle-hilit) on a dumb terminal will toggle
1212 ;; between ASCII highlighting and no highlighting.
1213
1214 ;; Fri Feb 24, 1994
1215
1216 ;; Fixed problems with multiple Ediff sessions running simultaneously.
1217
1218 ;; Tue Mar 1, 1994
1219
1220 ;; Added vc-ediff, the Ediff interface to vc.el. (Thanks to Eric
1221 ;; Freudenthal <freudent@jan.ultra.nyu.edu> for contributing this
1222 ;; function.)
1223
1224 ;; Sun Mar 6, 1994
1225
1226 ;; Added rcs-ediff, an Ediff interface to RCS via rcs.el. (Thanks to
1227 ;; Alastair Burt <burt@dfki.uni-kl.de>.)
1228 ;; Some minor improvements.
1229
1230 ;; Tue March 15, 1994
1231
1232 ;; Fixed a buglet in defining ediff-current-diff-face-A/B.
1233 ;; (Thanks to Job Ganzevoort <Job.Ganzevoort@cwi.nl>.)
1234
1235 ;; Tue March 22, 1994
1236
1237 ;; Fixed a bug with ediffing narrowed buffers, reported by Kevin
1238 ;; Broadey <KevinB@bartley.demon.co.uk>.
1239 ;; Made Ediff to work with files that have incomplete last line.
1240 ;; Made Ediff execute diff and patch using Bourne Shell, which
1241 ;; should eliminate problems with $prompt that some people had.
1242
1243 ;; Thu March 24, 1994
1244
1245 ;; Achieved quadratic speedup in the size of the file by replacing the
1246 ;; slow goto-line by forward-line.
1247 ;; Converted demarkation of difference regions
1248 ;; from markers to overlays. This will later allow us to highlight all
1249 ;; diffs, not just the current one.
1250
1251 ;; Wed March 30, 1994
1252
1253 ;; Under X, Ediff now highlights all differences in dim colors and the
1254 ;; current difference in bright colors. Improved XEmacs support.
1255 ;; Changed toggle hilit to cycle through 3 states: highlighting all
1256 ;; diffs, highlighting only the current diff, and highlighting using
1257 ;; ASCII flags.
1258 ;; Added support for difference regions that are not full lines.
1259
1260 ;; Fri April 1, 1994
1261
1262 ;; Fixed bugs related to writing buffers A and B.
1263 ;; Added commands `ga', `gb' to jump directly to the closest diff in
1264 ;; buffer A and B, respectively.
1265
1266 ;; Fri April 11, 1994
1267
1268 ;; Added `ediff-update-diffs', a function that lets the user recompute
1269 ;; difference regions after extensive editing done to buffers A and B
1270 ;; (bound to `!').
1271
1272 ;; Wed April 13, 1994
1273
1274 ;; Added the new feature: refining the current difference region.
1275 ;; This would highlight the precise differences between the regions in
1276 ;; buffer A and B. (A way to implement this was suggested by Boris
1277 ;; Goldowsky <boris@cs.rochester.edu>.)
1278 ;;
1279 ;; Fixed Ediff to be immune to several different versions of rcs.el
1280 ;; that are currently in distribution.
1281
1282 ;; Thu April 14, 1994
1283
1284 ;; Ediff now respects X resources for the faces it uses. It no longer
1285 ;; barks when the colormap has no colors it is using; or when face
1286 ;; fonts can't be italicized, etc.
1287
1288 ;; Fri April 15, 1994
1289
1290 ;; Changed `ediff-setup-windows' to minimize the need to delete and
1291 ;; create windows. Now jumps faster from diff to diff.
1292 ;; Added Ediff to the File menu on the menu bar (FSF's version).
1293
1294 ;; Mon April 18, 1994
1295
1296 ;; Fixed to work with OS/2's PM-Emacs.
1297
1298 ;; Thu April 21, 1994
1299
1300 ;; Lemacs' menus added (thanks to Alastair Burt for the help).
1301
1302 ;; Wed April 28, 1994
1303
1304 ;; Fixed ediff-keep-window-config (thanks to Norbert Kiesel
1305 ;; <norbert@i3.informatik.rwth-aachen.de>), ediff-shell and
1306 ;; ediff-protect-metachars (thanks to Richard Stanton
1307 ;; <stanton@haas.berkeley.edu>). Made access to difference
1308 ;; overlays structure-independent, making it less bug-prone.
1309 ;; Patched ediff-read-file-name to work more intuitively with directory
1310 ;; names (thanks to Kevin Broadey <KevinB@bartley.demon.co.uk>).
1311
1312 ;; Mon May 2, 1994
1313
1314 ;; Added `ediff-frame-has-menubar' to guard against the possibility that
1315 ;; the current frame has no menu bar.
1316
1317 ;; Fri May 6, 1994
1318
1319 ;; Fixed buglet in vc-ediff (thanks to Ray Nickson <nickson@cs.uq.oz.au>).
1320
1321 ;; Wed May 18, 1994
1322
1323 ;; Modified ediff-read-file-name to not put long file names in the
1324 ;; default prompt area, as suggested by KevinB@bartley.demon.co.uk.
1325 ;; Applied patch supplied by burt@dfki.uni-kl.de, fixing a problem with
1326 ;; ediff-diff-to-diff in Lemacs.
1327
1328 ;; Tue May 31, 1994
1329
1330 ;; Added ediff-forward-word-function (as suggested by Job Ganzevoort
1331 ;; <Job.Ganzevoort@cwi.nl>). Modified ediff-default-quit-hook so it
1332 ;; will clean things up in a more satisfactory way.
1333
1334 ;; Thu Jun 2, 1994
1335
1336 ;; Added `ediff-toggle-regexp-match', which allows the user to step
1337 ;; through only those difference regions that match some regexp; or,
1338 ;; vice versa, to skip over regions that match a regexp. (This feature
1339 ;; was suggested by Andy Scott <ascott@pcocd2.intel.com>.)
1340 ;; Added ediff-eval-in-buffer, which is a modified emerge-eval-in-buffer.
1341 ;; The function ediff-status-info, bound to `i', now replaces and extends
1342 ;; ediff-file-names and ediff-line-numbers, which were bound to `f'
1343 ;; and `i', respectively.
1344
1345
1346 ;; Wed Jun 10, 1994
1347
1348 ;; Improved `ediff-read-file-name' and `ediff-buffers' so they are now
1349 ;; providing more intuitive defaults. Modified `ediff-read-file-name'
1350 ;; so it won't cause problems under OS/2.
1351
1352 ;; Fri Jun 24, 1994
1353
1354 ;; Modified ediff-find-file, ediff-files-internal, and made
1355 ;; emerge-verify-file-buffer into ediff-verify-file-buffer so that
1356 ;; Ediff will work correctly with remote and compressed
1357 ;; files. (Suggested by Sandy Rutherford <sandy@ibm550.sissa.it>.)
1358
1359 ;; Fri Jun 28, 1994
1360
1361 ;; Fixed ediff-patch-files to work with remote and compressed files.
1362
1363 ;; Wed July 20, 1994
1364
1365 ;; Changed menu bar items per RMS's suggestion. Changed odd/even faces
1366 ;; in Lemacs to italic. Changed ediff-*-face-* variables so that they
1367 ;; will contain names of faces instead of the face internal
1368 ;; representation. (Copy-face works better with face names than with
1369 ;; face internal representation. With face internal representation, if
1370 ;; a face vector mentions a font explicitly, copy-face may attempt to
1371 ;; copy this font, which would cause an error if the font has a wrong
1372 ;; size for one of the existing frames.) Improved the way
1373 ;; mode-line-buffer-identification is set in ediff-setup so that Ediff
1374 ;; will accommodate the way buffers are identified in mode-line.el and
1375 ;; uniquify.el.
1376
1377 ;; Fri August 5, 1994
1378
1379 ;; Ediff can now automatically skip over regions that differ only in
1380 ;; the white space and line breaks. This is controled with the variable
1381 ;; `ediff-ignore-similar-regions' and can be toggled on/off by typing
1382 ;; `##'.
1383
1384 ;; Mon August 8, 1994
1385
1386 ;; If ediff-save-buffer is invoked with `wd', it'll save the diff
1387 ;; output in a file.
1388
1389 ;; Wed August 24, 1994
1390
1391 ;; Fixed ediff-toggle-read-only and ediff-patch-file so that they will
1392 ;; check out version-controled files before modifying them. This will
1393 ;; permit checking the modified versions back in. In earlier
1394 ;; versions, such modifications could be lost, unless the user takes
1395 ;; special care of preserving them.
1396
1397 ;; Tue August 30, 1994
1398
1399 ;; Added ediff-submit-report.
1400 ;; Introduced ediff-revision as a uniform way of calling vc.el and
1401 ;; rcs.el. This is controled by ediff-version-control-package
1402 ;; variable. Functions vc-ediff, rcs-ediff are replaced by their
1403 ;; internal versions.
1404 ;; Added ediff-find-file-name-handler function to smooth out the
1405 ;; transition from Emacs 19.22/XEmacs 19.9 to 19.23/19/10
1406
1407 ;; Thu September 1, 1994
1408
1409 ;; Made ediff-overlay-put and ediff-move-overlay into bona fide
1410 ;; functions (rather than fset symbols). These now check if overlay's
1411 ;; buffer is alive. If not, overlay is deleted. This overcomes some of
1412 ;; the problems with Lemacs.
1413
1414 ;; Thu September 8, 1994
1415
1416 ;; Added ediff-revision-key, ediff-load-version-control and streamlined
1417 ;; vc/rcs-ediff[-internal]. Eliminated dependency on emerge.el.
1418
1419 ;; Fri September 23, 1994
1420
1421 ;; Added ediff-windows and ediff-regions.
1422 ;; Changed ediff-setup-windows and related procedures to create
1423 ;; a separate dedicated control frame for each invocation of Ediff.
1424
1425 ;; Tue September 27, 1994
1426
1427 ;; Added redraw-display everywhere before creating or deleting
1428 ;; frames. It appears that this cures Emacs' bug where it trashes some
1429 ;; fonts which leads to crashes. Also, some code cleanups and bug fixes.
1430
1431 ;; Fri September 30, 1994
1432
1433 ;; Fixed ediff-update-diffs so it'll work correctly with
1434 ;; ediff-windows and ediff-regions. Added narrowing and widening to the
1435 ;; suite of commands available for ediff-windows and ediff-regions.
1436
1437 ;; Fri October 7, 1994
1438
1439 ;; Changed ediff-setup-windows to funcall the actual window setting
1440 ;; function, which is either ediff-setup-windows-multiframe or
1441 ;; ediff-setup-windows-plain. Changed all temp file names to use `_'
1442 ;; instead of `.'. Presumably, this makes VMS happier.
1443 ;; Ported to VMS (thanks to Richard Levitte <levitte@e.kth.se>).
1444 ;; Added ediff-prefer-long-help-message and changed defaults.
1445 ;; Fighting with XEmacs bugs. Made it possible to switch between plain
1446 ;; and multiframe display easier, but XEmacs is still getting confused
1447 ;; at times. Added ediff-check-version and ediff-set-help-message.
1448 ;; Made more sensible temp file names, which is important when
1449 ;; generating context diffs. Added ediff-make-frame-position and
1450 ;; ediff-control-frame-position-function.
1451
1452 ;; Wed October 12, 1994
1453
1454 ;; ediff-window-visible-p now makes a call to ediff-frame-visible-p
1455 ;; only when window-system is non-nil. Rearranged the block of fset's
1456 ;; so that the wrong things won't be defined when window-system is nil.
1457 ;; Added ediff-revert-buffers-then-recompute-diffs function.
1458 ;; Removed flag-argument from a background call to shell-command.
1459 ;; Added ediff-shell-command to enable custom diff execute in the
1460 ;; background and insert output in ediff-custom-diff-buffer.
1461 ;; Added ediff-shell-command-filter, because XEmacs doesn't have it.
1462 ;; Made ediff-revision set up ediff-job-name to `ediff-revision'.
1463 ;; This enables users do ediff-revision-specific actions on exiting
1464 ;; Ediff using ediff-quit-hooks.
1465 ;; Reshaffled some fset's so that functions for checking color and
1466 ;; faces won't be touched on a non-windowing display.
1467
1468 ;; Thu October 20, 1994
1469
1470 ;; Modified ediff-make-fine-diffs so that no fine diffs are computed if
1471 ;; one of the diff regions is empty. Saves time and also works around
1472 ;; the buggy diff program in AIX.
1473 ;; ediff no longer loads the version control package
1474 ;; automatically---only when ediff-revision is called.
1475 ;; Enabled focusing/hiding diff regions that match both or just one of the
1476 ;; regexps.
1477 ;; Changed ediff-regions to ediff-small-regions. Added ediff-large-regions.
1478 ;; Modified ediff-next/previous-difference to work right when both
1479 ;; skipping regexp matches and skipping similar regions is enabled.
1480 ;; Fixed bugs in positioning the control frame.
1481
1482 ;; Fri October 28, 1994
1483
1484 ;; Fixed bugs in ediff-next/previous-difference, ediff-set-visible-region
1485 ;; Changed/added ediff-word-[1-4].
1486
1487 ;; Tue November 1, 1994
1488
1489 ;; Made ediff-revision delete the temporary version files it creates.
1490
1491 ;; Tue November 29, 1994
1492
1493 ;; Added ediff-swap-buffers. Split ediff-difference-vector into
1494 ;; ediff-difference-vector-A and ediff-difference-vector-B, which
1495 ;; allowed to factor out a lot of stuff.
1496 ;; Made the code buffer-C ready.
1497
1498 ;; Thu December 1, 1994
1499
1500 ;; Lotsa bug fixes. Further rationalized the code.
1501 ;; Added ediff-display-help-hooks, ediff-mode-hooks.
1502 ;; Replaced almost identical ediff-scroll-up/down with
1503 ;; ediff-scroll-vertically.
1504 ;; Replaced almost identical ediff-scroll-left/right with
1505 ;; ediff-scroll-horizontally.
1506 ;; Made the code buffer-C ready.
1507
1508 ;; Thu December 8, 1994
1509
1510 ;; Added ediff-toggle-wide-display. In plain display, help message is
1511 ;; now centered correctly.
1512
1513 ;; Fri December 9, 1994
1514
1515 ;; Added ediff-toggle-multiframe (it doesn't work with XEmacs for some
1516 ;; reason). Fixed ediff-pop-diff and ediff-copy-diff, so that they will
1517 ;; invoke auto-refining, if necessary.
1518
1519 ;; Mon December 12, 1994
1520
1521 ;; Modified ediff-toggle-wide-display so it would funcall
1522 ;; ediff-make-wide-display-function.
1523
1524 ;; Tue December 13, 1994
1525
1526 ;; Ediff now chooses its surrogate minibuffer from frame A.
1527
1528 ;; Mon December 20, 1994
1529
1530 ;; Added ediff-keymap-setup-hooks.
1531
1532 ;; Fri December 23, 1994
1533
1534 ;; Changed the representation in ediff-killed-diffs-alist so that
1535 ;; ediff-save-diff-region and ediff-pop-diff won't be confused when the
1536 ;; user swaps buffers.
1537
1538 ;; Mon December 26, 1994
1539
1540 ;; Placated OS/2 by making Ediff to synchronize the call to startup
1541 ;; hooks with the acynchronous process that computes custom diffs.
1542 ;; This has no effect on Unix installations (and VMS?), but
1543 ;; may increase Ediff's startup time under OS/2 by 1 or 2 seconds.
1544
1545 ;; Thu December 29, 1994
1546
1547 ;; ediff-recenter now deactivates the mark, so that transient mark mode
1548 ;; highlighting won't interfere with Ediff's highlighting.
1549 ;; Also, ediff-recenter tries to not deiconify control frame, if it is
1550 ;; not needed.
1551
1552 ;; Fri December 30, 1994
1553
1554 ;; Small bugs. Worked around the OS/2 bug where
1555 ;; modify-frame-parameters has no effect on iconified frames. Ediff
1556 ;; now remembers the iconification status of the control frame and uses
1557 ;; it as a preferred way of displaying it when help is toggled
1558 ;; off. (This can be observed only in Emacs (not XEmacs) and only if
1559 ;; the window manager lets icons accept keyboard input.)
1560
1561 ;; Tue January 3, 1995
1562
1563 ;; Some futher work on incorporating buffer C in ediff-extract-diffs,
1564 ;; ediff-focus/hide-on-regexp-matches, and
1565 ;; ediff-setup-windows-plain/multiframe. The preceding two functions
1566 ;; now dispatch the appropriate setup function depending on whether the
1567 ;; current job is comparison or merge.
1568
1569 ;; Wed January 4, 1995
1570
1571 ;; Made it work under Emacs built without the X support.
1572
1573 ;; Fri January 6, 1995
1574
1575 ;; Slightly changed the prompting behavior of ediff-files. Bug fix in
1576 ;; mode-line-buffer-identification.
1577
1578 ;; Wed January 18, 1995
1579
1580 ;; Added 3way comparison and support for diff3. Ported to NeXTStep
1581 ;;
1582 ;; Fri January 20, 1995
1583
1584 ;; Added ediff-merge-files, ediff-merge-buffers,
1585 ;; ediff-merge-files-with-ancestor, ediff-merge-buffers-with-ancestor,
1586 ;; ediff-merge-revisions, ediff-merge-revisions-with-ancestor.
1587
1588 ;; Tue January 24, 1995
1589
1590 ;; Bug fixes. Split into several files.
1591
1592 ;; Thu January 26, 1995
1593
1594 ;; `*' is now bound to ediff-make-or-kill-fine-diffs. This lets the
1595 ;; user to kill fine diffs for the current region (by providing a
1596 ;; negative prefix arg), if there are so many of them as to hamper
1597 ;; the viewing.
1598
1599 ;; Mon January 30, 1995
1600
1601 ;; Changed ediff-selective-display to ediff-set-visible-region,
1602 ;; ediff-toggle-selective-display to ediff-toggle-narrow-region.
1603 ;; Ediff now turns selective display off before starting. Restores
1604 ;; selective display on exit.
1605 ;; In 2-way comparison, `a' now copies to buf `b' and `b' to buf `a'.
1606 ;; Previously, the bindings were `ab' and `ba'.
1607
1608 ;; Wed February 1, 1995
1609
1610 ;; Added ediff-undo-selective-display (thanks to Stig <stig@inse.com>).
1611 ;; Rearranged autoloads. Renamed ediff-entry.el into ediff.el and
1612 ;; ediff.el into ediff-util.el.
1613
1614 ;; Fri February 3
1615
1616 ;; Added ediff-toggle-show-clashes-only, which is bound to `$'.
1617
1618 ;; Fri February 19
1619
1620 ;; Some minor patches from Stig. Also, made ediff-xemacs-p and
1621 ;; ediff-*-job into variables for better performance.
1622 ;; In ediff-setup, diff regions are now computed after buffers A/B/C
1623 ;; are set up. Previously, it didn't work right with selective display.
1624 ;; Also, added ediff-profile to time Ediff commands and
1625 ;; ediff-debug-info for civilized display of the difference vectors
1626 ;; (and possibly more in the future).
1627
1628 ;; Tue March 14
1629
1630 ;; Fixed ediff-diff-at-point.
1631
1632
1633 ;;; TO DO:
1634 ;; ------
1635 ;;
1636 ;; 1. Add support for multiple sessions. (At present, one can run
1637 ;; multiple Ediff sessions, but they won't be related.) The idea is to
1638 ;; have vars local to each control buffer, which will tell which buffer is
1639 ;; the next and which is the previous one. The user could then go forward
1640 ;; and backward by typing C-SPC and C-DEL (or C-n and C-p).
1641 ;; This will probably entail some minor modifications to ediff-setup.
1642 ;; The primary use of this feature would be comparing directories of
1643 ;; similarly named files and multi-file patch. For the latter, Ediff will
1644 ;; have to parse patches to extract the names of files.
1645
1646
1647 ;;; Acknowledgements:
1648
1649 ;; Special thanks to Alastair Burt <burt@dfki.uni-kl.de>, Kevin Broadey
1650 ;; <KevinB@bartley.demon.co.uk>, Harald Boegeholz
1651 ;; <hwb@machnix.mathematik.uni-stuttgart.de>, Jin S. Choi" <jin@atype.com>,
1652 ;; Eric Eide <eeide@asylum.cs.utah.edu>, Kevin Esler <esler@ch.hp.com>, Robert
1653 ;; Estes <estes@ece.ucdavis.edu>, Eric Freudenthal
1654 ;; <freudent@jan.ultra.nyu.edu>,
1655 ;; Job Ganzevoort <Job.Ganzevoort@cwi.nl>, Boris Goldowsky
1656 ;; <boris@cs.rochester.edu>, Allan Gottlieb <gottlieb@allan.ultra.nyu.edu>,
1657 ;; Xiaoli Huang <hxl@epic.com>, Larry Gouge <larry@itginc.com>,
1658 ;; irvine@lks.csi.com, jaffe@chipmunk.cita.utoronto.ca, David Karr
1659 ;; <dkarr@nmo.gtegsc.com>, Norbert Kiesel
1660 ;; <norbert@i3.informatik.rwth-aachen.de>, Fritz Knabe <Fritz.Knabe@ecrc.de>,
1661 ;; Heinz Knutzen <hk@informatik.uni-kiel.d400.de>, Ken Laprade
1662 ;; <laprade@dw3f.ess.harris.com>, Richard Levitte
1663 ;; <levitte@e.kth.se>, Martin Maechler <maechler@stat.math.ethz.ch>,
1664 ;; Richard Mlynarik <mly@adoc.xerox.com>, Chris Murphy
1665 ;; <murphycm@sun.aston.ac.uk>, Eyvind Ness <Eyvind.Ness@hrp.no>, Ray Nickson
1666 ;; <nickson@cs.uq.oz.au>, Paul Raines <raines@slac.stanford.edu>, Tibor
1667 ;; Polgar <tlp00@spg.amdahl.com>, C.S. Roberson <roberson@aur.alcatel.com>,
1668 ;; Kevin Rodgers <kevin.rodgers@ihs.com>, Sandy Rutherford
1669 ;; <sandy@ibm550.sissa.it>, Heribert Schuetz <schuetz@ecrc.de>, Andy Scott
1670 ;; <ascott@pcocd2.intel.com>, Axel Seibert
1671 ;; <axel@tumbolia.ppp.informatik.uni-muenchen.de>, Richard Stallman
1672 ;; <rms@gnu.ai.mit.edu>, Richard Stanton <stanton@haas.berkeley.edu>,
1673 ;; Ake Stenhoff <etxaksf@aom.ericsson.se>,
1674 ;; Stig <stig@hackvan.com>, Peter Stout <Peter_Stout@cs.cmu.edu>,
1675 ;; Raymond Toy <toy@rtp.ericsson.se>,
1676 ;; and Ilya Zakharevich <ilya@math.ohio-state.edu>
1677 ;; for contributing ideas, patches, and bug reports.
1678 ;;
1679 ;; Thanks also to many others who felt obliged to drop a thank you note.
1680
1681
1682 ;;; Code:
1683
1684 (require 'ediff-init)
1685
1686 (defvar ediff-version-control-package 'vc
1687 "Version control package used.
1688 Currently, Ediff supports vc.el and rcs.el. Set this to `rcs' if you have
1689 rcs.el and want to use it instead of the standard vc.el.
1690
1691 Note: both packages provide access to RCS, but only vc.el comes with Emacs
1692 distribution.")
1693
1694 (defvar ediff-revision-key "="
1695 "Key to which `ediff-revision' is to be bound.")
1696
1697 (defvar ediff-use-last-dir nil
1698 "*If t, Ediff uses previous directory as default when reading file name.")
1699
1700 (defvar ediff-last-dir-A nil
1701 "Last directory used by an Ediff command for file-A.")
1702 (defvar ediff-last-dir-B nil
1703 "Last directory used by an Ediff command for file-B.")
1704 (defvar ediff-last-dir-C nil
1705 "Last directory used by an Ediff command for file-C.")
1706 (defvar ediff-last-dir-ancestor nil
1707 "Last directory used by an Ediff command for the ancestor file.")
1708 (defvar ediff-last-dir-patch nil
1709 "Last directory used by an Ediff command for file to patch.")
1710
1711 ;;; Patching
1712
1713 ;;;###autoload
1714 (defun ediff-patch-file (source-filename &optional startup-hooks)
1715 "Run Ediff by patching FILE-TP-PATCH."
1716 (interactive
1717 (list (ediff-read-file-name "File to patch"
1718 (if ediff-use-last-dir
1719 ediff-last-dir-patch
1720 default-directory)
1721 nil)))
1722
1723 (setq source-filename (expand-file-name source-filename))
1724 (ediff-get-patch-buffer (file-name-directory source-filename))
1725
1726 (let* ((backup-extension
1727 ;; if the user specified a -b option, extract the backup
1728 ;; extension from there; else use `_orig'
1729 (substring ediff-patch-options
1730 (if (string-match "-b[ \t]+" ediff-patch-options)
1731 (match-end 0) 0)
1732 (if (string-match "-b[ \t]+[^ \t]+" ediff-patch-options)
1733 (match-end 0) 0)))
1734 (shell-file-name ediff-shell)
1735 ;; ediff-find-file may use a temp file to do the patch
1736 ;; so, we save source-filename and true-source-filename as a var
1737 ;; that initially is source-filename but may be changed to a temp
1738 ;; file for the purpose of patching.
1739 (true-source-filename source-filename)
1740 (target-filename source-filename)
1741 target-buf buf-to-patch file-name-magic-p)
1742
1743 ;; if the user didn't specify a backup extension, use _orig
1744 (if (string= backup-extension "")
1745 (setq backup-extension "_orig"))
1746
1747 ;; Make a temp file, if source-filename has a magic file handler (or if
1748 ;; it is handled via auto-mode-alist and similar magic).
1749 ;; Check if there is a buffer visiting source-filename and if they are in
1750 ;; synch; arrange for the deletion of temp file.
1751 (ediff-find-file 'true-source-filename 'buf-to-patch
1752 'ediff-last-dir-patch 'startup-hooks)
1753
1754 ;; Check if source file name has triggered black magic, such as file name
1755 ;; handlers or auto mode alist, and make a note of it.
1756 ;; true-source-filename should be either the original name or a
1757 ;; temporary file where we put the after-product of the file handler.
1758 (setq file-name-magic-p (not (equal (file-truename true-source-filename)
1759 (file-truename source-filename))))
1760
1761 ;; Checkout orig file, if necessary so that the patched file could be
1762 ;; checked back in.
1763 (ediff-toggle-read-only buf-to-patch)
1764
1765 (ediff-eval-in-buffer ediff-patch-diagnostics
1766 (message "Applying patch ... ")(sit-for 0)
1767 ;; always pass patch the -f option, so it won't ask any questions
1768 (shell-command-on-region
1769 (point-min) (point-max)
1770 (format "%s -f %s -b %s %s"
1771 ediff-patch-program ediff-patch-options
1772 backup-extension
1773 (expand-file-name true-source-filename))
1774 t))
1775 (message "Applying patch ... done")(sit-for 0)
1776 (switch-to-buffer ediff-patch-diagnostics)
1777 (sit-for 0) ; synchronize
1778
1779 (or (file-exists-p (concat true-source-filename backup-extension))
1780 (error "Patch failed or didn't modify the original file"))
1781
1782 ;; If black magic is involved, apply patch to a temp copy of the
1783 ;; file. Otherwise, apply patch to the orig copy. If patch is applied
1784 ;; to temp copy, we name the result old-name_patched for local files
1785 ;; and temp-copy_patched for remote files. The orig file name isn't
1786 ;; changed, and the temp copy of the original is later deleted.
1787 ;; Without magic, the original file is renamed (usually into
1788 ;; old-name_orig) and the result of patching will have the same name as
1789 ;; the original.
1790 (if (not file-name-magic-p)
1791 (ediff-eval-in-buffer buf-to-patch
1792 (set-visited-file-name (concat source-filename backup-extension))
1793 (set-buffer-modified-p nil))
1794
1795 ;; Black magic in effect.
1796 ;; If orig file was remote, put the patched file in the temp directory.
1797 ;; If orig file is local, put the patched file in the directory of
1798 ;; the orig file.
1799 (setq target-filename
1800 (concat
1801 (if (ediff-file-remote-p (file-truename source-filename))
1802 true-source-filename
1803 source-filename)
1804 "_patched"))
1805
1806 (rename-file true-source-filename target-filename t)
1807
1808 ;; arrange that the temp copy of orig will be deleted
1809 (rename-file (concat true-source-filename backup-extension)
1810 true-source-filename t))
1811
1812 ;; make orig buffer read-only
1813 (setq startup-hooks
1814 (cons 'ediff-toggle-read-only-patch-orig startup-hooks))
1815
1816 ;; set up a buf for the patched file
1817 (ediff-eval-in-buffer
1818 (setq target-buf (find-file-noselect target-filename))
1819 ;; files to be patched are always checked out first
1820 (setq ediff-file-checked-out-flag t))
1821
1822 (ediff-buffers buf-to-patch target-buf startup-hooks 'epatch)
1823
1824 (bury-buffer ediff-patch-diagnostics)
1825 (message "Patch diagnostics available in buffer %s"
1826 (buffer-name ediff-patch-diagnostics))))
1827
1828 (defun ediff-toggle-read-only-patch-orig ()
1829 "Used as a startup hook to set `_orig' patch file read-only."
1830 (ediff-toggle-read-only ediff-buffer-A))
1831
1832 ;;;###autoload
1833 (defalias 'epatch 'ediff-patch-file)
1834 ;;;###autoload
1835 (defalias 'epatch-buffer 'ediff-patch-buffer)
1836
1837 ;;; Compare files/buffers
1838
1839 ;;;###autoload
1840 (defun ediff-files (file-A file-B &optional startup-hooks)
1841 "Run Ediff on a pair of files, FILE-A and FILE-B."
1842 (interactive
1843 (let ((dir-A (if ediff-use-last-dir
1844 ediff-last-dir-A
1845 default-directory))
1846 dir-B f)
1847 (list (setq f (ediff-read-file-name "File A to compare" dir-A nil))
1848 (ediff-read-file-name "File B to compare"
1849 (setq dir-B
1850 (if ediff-use-last-dir
1851 ediff-last-dir-B
1852 (file-name-directory f)))
1853 (progn
1854 (setq file-name-history
1855 (cons (abbreviate-file-name
1856 (expand-file-name
1857 (file-name-nondirectory f)
1858 dir-B))
1859 file-name-history))
1860 f))
1861 )))
1862 (ediff-files-internal file-A
1863 (if (file-directory-p file-B)
1864 (expand-file-name
1865 (file-name-nondirectory file-A) file-B)
1866 file-B)
1867 nil ; file-C
1868 startup-hooks
1869 'ediff-files))
1870
1871 ;;;###autoload
1872 (defun ediff-files3 (file-A file-B file-C &optional startup-hooks)
1873 "Run Ediff on three files, FILE-A, FILE-B, and FILE-C."
1874 (interactive
1875 (let ((dir-A (if ediff-use-last-dir
1876 ediff-last-dir-A
1877 default-directory))
1878 dir-B dir-C f ff)
1879 (list (setq f (ediff-read-file-name "File A to compare" dir-A nil))
1880 (setq ff (ediff-read-file-name "File B to compare"
1881 (setq dir-B
1882 (if ediff-use-last-dir
1883 ediff-last-dir-B
1884 (file-name-directory f)))
1885 (progn
1886 (setq file-name-history
1887 (cons
1888 (abbreviate-file-name
1889 (expand-file-name
1890 (file-name-nondirectory f)
1891 dir-B))
1892 file-name-history))
1893 f)))
1894 (ediff-read-file-name "File C to compare"
1895 (setq dir-C (if ediff-use-last-dir
1896 ediff-last-dir-C
1897 (file-name-directory ff)))
1898 (progn
1899 (setq file-name-history
1900 (cons (abbreviate-file-name
1901 (expand-file-name
1902 (file-name-nondirectory ff)
1903 dir-C))
1904 file-name-history))
1905 ff))
1906 )))
1907 (ediff-files-internal file-A
1908 (if (file-directory-p file-B)
1909 (expand-file-name
1910 (file-name-nondirectory file-A) file-B)
1911 file-B)
1912 (if (file-directory-p file-C)
1913 (expand-file-name
1914 (file-name-nondirectory file-A) file-C)
1915 file-C)
1916 startup-hooks
1917 'ediff-files3))
1918
1919 ;;;###autoload
1920 (defalias 'ediff3 'ediff-files3)
1921
1922
1923 (defun ediff-find-file (file-var buffer-name &optional last-dir hooks-var)
1924 "Visit FILE and arrange its buffer to Ediff's liking.
1925 FILE is actually a variable symbol that must contain a true file name.
1926 BUFFER-NAME is a variable symbol, which will get the buffer object into which
1927 FILE is read. LAST-DIR is the directory variable symbol where FILE's
1928 directory name should be returned. HOOKS is a variable symbol that will be
1929 assigned the hook to be executed after `ediff-startup' is finished.
1930 `ediff-find-file' arranges that the temp files it might create will be
1931 deleted."
1932 (let* ((file (symbol-value file-var))
1933 (file-magic (ediff-find-file-name-handler file))
1934 (temp-file-name-prefix (file-name-nondirectory file)))
1935 (if (not (file-readable-p file))
1936 (error "File `%s' does not exist or is not readable" file))
1937
1938 ;; some of the command, below, require full file name
1939 (setq file (expand-file-name file))
1940
1941 ;; Record the directory of the file
1942 (if last-dir
1943 (set last-dir (expand-file-name (file-name-directory file))))
1944
1945 ;; Setup the buffer
1946 (set buffer-name (find-file-noselect file))
1947
1948 (ediff-eval-in-buffer (symbol-value buffer-name)
1949 (widen) ; Make sure the entire file is seen
1950 (cond (file-magic ;; file has handler, such as jka-compr-handler or
1951 ;; ange-ftp-hook-function--arrange for temp file
1952 (ediff-verify-file-buffer 'magic)
1953 (setq file (ediff-make-temp-file temp-file-name-prefix))
1954 (set hooks-var (cons (` (lambda () (delete-file (, file))))
1955 (symbol-value hooks-var))))
1956 ;; file processed via auto-mode-alist, a la uncompress.el
1957 ((not (equal (file-truename file)
1958 (file-truename (buffer-file-name))))
1959 (setq file (ediff-make-temp-file temp-file-name-prefix))
1960 (set hooks-var (cons (` (lambda () (delete-file (, file))))
1961 (symbol-value hooks-var))))
1962 (t ;; plain file---just check that the file matches the buffer
1963 (ediff-verify-file-buffer))))
1964 (set file-var file)))
1965
1966 (defun ediff-files-internal (file-A file-B file-C startup-hooks job-name)
1967 (let (buf-A buf-B buf-C)
1968 (message "Reading file %s ... " file-A)(sit-for 0)
1969 (ediff-find-file 'file-A 'buf-A 'ediff-last-dir-A 'startup-hooks)
1970 (message "Reading file %s ... " file-B)(sit-for 0)
1971 (ediff-find-file 'file-B 'buf-B 'ediff-last-dir-B 'startup-hooks)
1972 (if (and (stringp file-C) (not ediff-merge-job))
1973 (progn
1974 (message "Reading file %s ... " file-C)(sit-for 0)
1975 (ediff-find-file
1976 'file-C 'buf-C
1977 (if (eq job-name 'ediff-merge-files-with-ancestor)
1978 'ediff-last-dir-ancestor 'ediff-last-dir-C)
1979 'startup-hooks)))
1980 (ediff-setup buf-A file-A
1981 buf-B file-B
1982 buf-C file-C
1983 startup-hooks
1984 (list (cons 'ediff-job-name job-name)))))
1985
1986
1987 ;;;###autoload
1988 (defalias 'ediff 'ediff-files)
1989
1990
1991 ;;;###autoload
1992 (defun ediff-buffers (buffer-A buffer-B &optional startup-hooks job-name)
1993 "Run Ediff on a pair of buffers, BUFFER-A and BUFFER-B."
1994 (interactive
1995 (let (bf)
1996 (list (setq bf (read-buffer "Buffer A to compare: "
1997 (ediff-other-buffer "") t))
1998 (read-buffer "Buffer B to compare: "
1999 (progn
2000 ;; realign buffers so that two visible bufs will be
2001 ;; at the top
2002 (save-window-excursion (other-window 1))
2003 (ediff-other-buffer bf))
2004 t))))
2005
2006 (or job-name (setq job-name 'ediff-buffers))
2007 (ediff-buffers-internal buffer-A buffer-B nil startup-hooks job-name))
2008
2009 ;;;###autoload
2010 (defun ediff-buffers3 (buffer-A buffer-B buffer-C
2011 &optional startup-hooks job-name)
2012 "Run Ediff on three buffers, BUFFER-A, BUFFER-B, and BUFFER-C."
2013 (interactive
2014 (let (bf bff)
2015 (list (setq bf (read-buffer "Buffer A to compare: "
2016 (ediff-other-buffer "") t))
2017 (setq bff (read-buffer "Buffer B to compare: "
2018 (progn
2019 ;; realign buffers so that two visible
2020 ;; bufs will be at the top
2021 (save-window-excursion (other-window 1))
2022 (ediff-other-buffer bf))
2023 t))
2024 (read-buffer "Buffer C to compare: "
2025 (progn
2026 ;; realign buffers so that three visible
2027 ;; bufs will be at the top
2028 (save-window-excursion (other-window 1))
2029 (ediff-other-buffer (list bf bff)))
2030 t)
2031 )))
2032
2033 (or job-name (setq job-name 'ediff-buffers3))
2034 (ediff-buffers-internal buffer-A buffer-B buffer-C startup-hooks job-name))
2035
2036
2037
2038 (defun ediff-buffers-internal (buf-A buf-B buf-C startup-hooks job-name)
2039 (let* ((buf-A-file-name (buffer-file-name (get-buffer buf-A)))
2040 (buf-B-file-name (buffer-file-name (get-buffer buf-B)))
2041 (buf-C-is-alive (ediff-buffer-live-p buf-C))
2042 (buf-C-file-name (if buf-C-is-alive
2043 (buffer-file-name (get-buffer buf-B))))
2044 file-A file-B file-C)
2045 (if (not (ediff-buffer-live-p buf-A))
2046 (error "Buffer %S doesn't exist" buf-A))
2047 (if (not (ediff-buffer-live-p buf-B))
2048 (error "Buffer %S doesn't exist" buf-B))
2049 (let ((ediff-job-name job-name))
2050 (if (and ediff-3way-comparison-job
2051 (not buf-C-is-alive))
2052 (error "Buffer %S doesn't exist" buf-C)))
2053 (if (stringp buf-A-file-name)
2054 (setq buf-A-file-name (file-name-nondirectory buf-A-file-name)))
2055 (if (stringp buf-B-file-name)
2056 (setq buf-B-file-name (file-name-nondirectory buf-B-file-name)))
2057 (if (stringp buf-C-file-name)
2058 (setq buf-C-file-name (file-name-nondirectory buf-C-file-name)))
2059
2060 ;; these three need to be evaluated in their buffers, since
2061 ;; ediff-make-temp-file checks the current buffer when assigning file
2062 ;; names
2063 (ediff-eval-in-buffer buf-A
2064 (setq file-A (ediff-make-temp-file buf-A-file-name)))
2065 (ediff-eval-in-buffer buf-B
2066 (setq file-B (ediff-make-temp-file buf-B-file-name)))
2067 (if buf-C-is-alive
2068 (ediff-eval-in-buffer buf-C
2069 (setq file-C (ediff-make-temp-file buf-C-file-name))))
2070
2071 (ediff-setup (get-buffer buf-A) file-A
2072 (get-buffer buf-B) file-B
2073 (if buf-C-is-alive (get-buffer buf-C))
2074 file-C
2075 (cons (` (lambda ()
2076 (delete-file (, file-A))
2077 (delete-file (, file-B))
2078 (if (stringp (, file-C)) (delete-file (, file-C)))
2079 ))
2080 startup-hooks)
2081 (list (cons 'ediff-job-name job-name))
2082 )))
2083
2084
2085
2086 ;;; Compare regions and windows
2087
2088 ;;;###autoload
2089 (defun ediff-windows (dumb-mode &optional wind-A wind-B startup-hooks)
2090 "Compare WIND-A and WIND-B, which are selected by clicking.
2091 With prefix argument, DUMB-MODE, or on a non-windowing display, works as
2092 follows:
2093 If WIND-A is nil, use selected window.
2094 If WIND-B is nil, use window next to WIND-A."
2095
2096 (interactive "P")
2097
2098 (if (or dumb-mode (not window-system))
2099 (setq wind-A (ediff-get-next-window wind-A nil)
2100 wind-B (ediff-get-next-window wind-B wind-A))
2101 (setq wind-A (ediff-get-window-by-clicking wind-A nil 1)
2102 wind-B (ediff-get-window-by-clicking wind-B wind-A 2)))
2103
2104 (let ((buffer-A (window-buffer wind-A))
2105 (buffer-B (window-buffer wind-B))
2106 beg-A end-A beg-B end-B)
2107
2108 (save-excursion
2109 (save-window-excursion
2110 (sit-for 0) ; synch before using window-start/end -- a precaution
2111 (select-window wind-A)
2112 (setq beg-A (window-start)
2113 end-A (window-end))
2114 (select-window wind-B)
2115 (setq beg-B (window-start)
2116 end-B (window-end))))
2117 (ediff-regions-internal
2118 buffer-A beg-A end-A buffer-B beg-B end-B
2119 startup-hooks 'ediff-windows 'word-mode)))
2120
2121 ;;;###autoload
2122 (defun ediff-small-regions (buffer-A buffer-B &optional startup-hooks)
2123 "Run Ediff on a pair of regions in two different buffers.
2124 Regions \(i.e., point and mark\) are assumed to be set in advance.
2125 This function is effective only for relatively small regions, up to 200
2126 lines. For large regions, use `ediff-large-regions'."
2127 (interactive
2128 (let (bf)
2129 (list (setq bf (read-buffer "Region's A buffer: "
2130 (ediff-other-buffer "") t))
2131 (read-buffer "Region's B buffer: "
2132 (progn
2133 ;; realign buffers so that two visible bufs will be
2134 ;; at the top
2135 (save-window-excursion (other-window 1))
2136 (ediff-other-buffer bf))
2137 t))))
2138 (if (not (ediff-buffer-live-p buffer-A))
2139 (error "Buffer %S doesn't exist" buffer-A))
2140 (if (not (ediff-buffer-live-p buffer-B))
2141 (error "Buffer %S doesn't exist" buffer-B))
2142
2143
2144 (let (reg-A-beg reg-A-end reg-B-beg reg-B-end)
2145 (save-excursion
2146 (set-buffer buffer-A)
2147 (setq reg-A-beg (region-beginning)
2148 reg-A-end (region-end))
2149 (set-buffer buffer-B)
2150 (setq reg-B-beg (region-beginning)
2151 reg-B-end (region-end)))
2152
2153 (ediff-regions-internal
2154 (get-buffer buffer-A) reg-A-beg reg-A-end
2155 (get-buffer buffer-B) reg-B-beg reg-B-end
2156 startup-hooks 'ediff-small-regions 'word-mode)))
2157
2158 ;;;###autoload
2159 (defun ediff-large-regions (buffer-A buffer-B &optional startup-hooks)
2160 "Run Ediff on a pair of regions in two different buffers.
2161 Regions \(i.e., point and mark\) are assumed to be set in advance.
2162 Each region is enlarged to contain full lines.
2163 This function is effective for large regions, over 100-200
2164 lines. For small regions, use `ediff-small-regions'."
2165 (interactive
2166 (let (bf)
2167 (list (setq bf (read-buffer "Region A's buffer: "
2168 (ediff-other-buffer "") t))
2169 (read-buffer "Region B's buffer: "
2170 (progn
2171 ;; realign buffers so that two visible bufs will be
2172 ;; at the top
2173 (save-window-excursion (other-window 1))
2174 (ediff-other-buffer bf))
2175 t))))
2176 (if (not (ediff-buffer-live-p buffer-A))
2177 (error "Buffer %S doesn't exist" buffer-A))
2178 (if (not (ediff-buffer-live-p buffer-B))
2179 (error "Buffer %S doesn't exist" buffer-B))
2180
2181 (let (reg-A-beg reg-A-end reg-B-beg reg-B-end)
2182 (save-excursion
2183 (set-buffer buffer-A)
2184 (setq reg-A-beg (region-beginning)
2185 reg-A-end (region-end))
2186 ;; enlarge the region to hold full lines
2187 (goto-char reg-A-beg)
2188 (beginning-of-line)
2189 (setq reg-A-beg (point))
2190 (goto-char reg-A-end)
2191 (end-of-line)
2192 (or (eobp) (forward-char)) ; include the newline char
2193 (setq reg-A-end (point))
2194
2195 (set-buffer buffer-B)
2196 (setq reg-B-beg (region-beginning)
2197 reg-B-end (region-end))
2198 ;; enlarge the region to hold full lines
2199 (goto-char reg-A-beg)
2200 (goto-char reg-B-beg)
2201 (beginning-of-line)
2202 (setq reg-B-beg (point))
2203 (goto-char reg-B-end)
2204 (end-of-line)
2205 (or (eobp) (forward-char)) ; include the newline char
2206 (setq reg-B-end (point))
2207 ) ; save excursion
2208
2209 (ediff-regions-internal
2210 (get-buffer buffer-A) reg-A-beg reg-A-end
2211 (get-buffer buffer-B) reg-B-beg reg-B-end
2212 startup-hooks 'ediff-large-regions nil))) ; no word mode
2213
2214 ;; compare region beg-A to end-A of buffer-A
2215 ;; to regions beg-B -- end-B in buffer-B.
2216 (defun ediff-regions-internal (buffer-A beg-A end-A buffer-B beg-B end-B
2217 startup-hooks job-name word-mode)
2218 (let ((tmp-buffer (get-buffer-create ediff-tmp-buffer))
2219 overl-A overl-B
2220 file-A file-B)
2221
2222 ;; in case beg/end-A/B aren't markers--make them into markers
2223 (ediff-eval-in-buffer buffer-A
2224 (setq beg-A (move-marker (make-marker) beg-A)
2225 end-A (move-marker (make-marker) end-A)))
2226 (ediff-eval-in-buffer buffer-B
2227 (setq beg-B (move-marker (make-marker) beg-B)
2228 end-B (move-marker (make-marker) end-B)))
2229
2230 (if (and (eq buffer-A buffer-B)
2231 (or (and (< beg-A end-B) (<= beg-B beg-A)) ; b-B b-A e-B
2232 (and (< beg-B end-A) (<= end-A end-B)))) ; b-B e-A e-B
2233 (progn
2234 (with-output-to-temp-buffer ediff-msg-buffer
2235 (princ "
2236 You have requested to compare overlapping regions of the same buffer.
2237
2238 In this case, Ediff's highlighting may be confusing---in the same window,
2239 you may see highlighted regions that belong to different regions.
2240
2241 Continue anyway? (y/n) "))
2242
2243 (if (y-or-n-p "Continue anyway? ")
2244 ()
2245 (error "%S aborted" job-name))))
2246
2247 ;; make file-A
2248 (if word-mode
2249 (ediff-wordify beg-A end-A buffer-A tmp-buffer)
2250 (ediff-copy-to-buffer beg-A end-A buffer-A tmp-buffer))
2251 (ediff-eval-in-buffer tmp-buffer
2252 (setq file-A (ediff-make-temp-file "regA")))
2253
2254 ;; make file-B
2255 (if word-mode
2256 (ediff-wordify beg-B end-B buffer-B tmp-buffer)
2257 (ediff-copy-to-buffer beg-B end-B buffer-B tmp-buffer))
2258 (ediff-eval-in-buffer tmp-buffer
2259 (setq file-B (ediff-make-temp-file "regB")))
2260
2261 (setq overl-A (ediff-make-bullet-proof-overlay beg-A end-A buffer-A))
2262 (setq overl-B (ediff-make-bullet-proof-overlay beg-B end-B buffer-B))
2263 (ediff-setup buffer-A file-A
2264 buffer-B file-B
2265 nil nil ; buffer & file C
2266 (cons (` (lambda ()
2267 (delete-file (, file-A))
2268 (delete-file (, file-B))))
2269 startup-hooks)
2270 (list (cons 'ediff-word-mode word-mode)
2271 (cons 'ediff-narrow-bounds (list overl-A overl-B))
2272 (cons 'ediff-job-name job-name))
2273 )
2274 ))
2275
2276
2277 ;;; Merge files and buffers
2278
2279 ;;;###autoload
2280 (defalias 'ediff-merge 'ediff-merge-files)
2281
2282 (defsubst ediff-merge-on-startup ()
2283 (ediff-do-merge 0)
2284 (ediff-eval-in-buffer ediff-buffer-C
2285 (set-buffer-modified-p nil)))
2286
2287 ;;;###autoload
2288 (defun ediff-merge-files (file-A file-B &optional startup-hooks)
2289 "Merge two files without ancestor."
2290 (interactive
2291 (let ((dir-A (if ediff-use-last-dir
2292 ediff-last-dir-A
2293 default-directory))
2294 dir-B f)
2295 (list (setq f (ediff-read-file-name "File A to merge" dir-A nil))
2296 (ediff-read-file-name "File B to merge"
2297 (setq dir-B
2298 (if ediff-use-last-dir
2299 ediff-last-dir-B
2300 (file-name-directory f)))
2301 (progn
2302 (setq file-name-history
2303 (cons (abbreviate-file-name
2304 (expand-file-name
2305 (file-name-nondirectory f)
2306 dir-B))
2307 file-name-history))
2308 f))
2309 )))
2310 (setq startup-hooks (cons 'ediff-merge-on-startup startup-hooks))
2311 (ediff-files-internal file-A
2312 (if (file-directory-p file-B)
2313 (expand-file-name
2314 (file-name-nondirectory file-A) file-B)
2315 file-B)
2316 nil ; file-C
2317 startup-hooks
2318 'ediff-merge-files))
2319
2320 ;;;###autoload
2321 (defun ediff-merge-files-with-ancestor (file-A file-B file-ancestor
2322 &optional startup-hooks)
2323 "Merge two files with ancestor."
2324 (interactive
2325 (let ((dir-A (if ediff-use-last-dir
2326 ediff-last-dir-A
2327 default-directory))
2328 dir-B dir-ancestor f ff)
2329 (list (setq f (ediff-read-file-name "File A to merge" dir-A nil))
2330 (setq ff (ediff-read-file-name "File B to merge"
2331 (setq dir-B
2332 (if ediff-use-last-dir
2333 ediff-last-dir-B
2334 (file-name-directory f)))
2335 (progn
2336 (setq file-name-history
2337 (cons
2338 (abbreviate-file-name
2339 (expand-file-name
2340 (file-name-nondirectory f)
2341 dir-B))
2342 file-name-history))
2343 f)))
2344 (ediff-read-file-name "Ancestor file"
2345 (setq dir-ancestor
2346 (if ediff-use-last-dir
2347 ediff-last-dir-ancestor
2348 (file-name-directory ff)))
2349 (progn
2350 (setq file-name-history
2351 (cons (abbreviate-file-name
2352 (expand-file-name
2353 (file-name-nondirectory ff)
2354 dir-ancestor))
2355 file-name-history))
2356 ff))
2357 )))
2358 (setq startup-hooks (cons 'ediff-merge-on-startup startup-hooks))
2359 (ediff-files-internal file-A
2360 (if (file-directory-p file-B)
2361 (expand-file-name
2362 (file-name-nondirectory file-A) file-B)
2363 file-B)
2364 file-ancestor
2365 startup-hooks
2366 'ediff-merge-files-with-ancestor))
2367
2368 ;;;###autoload
2369 (defalias 'ediff-merge-with-ancestor 'ediff-merge-files-with-ancestor)
2370
2371 ;;;###autoload
2372 (defun ediff-merge-buffers (buffer-A buffer-B &optional startup-hooks job-name)
2373 "Merge buffers without ancestor."
2374 (interactive
2375 (let (bf)
2376 (list (setq bf (read-buffer "Buffer A to merge: "
2377 (ediff-other-buffer "") t))
2378 (read-buffer "Buffer B to merge: "
2379 (progn
2380 ;; realign buffers so that two visible bufs will be
2381 ;; at the top
2382 (save-window-excursion (other-window 1))
2383 (ediff-other-buffer bf))
2384 t))))
2385
2386 (setq startup-hooks (cons 'ediff-merge-on-startup startup-hooks))
2387 (or job-name (setq job-name 'ediff-merge-buffers))
2388 (ediff-buffers-internal
2389 buffer-A buffer-B nil startup-hooks job-name))
2390
2391 ;;;###autoload
2392 (defun ediff-merge-buffers-with-ancestor (buffer-A
2393 buffer-B buffer-ancestor
2394 &optional startup-hooks job-name)
2395 "Merge buffers with ancestor."
2396 (interactive
2397 (let (bf bff)
2398 (list (setq bf (read-buffer "Buffer A to merge: "
2399 (ediff-other-buffer "") t))
2400 (setq bff (read-buffer "Buffer B to merge: "
2401 (progn
2402 ;; realign buffers so that two visible
2403 ;; bufs will be at the top
2404 (save-window-excursion (other-window 1))
2405 (ediff-other-buffer bf))
2406 t))
2407 (read-buffer "Ancestor buffer: "
2408 (progn
2409 ;; realign buffers so that three visible
2410 ;; bufs will be at the top
2411 (save-window-excursion (other-window 1))
2412 (ediff-other-buffer (list bf bff)))
2413 t)
2414 )))
2415
2416 (setq startup-hooks (cons 'ediff-merge-on-startup startup-hooks))
2417 (or job-name (setq job-name 'ediff-merge-buffers-with-ancestor))
2418 (ediff-buffers-internal
2419 buffer-A buffer-B buffer-ancestor startup-hooks job-name))
2420
2421
2422 ;;;###autoload
2423 (defun ediff-merge-revisions (rev1 rev2 &optional startup-hooks)
2424 "Run Ediff by merging two revisions of a file.
2425 The file is the one visited by the current buffer."
2426 (interactive
2427 "sVersion 1 to merge (default is the latest version): \nsVersion 2 to merge (default is the latest version): ")
2428 (ediff-load-version-control)
2429 (let (buf1 buf2)
2430 (if (eq ediff-version-control-package 'vc)
2431 (progn
2432 (save-excursion
2433 (vc-version-other-window rev1)
2434 (setq buf1 (current-buffer)))
2435 (save-excursion
2436 (vc-version-other-window rev2)
2437 (setq buf2 (current-buffer)))
2438 (setq startup-hooks
2439 (list (` (lambda ()
2440 (delete-file (, (buffer-file-name buf1)))
2441 (delete-file (, (buffer-file-name buf2))))))))
2442 (setq buf1 (rcs-ediff-view-revision rev1)
2443 buf2 (rcs-ediff-view-revision rev2)))
2444 (ediff-merge-buffers buf1 buf2 startup-hooks 'ediff-merge-revisions)))
2445
2446
2447 ;;;###autoload
2448 (defun ediff-merge-revisions-with-ancestor (rev1
2449 rev2 ancestor-rev
2450 &optional startup-hooks)
2451 "Run Ediff by merging with ancestor of two revisions of a file.
2452 The file is the one visited by the current buffer."
2453 (interactive
2454 "sVersion 1 to merge (default: the latest version): \nsVersion 2 to merge (default: the latest version): \nsAncestor version (default: the latest version): ")
2455 (ediff-load-version-control)
2456 (let (buf1 buf2 ancestor-buf)
2457 (if (eq ediff-version-control-package 'vc)
2458 (progn
2459 (save-excursion
2460 (vc-version-other-window rev1)
2461 (setq buf1 (current-buffer)))
2462 (save-excursion
2463 (vc-version-other-window rev2)
2464 (setq buf2 (current-buffer)))
2465 (save-excursion
2466 (vc-version-other-window ancestor-rev)
2467 (setq ancestor-buf (current-buffer)))
2468 (setq startup-hooks
2469 (list (` (lambda ()
2470 (delete-file (, (buffer-file-name buf1)))
2471 (delete-file (, (buffer-file-name buf2)))
2472 (delete-file (, (buffer-file-name ancestor-buf)))
2473 )))))
2474 (setq buf1 (rcs-ediff-view-revision rev1)
2475 buf2 (rcs-ediff-view-revision rev2)
2476 ancestor-buf (rcs-ediff-view-revision ancestor-rev)))
2477 (ediff-merge-buffers-with-ancestor
2478 buf1 buf2 ancestor-buf
2479 startup-hooks 'ediff-merge-revisions-with-ancestor)))
2480
2481
2482 ;;; Apply patch
2483
2484
2485 ;;;###autoload
2486 (defun ediff-patch-buffer (buffer-name &optional startup-hooks)
2487 "Run Ediff by patching BUFFER-NAME."
2488 (interactive "bBuffer to patch: ")
2489
2490 (let* ((file-buffer (get-buffer buffer-name))
2491 (file-name (if file-buffer (buffer-file-name file-buffer))))
2492 (if (not file-name)
2493 (error "Buffer %s doesn't exist or doesn't visit any file. Why patch?"
2494 file-name))
2495
2496 (ediff-patch-file file-name startup-hooks)))
2497
2498
2499 (defun ediff-get-patch-buffer (dir)
2500 "Obtain patch buffer. If patch is already in a buffer---use it.
2501 Else, read patch file into a new buffer."
2502 (if (y-or-n-p "Is the patch file already in a buffer? ")
2503 (setq ediff-patch-buf
2504 (get-buffer (read-buffer "Patch buffer name: " nil t))) ;must match
2505 (setq ediff-patch-buf
2506 (find-file-noselect (read-file-name "Patch file name: " dir))))
2507
2508 ;; secure the patch buffer against accidental changes
2509 (ediff-eval-in-buffer ediff-patch-buf
2510 (setq buffer-read-only t))
2511
2512 (setq ediff-patch-diagnostics
2513 (get-buffer-create "*ediff patch diagnostics*"))
2514 (ediff-eval-in-buffer
2515 ediff-patch-diagnostics
2516 (insert-buffer ediff-patch-buf))
2517 )
2518
2519
2520
2521
2522 \f
2523 ;;; Versions Control functions
2524
2525 ;;;###autoload
2526 (defun ediff-revision (revision)
2527 "Call `vc.el' or `rcs.el' depending on `ediff-version-control-package'.
2528 This function is introduced to provide a uniform interface to version
2529 control packages from Ediff."
2530 (interactive "sVersion to Ediff with (default: the latest version): ")
2531 (ediff-load-version-control)
2532 (funcall
2533 (intern (format "%S-ediff-internal" ediff-version-control-package))
2534 revision))
2535
2536 ;; Backward compatibility
2537 ;;;###autoload
2538 (defun vc-ediff ()
2539 (interactive)
2540 (beep 1)
2541 (with-output-to-temp-buffer ediff-msg-buffer
2542 (princ "
2543 You have invoked an obsolete function `vc-ediff' or `rcs-ediff'.
2544 Please use `M-x ediff-revision' instead.
2545
2546 Also, please check the variables `ediff-version-control-package'
2547 and `ediff-revision-key' for customization.")))
2548
2549 (defalias 'rcs-ediff 'vc-ediff)
2550
2551 ;; Test if version control package is loaded and load if not
2552 ;; Is SILENT is non-nil, don't report error if package is not found.
2553 (defun ediff-load-version-control (&optional silent)
2554 (or (featurep ediff-version-control-package)
2555 (if (locate-library (symbol-name ediff-version-control-package))
2556 (progn
2557 (message "") ; kill the message from `locate-library'
2558 (require ediff-version-control-package)
2559 (define-key
2560 (cond ((eq ediff-version-control-package 'vc) vc-prefix-map)
2561 ((eq ediff-version-control-package 'rcs) global-map)
2562 (t global-map))
2563 ediff-revision-key 'ediff-revision))
2564 (or silent
2565 (error "Version control package %S.el not found. Use vc.el instead"
2566 ediff-version-control-package)))))
2567
2568
2569 ;; Note: this function will work only with Emacs 19.22 or later.
2570 (defun vc-ediff-internal (rev)
2571 "Run Ediff on version REV of the current buffer in another window.
2572 If the current buffer is named `F', the version is named `F.~REV~'.
2573 If `F.~REV~' already exists, it is used instead of being re-created."
2574 (let ((newvers (current-buffer)))
2575 (vc-version-other-window rev)
2576 ;; current-buffer is now supposed to contain the old version
2577 ;; in another window
2578 ;; We delete the temp file that was created by vc.el for the old
2579 ;; version
2580 (ediff-buffers (current-buffer) newvers
2581 (list (` (lambda () (delete-file (, (buffer-file-name))))))
2582 'ediff-revision)
2583 ))
2584
2585 (defun rcs-ediff-view-revision (&optional rev)
2586 "View previous RCS revision of current file.
2587 With prefix argument, prompts for a revision name."
2588 (interactive (list (if current-prefix-arg
2589 (read-string "Revision: "))))
2590 (let* ((filename (buffer-file-name (current-buffer)))
2591 (switches (append '("-p")
2592 (if rev (list (concat "-r" rev)) nil)))
2593 (buff (concat (file-name-nondirectory filename) ".~" rev "~")))
2594 (message "Working ...")
2595 (setq filename (expand-file-name filename))
2596 (with-output-to-temp-buffer buff
2597 (let ((output-buffer (ediff-rcs-get-output-buffer filename buff)))
2598 (delete-windows-on output-buffer)
2599 (save-excursion
2600 (set-buffer output-buffer)
2601 (apply 'call-process "co" nil t nil
2602 ;; -q: quiet (no diagnostics)
2603 (append switches rcs-default-co-switches
2604 (list "-q" filename)))))
2605 (message "")
2606 buff)))
2607
2608 (defun ediff-rcs-get-output-buffer (file name)
2609 ;; Get a buffer for RCS output for FILE, make it writable and clean it up.
2610 ;; Optional NAME is name to use instead of `*RCS-output*'.
2611 ;; This is a modified version from rcs.el v1.1. I use it here to make
2612 ;; Ediff immune to changes in rcs.el
2613 (let* ((default-major-mode 'fundamental-mode) ; no frills!
2614 (buf (get-buffer-create name)))
2615 (save-excursion
2616 (set-buffer buf)
2617 (setq buffer-read-only nil
2618 default-directory (file-name-directory (expand-file-name file)))
2619 (erase-buffer))
2620 buf))
2621
2622 (defun rcs-ediff-internal (rev)
2623 "Run Ediff on the current buffer, comparing it with previous RCS revision."
2624 (let ((newvers (current-buffer))
2625 (oldvers (rcs-ediff-view-revision rev)))
2626
2627 ;; rcs.el doesn't create temp version files, so we don't have to delete
2628 ;; anything in startup hooks to ediff-buffers
2629 (ediff-buffers oldvers newvers nil 'ediff-revision)
2630 ))
2631
2632 ;;; Menu bar
2633
2634 ;;; This is split in several parts to avoid
2635 ;;; making a line in loaddefs.el that is too long for patch.
2636 ;;; Note that autoload.el currently looks for cookies
2637 ;;; only at top level in the file.
2638 ;;; So I moved these to top level. But the conditionals on
2639 ;;; purify-flag make these no-ops when you load ediff.
2640 ;;; They only do something in loaddefs.el.
2641
2642 ;;;###autoload
2643 (if purify-flag
2644 ;; explicit string-match, as ediff-xemacs-p is not defined at build time
2645 (if (string-match "\\(Lucid\\|Xemacs\\)" emacs-version)
2646 ()
2647 (defvar menu-bar-epatch-menu (make-sparse-keymap "Epatch"))
2648 (fset 'menu-bar-epatch-menu (symbol-value 'menu-bar-epatch-menu))
2649 (defvar menu-bar-ediff-merge-menu (make-sparse-keymap "Ediff merge"))
2650 (fset 'menu-bar-ediff-merge-menu
2651 (symbol-value 'menu-bar-ediff-merge-menu))
2652 (defvar menu-bar-ediff-menu (make-sparse-keymap "Ediff"))
2653 (fset 'menu-bar-ediff-menu (symbol-value 'menu-bar-ediff-menu))
2654 ))
2655
2656
2657 ;;;###autoload
2658 (if purify-flag
2659 ;; explicit string-match, as ediff-xemacs-p is not defined at build time
2660 (if (string-match "\\(Lucid\\|Xemacs\\)" emacs-version)
2661 ()
2662 (define-key menu-bar-ediff-menu [ediff-revision]
2663 '("File with Revision ..." . ediff-revision))
2664 (define-key menu-bar-ediff-menu [ediff-large-regions]
2665 '("Large Regions ..." . ediff-large-regions))
2666 (define-key menu-bar-ediff-menu [ediff-small-regions]
2667 '("Small Regions ..." . ediff-small-regions))
2668 (define-key menu-bar-ediff-menu [ediff-windows]
2669 '("Windows ..." . ediff-windows))
2670 ))
2671
2672 ;;;###autoload
2673 (if purify-flag
2674 ;; explicit string-match, as ediff-xemacs-p is not defined at build time
2675 (if (string-match "\\(Lucid\\|Xemacs\\)" emacs-version)
2676 ()
2677 (define-key menu-bar-ediff-menu [ediff-buffers3]
2678 '("Three Buffers ..." . ediff-buffers3))
2679 (define-key menu-bar-ediff-menu [ediff-files3]
2680 '("Three Files ..." . ediff-files3))
2681 (define-key menu-bar-ediff-menu [ediff-buffers]
2682 '("Two Buffers ..." . ediff-buffers))
2683 (define-key menu-bar-ediff-menu [ediff-files]
2684 '("Two Files ..." . ediff-files))
2685 ))
2686
2687 ;;;###autoload
2688 (if purify-flag
2689 ;; explicit string-match, as ediff-xemacs-p is not defined at build time
2690 (if (string-match "\\(Lucid\\|Xemacs\\)" emacs-version)
2691 ()
2692 (define-key
2693 menu-bar-ediff-merge-menu [ediff-merge-revisions-with-ancestor]
2694 '("Revisions with Ancestor ..." . ediff-merge-revisions-with-ancestor))
2695 (define-key menu-bar-ediff-merge-menu [ediff-merge-revisions]
2696 '("Revisions ..." . ediff-merge-revisions))
2697 (define-key menu-bar-ediff-merge-menu [ediff-merge-buffers-with-ancestor]
2698 '("Buffers with Ancestor ..." . ediff-merge-buffers-with-ancestor))
2699 (define-key menu-bar-ediff-merge-menu [ediff-merge-buffers]
2700 '("Buffers ..." . ediff-merge-buffers))
2701 (define-key menu-bar-ediff-merge-menu [ediff-merge-files-with-ancestor]
2702 '("Files with Ancestor ..." . ediff-merge-files-with-ancestor))
2703 (define-key menu-bar-ediff-merge-menu [ediff-merge-files]
2704 '("Files ..." . ediff-merge-files))
2705 ))
2706
2707 ;;;###autoload
2708 (if purify-flag
2709 ;; explicit string-match, as ediff-xemacs-p is not defined at build time
2710 (if (string-match "\\(Lucid\\|Xemacs\\)" emacs-version)
2711 ()
2712 (define-key menu-bar-epatch-menu [ediff-patch-buffer]
2713 '("To a Buffer ..." . ediff-patch-buffer))
2714 (define-key menu-bar-epatch-menu [ediff-patch-file]
2715 '("To a File ..." . ediff-patch-file))
2716 ))
2717
2718
2719 ;;;###autoload
2720 (if purify-flag
2721 ;; explicit string-match, as ediff-xemacs-p is not defined at build time
2722 (if (string-match "\\(Lucid\\|Xemacs\\)" emacs-version)
2723 (progn
2724 (defvar ediff-menu
2725 '(""
2726 ["Two Files ..." ediff-files t]
2727 ["Two Buffers ..." ediff-buffers t]
2728 ["Three Files ..." ediff-files3 t]
2729 ["Three Buffers ..." ediff-buffers3 t]
2730 ["Windows ..." ediff-windows t]
2731 ["Small Regions ..." ediff-small-regions t]
2732 ["Large Regions ..." ediff-large-regions t]
2733 ["File with Revision ..." ediff-revision t]))
2734 (defvar ediff-merge-menu
2735 '(""
2736 ["Files ..." ediff-merge-files t]
2737 ["Files with Ancestor ..." ediff-merge-files-with-ancestor t]
2738 ["Buffers ..." ediff-merge-buffers t]
2739 ["Buffers with Ancestor ..."
2740 ediff-merge-buffers-with-ancestor t]
2741 ["Revisions ..." ediff-merge-revisions t]
2742 ["Revisions with Ancestor ..."
2743 ediff-merge-revisions-with-ancestor t]))
2744 (defvar epatch-menu
2745 '(""
2746 ["To a file ..." ediff-patch-file t]
2747 ["To a buffer ..." ediff-patch-buffer t]))
2748 (add-menu '("File") "Compare"
2749 ediff-menu
2750 "New Frame")
2751 (add-menu '("File") "Merge"
2752 ediff-merge-menu
2753 "New Frame")
2754 (add-menu '("File") "Apply Patch"
2755 epatch-menu
2756 "New Frame")
2757 ;; Display a solid horizontal line
2758 (add-menu-item '("File") "---" nil nil "New Screen")
2759 )))
2760
2761
2762 (provide 'ediff)
2763 (require 'ediff-util)
2764
2765 ;;; ediff.el ends here