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