Mercurial > emacs
comparison lisp/ediff-diff.el @ 18054:0b9d9cbf3cd4
new version
author | Michael Kifer <kifer@cs.stonybrook.edu> |
---|---|
date | Sat, 31 May 1997 01:10:39 +0000 |
parents | b2fae8abc5b0 |
children | f90d40b0bff5 |
comparison
equal
deleted
inserted
replaced
18053:941f5d1a241e | 18054:0b9d9cbf3cd4 |
---|---|
1 ;;; ediff-diff.el --- diff-related utilities | 1 ;;; ediff-diff.el --- diff-related utilities |
2 | 2 |
3 ;; Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> | 5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> |
6 | 6 |
7 ;; This file is part of GNU Emacs. | 7 ;; This file is part of GNU Emacs. |
8 | 8 |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
22 ;; Boston, MA 02111-1307, USA. | 22 ;; Boston, MA 02111-1307, USA. |
23 | 23 |
24 ;;; Code: | 24 ;;; Code: |
25 | 25 |
26 (provide 'ediff-diff) | |
27 | |
28 ;; compiler pacifier | |
29 (defvar ediff-default-variant) | |
30 | |
31 (eval-when-compile | |
32 (let ((load-path (cons (expand-file-name ".") load-path))) | |
33 (or (featurep 'ediff-init) | |
34 (load "ediff-init.el" nil nil 'nosuffix)) | |
35 (or (featurep 'ediff-util) | |
36 (load "ediff-util.el" nil nil 'nosuffix)) | |
37 )) | |
38 ;; end pacifier | |
39 | |
26 (require 'ediff-init) | 40 (require 'ediff-init) |
27 | 41 |
28 | 42 (defgroup ediff-diff nil |
29 (defvar ediff-shell | 43 "Diff related utilities" |
44 :prefix "ediff-" | |
45 :group 'ediff) | |
46 | |
47 | |
48 (defcustom ediff-shell | |
30 (cond ((eq system-type 'emx) "cmd") ; OS/2 | 49 (cond ((eq system-type 'emx) "cmd") ; OS/2 |
31 ((memq system-type '(ms-dos windows-nt windows-95)) | 50 ((memq system-type '(ms-dos windows-nt windows-95)) |
32 shell-file-name) ; no standard name on MS-DOS | 51 shell-file-name) ; no standard name on MS-DOS |
33 ((memq system-type '(vax-vms axp-vms)) "*dcl*") ; VMS | 52 ((memq system-type '(vax-vms axp-vms)) "*dcl*") ; VMS |
34 (t "sh")) ; UNIX | 53 (t "sh")) ; UNIX |
35 "*The shell used to run diff and patch. If user's .profile or | 54 "*The shell used to run diff and patch. If user's .profile or |
36 .cshrc files are set up correctly, any shell will do. However, some people | 55 .cshrc files are set up correctly, any shell will do. However, some people |
37 set $prompt or other things incorrectly, which leads to undesirable output | 56 set $prompt or other things incorrectly, which leads to undesirable output |
38 messages. These may cause Ediff to fail. In such a case, set ediff-shell | 57 messages. These may cause Ediff to fail. In such a case, set ediff-shell |
39 to a shell that you are not using or, better, fix your shell's startup file.") | 58 to a shell that you are not using or, better, fix your shell's startup file." |
40 | 59 :type 'string |
41 | 60 :group 'ediff-diff) |
42 (defvar ediff-diff-program "diff" | 61 |
43 "*Program to use for generating the differential of the two files.") | 62 |
44 (defvar ediff-diff-options "" | 63 (defcustom ediff-diff-program "diff" |
64 "*Program to use for generating the differential of the two files." | |
65 :type 'string | |
66 :group 'ediff-diff) | |
67 (defcustom ediff-diff-options "" | |
45 "*Options to pass to `ediff-diff-program'. | 68 "*Options to pass to `ediff-diff-program'. |
46 If diff\(1\) is used as `ediff-diff-program', then the most useful options are | 69 If diff\(1\) is used as `ediff-diff-program', then the most useful options are |
47 `-w', to ignore space, and `-i', to ignore case of letters. | 70 `-w', to ignore space, and `-i', to ignore case of letters. |
48 At present, the option `-c' is ignored, since Ediff doesn't understand this | 71 At present, the option `-c' is ignored, since Ediff doesn't understand this |
49 type of output.") | 72 type of output." |
50 | 73 :type 'string |
51 (defvar ediff-custom-diff-program ediff-diff-program | 74 :group 'ediff-diff) |
75 | |
76 (defcustom ediff-custom-diff-program ediff-diff-program | |
52 "*Program to use for generating custom diff output for saving it in a file. | 77 "*Program to use for generating custom diff output for saving it in a file. |
53 This output is not used by Ediff internally.") | 78 This output is not used by Ediff internally." |
54 (defvar ediff-custom-diff-options "-c" | 79 :type 'string |
55 "*Options to pass to `ediff-custom-diff-program'.") | 80 :group 'ediff-diff) |
81 (defcustom ediff-custom-diff-options "-c" | |
82 "*Options to pass to `ediff-custom-diff-program'." | |
83 :type 'string | |
84 :group 'ediff-diff) | |
56 | 85 |
57 ;;; Support for diff3 | 86 ;;; Support for diff3 |
58 | 87 |
59 (defvar ediff-match-diff3-line "^====\\(.?\\)$" | 88 (defvar ediff-match-diff3-line "^====\\(.?\\)$" |
60 "Pattern to match lines produced by diff3 that describe differences.") | 89 "Pattern to match lines produced by diff3 that describe differences.") |
61 (defvar ediff-diff3-program "diff3" | 90 (defcustom ediff-diff3-program "diff3" |
62 "*Program to be used for three-way comparison. | 91 "*Program to be used for three-way comparison. |
63 Must produce output compatible with Unix's diff3 program.") | 92 Must produce output compatible with Unix's diff3 program." |
64 (defvar ediff-diff3-options "" | 93 :type 'string |
65 "*Options to pass to `ediff-diff3-program'.") | 94 :group 'ediff-diff) |
66 (defvar ediff-diff3-ok-lines-regexp | 95 (defcustom ediff-diff3-options "" |
96 "*Options to pass to `ediff-diff3-program'." | |
97 :type 'string | |
98 :group 'ediff-diff) | |
99 (defcustom ediff-diff3-ok-lines-regexp | |
67 "^\\([1-3]:\\|====\\| \\|.*Warning *:\\|.*No newline\\|.*missing newline\\|^\C-m$\\)" | 100 "^\\([1-3]:\\|====\\| \\|.*Warning *:\\|.*No newline\\|.*missing newline\\|^\C-m$\\)" |
68 "*Regexp that matches normal output lines from `ediff-diff3-program'. | 101 "*Regexp that matches normal output lines from `ediff-diff3-program'. |
69 Lines that do not match are assumed to be error messages.") | 102 Lines that do not match are assumed to be error messages." |
103 :type 'regexp | |
104 :group 'ediff-diff) | |
70 | 105 |
71 ;; keeps the status of the current diff in 3-way jobs. | 106 ;; keeps the status of the current diff in 3-way jobs. |
72 ;; the status can be =diff(A), =diff(B), or =diff(A+B) | 107 ;; the status can be =diff(A), =diff(B), or =diff(A+B) |
73 (ediff-defvar-local ediff-diff-status "" "") | 108 (ediff-defvar-local ediff-diff-status "" "") |
74 | 109 |
549 (whitespace-A (ediff-whitespace-diff-region-p n 'A)) | 584 (whitespace-A (ediff-whitespace-diff-region-p n 'A)) |
550 (whitespace-B (ediff-whitespace-diff-region-p n 'B)) | 585 (whitespace-B (ediff-whitespace-diff-region-p n 'B)) |
551 (whitespace-C (ediff-whitespace-diff-region-p n 'C)) | 586 (whitespace-C (ediff-whitespace-diff-region-p n 'C)) |
552 cumulative-fine-diff-length) | 587 cumulative-fine-diff-length) |
553 | 588 |
554 (cond ((and (eq flag 'noforce) (ediff-get-fine-diff-vector n 'A)) | 589 (cond ;; If one of the regions is empty (or 2 in 3way comparison) |
555 ;; don't compute fine diffs if diff vector exists | |
556 (if (ediff-no-fine-diffs-p n) | |
557 ;;(ediff-message-if-verbose | |
558 (message | |
559 "Only white-space differences in region %d" (1+ n)))) | |
560 ;; If one of the regions is empty (or 2 in 3way comparison) | |
561 ;; then don't refine. | 590 ;; then don't refine. |
562 ;; If the region happens to be entirely whitespace or empty then | 591 ;; If the region happens to be entirely whitespace or empty then |
563 ;; mark as such. | 592 ;; mark as such. |
564 ((> (length (delq nil (list empty-A empty-B empty-C))) 1) | 593 ((> (length (delq nil (list empty-A empty-B empty-C))) 1) |
565 (if (and (ediff-looks-like-combined-merge n) | 594 (if (and (ediff-looks-like-combined-merge n) |
584 ;; mark as space only | 613 ;; mark as space only |
585 (ediff-mark-diff-as-space-only n t) | 614 (ediff-mark-diff-as-space-only n t) |
586 ;; if some regions are white and others don't, then mark as | 615 ;; if some regions are white and others don't, then mark as |
587 ;; non-white-space-only | 616 ;; non-white-space-only |
588 (ediff-mark-diff-as-space-only n nil))) | 617 (ediff-mark-diff-as-space-only n nil))) |
618 | |
619 ;; don't compute fine diffs if diff vector exists | |
620 ((and (eq flag 'noforce) (ediff-get-fine-diff-vector n 'A)) | |
621 (if (ediff-no-fine-diffs-p n) | |
622 (message | |
623 "Only white-space differences in region %d %s" | |
624 (1+ n) | |
625 (cond ((eq (ediff-no-fine-diffs-p n) 'A) | |
626 "in buffers B & C") | |
627 ((eq (ediff-no-fine-diffs-p n) 'B) | |
628 "in buffers A & C") | |
629 ((eq (ediff-no-fine-diffs-p n) 'C) | |
630 "in buffers A & B") | |
631 (t ""))))) | |
589 ;; don't compute fine diffs for this region | 632 ;; don't compute fine diffs for this region |
590 ((eq flag 'skip) | 633 ((eq flag 'skip) |
591 (or (ediff-get-fine-diff-vector n 'A) | 634 (or (ediff-get-fine-diff-vector n 'A) |
592 (memq ediff-auto-refine '(off nix)) | 635 (memq ediff-auto-refine '(off nix)) |
593 (ediff-message-if-verbose | 636 (ediff-message-if-verbose |
664 (eq cumulative-fine-diff-length 0))) | 707 (eq cumulative-fine-diff-length 0))) |
665 (ediff-mark-diff-as-space-only n t) | 708 (ediff-mark-diff-as-space-only n t) |
666 (ediff-message-if-verbose | 709 (ediff-message-if-verbose |
667 "Only white-space differences in region %d" (1+ n))) | 710 "Only white-space differences in region %d" (1+ n))) |
668 ((eq cumulative-fine-diff-length 0) | 711 ((eq cumulative-fine-diff-length 0) |
669 (ediff-mark-diff-as-space-only n t) | |
670 (ediff-message-if-verbose | 712 (ediff-message-if-verbose |
671 "Only white-space differences in region %d %s" | 713 "Only white-space differences in region %d %s" |
672 (1+ n) | 714 (1+ n) |
673 (cond (whitespace-A "in buffers B & C") | 715 (cond (whitespace-A (ediff-mark-diff-as-space-only n 'A) |
674 (whitespace-B "in buffers A & C") | 716 "in buffers B & C") |
675 (whitespace-C "in buffers A & B")))) | 717 (whitespace-B (ediff-mark-diff-as-space-only n 'B) |
718 "in buffers A & C") | |
719 (whitespace-C (ediff-mark-diff-as-space-only n 'C) | |
720 "in buffers A & B")))) | |
676 (t | 721 (t |
677 (ediff-mark-diff-as-space-only n nil))) | 722 (ediff-mark-diff-as-space-only n nil))) |
678 ) | 723 ) |
679 ) ; end cond | 724 ) ; end cond |
680 (ediff-set-fine-diff-properties n) | 725 (ediff-set-fine-diff-properties n) |
1202 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) | 1247 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) |
1203 ;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1) | 1248 ;;; eval: (put 'ediff-eval-in-buffer 'lisp-indent-hook 1) |
1204 ;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body)) | 1249 ;;; eval: (put 'ediff-eval-in-buffer 'edebug-form-spec '(form body)) |
1205 ;;; End: | 1250 ;;; End: |
1206 | 1251 |
1207 (provide 'ediff-diff) | |
1208 | |
1209 | 1252 |
1210 ;; ediff-diff.el ends here | 1253 ;; ediff-diff.el ends here |