(draw_fringe_bitmap): Fix overlay-arrow display.
[bpt/emacs.git] / lisp / ediff-diff.el
CommitLineData
475f9031 1;;; ediff-diff.el --- diff-related utilities
b578f267 2
0d30b337 3;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
aaef169d 4;; 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
475f9031 5
50a07e18 6;; Author: Michael Kifer <kifer@cs.stonybrook.edu>
475f9031
KH
7
8;; This file is part of GNU Emacs.
9
10;; GNU Emacs is free software; you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation; either version 2, or (at your option)
13;; any later version.
14
15;; GNU Emacs is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
b578f267 21;; along with GNU Emacs; see the file COPYING. If not, write to the
086add15
LK
22;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23;; Boston, MA 02110-1301, USA.
475f9031 24
3afbc435
PJ
25;;; Commentary:
26
b578f267 27;;; Code:
475f9031 28
ddc90f39
MK
29
30;; compiler pacifier
31(defvar ediff-default-variant)
50a07e18 32(defvar null-device)
1a24f45a 33(defvar longlines-mode)
ddc90f39
MK
34
35(eval-when-compile
36 (let ((load-path (cons (expand-file-name ".") load-path)))
37 (or (featurep 'ediff-init)
38 (load "ediff-init.el" nil nil 'nosuffix))
39 (or (featurep 'ediff-util)
40 (load "ediff-util.el" nil nil 'nosuffix))
41 ))
42;; end pacifier
43
b578f267 44(require 'ediff-init)
475f9031 45
ddc90f39 46(defgroup ediff-diff nil
3b9ae202 47 "Diff related utilities."
ddc90f39
MK
48 :prefix "ediff-"
49 :group 'ediff)
50
7d027816
MK
51;; these two must be here to prevent ediff-test-utility from barking
52(defcustom ediff-diff-program "diff"
53 "*Program to use for generating the differential of the two files."
54 :type 'string
55 :group 'ediff-diff)
56(defcustom ediff-diff3-program "diff3"
57 "*Program to be used for three-way comparison.
58Must produce output compatible with Unix's diff3 program."
59 :type 'string
60 :group 'ediff-diff)
61
513bea45 62
7d027816 63;; The following functions must precede all defcustom-defined variables.
4ae69eac 64
6de3983f
MK
65;; The following functions needed for setting diff/diff3 options
66;; test if diff supports the --binary option
67(defsubst ediff-test-utility (diff-util option &optional files)
15502042
EZ
68 (eq 0 (apply 'call-process
69 (append (list diff-util nil nil nil option) files))))
6de3983f
MK
70
71(defun ediff-diff-mandatory-option (diff-util)
72 (let ((file (if (boundp 'null-device) null-device "/dev/null")))
73 (cond ((not (memq system-type '(ms-dos windows-nt windows-95)))
74 "")
75 ((and (string= diff-util ediff-diff-program)
76 (ediff-test-utility
77 ediff-diff-program "--binary" (list file file)))
78 "--binary")
79 ((and (string= diff-util ediff-diff3-program)
80 (ediff-test-utility
81 ediff-diff3-program "--binary" (list file file file)))
82 "--binary")
83 (t ""))))
84
85;; make sure that mandatory options are added even if the user changes
86;; ediff-diff-options or ediff-diff3-options in the customization widget
87(defun ediff-reset-diff-options (symb val)
50a07e18
MK
88 (let* ((diff-program
89 (if (eq symb 'ediff-diff-options)
6de3983f
MK
90 ediff-diff-program
91 ediff-diff3-program))
92 (mandatory-option (ediff-diff-mandatory-option diff-program))
93 (spacer (if (string-equal mandatory-option "") "" " ")))
50a07e18 94 (set symb
6de3983f
MK
95 (if (string-match mandatory-option val)
96 val
97 (concat mandatory-option spacer val)))
98 ))
99
100
ddc90f39 101(defcustom ediff-shell
475f9031 102 (cond ((eq system-type 'emx) "cmd") ; OS/2
bbe6126c
MK
103 ((memq system-type '(ms-dos windows-nt windows-95))
104 shell-file-name) ; no standard name on MS-DOS
475f9031
KH
105 ((memq system-type '(vax-vms axp-vms)) "*dcl*") ; VMS
106 (t "sh")) ; UNIX
50a07e18
MK
107 "*The shell used to run diff and patch.
108If user's .profile or .cshrc files are set up correctly, any shell
109will do. However, some people set $prompt or other things
110incorrectly, which leads to undesirable output messages. These may
111cause Ediff to fail. In such a case, set `ediff-shell' to a shell that
112you are not using or, better, fix your shell's startup file."
ddc90f39
MK
113 :type 'string
114 :group 'ediff-diff)
475f9031 115
328b4b70
MK
116(defcustom ediff-cmp-program "cmp"
117 "*Utility to use to determine if two files are identical.
118It must return code 0, if its arguments are identical files."
119 :type 'string
120 :group 'ediff-diff)
475f9031 121
3af0304a 122(defcustom ediff-cmp-options nil
ff4968b6
RS
123 "*Options to pass to `ediff-cmp-program'.
124If GNU diff is used as `ediff-cmp-program', then the most useful options
50a07e18 125are `-I REGEXP', to ignore changes whose lines match the REGEXP."
3af0304a
MK
126 :type '(repeat string)
127 :group 'ediff-diff)
128
6de3983f 129(defcustom ediff-diff-options ""
71296446 130 "*Options to pass to `ediff-diff-program'.
b6178721 131If Unix diff is used as `ediff-diff-program', then a useful option is
475f9031 132`-w', to ignore space, and `-i', to ignore case of letters.
b6178721
MK
133Options `-c' and `-i' are not allowed. Case sensitivity can be toggled
134interactively using [ediff-toggle-ignore-case]"
6de3983f 135 :set 'ediff-reset-diff-options
ddc90f39
MK
136 :type 'string
137 :group 'ediff-diff)
475f9031 138
b6178721
MK
139(ediff-defvar-local ediff-ignore-case nil
140 "*If t, skip over difference regions that differ only in letter case.
141This variable can be set either in .emacs or toggled interactively.
142Use `setq-default' if setting it in .emacs")
143
144(defcustom ediff-ignore-case-option "-i"
145 "*Option that causes the diff program to ignore case of letters."
146 :type 'string
147 :group 'ediff-diff)
148
149(defcustom ediff-ignore-case-option3 ""
150 "*Option that causes the diff3 program to ignore case of letters.
151GNU diff3 doesn't have such an option."
152 :type 'string
153 :group 'ediff-diff)
154
155;; the actual options used in comparison
156(ediff-defvar-local ediff-actual-diff-options "" "")
157
ddc90f39 158(defcustom ediff-custom-diff-program ediff-diff-program
475f9031 159 "*Program to use for generating custom diff output for saving it in a file.
ddc90f39
MK
160This output is not used by Ediff internally."
161 :type 'string
162 :group 'ediff-diff)
163(defcustom ediff-custom-diff-options "-c"
164 "*Options to pass to `ediff-custom-diff-program'."
165 :type 'string
166 :group 'ediff-diff)
475f9031
KH
167
168;;; Support for diff3
169
4960e757 170(defvar ediff-match-diff3-line "^====\\(.?\\)\C-m?$"
475f9031 171 "Pattern to match lines produced by diff3 that describe differences.")
50a07e18 172(defcustom ediff-diff3-options ""
ddc90f39 173 "*Options to pass to `ediff-diff3-program'."
6de3983f 174 :set 'ediff-reset-diff-options
ddc90f39
MK
175 :type 'string
176 :group 'ediff-diff)
b6178721
MK
177
178;; the actual options used in comparison
179(ediff-defvar-local ediff-actual-diff3-options "" "")
180
ddc90f39 181(defcustom ediff-diff3-ok-lines-regexp
bbe6126c 182 "^\\([1-3]:\\|====\\| \\|.*Warning *:\\|.*No newline\\|.*missing newline\\|^\C-m$\\)"
475f9031 183 "*Regexp that matches normal output lines from `ediff-diff3-program'.
ddc90f39
MK
184Lines that do not match are assumed to be error messages."
185 :type 'regexp
186 :group 'ediff-diff)
475f9031
KH
187
188;; keeps the status of the current diff in 3-way jobs.
189;; the status can be =diff(A), =diff(B), or =diff(A+B)
190(ediff-defvar-local ediff-diff-status "" "")
191
71296446 192
50a07e18 193;;; Fine differences
475f9031 194
4ae69eac 195(ediff-defvar-local ediff-auto-refine (if (ediff-has-face-support-p) 'on 'nix)
475f9031
KH
196 "If `on', Ediff auto-highlights fine diffs for the current diff region.
197If `off', auto-highlighting is not used. If `nix', no fine diffs are shown
198at all, unless the user force-refines the region by hitting `*'.
199
200This variable can be set either in .emacs or toggled interactively.
201Use `setq-default' if setting it in .emacs")
202
203(ediff-defvar-local ediff-ignore-similar-regions nil
204 "*If t, skip over difference regions that differ only in the white space and line breaks.
205This variable can be set either in .emacs or toggled interactively.
206Use `setq-default' if setting it in .emacs")
207
b6178721 208(ediff-defvar-local ediff-auto-refine-limit 14000
bbe6126c 209 "*Auto-refine only the regions of this size \(in bytes\) or less.")
71296446 210
475f9031
KH
211;;; General
212
50a07e18 213(defvar ediff-diff-ok-lines-regexp
c004db97
MK
214 (concat
215 "^\\("
216 "[0-9,]+[acd][0-9,]+\C-m?$"
217 "\\|[<>] "
218 "\\|---"
219 "\\|.*Warning *:"
220 "\\|.*No +newline"
221 "\\|.*missing +newline"
222 "\\|^\C-m?$"
223 "\\)")
475f9031
KH
224 "Regexp that matches normal output lines from `ediff-diff-program'.
225This is mostly lifted from Emerge, except that Ediff also considers
226warnings and `Missing newline'-type messages to be normal output.
227Lines that do not match are assumed to be error messages.")
228
c004db97
MK
229(defvar ediff-match-diff-line
230 (let ((x "\\([0-9]+\\)\\(\\|,\\([0-9]+\\)\\)"))
231 (concat "^" x "\\([acd]\\)" x "\C-m?$"))
475f9031
KH
232 "Pattern to match lines produced by diff that describe differences.")
233
234(ediff-defvar-local ediff-setup-diff-regions-function nil
235 "value is a function symbol depending on the kind of job is to be done.
236For 2-way jobs and for ediff-merge, it should be `ediff-setup-diff-regions'.
237For jobs requiring diff3, it should be `ediff-setup-diff-regions3'.
238
239The function should take three mandatory arguments, file-A, file-B, and
240file-C. It may ignore file C for diff2 jobs. It should also take
241one optional arguments, diff-number to refine.")
242
71296446 243
475f9031
KH
244;;; Functions
245
246;; Generate the difference vector and overlays for the two files
247;; With optional arg REG-TO-REFINE, refine this region.
248;; File-C argument is not used here. It is there just because
249;; ediff-setup-diff-regions is called via a funcall to
250;; ediff-setup-diff-regions-function, which can also have the value
251;; ediff-setup-diff-regions3, which takes 4 arguments.
252(defun ediff-setup-diff-regions (file-A file-B file-C)
b6178721
MK
253 ;; looking for '-c', '-i', or a 'c', 'i' among clustered non-long options
254 (if (string-match "^-[ci]\\| -[ci]\\|-[^- ]+[ci]" ediff-diff-options)
255 (error "Options `-c' and `-i' are not allowed in `ediff-diff-options'"))
71296446 256
bbe6126c 257 ;; create, if it doesn't exist
475f9031
KH
258 (or (ediff-buffer-live-p ediff-diff-buffer)
259 (setq ediff-diff-buffer
260 (get-buffer-create (ediff-unique-buffer-name "*ediff-diff" "*"))))
bbe6126c 261 (ediff-make-diff2-buffer ediff-diff-buffer file-A file-B)
475f9031 262 (ediff-prepare-error-list ediff-diff-ok-lines-regexp ediff-diff-buffer)
475f9031
KH
263 (ediff-convert-diffs-to-overlays
264 (ediff-extract-diffs
4ae69eac 265 ediff-diff-buffer ediff-word-mode ediff-narrow-bounds)))
bbe6126c 266
52fa07ba
MK
267;; Run the diff program on FILE1 and FILE2 and put the output in DIFF-BUFFER
268;; Return the size of DIFF-BUFFER
513bea45 269;; The return code isn't used in the program at present.
bbe6126c 270(defun ediff-make-diff2-buffer (diff-buffer file1 file2)
92c51e07
MK
271 (let ((file1-size (ediff-file-size file1))
272 (file2-size (ediff-file-size file2)))
273 (cond ((not (numberp file1-size))
274 (message "Can't find file: %s"
275 (ediff-abbreviate-file-name file1))
276 (sit-for 2)
277 ;; 1 is an error exit code
278 1)
279 ((not (numberp file2-size))
280 (message "Can't find file: %s"
281 (ediff-abbreviate-file-name file2))
282 (sit-for 2)
283 ;; 1 is an error exit code
284 1)
92c51e07
MK
285 (t (message "Computing differences between %s and %s ..."
286 (file-name-nondirectory file1)
287 (file-name-nondirectory file2))
288 ;; this erases the diff buffer automatically
289 (ediff-exec-process ediff-diff-program
290 diff-buffer
291 'synchronize
b6178721 292 ediff-actual-diff-options file1 file2)
92c51e07 293 (message "")
e756eb9f 294 (ediff-with-current-buffer diff-buffer
92c51e07 295 (buffer-size))))))
bbe6126c 296
71296446
JB
297
298
475f9031
KH
299;; If file-A/B/C is nil, do 2-way comparison with the non-nil buffers
300;; This function works for diff3 and diff2 jobs
301(defun ediff-setup-fine-diff-regions (file-A file-B file-C reg-num)
302 (or (ediff-buffer-live-p ediff-fine-diff-buffer)
303 (setq ediff-fine-diff-buffer
304 (get-buffer-create
305 (ediff-unique-buffer-name "*ediff-fine-diff" "*"))))
71296446 306
ab8a391e 307 (let (diff3-job diff-program diff-options ok-regexp diff-list)
475f9031
KH
308 (setq diff3-job ediff-3way-job
309 diff-program (if diff3-job ediff-diff3-program ediff-diff-program)
b6178721
MK
310 diff-options (if diff3-job
311 ediff-actual-diff3-options
312 ediff-actual-diff-options)
475f9031
KH
313 ok-regexp (if diff3-job
314 ediff-diff3-ok-lines-regexp
315 ediff-diff-ok-lines-regexp))
71296446 316
4ad42cb5
MK
317 (ediff-message-if-verbose "Refining difference region %d ..." (1+ reg-num))
318 (ediff-exec-process diff-program ediff-fine-diff-buffer 'synchronize
ab8a391e 319 diff-options
4ad42cb5
MK
320 ;; The shuffle below is because we can compare 3-way
321 ;; or in several 2-way fashions, like fA fC, fA fB,
322 ;; or fB fC.
323 (if file-A file-A file-B)
324 (if file-B file-B file-A)
325 (if diff3-job
326 (if file-C file-C file-B))
327 ) ; exec process
71296446 328
475f9031 329 (ediff-prepare-error-list ok-regexp ediff-fine-diff-buffer)
4ae69eac
MK
330 (ediff-message-if-verbose
331 "")
4ad42cb5 332 ;; "Refining difference region %d ... done" (1+ reg-num))
71296446 333
475f9031
KH
334 (setq diff-list
335 (if diff3-job
336 (ediff-extract-diffs3
337 ediff-fine-diff-buffer '3way-comparison 'word-mode)
338 (ediff-extract-diffs ediff-fine-diff-buffer 'word-mode)))
339 ;; fixup diff-list
340 (if diff3-job
341 (cond ((not file-A)
3af0304a
MK
342 (mapcar (lambda (elt)
343 (aset elt 0 nil)
344 (aset elt 1 nil))
475f9031
KH
345 (cdr diff-list)))
346 ((not file-B)
3af0304a
MK
347 (mapcar (lambda (elt)
348 (aset elt 2 nil)
349 (aset elt 3 nil))
475f9031
KH
350 (cdr diff-list)))
351 ((not file-C)
3af0304a
MK
352 (mapcar (lambda (elt)
353 (aset elt 4 nil)
354 (aset elt 5 nil))
475f9031
KH
355 (cdr diff-list)))
356 ))
71296446 357
475f9031
KH
358 (ediff-convert-fine-diffs-to-overlays diff-list reg-num)
359 ))
71296446
JB
360
361
475f9031 362(defun ediff-prepare-error-list (ok-regexp diff-buff)
4ad42cb5
MK
363 (or (ediff-buffer-live-p ediff-error-buffer)
364 (setq ediff-error-buffer
365 (get-buffer-create (ediff-unique-buffer-name
366 "*ediff-errors" "*"))))
e756eb9f 367 (ediff-with-current-buffer ediff-error-buffer
4ad42cb5 368 (erase-buffer)
e756eb9f 369 (insert (ediff-with-current-buffer diff-buff (buffer-string)))
4ad42cb5
MK
370 (goto-char (point-min))
371 (delete-matching-lines ok-regexp)
372 (if (memq system-type '(vax-vms axp-vms))
373 (delete-matching-lines "^$")))
374 ;; If diff reports errors, show them then quit.
e756eb9f 375 (if (/= 0 (ediff-with-current-buffer ediff-error-buffer (buffer-size)))
4ad42cb5
MK
376 (let ((ctl-buf ediff-control-buffer)
377 (error-buf ediff-error-buffer))
378 (ediff-skip-unsuitable-frames)
379 (switch-to-buffer error-buf)
380 (ediff-kill-buffer-carefully ctl-buf)
50a07e18 381 (error "Errors in diff output. Diff output is in %S" diff-buff))))
475f9031
KH
382
383;; BOUNDS specifies visibility bounds to use.
384;; WORD-MODE tells whether we are in the word-mode or not.
385;; If WORD-MODE, also construct vector of diffs using word numbers.
386;; Else, use point values.
387;; This function handles diff-2 jobs including the case of
388;; merging buffers and files without ancestor.
389(defun ediff-extract-diffs (diff-buffer word-mode &optional bounds)
390 (let ((A-buffer ediff-buffer-A)
391 (B-buffer ediff-buffer-B)
392 (C-buffer ediff-buffer-C)
393 (a-prev 1) ; this is needed to set the first diff line correctly
b6178721 394 (a-prev-pt nil)
475f9031 395 (b-prev 1)
b6178721 396 (b-prev-pt nil)
475f9031 397 (c-prev 1)
b6178721 398 (c-prev-pt nil)
475f9031
KH
399 diff-list shift-A shift-B
400 )
b6178721 401
475f9031
KH
402 ;; diff list contains word numbers, unless changed later
403 (setq diff-list (cons (if word-mode 'words 'points)
404 diff-list))
405 ;; we don't use visibility bounds for buffer C when merging
406 (if bounds
407 (setq shift-A
408 (ediff-overlay-start
409 (ediff-get-value-according-to-buffer-type 'A bounds))
50a07e18 410 shift-B
475f9031
KH
411 (ediff-overlay-start
412 (ediff-get-value-according-to-buffer-type 'B bounds))))
b6178721 413
475f9031 414 ;; reset point in buffers A/B/C
e756eb9f 415 (ediff-with-current-buffer A-buffer
475f9031 416 (goto-char (if shift-A shift-A (point-min))))
e756eb9f 417 (ediff-with-current-buffer B-buffer
475f9031
KH
418 (goto-char (if shift-B shift-B (point-min))))
419 (if (ediff-buffer-live-p C-buffer)
e756eb9f 420 (ediff-with-current-buffer C-buffer
475f9031 421 (goto-char (point-min))))
71296446 422
e756eb9f 423 (ediff-with-current-buffer diff-buffer
475f9031
KH
424 (goto-char (point-min))
425 (while (re-search-forward ediff-match-diff-line nil t)
027a4b6b
JB
426 (let* ((a-begin (string-to-number (buffer-substring (match-beginning 1)
427 (match-end 1))))
475f9031
KH
428 (a-end (let ((b (match-beginning 3))
429 (e (match-end 3)))
430 (if b
027a4b6b 431 (string-to-number (buffer-substring b e))
475f9031
KH
432 a-begin)))
433 (diff-type (buffer-substring (match-beginning 4) (match-end 4)))
027a4b6b
JB
434 (b-begin (string-to-number (buffer-substring (match-beginning 5)
435 (match-end 5))))
475f9031
KH
436 (b-end (let ((b (match-beginning 7))
437 (e (match-end 7)))
438 (if b
027a4b6b 439 (string-to-number (buffer-substring b e))
475f9031
KH
440 b-begin)))
441 a-begin-pt a-end-pt b-begin-pt b-end-pt
442 c-begin c-end c-begin-pt c-end-pt)
443 ;; fix the beginning and end numbers, because diff is somewhat
444 ;; strange about how it numbers lines
445 (if (string-equal diff-type "a")
446 (setq b-end (1+ b-end)
447 a-begin (1+ a-begin)
448 a-end a-begin)
449 (if (string-equal diff-type "d")
450 (setq a-end (1+ a-end)
451 b-begin (1+ b-begin)
452 b-end b-begin)
453 ;; (string-equal diff-type "c")
454 (setq a-end (1+ a-end)
455 b-end (1+ b-end))))
71296446 456
475f9031
KH
457 (if (eq ediff-default-variant 'default-B)
458 (setq c-begin b-begin
459 c-end b-end)
460 (setq c-begin a-begin
461 c-end a-end))
71296446 462
475f9031
KH
463 ;; compute main diff vector
464 (if word-mode
465 ;; make diff-list contain word numbers
50a07e18 466 (setq diff-list
475f9031
KH
467 (nconc diff-list
468 (list
469 (if (ediff-buffer-live-p C-buffer)
470 (vector (- a-begin a-prev) (- a-end a-begin)
471 (- b-begin b-prev) (- b-end b-begin)
472 (- c-begin c-prev) (- c-end c-begin)
4ad42cb5
MK
473 nil nil ; dummy ancestor
474 nil ; state of diff
475 nil ; state of merge
476 nil ; state of ancestor
475f9031
KH
477 )
478 (vector (- a-begin a-prev) (- a-end a-begin)
479 (- b-begin b-prev) (- b-end b-begin)
480 nil nil ; dummy buf C
4ad42cb5 481 nil nil ; dummy ancestor
475f9031
KH
482 nil ; state of diff
483 nil ; state of merge
4ad42cb5 484 nil ; state of ancestor
475f9031
KH
485 ))
486 ))
487 a-prev a-end
488 b-prev b-end
489 c-prev c-end)
490 ;; else convert lines to points
e756eb9f 491 (ediff-with-current-buffer A-buffer
8ea74b0e
MK
492 (let ((longlines-mode-val
493 (if (and (boundp 'longlines-mode) longlines-mode) 1 0)))
494 ;; we must disable and then restore longlines-mode
495 (if (eq longlines-mode-val 1)
496 (longlines-mode 0))
b6178721 497 (goto-char (or a-prev-pt shift-A (point-min)))
8ea74b0e
MK
498 (forward-line (- a-begin a-prev))
499 (setq a-begin-pt (point))
500 (forward-line (- a-end a-begin))
501 (setq a-end-pt (point)
b6178721
MK
502 a-prev a-end
503 a-prev-pt a-end-pt)
8ea74b0e
MK
504 (if (eq longlines-mode-val 1)
505 (longlines-mode longlines-mode-val))
506 ))
e756eb9f 507 (ediff-with-current-buffer B-buffer
8ea74b0e
MK
508 (let ((longlines-mode-val
509 (if (and (boundp 'longlines-mode) longlines-mode) 1 0)))
510 (if (eq longlines-mode-val 1)
511 (longlines-mode 0))
b6178721 512 (goto-char (or b-prev-pt shift-B (point-min)))
8ea74b0e
MK
513 (forward-line (- b-begin b-prev))
514 (setq b-begin-pt (point))
515 (forward-line (- b-end b-begin))
516 (setq b-end-pt (point)
b6178721
MK
517 b-prev b-end
518 b-prev-pt b-end-pt)
8ea74b0e
MK
519 (if (eq longlines-mode-val 1)
520 (longlines-mode longlines-mode-val))
521 ))
475f9031 522 (if (ediff-buffer-live-p C-buffer)
e756eb9f 523 (ediff-with-current-buffer C-buffer
8ea74b0e
MK
524 (let ((longlines-mode-val
525 (if (and (boundp 'longlines-mode) longlines-mode) 1 0)))
526 (if (eq longlines-mode-val 1)
527 (longlines-mode 0))
b6178721 528 (goto-char (or c-prev-pt (point-min)))
8ea74b0e
MK
529 (forward-line (- c-begin c-prev))
530 (setq c-begin-pt (point))
531 (forward-line (- c-end c-begin))
532 (setq c-end-pt (point)
b6178721
MK
533 c-prev c-end
534 c-prev-pt c-end-pt)
8ea74b0e
MK
535 (if (eq longlines-mode-val 1)
536 (longlines-mode longlines-mode-val))
537 )))
50a07e18 538 (setq diff-list
475f9031
KH
539 (nconc
540 diff-list
541 (list
542 (if (ediff-buffer-live-p C-buffer)
543 (vector
544 a-begin-pt a-end-pt b-begin-pt b-end-pt
545 c-begin-pt c-end-pt
4ad42cb5 546 nil nil ; dummy ancestor
475f9031
KH
547 ;; state of diff
548 ;; shows which buff is different from the other two
549 (if (eq ediff-default-variant 'default-B) 'A 'B)
4ad42cb5
MK
550 ediff-default-variant ; state of merge
551 nil ; state of ancestor
475f9031 552 )
4ad42cb5
MK
553 (vector a-begin-pt a-end-pt
554 b-begin-pt b-end-pt
555 nil nil ; dummy buf C
556 nil nil ; dummy ancestor
557 nil nil ; dummy state of diff & merge
558 nil ; dummy state of ancestor
50a07e18 559 )))
475f9031 560 )))
71296446 561
e756eb9f 562 ))) ; end ediff-with-current-buffer
475f9031
KH
563 diff-list
564 ))
71296446 565
475f9031 566
4ad42cb5
MK
567(defun ediff-convert-diffs-to-overlays (diff-list)
568 (ediff-set-diff-overlays-in-one-buffer 'A diff-list)
569 (ediff-set-diff-overlays-in-one-buffer 'B diff-list)
570 (if ediff-3way-job
571 (ediff-set-diff-overlays-in-one-buffer 'C diff-list))
572 (if ediff-merge-with-ancestor-job
573 (ediff-set-diff-overlays-in-one-buffer 'Ancestor diff-list))
574 ;; set up vector showing the status of merge regions
575 (if ediff-merge-job
576 (setq ediff-state-of-merge
577 (vconcat
3af0304a
MK
578 (mapcar (lambda (elt)
579 (let ((state-of-merge (aref elt 9))
580 (state-of-ancestor (aref elt 10)))
581 (vector
582 ;; state of merge: prefers/default-A/B or combined
583 (if state-of-merge (format "%S" state-of-merge))
584 ;; whether the ancestor region is empty
585 state-of-ancestor)))
4ad42cb5
MK
586 ;; the first elt designates type of list
587 (cdr diff-list))
588 )))
589 (message "Processing difference regions ... done"))
590
71296446 591
475f9031
KH
592(defun ediff-set-diff-overlays-in-one-buffer (buf-type diff-list)
593 (let* ((current-diff -1)
594 (buff (ediff-get-buffer buf-type))
17561e4f 595 (ctl-buf ediff-control-buffer)
475f9031
KH
596 ;; ediff-extract-diffs puts the type of diff-list as the first elt
597 ;; of this list. The type is either 'points or 'words
598 (diff-list-type (car diff-list))
599 (shift (ediff-overlay-start
600 (ediff-get-value-according-to-buffer-type
601 buf-type ediff-narrow-bounds)))
602 (limit (ediff-overlay-end
50a07e18 603 (ediff-get-value-according-to-buffer-type
475f9031
KH
604 buf-type ediff-narrow-bounds)))
605 diff-overlay-list list-element total-diffs
4ad42cb5 606 begin end pt-saved overlay state-of-diff)
475f9031
KH
607
608 (setq diff-list (cdr diff-list)) ; discard diff list type
609 (setq total-diffs (length diff-list))
71296446 610
475f9031 611 ;; shift, if necessary
e756eb9f 612 (ediff-with-current-buffer buff (setq pt-saved shift))
71296446 613
475f9031
KH
614 (while diff-list
615 (setq current-diff (1+ current-diff)
616 list-element (car diff-list)
617 begin (aref list-element (cond ((eq buf-type 'A) 0)
618 ((eq buf-type 'B) 2)
4ad42cb5
MK
619 ((eq buf-type 'C) 4)
620 (t 6))) ; Ancestor
475f9031
KH
621 end (aref list-element (cond ((eq buf-type 'A) 1)
622 ((eq buf-type 'B) 3)
4ad42cb5
MK
623 ((eq buf-type 'C) 5)
624 (t 7))) ; Ancestor
625 state-of-diff (aref list-element 8)
626 )
71296446 627
475f9031 628 (cond ((and (not (eq buf-type state-of-diff))
4ad42cb5 629 (not (eq buf-type 'Ancestor))
475f9031
KH
630 (memq state-of-diff '(A B C)))
631 (setq state-of-diff
632 (car (delq buf-type (delq state-of-diff (list 'A 'B 'C)))))
633 (setq state-of-diff (format "=diff(%S)" state-of-diff))
475f9031 634 )
4ad42cb5 635 (t (setq state-of-diff nil)))
71296446 636
475f9031
KH
637 ;; Put overlays at appropriate places in buffer
638 ;; convert word numbers to points, if necessary
639 (if (eq diff-list-type 'words)
640 (progn
e756eb9f 641 (ediff-with-current-buffer buff (goto-char pt-saved))
17561e4f
MK
642 (ediff-with-current-buffer ctl-buf
643 (setq begin (ediff-goto-word (1+ begin) buff)
644 end (ediff-goto-word end buff 'end)))
475f9031
KH
645 (if (> end limit) (setq end limit))
646 (if (> begin end) (setq begin end))
e756eb9f 647 (setq pt-saved (ediff-with-current-buffer buff (point)))))
475f9031 648 (setq overlay (ediff-make-bullet-proof-overlay begin end buff))
71296446 649
475f9031
KH
650 (ediff-overlay-put overlay 'priority ediff-shadow-overlay-priority)
651 (ediff-overlay-put overlay 'ediff-diff-num current-diff)
4ae69eac 652 (if (and (ediff-has-face-support-p)
4ad42cb5
MK
653 ediff-use-faces ediff-highlight-all-diffs)
654 (ediff-set-overlay-face
655 overlay (ediff-background-face buf-type current-diff)))
475f9031
KH
656
657 (if (= 0 (mod current-diff 10))
658 (message "Buffer %S: Processing difference region %d of %d"
659 buf-type current-diff total-diffs))
3af0304a
MK
660 ;; Record all overlays for this difference.
661 ;; The 2-d elt, nil, is a place holder for the fine diff vector.
662 ;; The 3-d elt, nil, is a place holder for no-fine-diffs flag.
663 ;; The 4-th elt says which diff region is different from the other two
664 ;; (3-way jobs only).
475f9031
KH
665 (setq diff-overlay-list
666 (nconc
667 diff-overlay-list
4ad42cb5 668 (list (vector overlay nil nil state-of-diff)))
475f9031
KH
669 diff-list
670 (cdr diff-list))
671 ) ; while
71296446 672
e756eb9f 673 (set (ediff-get-symbol-from-alist buf-type ediff-difference-vector-alist)
4ad42cb5 674 (vconcat diff-overlay-list))
475f9031 675 ))
4ad42cb5 676
475f9031
KH
677;; `n' is the diff region to work on. Default is ediff-current-difference.
678;; if `flag' is 'noforce then make fine-diffs only if this region's fine
679;; diffs have not been computed before.
680;; if `flag' is 'skip then don't compute fine diffs for this region.
50a07e18 681(defun ediff-make-fine-diffs (&optional n flag)
475f9031 682 (or n (setq n ediff-current-difference))
71296446 683
475f9031 684 (if (< ediff-number-of-differences 1)
bbe6126c 685 (error ediff-NO-DIFFERENCES))
71296446 686
475f9031
KH
687 (if ediff-word-mode
688 (setq flag 'skip
689 ediff-auto-refine 'nix))
71296446 690
475f9031
KH
691 (or (< n 0)
692 (>= n ediff-number-of-differences)
693 ;; n is within the range
694 (let ((tmp-buffer (get-buffer-create ediff-tmp-buffer))
695 (file-A ediff-temp-file-A)
696 (file-B ediff-temp-file-B)
697 (file-C ediff-temp-file-C)
698 (empty-A (ediff-empty-diff-region-p n 'A))
699 (empty-B (ediff-empty-diff-region-p n 'B))
700 (empty-C (ediff-empty-diff-region-p n 'C))
701 (whitespace-A (ediff-whitespace-diff-region-p n 'A))
702 (whitespace-B (ediff-whitespace-diff-region-p n 'B))
703 (whitespace-C (ediff-whitespace-diff-region-p n 'C))
704 cumulative-fine-diff-length)
71296446 705
ddc90f39 706 (cond ;; If one of the regions is empty (or 2 in 3way comparison)
4ad42cb5
MK
707 ;; then don't refine.
708 ;; If the region happens to be entirely whitespace or empty then
709 ;; mark as such.
475f9031
KH
710 ((> (length (delq nil (list empty-A empty-B empty-C))) 1)
711 (if (and (ediff-looks-like-combined-merge n)
712 ediff-merge-job)
713 (ediff-set-fine-overlays-in-one-buffer 'C nil n))
4ad42cb5
MK
714 (if ediff-3way-comparison-job
715 (ediff-message-if-verbose
716 "Region %d is empty in all buffers but %S"
50a07e18 717 (1+ n)
4ad42cb5
MK
718 (cond ((not empty-A) 'A)
719 ((not empty-B) 'B)
720 ((not empty-C) 'C)))
721 (ediff-message-if-verbose
722 "Region %d in buffer %S is empty"
50a07e18 723 (1+ n)
4ad42cb5
MK
724 (cond (empty-A 'A)
725 (empty-B 'B)
726 (empty-C 'C)))
727 )
bbe6126c 728 ;; if all regions happen to be whitespace
4ad42cb5 729 (if (and whitespace-A whitespace-B whitespace-C)
bbe6126c 730 ;; mark as space only
475f9031 731 (ediff-mark-diff-as-space-only n t)
bbe6126c
MK
732 ;; if some regions are white and others don't, then mark as
733 ;; non-white-space-only
475f9031 734 (ediff-mark-diff-as-space-only n nil)))
ddc90f39
MK
735
736 ;; don't compute fine diffs if diff vector exists
737 ((and (eq flag 'noforce) (ediff-get-fine-diff-vector n 'A))
738 (if (ediff-no-fine-diffs-p n)
739 (message
740 "Only white-space differences in region %d %s"
741 (1+ n)
742 (cond ((eq (ediff-no-fine-diffs-p n) 'A)
743 "in buffers B & C")
744 ((eq (ediff-no-fine-diffs-p n) 'B)
745 "in buffers A & C")
746 ((eq (ediff-no-fine-diffs-p n) 'C)
747 "in buffers A & B")
748 (t "")))))
475f9031
KH
749 ;; don't compute fine diffs for this region
750 ((eq flag 'skip)
751 (or (ediff-get-fine-diff-vector n 'A)
752 (memq ediff-auto-refine '(off nix))
4ad42cb5 753 (ediff-message-if-verbose
3af0304a 754 "Region %d exceeds the auto-refinement limit. Type `%s' to refine"
475f9031 755 (1+ n)
4ad42cb5
MK
756 (substitute-command-keys
757 "\\[ediff-make-or-kill-fine-diffs]")
475f9031
KH
758 )))
759 (t
475f9031
KH
760 ;; recompute fine diffs
761 (ediff-wordify
762 (ediff-get-diff-posn 'A 'beg n)
763 (ediff-get-diff-posn 'A 'end n)
764 ediff-buffer-A
765 tmp-buffer
766 ediff-control-buffer)
4ad42cb5
MK
767 (setq file-A
768 (ediff-make-temp-file tmp-buffer "fineDiffA" file-A))
71296446 769
475f9031
KH
770 (ediff-wordify
771 (ediff-get-diff-posn 'B 'beg n)
772 (ediff-get-diff-posn 'B 'end n)
773 ediff-buffer-B
774 tmp-buffer
775 ediff-control-buffer)
4ad42cb5
MK
776 (setq file-B
777 (ediff-make-temp-file tmp-buffer "fineDiffB" file-B))
71296446 778
475f9031
KH
779 (if ediff-3way-job
780 (progn
781 (ediff-wordify
782 (ediff-get-diff-posn 'C 'beg n)
783 (ediff-get-diff-posn 'C 'end n)
784 ediff-buffer-C
785 tmp-buffer
786 ediff-control-buffer)
4ad42cb5
MK
787 (setq file-C
788 (ediff-make-temp-file
789 tmp-buffer "fineDiffC" file-C))))
71296446 790
475f9031
KH
791 ;; save temp file names.
792 (setq ediff-temp-file-A file-A
793 ediff-temp-file-B file-B
794 ediff-temp-file-C file-C)
71296446 795
475f9031
KH
796 ;; set the new vector of fine diffs, if none exists
797 (cond ((and ediff-3way-job whitespace-A)
798 (ediff-setup-fine-diff-regions nil file-B file-C n))
799 ((and ediff-3way-job whitespace-B)
800 (ediff-setup-fine-diff-regions file-A nil file-C n))
801 ((and ediff-3way-job
bbe6126c
MK
802 ;; In merge-jobs, whitespace-C is t, since
803 ;; ediff-empty-diff-region-p returns t in this case
804 whitespace-C)
475f9031
KH
805 (ediff-setup-fine-diff-regions file-A file-B nil n))
806 (t
807 (ediff-setup-fine-diff-regions file-A file-B file-C n)))
71296446 808
475f9031
KH
809 (setq cumulative-fine-diff-length
810 (+ (length (ediff-get-fine-diff-vector n 'A))
bbe6126c
MK
811 (length (ediff-get-fine-diff-vector n 'B))
812 ;; in merge jobs, the merge buffer is never refined
813 (if (and file-C (not ediff-merge-job))
814 (length (ediff-get-fine-diff-vector n 'C))
815 0)))
71296446 816
475f9031
KH
817 (cond ((or
818 ;; all regions are white space
819 (and whitespace-A whitespace-B whitespace-C)
820 ;; none is white space and no fine diffs detected
821 (and (not whitespace-A)
822 (not whitespace-B)
823 (not (and ediff-3way-job whitespace-C))
824 (eq cumulative-fine-diff-length 0)))
825 (ediff-mark-diff-as-space-only n t)
4ad42cb5 826 (ediff-message-if-verbose
475f9031
KH
827 "Only white-space differences in region %d" (1+ n)))
828 ((eq cumulative-fine-diff-length 0)
4ad42cb5 829 (ediff-message-if-verbose
475f9031
KH
830 "Only white-space differences in region %d %s"
831 (1+ n)
ddc90f39
MK
832 (cond (whitespace-A (ediff-mark-diff-as-space-only n 'A)
833 "in buffers B & C")
834 (whitespace-B (ediff-mark-diff-as-space-only n 'B)
835 "in buffers A & C")
836 (whitespace-C (ediff-mark-diff-as-space-only n 'C)
837 "in buffers A & B"))))
50a07e18 838 (t
475f9031
KH
839 (ediff-mark-diff-as-space-only n nil)))
840 )
841 ) ; end cond
842 (ediff-set-fine-diff-properties n)
843 )))
71296446 844
475f9031
KH
845;; Interface to ediff-make-fine-diffs. Checks for auto-refine limit, etc.
846(defun ediff-install-fine-diff-if-necessary (n)
743a79af
MK
847 (cond ((and (eq ediff-auto-refine 'on)
848 ediff-use-faces
849 (not (eq ediff-highlighting-style 'off))
850 (not (eq ediff-highlighting-style 'ascii)))
475f9031
KH
851 (if (and
852 (> ediff-auto-refine-limit
853 (- (ediff-get-diff-posn 'A 'end n)
854 (ediff-get-diff-posn 'A 'beg n)))
855 (> ediff-auto-refine-limit
856 (- (ediff-get-diff-posn 'B 'end n)
857 (ediff-get-diff-posn 'B 'beg n))))
858 (ediff-make-fine-diffs n 'noforce)
859 (ediff-make-fine-diffs n 'skip)))
71296446 860
475f9031
KH
861 ;; highlight iff fine diffs already exist
862 ((eq ediff-auto-refine 'off)
863 (ediff-make-fine-diffs n 'skip))))
71296446
JB
864
865
475f9031
KH
866;; if fine diff vector is not set for diff N, then do nothing
867(defun ediff-set-fine-diff-properties (n &optional default)
4ae69eac 868 (or (not (ediff-has-face-support-p))
475f9031
KH
869 (< n 0)
870 (>= n ediff-number-of-differences)
4ae69eac 871 ;; when faces are supported, set faces and priorities of fine overlays
475f9031
KH
872 (progn
873 (ediff-set-fine-diff-properties-in-one-buffer 'A n default)
874 (ediff-set-fine-diff-properties-in-one-buffer 'B n default)
875 (if ediff-3way-job
876 (ediff-set-fine-diff-properties-in-one-buffer 'C n default)))))
71296446 877
475f9031
KH
878(defun ediff-set-fine-diff-properties-in-one-buffer (buf-type
879 n &optional default)
880 (let ((fine-diff-vector (ediff-get-fine-diff-vector n buf-type))
50a07e18 881 (face (if default
475f9031
KH
882 'default
883 (face-name
e756eb9f
MK
884 (ediff-get-symbol-from-alist
885 buf-type ediff-fine-diff-face-alist))))
475f9031
KH
886 (priority (if default
887 0
888 (1+ (or (ediff-overlay-get
889 (symbol-value
e756eb9f
MK
890 (ediff-get-symbol-from-alist
891 buf-type
892 ediff-current-diff-overlay-alist))
475f9031
KH
893 'priority)
894 0)))))
3af0304a
MK
895 (mapcar (lambda (overl)
896 (ediff-set-overlay-face overl face)
897 (ediff-overlay-put overl 'priority priority))
898 fine-diff-vector)))
71296446 899
086171bf 900;; Set overlays over the regions that denote delimiters
475f9031 901(defun ediff-set-fine-overlays-for-combined-merge (diff-list reg-num)
086171bf
MK
902 (let (overlay overlay-list)
903 (while diff-list
904 (condition-case nil
905 (setq overlay
906 (ediff-make-bullet-proof-overlay
907 (nth 0 diff-list) (nth 1 diff-list) ediff-buffer-C))
908 (error ""))
909 (setq overlay-list (cons overlay overlay-list))
910 (if (> (length diff-list) 1)
911 (setq diff-list (cdr (cdr diff-list)))
912 (error "ediff-set-fine-overlays-for-combined-merge: corrupt list of
913delimiter regions"))
914 )
915 (setq overlay-list (reverse overlay-list))
916 (ediff-set-fine-diff-vector
917 reg-num 'C (apply 'vector overlay-list))
475f9031 918 ))
71296446
JB
919
920
475f9031
KH
921;; Convert diff list to overlays for a given DIFF-REGION
922;; in buffer of type BUF-TYPE
923(defun ediff-set-fine-overlays-in-one-buffer (buf-type diff-list region-num)
924 (let* ((current-diff -1)
925 (reg-start (ediff-get-diff-posn buf-type 'beg region-num))
926 (buff (ediff-get-buffer buf-type))
17561e4f 927 (ctl-buf ediff-control-buffer)
475f9031
KH
928 combined-merge-diff-list
929 diff-overlay-list list-element
930 begin end overlay)
931
932 (ediff-clear-fine-differences-in-one-buffer region-num buf-type)
933 (setq diff-list (cdr diff-list)) ; discard list type (words or points)
e756eb9f 934 (ediff-with-current-buffer buff (goto-char reg-start))
71296446 935
475f9031
KH
936 ;; if it is a combined merge then set overlays in buff C specially
937 (if (and ediff-merge-job (eq buf-type 'C)
938 (setq combined-merge-diff-list
939 (ediff-looks-like-combined-merge region-num)))
940 (ediff-set-fine-overlays-for-combined-merge
941 combined-merge-diff-list region-num)
942 ;; regular fine diff
943 (while diff-list
944 (setq current-diff (1+ current-diff)
945 list-element (car diff-list)
946 begin (aref list-element (cond ((eq buf-type 'A) 0)
947 ((eq buf-type 'B) 2)
948 (t 4))) ; buf C
949 end (aref list-element (cond ((eq buf-type 'A) 1)
950 ((eq buf-type 'B) 3)
951 (t 5)))) ; buf C
952 (if (not (or begin end))
953 () ; skip this diff
954 ;; Put overlays at appropriate places in buffers
955 ;; convert lines to points, if necessary
17561e4f
MK
956 (ediff-with-current-buffer ctl-buf
957 (setq begin (ediff-goto-word (1+ begin) buff)
958 end (ediff-goto-word end buff 'end)))
475f9031
KH
959 (setq overlay (ediff-make-bullet-proof-overlay begin end buff))
960 ;; record all overlays for this difference region
961 (setq diff-overlay-list (nconc diff-overlay-list (list overlay))))
71296446 962
475f9031
KH
963 (setq diff-list (cdr diff-list))
964 ) ; while
965 ;; convert the list of difference information into a vector
966 ;; for fast access
50a07e18 967 (ediff-set-fine-diff-vector
4ad42cb5 968 region-num buf-type (vconcat diff-overlay-list))
475f9031
KH
969 )))
970
971
50a07e18
MK
972(defsubst ediff-convert-fine-diffs-to-overlays (diff-list region-num)
973 (ediff-set-fine-overlays-in-one-buffer 'A diff-list region-num)
974 (ediff-set-fine-overlays-in-one-buffer 'B diff-list region-num)
975 (if ediff-3way-job
976 (ediff-set-fine-overlays-in-one-buffer 'C diff-list region-num)
977 ))
978
979
475f9031
KH
980;; Stolen from emerge.el
981(defun ediff-get-diff3-group (file)
982 ;; This save-excursion allows ediff-get-diff3-group to be called for the
983 ;; various groups of lines (1, 2, 3) in any order, and for the lines to
984 ;; appear in any order. The reason this is necessary is that Gnu diff3
985 ;; can produce the groups in the order 1, 2, 3 or 1, 3, 2.
986 (save-excursion
987 (re-search-forward
4960e757 988 (concat "^" file ":\\([0-9]+\\)\\(,\\([0-9]+\\)\\)?\\([ac]\\)\C-m?$"))
475f9031
KH
989 (beginning-of-line 2)
990 ;; treatment depends on whether it is an "a" group or a "c" group
991 (if (string-equal (buffer-substring (match-beginning 4) (match-end 4)) "c")
992 ;; it is a "c" group
993 (if (match-beginning 2)
994 ;; it has two numbers
027a4b6b 995 (list (string-to-number
475f9031 996 (buffer-substring (match-beginning 1) (match-end 1)))
027a4b6b 997 (1+ (string-to-number
475f9031
KH
998 (buffer-substring (match-beginning 3) (match-end 3)))))
999 ;; it has one number
027a4b6b 1000 (let ((x (string-to-number
475f9031
KH
1001 (buffer-substring (match-beginning 1) (match-end 1)))))
1002 (list x (1+ x))))
1003 ;; it is an "a" group
027a4b6b 1004 (let ((x (1+ (string-to-number
475f9031
KH
1005 (buffer-substring (match-beginning 1) (match-end 1))))))
1006 (list x x)))))
1007
1008
1009;; If WORD-MODE, construct vector of diffs using word numbers.
1010;; Else, use point values.
1011;; WORD-MODE also tells if we are in the word-mode or not.
1012;; If THREE-WAY-COMP, then it is a 3-way comparison. Else, it is merging
4ad42cb5
MK
1013;; with ancestor, in which case buffer-C contents is identical to buffer-A/B,
1014;; contents (unless buffer-A is narrowed) depending on ediff-default-variant's
1015;; value.
475f9031
KH
1016;; BOUNDS specifies visibility bounds to use.
1017(defun ediff-extract-diffs3 (diff-buffer word-mode three-way-comp
1018 &optional bounds)
1019 (let ((A-buffer ediff-buffer-A)
1020 (B-buffer ediff-buffer-B)
1021 (C-buffer ediff-buffer-C)
4ad42cb5 1022 (anc-buffer ediff-ancestor-buffer)
475f9031 1023 (a-prev 1) ; needed to set the first diff line correctly
b6178721 1024 (a-prev-pt nil)
475f9031 1025 (b-prev 1)
b6178721 1026 (b-prev-pt nil)
475f9031 1027 (c-prev 1)
b6178721 1028 (c-prev-pt nil)
4ad42cb5 1029 (anc-prev 1)
475f9031
KH
1030 diff-list shift-A shift-B shift-C
1031 )
71296446 1032
475f9031
KH
1033 ;; diff list contains word numbers or points, depending on word-mode
1034 (setq diff-list (cons (if word-mode 'words 'points)
1035 diff-list))
1036 (if bounds
1037 (setq shift-A
1038 (ediff-overlay-start
1039 (ediff-get-value-according-to-buffer-type 'A bounds))
50a07e18 1040 shift-B
475f9031
KH
1041 (ediff-overlay-start
1042 (ediff-get-value-according-to-buffer-type 'B bounds))
50a07e18 1043 shift-C
475f9031
KH
1044 (if three-way-comp
1045 (ediff-overlay-start
1046 (ediff-get-value-according-to-buffer-type 'C bounds)))))
71296446 1047
475f9031 1048 ;; reset point in buffers A, B, C
e756eb9f 1049 (ediff-with-current-buffer A-buffer
475f9031 1050 (goto-char (if shift-A shift-A (point-min))))
e756eb9f 1051 (ediff-with-current-buffer B-buffer
475f9031 1052 (goto-char (if shift-B shift-B (point-min))))
4ad42cb5 1053 (if three-way-comp
e756eb9f 1054 (ediff-with-current-buffer C-buffer
4ad42cb5
MK
1055 (goto-char (if shift-C shift-C (point-min)))))
1056 (if (ediff-buffer-live-p anc-buffer)
e756eb9f 1057 (ediff-with-current-buffer anc-buffer
4ad42cb5 1058 (goto-char (point-min))))
71296446 1059
e756eb9f 1060 (ediff-with-current-buffer diff-buffer
475f9031
KH
1061 (goto-char (point-min))
1062 (while (re-search-forward ediff-match-diff3-line nil t)
1063 ;; leave point after matched line
1064 (beginning-of-line 2)
1065 (let ((agreement (buffer-substring (match-beginning 1) (match-end 1))))
bbe6126c 1066 ;; if the files A and B are the same and not 3way-comparison,
475f9031
KH
1067 ;; ignore the difference
1068 (if (or three-way-comp (not (string-equal agreement "3")))
1069 (let* ((a-begin (car (ediff-get-diff3-group "1")))
1070 (a-end (nth 1 (ediff-get-diff3-group "1")))
1071 (b-begin (car (ediff-get-diff3-group "2")))
1072 (b-end (nth 1 (ediff-get-diff3-group "2")))
4ad42cb5
MK
1073 (c-or-anc-begin (car (ediff-get-diff3-group "3")))
1074 (c-or-anc-end (nth 1 (ediff-get-diff3-group "3")))
475f9031
KH
1075 (state-of-merge
1076 (cond ((string-equal agreement "1") 'prefer-A)
1077 ((string-equal agreement "2") 'prefer-B)
1078 (t ediff-default-variant)))
1079 (state-of-diff-merge
1080 (if (memq state-of-merge '(default-A prefer-A)) 'B 'A))
1081 (state-of-diff-comparison
1082 (cond ((string-equal agreement "1") 'A)
1083 ((string-equal agreement "2") 'B)
1084 ((string-equal agreement "3") 'C)))
4ad42cb5 1085 state-of-ancestor
475f9031
KH
1086 c-begin c-end
1087 a-begin-pt a-end-pt
4ad42cb5
MK
1088 b-begin-pt b-end-pt
1089 c-begin-pt c-end-pt
1090 anc-begin-pt anc-end-pt)
71296446 1091
4ad42cb5
MK
1092 (setq state-of-ancestor
1093 (= c-or-anc-begin c-or-anc-end))
1094
1095 (cond (three-way-comp
1096 (setq c-begin c-or-anc-begin
1097 c-end c-or-anc-end))
1098 ((eq ediff-default-variant 'default-B)
1099 (setq c-begin b-begin
1100 c-end b-end))
1101 (t
1102 (setq c-begin a-begin
1103 c-end a-end)))
71296446 1104
475f9031
KH
1105 ;; compute main diff vector
1106 (if word-mode
1107 ;; make diff-list contain word numbers
50a07e18 1108 (setq diff-list
475f9031
KH
1109 (nconc diff-list
1110 (list (vector
1111 (- a-begin a-prev) (- a-end a-begin)
1112 (- b-begin b-prev) (- b-end b-begin)
1113 (- c-begin c-prev) (- c-end c-begin)
4ad42cb5
MK
1114 nil nil ; dummy ancestor
1115 nil ; state of diff
1116 nil ; state of merge
1117 nil ; state of ancestor
1118 )))
475f9031
KH
1119 a-prev a-end
1120 b-prev b-end
1121 c-prev c-end)
1122 ;; else convert lines to points
e756eb9f 1123 (ediff-with-current-buffer A-buffer
8ea74b0e
MK
1124 (let ((longlines-mode-val
1125 (if (and (boundp 'longlines-mode) longlines-mode) 1 0)))
1126 ;; we must disable and then restore longlines-mode
1127 (if (eq longlines-mode-val 1)
1128 (longlines-mode 0))
b6178721 1129 (goto-char (or a-prev-pt shift-A (point-min)))
8ea74b0e
MK
1130 (forward-line (- a-begin a-prev))
1131 (setq a-begin-pt (point))
1132 (forward-line (- a-end a-begin))
1133 (setq a-end-pt (point)
b6178721
MK
1134 a-prev a-end
1135 a-prev-pt a-end-pt)
8ea74b0e
MK
1136 (if (eq longlines-mode-val 1)
1137 (longlines-mode longlines-mode-val))
1138 ))
e756eb9f 1139 (ediff-with-current-buffer B-buffer
8ea74b0e
MK
1140 (let ((longlines-mode-val
1141 (if (and (boundp 'longlines-mode) longlines-mode) 1 0)))
1142 (if (eq longlines-mode-val 1)
1143 (longlines-mode 0))
b6178721 1144 (goto-char (or b-prev-pt shift-B (point-min)))
8ea74b0e
MK
1145 (forward-line (- b-begin b-prev))
1146 (setq b-begin-pt (point))
1147 (forward-line (- b-end b-begin))
1148 (setq b-end-pt (point)
b6178721
MK
1149 b-prev b-end
1150 b-prev-pt b-end-pt)
8ea74b0e
MK
1151 (if (eq longlines-mode-val 1)
1152 (longlines-mode longlines-mode-val))
1153 ))
e756eb9f 1154 (ediff-with-current-buffer C-buffer
8ea74b0e
MK
1155 (let ((longlines-mode-val
1156 (if (and (boundp 'longlines-mode) longlines-mode) 1 0)))
1157 (if (eq longlines-mode-val 1)
1158 (longlines-mode 0))
b6178721 1159 (goto-char (or c-prev-pt shift-C (point-min)))
8ea74b0e
MK
1160 (forward-line (- c-begin c-prev))
1161 (setq c-begin-pt (point))
1162 (forward-line (- c-end c-begin))
1163 (setq c-end-pt (point)
b6178721
MK
1164 c-prev c-end
1165 c-prev-pt c-end-pt)
8ea74b0e
MK
1166 (if (eq longlines-mode-val 1)
1167 (longlines-mode longlines-mode-val))
1168 ))
4ad42cb5 1169 (if (ediff-buffer-live-p anc-buffer)
e756eb9f 1170 (ediff-with-current-buffer anc-buffer
8ea74b0e
MK
1171 (let ((longlines-mode-val
1172 (if (and (boundp 'longlines-mode) longlines-mode) 1 0)))
1173 (if (eq longlines-mode-val 1)
1174 (longlines-mode 0))
1175 (forward-line (- c-or-anc-begin anc-prev))
1176 (setq anc-begin-pt (point))
1177 (forward-line (- c-or-anc-end c-or-anc-begin))
1178 (setq anc-end-pt (point)
1179 anc-prev c-or-anc-end)
1180 (if (eq longlines-mode-val 1)
1181 (longlines-mode longlines-mode-val))
1182 )))
50a07e18 1183 (setq diff-list
475f9031
KH
1184 (nconc
1185 diff-list
1186 ;; if comparing with ancestor, then there also is a
1187 ;; state-of-difference marker
1188 (if three-way-comp
1189 (list (vector
1190 a-begin-pt a-end-pt
1191 b-begin-pt b-end-pt
1192 c-begin-pt c-end-pt
4ad42cb5 1193 nil nil ; ancestor begin/end
475f9031 1194 state-of-diff-comparison
4ad42cb5
MK
1195 nil ; state of merge
1196 nil ; state of ancestor
475f9031
KH
1197 ))
1198 (list (vector a-begin-pt a-end-pt
1199 b-begin-pt b-end-pt
1200 c-begin-pt c-end-pt
4ad42cb5 1201 anc-begin-pt anc-end-pt
475f9031
KH
1202 state-of-diff-merge
1203 state-of-merge
4ad42cb5 1204 state-of-ancestor
475f9031
KH
1205 )))
1206 )))
1207 ))
71296446 1208
e756eb9f 1209 ))) ; end ediff-with-current-buffer
475f9031
KH
1210 diff-list
1211 ))
71296446 1212
475f9031
KH
1213;; Generate the difference vector and overlays for three files
1214;; File-C is either the third file to compare (in case of 3-way comparison)
1215;; or it is the ancestor file.
1216(defun ediff-setup-diff-regions3 (file-A file-B file-C)
b6178721
MK
1217 ;; looking for '-i' or a 'i' among clustered non-long options
1218 (if (string-match "^-i\\| -i\\|-[^- ]+i" ediff-diff-options)
1219 (error "Option `-i' is not allowed in `ediff-diff3-options'"))
1220
475f9031
KH
1221 (or (ediff-buffer-live-p ediff-diff-buffer)
1222 (setq ediff-diff-buffer
1223 (get-buffer-create (ediff-unique-buffer-name "*ediff-diff" "*"))))
71296446 1224
4ad42cb5
MK
1225 (message "Computing differences ...")
1226 (ediff-exec-process ediff-diff3-program ediff-diff-buffer 'synchronize
b6178721 1227 ediff-actual-diff3-options file-A file-B file-C)
71296446 1228
475f9031 1229 (ediff-prepare-error-list ediff-diff3-ok-lines-regexp ediff-diff-buffer)
4ad42cb5 1230 ;;(message "Computing differences ... done")
475f9031
KH
1231 (ediff-convert-diffs-to-overlays
1232 (ediff-extract-diffs3
1233 ediff-diff-buffer
1234 ediff-word-mode ediff-3way-comparison-job ediff-narrow-bounds)
1235 ))
71296446 1236
475f9031 1237
4ae69eac 1238;; Execute PROGRAM asynchronously, unless OS/2, Windows-*, or DOS, or unless
e756eb9f
MK
1239;; SYNCH is non-nil. BUFFER must be a buffer object, and must be alive. The
1240;; OPTIONS arg is a list of options to pass to PROGRAM. It may be a blank
1241;; string. All elements in FILES must be strings. We also delete nil from
1242;; args.
1243(defun ediff-exec-process (program buffer synch options &rest files)
1244 (let ((data (match-data))
513bea45 1245 (coding-system-for-read ediff-coding-system-for-read)
e756eb9f
MK
1246 args)
1247 (setq args (append (split-string options) files))
1248 (setq args (delete "" (delq nil args))) ; delete nil and "" from arguments
7997f1ca 1249 ;; the --binary option, if present, should be used only for buffer jobs
560ef11a 1250 ;; or for refining the differences
7997f1ca 1251 (or (string-match "buffer" (symbol-name ediff-job-name))
560ef11a 1252 (eq buffer ediff-fine-diff-buffer)
7997f1ca 1253 (setq args (delete "--binary" args)))
475f9031
KH
1254 (unwind-protect
1255 (let ((directory default-directory)
1256 proc)
475f9031
KH
1257 (save-excursion
1258 (set-buffer buffer)
1259 (erase-buffer)
1260 (setq default-directory directory)
4ae69eac
MK
1261 (if (or (memq system-type '(emx ms-dos windows-nt windows-95))
1262 synch)
1263 ;; In OS/2 (emx) do it synchronously, since OS/2 doesn't let us
4ad42cb5
MK
1264 ;; delete files used by other processes. Thus, in ediff-buffers
1265 ;; and similar functions, we can't delete temp files because
4ae69eac 1266 ;; they might be used by the asynch process that computes
4ad42cb5
MK
1267 ;; custom diffs. So, we have to wait till custom diff
1268 ;; subprocess is done.
4ae69eac
MK
1269 ;; Similarly for Windows-*
1270 ;; In DOS, must synchronize because DOS doesn't have
1271 ;; asynchronous processes.
4ad42cb5
MK
1272 (apply 'call-process program nil buffer nil args)
1273 ;; On other systems, do it asynchronously.
1274 (setq proc (get-buffer-process buffer))
1275 (if proc (kill-process proc))
1276 (setq proc
1277 (apply 'start-process "Custom Diff" buffer program args))
1278 (setq mode-line-process '(":%s"))
1279 (set-process-sentinel proc 'ediff-process-sentinel)
1280 (set-process-filter proc 'ediff-process-filter)
1281 )))
2eb4bdca 1282 (store-match-data data))))
71296446 1283
863312cd 1284;; This is shell-command-filter from simple.el in Emacs.
475f9031 1285;; Copied here because XEmacs doesn't have it.
4ad42cb5 1286(defun ediff-process-filter (proc string)
475f9031
KH
1287 ;; Do save-excursion by hand so that we can leave point numerically unchanged
1288 ;; despite an insertion immediately after it.
1289 (let* ((obuf (current-buffer))
1290 (buffer (process-buffer proc))
1291 opoint
1292 (window (get-buffer-window buffer))
1293 (pos (window-start window)))
1294 (unwind-protect
1295 (progn
1296 (set-buffer buffer)
1297 (or (= (point) (point-max))
1298 (setq opoint (point)))
1299 (goto-char (point-max))
1300 (insert-before-markers string))
1301 ;; insert-before-markers moved this marker: set it back.
1302 (set-window-start window pos)
1303 ;; Finish our save-excursion.
1304 (if opoint
1305 (goto-char opoint))
1306 (set-buffer obuf))))
71296446 1307
475f9031
KH
1308;; like shell-command-sentinel but doesn't print an exit status message
1309;; we do this because diff always exits with status 1, if diffs are found
1310;; so shell-command-sentinel displays a confusing message to the user
4ad42cb5 1311(defun ediff-process-sentinel (process signal)
475f9031
KH
1312 (if (and (memq (process-status process) '(exit signal))
1313 (buffer-name (process-buffer process)))
1314 (progn
1315 (save-excursion
1316 (set-buffer (process-buffer process))
1317 (setq mode-line-process nil))
1318 (delete-process process))))
71296446 1319
475f9031 1320
50a07e18 1321;;; Word functions used to refine the current diff
475f9031
KH
1322
1323(defvar ediff-forward-word-function 'ediff-forward-word
1324 "*Function to call to move to the next word.
1325Used for splitting difference regions into individual words.")
743a79af 1326(make-variable-buffer-local 'ediff-forward-word-function)
475f9031
KH
1327
1328(defvar ediff-whitespace " \n\t\f"
1329 "*Characters constituting white space.
1330These characters are ignored when differing regions are split into words.")
743a79af 1331(make-variable-buffer-local 'ediff-whitespace)
475f9031 1332
50a07e18
MK
1333(defvar ediff-word-1
1334 (ediff-cond-compile-for-xemacs-or-emacs "a-zA-Z---_" "-[:word:]_")
475f9031
KH
1335 "*Characters that constitute words of type 1.
1336More precisely, [ediff-word-1] is a regexp that matches type 1 words.
50a07e18 1337See `ediff-forward-word' for more details.")
743a79af 1338(make-variable-buffer-local 'ediff-word-1)
475f9031
KH
1339
1340(defvar ediff-word-2 "0-9.,"
1341 "*Characters that constitute words of type 2.
1342More precisely, [ediff-word-2] is a regexp that matches type 2 words.
1343See `ediff-forward-word' for more details.")
743a79af 1344(make-variable-buffer-local 'ediff-word-2)
475f9031
KH
1345
1346(defvar ediff-word-3 "`'?!:;\"{}[]()"
1347 "*Characters that constitute words of type 3.
1348More precisely, [ediff-word-3] is a regexp that matches type 3 words.
1349See `ediff-forward-word' for more details.")
743a79af 1350(make-variable-buffer-local 'ediff-word-3)
475f9031
KH
1351
1352(defvar ediff-word-4
1353 (concat "^" ediff-word-1 ediff-word-2 ediff-word-3 ediff-whitespace)
1354 "*Characters that constitute words of type 4.
1355More precisely, [ediff-word-4] is a regexp that matches type 4 words.
50a07e18 1356See `ediff-forward-word' for more details.")
743a79af 1357(make-variable-buffer-local 'ediff-word-4)
475f9031
KH
1358
1359;; Split region along word boundaries. Each word will be on its own line.
1360;; Output to buffer out-buffer.
1361(defun ediff-forward-word ()
1362 "Move point one word forward.
1363There are four types of words, each of which consists entirely of
1364characters in `ediff-word-1', `ediff-word-2', `ediff-word-3', or
6de3983f
MK
1365`ediff-word-4'. Words are recognized by passing these one after another as
1366arguments to `skip-chars-forward'."
1367 (or (> (+ (skip-chars-forward ediff-word-1)
1368 (skip-syntax-forward "w"))
1369 0)
475f9031
KH
1370 (> (skip-chars-forward ediff-word-2) 0)
1371 (> (skip-chars-forward ediff-word-3) 0)
1372 (> (skip-chars-forward ediff-word-4) 0)
1373 ))
1374
d396e521 1375
475f9031 1376(defun ediff-wordify (beg end in-buffer out-buffer &optional control-buf)
50a07e18
MK
1377 (let ((forward-word-function
1378 ;; eval in control buf to let user create local versions for
1379 ;; different invocations
1380 (if control-buf
1381 (ediff-with-current-buffer control-buf
1382 ediff-forward-word-function)
1383 ediff-forward-word-function))
1384 inbuf-syntax-tbl sv-point diff-string)
475f9031
KH
1385 (save-excursion
1386 (set-buffer in-buffer)
4986c2c6
MK
1387 (setq inbuf-syntax-tbl
1388 (if control-buf
1389 (ediff-with-current-buffer control-buf
1390 ediff-syntax-table)
1391 (syntax-table)))
1392 (setq diff-string (buffer-substring-no-properties beg end))
475f9031
KH
1393
1394 (set-buffer out-buffer)
4696802b 1395 ;; Make sure that temp buff syntax table is the same as the original buf
d396e521
MK
1396 ;; syntax tbl, because we use ediff-forward-word in both and
1397 ;; ediff-forward-word depends on the syntax classes of characters.
1398 (set-syntax-table inbuf-syntax-tbl)
475f9031 1399 (erase-buffer)
4986c2c6 1400 (insert diff-string)
475f9031
KH
1401 (goto-char (point-min))
1402 (skip-chars-forward ediff-whitespace)
1403 (delete-region (point-min) (point))
71296446 1404
475f9031 1405 (while (not (eobp))
50a07e18 1406 (funcall forward-word-function)
475f9031
KH
1407 (setq sv-point (point))
1408 (skip-chars-forward ediff-whitespace)
1409 (delete-region sv-point (point))
1410 (insert "\n")))))
71296446 1411
50a07e18 1412;; copy string specified as BEG END from IN-BUF to OUT-BUF
475f9031 1413(defun ediff-copy-to-buffer (beg end in-buffer out-buffer)
50a07e18
MK
1414 (with-current-buffer out-buffer
1415 (erase-buffer)
1416 (insert-buffer-substring in-buffer beg end)
1417 (goto-char (point-min))))
475f9031
KH
1418
1419
1420;; goto word #n starting at current position in buffer `buf'
4986c2c6 1421;; For ediff, a word is determined by ediff-forward-word-function
475f9031
KH
1422;; If `flag' is non-nil, goto the end of the n-th word.
1423(defun ediff-goto-word (n buf &optional flag)
1424 ;; remember val ediff-forward-word-function has in ctl buf
4986c2c6
MK
1425 (let ((fwd-word-fun ediff-forward-word-function)
1426 (syntax-tbl ediff-syntax-table))
e756eb9f 1427 (ediff-with-current-buffer buf
475f9031 1428 (skip-chars-forward ediff-whitespace)
50a07e18
MK
1429 (ediff-with-syntax-table syntax-tbl
1430 (while (> n 1)
1431 (funcall fwd-word-fun)
1432 (skip-chars-forward ediff-whitespace)
17561e4f
MK
1433 (setq n (1- n)))
1434 (if (and flag (> n 0))
1435 (funcall fwd-word-fun)))
475f9031
KH
1436 (point))))
1437
328b4b70 1438(defun ediff-same-file-contents (f1 f2)
17561e4f
MK
1439 "Return t if files F1 and F2 have identical contents."
1440 (if (and (not (file-directory-p f1))
1441 (not (file-directory-p f2)))
1442 (let ((res
1443 (apply 'call-process ediff-cmp-program nil nil nil
1444 (append ediff-cmp-options (list f1 f2)))))
1445 (and (numberp res) (eq res 0))))
1446 )
1447
1448
1449(defun ediff-same-contents (d1 d2 &optional filter-re)
1450 "Returns t iff D1 and D2 have the same content.
1451D1 and D2 can either be both directories or both regular files.
1452Symlinks and the likes are not handled.
1453If FILTER-RE is non-nil, recursive checking in directories
1454affects only files whose names match the expression."
1455 ;; Normalize empty filter RE to nil.
899a431b 1456 (unless (> (length filter-re) 0) (setq filter-re nil))
17561e4f
MK
1457 ;; Indicate progress
1458 (message "Comparing '%s' and '%s' modulo '%s'" d1 d2 filter-re)
1459 (cond
1460 ;; D1 & D2 directories => recurse
1461 ((and (file-directory-p d1)
1462 (file-directory-p d2))
1463 (if (null ediff-recurse-to-subdirectories)
1464 (if (y-or-n-p "Compare subdirectories recursively? ")
1465 (setq ediff-recurse-to-subdirectories 'yes)
1466 (setq ediff-recurse-to-subdirectories 'no)))
1467 (if (eq ediff-recurse-to-subdirectories 'yes)
1468 (let* ((all-entries-1 (directory-files d1 t filter-re))
1469 (all-entries-2 (directory-files d2 t filter-re))
899a431b
MK
1470 (entries-1 (ediff-delete-all-matches "^\\.\\.?$" all-entries-1))
1471 (entries-2 (ediff-delete-all-matches "^\\.\\.?$" all-entries-2))
17561e4f 1472 )
899a431b
MK
1473
1474 (ediff-same-file-contents-lists entries-1 entries-2 filter-re)
17561e4f
MK
1475 ))
1476 ) ; end of the directories case
1477 ;; D1 & D2 are both files => compare directly
1478 ((and (file-regular-p d1)
1479 (file-regular-p d2))
1480 (ediff-same-file-contents d1 d2))
1481 ;; Otherwise => false: unequal contents
1482 )
1483 )
328b4b70 1484
899a431b
MK
1485;; If lists have the same length and names of files are pairwise equal
1486;; (removing the directories) then compare contents pairwise.
1487;; True if all contents are the same; false otherwise
1488(defun ediff-same-file-contents-lists (entries-1 entries-2 filter-re)
1489 ;; First, check only the names (works quickly and ensures a
1490 ;; precondition for subsequent code)
1491 (if (and (= (length entries-1) (length entries-2))
1492 (equal (mapcar 'file-name-nondirectory entries-1)
1493 (mapcar 'file-name-nondirectory entries-2)))
1494 ;; With name equality established, compare the entries
1495 ;; through recursion.
1496 (let ((continue t))
1497 (while (and entries-1 continue)
1498 (if (ediff-same-contents
1499 (car entries-1) (car entries-2) filter-re)
1500 (setq entries-1 (cdr entries-1)
1501 entries-2 (cdr entries-2))
1502 (setq continue nil))
1503 )
1504 ;; if reached the end then lists are equal
1505 (null entries-1))
1506 )
1507 )
1508
1509
1510;; ARG1 is a regexp, ARG2 is a list of full-filenames
1511;; Delete all entries that match the regexp
1512(defun ediff-delete-all-matches (regex file-list-list)
1513 (let (result elt)
1514 (while file-list-list
1515 (setq elt (car file-list-list))
1516 (or (string-match regex (file-name-nondirectory elt))
1517 (setq result (cons elt result)))
1518 (setq file-list-list (cdr file-list-list)))
1519 (reverse result)))
1520
b6178721
MK
1521;; Ignore case handling - some ideas from drew.adams@@oracle.com
1522(defun ediff-toggle-ignore-case ()
1523 (interactive)
1524 (ediff-barf-if-not-control-buffer)
1525 (setq ediff-ignore-case (not ediff-ignore-case))
1526 (cond (ediff-ignore-case
1527 (setq ediff-actual-diff-options
1528 (concat ediff-diff-options " " ediff-ignore-case-option)
1529 ediff-actual-diff3-options
1530 (concat ediff-diff3-options " " ediff-ignore-case-option3))
1531 (message "Ignoring regions that differ only in case"))
1532 (t
1533 (setq ediff-actual-diff-options ediff-diff-options
1534 ediff-actual-diff3-options ediff-diff3-options)
1535 (message "Ignoring case differences turned OFF")))
1536 (cond (ediff-merge-job
1537 (message "Ignoring letter case is too dangerous in merge jobs"))
1538 ((and ediff-diff3-job (string= ediff-ignore-case-option3 ""))
1539 (message "Ignoring letter case is not supported by this diff3 program"))
1540 ((and (not ediff-3way-job) (string= ediff-ignore-case-option ""))
1541 (message "Ignoring letter case is not supported by this diff program"))
1542 (t
1543 (sit-for 1)
1544 (ediff-update-diffs)))
1545 )
1546
1547
1548(provide 'ediff-diff)
1549
475f9031 1550
bbe6126c
MK
1551;;; Local Variables:
1552;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun)
e756eb9f
MK
1553;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1)
1554;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body))
bbe6126c
MK
1555;;; End:
1556
ab5796a9 1557;;; arch-tag: a86d448e-58d7-4572-a1d9-fdedfa22f648
3afbc435 1558;;; ediff-diff.el ends here