126 |
:group 'ediff-diff) |
:group 'ediff-diff) |
127 |
|
|
128 |
(defcustom ediff-diff-options "" |
(defcustom ediff-diff-options "" |
129 |
"*Options to pass to `ediff-diff-program'. |
"*Options to pass to `ediff-diff-program'. |
130 |
If Unix diff is used as `ediff-diff-program', then the most useful options are |
If Unix diff is used as `ediff-diff-program', then the most useful options are |
131 |
`-w', to ignore space, and `-i', to ignore case of letters. |
`-w', to ignore space, and `-i', to ignore case of letters. |
132 |
At present, the option `-c' is not allowed." |
At present, the option `-c' is not allowed." |
164 |
;; the status can be =diff(A), =diff(B), or =diff(A+B) |
;; the status can be =diff(A), =diff(B), or =diff(A+B) |
165 |
(ediff-defvar-local ediff-diff-status "" "") |
(ediff-defvar-local ediff-diff-status "" "") |
166 |
|
|
167 |
|
|
168 |
;;; Fine differences |
;;; Fine differences |
169 |
|
|
170 |
(ediff-defvar-local ediff-auto-refine (if (ediff-has-face-support-p) 'on 'nix) |
(ediff-defvar-local ediff-auto-refine (if (ediff-has-face-support-p) 'on 'nix) |
182 |
|
|
183 |
(ediff-defvar-local ediff-auto-refine-limit 1400 |
(ediff-defvar-local ediff-auto-refine-limit 1400 |
184 |
"*Auto-refine only the regions of this size \(in bytes\) or less.") |
"*Auto-refine only the regions of this size \(in bytes\) or less.") |
185 |
|
|
186 |
;;; General |
;;; General |
187 |
|
|
188 |
(defvar ediff-diff-ok-lines-regexp |
(defvar ediff-diff-ok-lines-regexp |
215 |
file-C. It may ignore file C for diff2 jobs. It should also take |
file-C. It may ignore file C for diff2 jobs. It should also take |
216 |
one optional arguments, diff-number to refine.") |
one optional arguments, diff-number to refine.") |
217 |
|
|
218 |
|
|
219 |
;;; Functions |
;;; Functions |
220 |
|
|
221 |
;; Generate the difference vector and overlays for the two files |
;; Generate the difference vector and overlays for the two files |
225 |
;; ediff-setup-diff-regions-function, which can also have the value |
;; ediff-setup-diff-regions-function, which can also have the value |
226 |
;; ediff-setup-diff-regions3, which takes 4 arguments. |
;; ediff-setup-diff-regions3, which takes 4 arguments. |
227 |
(defun ediff-setup-diff-regions (file-A file-B file-C) |
(defun ediff-setup-diff-regions (file-A file-B file-C) |
228 |
(if (string-match "c" ediff-diff-options) |
;; looking either for '-c' or a 'c' in a set of clustered non-long options |
229 |
|
(if (string-match "^-c\\| -c\\|-[^- ]+c" ediff-diff-options) |
230 |
(error "Option `-c' is not allowed in `ediff-diff-options'")) |
(error "Option `-c' is not allowed in `ediff-diff-options'")) |
231 |
|
|
232 |
;; create, if it doesn't exist |
;; create, if it doesn't exist |
233 |
(or (ediff-buffer-live-p ediff-diff-buffer) |
(or (ediff-buffer-live-p ediff-diff-buffer) |
234 |
(setq ediff-diff-buffer |
(setq ediff-diff-buffer |
268 |
(message "") |
(message "") |
269 |
(ediff-with-current-buffer diff-buffer |
(ediff-with-current-buffer diff-buffer |
270 |
(buffer-size)))))) |
(buffer-size)))))) |
|
|
|
271 |
|
|
272 |
|
|
273 |
|
|
274 |
;; If file-A/B/C is nil, do 2-way comparison with the non-nil buffers |
;; If file-A/B/C is nil, do 2-way comparison with the non-nil buffers |
275 |
;; This function works for diff3 and diff2 jobs |
;; This function works for diff3 and diff2 jobs |
276 |
(defun ediff-setup-fine-diff-regions (file-A file-B file-C reg-num) |
(defun ediff-setup-fine-diff-regions (file-A file-B file-C reg-num) |
278 |
(setq ediff-fine-diff-buffer |
(setq ediff-fine-diff-buffer |
279 |
(get-buffer-create |
(get-buffer-create |
280 |
(ediff-unique-buffer-name "*ediff-fine-diff" "*")))) |
(ediff-unique-buffer-name "*ediff-fine-diff" "*")))) |
281 |
|
|
282 |
(let (diff3-job diff-program diff-options ok-regexp diff-list) |
(let (diff3-job diff-program diff-options ok-regexp diff-list) |
283 |
(setq diff3-job ediff-3way-job |
(setq diff3-job ediff-3way-job |
284 |
diff-program (if diff3-job ediff-diff3-program ediff-diff-program) |
diff-program (if diff3-job ediff-diff3-program ediff-diff-program) |
286 |
ok-regexp (if diff3-job |
ok-regexp (if diff3-job |
287 |
ediff-diff3-ok-lines-regexp |
ediff-diff3-ok-lines-regexp |
288 |
ediff-diff-ok-lines-regexp)) |
ediff-diff-ok-lines-regexp)) |
289 |
|
|
290 |
(ediff-message-if-verbose "Refining difference region %d ..." (1+ reg-num)) |
(ediff-message-if-verbose "Refining difference region %d ..." (1+ reg-num)) |
291 |
(ediff-exec-process diff-program ediff-fine-diff-buffer 'synchronize |
(ediff-exec-process diff-program ediff-fine-diff-buffer 'synchronize |
292 |
diff-options |
diff-options |
298 |
(if diff3-job |
(if diff3-job |
299 |
(if file-C file-C file-B)) |
(if file-C file-C file-B)) |
300 |
) ; exec process |
) ; exec process |
301 |
|
|
302 |
(ediff-prepare-error-list ok-regexp ediff-fine-diff-buffer) |
(ediff-prepare-error-list ok-regexp ediff-fine-diff-buffer) |
303 |
(ediff-message-if-verbose |
(ediff-message-if-verbose |
304 |
"") |
"") |
305 |
;; "Refining difference region %d ... done" (1+ reg-num)) |
;; "Refining difference region %d ... done" (1+ reg-num)) |
306 |
|
|
307 |
(setq diff-list |
(setq diff-list |
308 |
(if diff3-job |
(if diff3-job |
309 |
(ediff-extract-diffs3 |
(ediff-extract-diffs3 |
327 |
(aset elt 5 nil)) |
(aset elt 5 nil)) |
328 |
(cdr diff-list))) |
(cdr diff-list))) |
329 |
)) |
)) |
330 |
|
|
331 |
(ediff-convert-fine-diffs-to-overlays diff-list reg-num) |
(ediff-convert-fine-diffs-to-overlays diff-list reg-num) |
332 |
)) |
)) |
333 |
|
|
334 |
|
|
335 |
(defun ediff-prepare-error-list (ok-regexp diff-buff) |
(defun ediff-prepare-error-list (ok-regexp diff-buff) |
336 |
(or (ediff-buffer-live-p ediff-error-buffer) |
(or (ediff-buffer-live-p ediff-error-buffer) |
337 |
(setq ediff-error-buffer |
(setq ediff-error-buffer |
368 |
(c-prev 1) |
(c-prev 1) |
369 |
diff-list shift-A shift-B |
diff-list shift-A shift-B |
370 |
) |
) |
371 |
|
|
372 |
;; diff list contains word numbers, unless changed later |
;; diff list contains word numbers, unless changed later |
373 |
(setq diff-list (cons (if word-mode 'words 'points) |
(setq diff-list (cons (if word-mode 'words 'points) |
374 |
diff-list)) |
diff-list)) |
380 |
shift-B |
shift-B |
381 |
(ediff-overlay-start |
(ediff-overlay-start |
382 |
(ediff-get-value-according-to-buffer-type 'B bounds)))) |
(ediff-get-value-according-to-buffer-type 'B bounds)))) |
383 |
|
|
384 |
;; reset point in buffers A/B/C |
;; reset point in buffers A/B/C |
385 |
(ediff-with-current-buffer A-buffer |
(ediff-with-current-buffer A-buffer |
386 |
(goto-char (if shift-A shift-A (point-min)))) |
(goto-char (if shift-A shift-A (point-min)))) |
389 |
(if (ediff-buffer-live-p C-buffer) |
(if (ediff-buffer-live-p C-buffer) |
390 |
(ediff-with-current-buffer C-buffer |
(ediff-with-current-buffer C-buffer |
391 |
(goto-char (point-min)))) |
(goto-char (point-min)))) |
392 |
|
|
393 |
(ediff-with-current-buffer diff-buffer |
(ediff-with-current-buffer diff-buffer |
394 |
(goto-char (point-min)) |
(goto-char (point-min)) |
395 |
(while (re-search-forward ediff-match-diff-line nil t) |
(while (re-search-forward ediff-match-diff-line nil t) |
423 |
;; (string-equal diff-type "c") |
;; (string-equal diff-type "c") |
424 |
(setq a-end (1+ a-end) |
(setq a-end (1+ a-end) |
425 |
b-end (1+ b-end)))) |
b-end (1+ b-end)))) |
426 |
|
|
427 |
(if (eq ediff-default-variant 'default-B) |
(if (eq ediff-default-variant 'default-B) |
428 |
(setq c-begin b-begin |
(setq c-begin b-begin |
429 |
c-end b-end) |
c-end b-end) |
430 |
(setq c-begin a-begin |
(setq c-begin a-begin |
431 |
c-end a-end)) |
c-end a-end)) |
432 |
|
|
433 |
;; compute main diff vector |
;; compute main diff vector |
434 |
(if word-mode |
(if word-mode |
435 |
;; make diff-list contain word numbers |
;; make diff-list contain word numbers |
500 |
nil ; dummy state of ancestor |
nil ; dummy state of ancestor |
501 |
))) |
))) |
502 |
))) |
))) |
503 |
|
|
504 |
))) ; end ediff-with-current-buffer |
))) ; end ediff-with-current-buffer |
505 |
diff-list |
diff-list |
506 |
)) |
)) |
507 |
|
|
508 |
|
|
509 |
(defun ediff-convert-diffs-to-overlays (diff-list) |
(defun ediff-convert-diffs-to-overlays (diff-list) |
510 |
(ediff-set-diff-overlays-in-one-buffer 'A diff-list) |
(ediff-set-diff-overlays-in-one-buffer 'A diff-list) |
530 |
))) |
))) |
531 |
(message "Processing difference regions ... done")) |
(message "Processing difference regions ... done")) |
532 |
|
|
533 |
|
|
534 |
(defun ediff-set-diff-overlays-in-one-buffer (buf-type diff-list) |
(defun ediff-set-diff-overlays-in-one-buffer (buf-type diff-list) |
535 |
(let* ((current-diff -1) |
(let* ((current-diff -1) |
536 |
(buff (ediff-get-buffer buf-type)) |
(buff (ediff-get-buffer buf-type)) |
548 |
|
|
549 |
(setq diff-list (cdr diff-list)) ; discard diff list type |
(setq diff-list (cdr diff-list)) ; discard diff list type |
550 |
(setq total-diffs (length diff-list)) |
(setq total-diffs (length diff-list)) |
551 |
|
|
552 |
;; shift, if necessary |
;; shift, if necessary |
553 |
(ediff-with-current-buffer buff (setq pt-saved shift)) |
(ediff-with-current-buffer buff (setq pt-saved shift)) |
554 |
|
|
555 |
(while diff-list |
(while diff-list |
556 |
(setq current-diff (1+ current-diff) |
(setq current-diff (1+ current-diff) |
557 |
list-element (car diff-list) |
list-element (car diff-list) |
565 |
(t 7))) ; Ancestor |
(t 7))) ; Ancestor |
566 |
state-of-diff (aref list-element 8) |
state-of-diff (aref list-element 8) |
567 |
) |
) |
568 |
|
|
569 |
(cond ((and (not (eq buf-type state-of-diff)) |
(cond ((and (not (eq buf-type state-of-diff)) |
570 |
(not (eq buf-type 'Ancestor)) |
(not (eq buf-type 'Ancestor)) |
571 |
(memq state-of-diff '(A B C))) |
(memq state-of-diff '(A B C))) |
574 |
(setq state-of-diff (format "=diff(%S)" state-of-diff)) |
(setq state-of-diff (format "=diff(%S)" state-of-diff)) |
575 |
) |
) |
576 |
(t (setq state-of-diff nil))) |
(t (setq state-of-diff nil))) |
577 |
|
|
578 |
;; Put overlays at appropriate places in buffer |
;; Put overlays at appropriate places in buffer |
579 |
;; convert word numbers to points, if necessary |
;; convert word numbers to points, if necessary |
580 |
(if (eq diff-list-type 'words) |
(if (eq diff-list-type 'words) |
586 |
(if (> begin end) (setq begin end)) |
(if (> begin end) (setq begin end)) |
587 |
(setq pt-saved (ediff-with-current-buffer buff (point))))) |
(setq pt-saved (ediff-with-current-buffer buff (point))))) |
588 |
(setq overlay (ediff-make-bullet-proof-overlay begin end buff)) |
(setq overlay (ediff-make-bullet-proof-overlay begin end buff)) |
589 |
|
|
590 |
(ediff-overlay-put overlay 'priority ediff-shadow-overlay-priority) |
(ediff-overlay-put overlay 'priority ediff-shadow-overlay-priority) |
591 |
(ediff-overlay-put overlay 'ediff-diff-num current-diff) |
(ediff-overlay-put overlay 'ediff-diff-num current-diff) |
592 |
(if (and (ediff-has-face-support-p) |
(if (and (ediff-has-face-support-p) |
609 |
diff-list |
diff-list |
610 |
(cdr diff-list)) |
(cdr diff-list)) |
611 |
) ; while |
) ; while |
612 |
|
|
613 |
(set (ediff-get-symbol-from-alist buf-type ediff-difference-vector-alist) |
(set (ediff-get-symbol-from-alist buf-type ediff-difference-vector-alist) |
614 |
(vconcat diff-overlay-list)) |
(vconcat diff-overlay-list)) |
615 |
)) |
)) |
620 |
;; if `flag' is 'skip then don't compute fine diffs for this region. |
;; if `flag' is 'skip then don't compute fine diffs for this region. |
621 |
(defun ediff-make-fine-diffs (&optional n flag) |
(defun ediff-make-fine-diffs (&optional n flag) |
622 |
(or n (setq n ediff-current-difference)) |
(or n (setq n ediff-current-difference)) |
623 |
|
|
624 |
(if (< ediff-number-of-differences 1) |
(if (< ediff-number-of-differences 1) |
625 |
(error ediff-NO-DIFFERENCES)) |
(error ediff-NO-DIFFERENCES)) |
626 |
|
|
627 |
(if ediff-word-mode |
(if ediff-word-mode |
628 |
(setq flag 'skip |
(setq flag 'skip |
629 |
ediff-auto-refine 'nix)) |
ediff-auto-refine 'nix)) |
630 |
|
|
631 |
(or (< n 0) |
(or (< n 0) |
632 |
(>= n ediff-number-of-differences) |
(>= n ediff-number-of-differences) |
633 |
;; n is within the range |
;; n is within the range |
642 |
(whitespace-B (ediff-whitespace-diff-region-p n 'B)) |
(whitespace-B (ediff-whitespace-diff-region-p n 'B)) |
643 |
(whitespace-C (ediff-whitespace-diff-region-p n 'C)) |
(whitespace-C (ediff-whitespace-diff-region-p n 'C)) |
644 |
cumulative-fine-diff-length) |
cumulative-fine-diff-length) |
645 |
|
|
646 |
(cond ;; If one of the regions is empty (or 2 in 3way comparison) |
(cond ;; If one of the regions is empty (or 2 in 3way comparison) |
647 |
;; then don't refine. |
;; then don't refine. |
648 |
;; If the region happens to be entirely whitespace or empty then |
;; If the region happens to be entirely whitespace or empty then |
706 |
ediff-control-buffer) |
ediff-control-buffer) |
707 |
(setq file-A |
(setq file-A |
708 |
(ediff-make-temp-file tmp-buffer "fineDiffA" file-A)) |
(ediff-make-temp-file tmp-buffer "fineDiffA" file-A)) |
709 |
|
|
710 |
(ediff-wordify |
(ediff-wordify |
711 |
(ediff-get-diff-posn 'B 'beg n) |
(ediff-get-diff-posn 'B 'beg n) |
712 |
(ediff-get-diff-posn 'B 'end n) |
(ediff-get-diff-posn 'B 'end n) |
715 |
ediff-control-buffer) |
ediff-control-buffer) |
716 |
(setq file-B |
(setq file-B |
717 |
(ediff-make-temp-file tmp-buffer "fineDiffB" file-B)) |
(ediff-make-temp-file tmp-buffer "fineDiffB" file-B)) |
718 |
|
|
719 |
(if ediff-3way-job |
(if ediff-3way-job |
720 |
(progn |
(progn |
721 |
(ediff-wordify |
(ediff-wordify |
727 |
(setq file-C |
(setq file-C |
728 |
(ediff-make-temp-file |
(ediff-make-temp-file |
729 |
tmp-buffer "fineDiffC" file-C)))) |
tmp-buffer "fineDiffC" file-C)))) |
730 |
|
|
731 |
;; save temp file names. |
;; save temp file names. |
732 |
(setq ediff-temp-file-A file-A |
(setq ediff-temp-file-A file-A |
733 |
ediff-temp-file-B file-B |
ediff-temp-file-B file-B |
734 |
ediff-temp-file-C file-C) |
ediff-temp-file-C file-C) |
735 |
|
|
736 |
;; set the new vector of fine diffs, if none exists |
;; set the new vector of fine diffs, if none exists |
737 |
(cond ((and ediff-3way-job whitespace-A) |
(cond ((and ediff-3way-job whitespace-A) |
738 |
(ediff-setup-fine-diff-regions nil file-B file-C n)) |
(ediff-setup-fine-diff-regions nil file-B file-C n)) |
745 |
(ediff-setup-fine-diff-regions file-A file-B nil n)) |
(ediff-setup-fine-diff-regions file-A file-B nil n)) |
746 |
(t |
(t |
747 |
(ediff-setup-fine-diff-regions file-A file-B file-C n))) |
(ediff-setup-fine-diff-regions file-A file-B file-C n))) |
748 |
|
|
749 |
(setq cumulative-fine-diff-length |
(setq cumulative-fine-diff-length |
750 |
(+ (length (ediff-get-fine-diff-vector n 'A)) |
(+ (length (ediff-get-fine-diff-vector n 'A)) |
751 |
(length (ediff-get-fine-diff-vector n 'B)) |
(length (ediff-get-fine-diff-vector n 'B)) |
753 |
(if (and file-C (not ediff-merge-job)) |
(if (and file-C (not ediff-merge-job)) |
754 |
(length (ediff-get-fine-diff-vector n 'C)) |
(length (ediff-get-fine-diff-vector n 'C)) |
755 |
0))) |
0))) |
756 |
|
|
757 |
(cond ((or |
(cond ((or |
758 |
;; all regions are white space |
;; all regions are white space |
759 |
(and whitespace-A whitespace-B whitespace-C) |
(and whitespace-A whitespace-B whitespace-C) |
781 |
) ; end cond |
) ; end cond |
782 |
(ediff-set-fine-diff-properties n) |
(ediff-set-fine-diff-properties n) |
783 |
))) |
))) |
784 |
|
|
785 |
;; Interface to ediff-make-fine-diffs. Checks for auto-refine limit, etc. |
;; Interface to ediff-make-fine-diffs. Checks for auto-refine limit, etc. |
786 |
(defun ediff-install-fine-diff-if-necessary (n) |
(defun ediff-install-fine-diff-if-necessary (n) |
787 |
(cond ((and (eq ediff-auto-refine 'on) |
(cond ((and (eq ediff-auto-refine 'on) |
797 |
(ediff-get-diff-posn 'B 'beg n)))) |
(ediff-get-diff-posn 'B 'beg n)))) |
798 |
(ediff-make-fine-diffs n 'noforce) |
(ediff-make-fine-diffs n 'noforce) |
799 |
(ediff-make-fine-diffs n 'skip))) |
(ediff-make-fine-diffs n 'skip))) |
800 |
|
|
801 |
;; highlight iff fine diffs already exist |
;; highlight iff fine diffs already exist |
802 |
((eq ediff-auto-refine 'off) |
((eq ediff-auto-refine 'off) |
803 |
(ediff-make-fine-diffs n 'skip)))) |
(ediff-make-fine-diffs n 'skip)))) |
804 |
|
|
805 |
|
|
806 |
;; if fine diff vector is not set for diff N, then do nothing |
;; if fine diff vector is not set for diff N, then do nothing |
807 |
(defun ediff-set-fine-diff-properties (n &optional default) |
(defun ediff-set-fine-diff-properties (n &optional default) |
808 |
(or (not (ediff-has-face-support-p)) |
(or (not (ediff-has-face-support-p)) |
814 |
(ediff-set-fine-diff-properties-in-one-buffer 'B n default) |
(ediff-set-fine-diff-properties-in-one-buffer 'B n default) |
815 |
(if ediff-3way-job |
(if ediff-3way-job |
816 |
(ediff-set-fine-diff-properties-in-one-buffer 'C n default))))) |
(ediff-set-fine-diff-properties-in-one-buffer 'C n default))))) |
817 |
|
|
818 |
(defun ediff-set-fine-diff-properties-in-one-buffer (buf-type |
(defun ediff-set-fine-diff-properties-in-one-buffer (buf-type |
819 |
n &optional default) |
n &optional default) |
820 |
(let ((fine-diff-vector (ediff-get-fine-diff-vector n buf-type)) |
(let ((fine-diff-vector (ediff-get-fine-diff-vector n buf-type)) |
836 |
(ediff-set-overlay-face overl face) |
(ediff-set-overlay-face overl face) |
837 |
(ediff-overlay-put overl 'priority priority)) |
(ediff-overlay-put overl 'priority priority)) |
838 |
fine-diff-vector))) |
fine-diff-vector))) |
839 |
|
|
840 |
;; Set overlays over the regions that denote delimiters |
;; Set overlays over the regions that denote delimiters |
841 |
(defun ediff-set-fine-overlays-for-combined-merge (diff-list reg-num) |
(defun ediff-set-fine-overlays-for-combined-merge (diff-list reg-num) |
842 |
(let (overlay overlay-list) |
(let (overlay overlay-list) |
856 |
(ediff-set-fine-diff-vector |
(ediff-set-fine-diff-vector |
857 |
reg-num 'C (apply 'vector overlay-list)) |
reg-num 'C (apply 'vector overlay-list)) |
858 |
)) |
)) |
859 |
|
|
860 |
|
|
861 |
;; Convert diff list to overlays for a given DIFF-REGION |
;; Convert diff list to overlays for a given DIFF-REGION |
862 |
;; in buffer of type BUF-TYPE |
;; in buffer of type BUF-TYPE |
863 |
(defun ediff-set-fine-overlays-in-one-buffer (buf-type diff-list region-num) |
(defun ediff-set-fine-overlays-in-one-buffer (buf-type diff-list region-num) |
871 |
(ediff-clear-fine-differences-in-one-buffer region-num buf-type) |
(ediff-clear-fine-differences-in-one-buffer region-num buf-type) |
872 |
(setq diff-list (cdr diff-list)) ; discard list type (words or points) |
(setq diff-list (cdr diff-list)) ; discard list type (words or points) |
873 |
(ediff-with-current-buffer buff (goto-char reg-start)) |
(ediff-with-current-buffer buff (goto-char reg-start)) |
874 |
|
|
875 |
;; if it is a combined merge then set overlays in buff C specially |
;; if it is a combined merge then set overlays in buff C specially |
876 |
(if (and ediff-merge-job (eq buf-type 'C) |
(if (and ediff-merge-job (eq buf-type 'C) |
877 |
(setq combined-merge-diff-list |
(setq combined-merge-diff-list |
897 |
(setq overlay (ediff-make-bullet-proof-overlay begin end buff)) |
(setq overlay (ediff-make-bullet-proof-overlay begin end buff)) |
898 |
;; record all overlays for this difference region |
;; record all overlays for this difference region |
899 |
(setq diff-overlay-list (nconc diff-overlay-list (list overlay)))) |
(setq diff-overlay-list (nconc diff-overlay-list (list overlay)))) |
900 |
|
|
901 |
(setq diff-list (cdr diff-list)) |
(setq diff-list (cdr diff-list)) |
902 |
) ; while |
) ; while |
903 |
;; convert the list of difference information into a vector |
;; convert the list of difference information into a vector |
964 |
(anc-prev 1) |
(anc-prev 1) |
965 |
diff-list shift-A shift-B shift-C |
diff-list shift-A shift-B shift-C |
966 |
) |
) |
967 |
|
|
968 |
;; diff list contains word numbers or points, depending on word-mode |
;; diff list contains word numbers or points, depending on word-mode |
969 |
(setq diff-list (cons (if word-mode 'words 'points) |
(setq diff-list (cons (if word-mode 'words 'points) |
970 |
diff-list)) |
diff-list)) |
979 |
(if three-way-comp |
(if three-way-comp |
980 |
(ediff-overlay-start |
(ediff-overlay-start |
981 |
(ediff-get-value-according-to-buffer-type 'C bounds))))) |
(ediff-get-value-according-to-buffer-type 'C bounds))))) |
982 |
|
|
983 |
;; reset point in buffers A, B, C |
;; reset point in buffers A, B, C |
984 |
(ediff-with-current-buffer A-buffer |
(ediff-with-current-buffer A-buffer |
985 |
(goto-char (if shift-A shift-A (point-min)))) |
(goto-char (if shift-A shift-A (point-min)))) |
991 |
(if (ediff-buffer-live-p anc-buffer) |
(if (ediff-buffer-live-p anc-buffer) |
992 |
(ediff-with-current-buffer anc-buffer |
(ediff-with-current-buffer anc-buffer |
993 |
(goto-char (point-min)))) |
(goto-char (point-min)))) |
994 |
|
|
995 |
(ediff-with-current-buffer diff-buffer |
(ediff-with-current-buffer diff-buffer |
996 |
(goto-char (point-min)) |
(goto-char (point-min)) |
997 |
(while (re-search-forward ediff-match-diff3-line nil t) |
(while (re-search-forward ediff-match-diff3-line nil t) |
1023 |
b-begin-pt b-end-pt |
b-begin-pt b-end-pt |
1024 |
c-begin-pt c-end-pt |
c-begin-pt c-end-pt |
1025 |
anc-begin-pt anc-end-pt) |
anc-begin-pt anc-end-pt) |
1026 |
|
|
1027 |
(setq state-of-ancestor |
(setq state-of-ancestor |
1028 |
(= c-or-anc-begin c-or-anc-end)) |
(= c-or-anc-begin c-or-anc-end)) |
1029 |
|
|
1036 |
(t |
(t |
1037 |
(setq c-begin a-begin |
(setq c-begin a-begin |
1038 |
c-end a-end))) |
c-end a-end))) |
1039 |
|
|
1040 |
;; compute main diff vector |
;; compute main diff vector |
1041 |
(if word-mode |
(if word-mode |
1042 |
;; make diff-list contain word numbers |
;; make diff-list contain word numbers |
1105 |
))) |
))) |
1106 |
))) |
))) |
1107 |
)) |
)) |
1108 |
|
|
1109 |
))) ; end ediff-with-current-buffer |
))) ; end ediff-with-current-buffer |
1110 |
diff-list |
diff-list |
1111 |
)) |
)) |
1112 |
|
|
1113 |
;; Generate the difference vector and overlays for three files |
;; Generate the difference vector and overlays for three files |
1114 |
;; File-C is either the third file to compare (in case of 3-way comparison) |
;; File-C is either the third file to compare (in case of 3-way comparison) |
1115 |
;; or it is the ancestor file. |
;; or it is the ancestor file. |
1117 |
(or (ediff-buffer-live-p ediff-diff-buffer) |
(or (ediff-buffer-live-p ediff-diff-buffer) |
1118 |
(setq ediff-diff-buffer |
(setq ediff-diff-buffer |
1119 |
(get-buffer-create (ediff-unique-buffer-name "*ediff-diff" "*")))) |
(get-buffer-create (ediff-unique-buffer-name "*ediff-diff" "*")))) |
1120 |
|
|
1121 |
(message "Computing differences ...") |
(message "Computing differences ...") |
1122 |
(ediff-exec-process ediff-diff3-program ediff-diff-buffer 'synchronize |
(ediff-exec-process ediff-diff3-program ediff-diff-buffer 'synchronize |
1123 |
ediff-diff3-options file-A file-B file-C) |
ediff-diff3-options file-A file-B file-C) |
1124 |
|
|
1125 |
(ediff-prepare-error-list ediff-diff3-ok-lines-regexp ediff-diff-buffer) |
(ediff-prepare-error-list ediff-diff3-ok-lines-regexp ediff-diff-buffer) |
1126 |
;;(message "Computing differences ... done") |
;;(message "Computing differences ... done") |
1127 |
(ediff-convert-diffs-to-overlays |
(ediff-convert-diffs-to-overlays |
1129 |
ediff-diff-buffer |
ediff-diff-buffer |
1130 |
ediff-word-mode ediff-3way-comparison-job ediff-narrow-bounds) |
ediff-word-mode ediff-3way-comparison-job ediff-narrow-bounds) |
1131 |
)) |
)) |
1132 |
|
|
1133 |
|
|
1134 |
;; Execute PROGRAM asynchronously, unless OS/2, Windows-*, or DOS, or unless |
;; Execute PROGRAM asynchronously, unless OS/2, Windows-*, or DOS, or unless |
1135 |
;; SYNCH is non-nil. BUFFER must be a buffer object, and must be alive. The |
;; SYNCH is non-nil. BUFFER must be a buffer object, and must be alive. The |
1176 |
(set-process-filter proc 'ediff-process-filter) |
(set-process-filter proc 'ediff-process-filter) |
1177 |
))) |
))) |
1178 |
(store-match-data data)))) |
(store-match-data data)))) |
1179 |
|
|
1180 |
;; This is shell-command-filter from simple.el in Emacs. |
;; This is shell-command-filter from simple.el in Emacs. |
1181 |
;; Copied here because XEmacs doesn't have it. |
;; Copied here because XEmacs doesn't have it. |
1182 |
(defun ediff-process-filter (proc string) |
(defun ediff-process-filter (proc string) |
1200 |
(if opoint |
(if opoint |
1201 |
(goto-char opoint)) |
(goto-char opoint)) |
1202 |
(set-buffer obuf)))) |
(set-buffer obuf)))) |
1203 |
|
|
1204 |
;; like shell-command-sentinel but doesn't print an exit status message |
;; like shell-command-sentinel but doesn't print an exit status message |
1205 |
;; we do this because diff always exits with status 1, if diffs are found |
;; we do this because diff always exits with status 1, if diffs are found |
1206 |
;; so shell-command-sentinel displays a confusing message to the user |
;; so shell-command-sentinel displays a confusing message to the user |
1212 |
(set-buffer (process-buffer process)) |
(set-buffer (process-buffer process)) |
1213 |
(setq mode-line-process nil)) |
(setq mode-line-process nil)) |
1214 |
(delete-process process)))) |
(delete-process process)))) |
1215 |
|
|
1216 |
|
|
1217 |
;;; Word functions used to refine the current diff |
;;; Word functions used to refine the current diff |
1218 |
|
|
1288 |
(setq diff-string (buffer-substring-no-properties beg end)) |
(setq diff-string (buffer-substring-no-properties beg end)) |
1289 |
|
|
1290 |
(set-buffer out-buffer) |
(set-buffer out-buffer) |
1291 |
;; Make sure that temp buff syntax table is the same a the original buf |
;; Make sure that temp buff syntax table is the same as the original buf |
1292 |
;; syntax tbl, because we use ediff-forward-word in both and |
;; syntax tbl, because we use ediff-forward-word in both and |
1293 |
;; ediff-forward-word depends on the syntax classes of characters. |
;; ediff-forward-word depends on the syntax classes of characters. |
1294 |
(set-syntax-table inbuf-syntax-tbl) |
(set-syntax-table inbuf-syntax-tbl) |
1297 |
(goto-char (point-min)) |
(goto-char (point-min)) |
1298 |
(skip-chars-forward ediff-whitespace) |
(skip-chars-forward ediff-whitespace) |
1299 |
(delete-region (point-min) (point)) |
(delete-region (point-min) (point)) |
1300 |
|
|
1301 |
(while (not (eobp)) |
(while (not (eobp)) |
1302 |
(funcall forward-word-function) |
(funcall forward-word-function) |
1303 |
(setq sv-point (point)) |
(setq sv-point (point)) |
1304 |
(skip-chars-forward ediff-whitespace) |
(skip-chars-forward ediff-whitespace) |
1305 |
(delete-region sv-point (point)) |
(delete-region sv-point (point)) |
1306 |
(insert "\n"))))) |
(insert "\n"))))) |
1307 |
|
|
1308 |
;; copy string specified as BEG END from IN-BUF to OUT-BUF |
;; copy string specified as BEG END from IN-BUF to OUT-BUF |
1309 |
(defun ediff-copy-to-buffer (beg end in-buffer out-buffer) |
(defun ediff-copy-to-buffer (beg end in-buffer out-buffer) |
1310 |
(with-current-buffer out-buffer |
(with-current-buffer out-buffer |