Mercurial > emacs
comparison lisp/ediff-diff.el @ 88155:d7ddb3e565de
sync with trunk
author | Henrik Enberg <henrik.enberg@telia.com> |
---|---|
date | Mon, 16 Jan 2006 00:03:54 +0000 |
parents | 37645a051842 |
children |
comparison
equal
deleted
inserted
replaced
88154:8ce476d3ba36 | 88155:d7ddb3e565de |
---|---|
1 ;;; ediff-diff.el --- diff-related utilities | 1 ;;; ediff-diff.el --- diff-related utilities |
2 | 2 |
3 ;; Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 01, 02 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, |
4 ;; 2002, 2003, 2004, 2005 Free Software Foundation, Inc. | |
4 | 5 |
5 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu> | 6 ;; Author: Michael Kifer <kifer@cs.stonybrook.edu> |
6 | 7 |
7 ;; This file is part of GNU Emacs. | 8 ;; This file is part of GNU Emacs. |
8 | 9 |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 ;; GNU General Public License for more details. | 18 ;; GNU General Public License for more details. |
18 | 19 |
19 ;; You should have received a copy of the GNU General Public License | 20 ;; You should have received a copy of the GNU General Public License |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the | 21 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
22 ;; Boston, MA 02111-1307, USA. | 23 ;; Boston, MA 02110-1301, USA. |
23 | 24 |
24 ;;; Commentary: | 25 ;;; Commentary: |
25 | 26 |
26 ;;; Code: | 27 ;;; Code: |
27 | 28 |
28 (provide 'ediff-diff) | 29 (provide 'ediff-diff) |
29 | 30 |
30 ;; compiler pacifier | 31 ;; compiler pacifier |
31 (defvar ediff-default-variant) | 32 (defvar ediff-default-variant) |
32 (defvar null-device) | 33 (defvar null-device) |
34 (defvar longlines-mode) | |
33 | 35 |
34 (eval-when-compile | 36 (eval-when-compile |
35 (let ((load-path (cons (expand-file-name ".") load-path))) | 37 (let ((load-path (cons (expand-file-name ".") load-path))) |
36 (or (featurep 'ediff-init) | 38 (or (featurep 'ediff-init) |
37 (load "ediff-init.el" nil nil 'nosuffix)) | 39 (load "ediff-init.el" nil nil 'nosuffix)) |
41 ;; end pacifier | 43 ;; end pacifier |
42 | 44 |
43 (require 'ediff-init) | 45 (require 'ediff-init) |
44 | 46 |
45 (defgroup ediff-diff nil | 47 (defgroup ediff-diff nil |
46 "Diff related utilities" | 48 "Diff related utilities." |
47 :prefix "ediff-" | 49 :prefix "ediff-" |
48 :group 'ediff) | 50 :group 'ediff) |
49 | 51 |
50 ;; these two must be here to prevent ediff-test-utility from barking | 52 ;; these two must be here to prevent ediff-test-utility from barking |
51 (defcustom ediff-diff-program "diff" | 53 (defcustom ediff-diff-program "diff" |
62 ;; The following functions must precede all defcustom-defined variables. | 64 ;; The following functions must precede all defcustom-defined variables. |
63 | 65 |
64 ;; The following functions needed for setting diff/diff3 options | 66 ;; The following functions needed for setting diff/diff3 options |
65 ;; test if diff supports the --binary option | 67 ;; test if diff supports the --binary option |
66 (defsubst ediff-test-utility (diff-util option &optional files) | 68 (defsubst ediff-test-utility (diff-util option &optional files) |
67 (zerop (apply 'call-process | 69 (eq 0 (apply 'call-process |
68 (append (list diff-util nil nil nil option) files)))) | 70 (append (list diff-util nil nil nil option) files)))) |
69 | 71 |
70 (defun ediff-diff-mandatory-option (diff-util) | 72 (defun ediff-diff-mandatory-option (diff-util) |
71 (let ((file (if (boundp 'null-device) null-device "/dev/null"))) | 73 (let ((file (if (boundp 'null-device) null-device "/dev/null"))) |
72 (cond ((not (memq system-type '(ms-dos windows-nt windows-95))) | 74 (cond ((not (memq system-type '(ms-dos windows-nt windows-95))) |
73 "") | 75 "") |
391 (goto-char (point-min)))) | 393 (goto-char (point-min)))) |
392 | 394 |
393 (ediff-with-current-buffer diff-buffer | 395 (ediff-with-current-buffer diff-buffer |
394 (goto-char (point-min)) | 396 (goto-char (point-min)) |
395 (while (re-search-forward ediff-match-diff-line nil t) | 397 (while (re-search-forward ediff-match-diff-line nil t) |
396 (let* ((a-begin (string-to-int (buffer-substring (match-beginning 1) | 398 (let* ((a-begin (string-to-number (buffer-substring (match-beginning 1) |
397 (match-end 1)))) | 399 (match-end 1)))) |
398 (a-end (let ((b (match-beginning 3)) | 400 (a-end (let ((b (match-beginning 3)) |
399 (e (match-end 3))) | 401 (e (match-end 3))) |
400 (if b | 402 (if b |
401 (string-to-int (buffer-substring b e)) | 403 (string-to-number (buffer-substring b e)) |
402 a-begin))) | 404 a-begin))) |
403 (diff-type (buffer-substring (match-beginning 4) (match-end 4))) | 405 (diff-type (buffer-substring (match-beginning 4) (match-end 4))) |
404 (b-begin (string-to-int (buffer-substring (match-beginning 5) | 406 (b-begin (string-to-number (buffer-substring (match-beginning 5) |
405 (match-end 5)))) | 407 (match-end 5)))) |
406 (b-end (let ((b (match-beginning 7)) | 408 (b-end (let ((b (match-beginning 7)) |
407 (e (match-end 7))) | 409 (e (match-end 7))) |
408 (if b | 410 (if b |
409 (string-to-int (buffer-substring b e)) | 411 (string-to-number (buffer-substring b e)) |
410 b-begin))) | 412 b-begin))) |
411 a-begin-pt a-end-pt b-begin-pt b-end-pt | 413 a-begin-pt a-end-pt b-begin-pt b-end-pt |
412 c-begin c-end c-begin-pt c-end-pt) | 414 c-begin c-end c-begin-pt c-end-pt) |
413 ;; fix the beginning and end numbers, because diff is somewhat | 415 ;; fix the beginning and end numbers, because diff is somewhat |
414 ;; strange about how it numbers lines | 416 ;; strange about how it numbers lines |
457 a-prev a-end | 459 a-prev a-end |
458 b-prev b-end | 460 b-prev b-end |
459 c-prev c-end) | 461 c-prev c-end) |
460 ;; else convert lines to points | 462 ;; else convert lines to points |
461 (ediff-with-current-buffer A-buffer | 463 (ediff-with-current-buffer A-buffer |
462 (forward-line (- a-begin a-prev)) | 464 (let ((longlines-mode-val |
463 (setq a-begin-pt (point)) | 465 (if (and (boundp 'longlines-mode) longlines-mode) 1 0))) |
464 (forward-line (- a-end a-begin)) | 466 ;; we must disable and then restore longlines-mode |
465 (setq a-end-pt (point) | 467 (if (eq longlines-mode-val 1) |
466 a-prev a-end)) | 468 (longlines-mode 0)) |
469 (forward-line (- a-begin a-prev)) | |
470 (setq a-begin-pt (point)) | |
471 (forward-line (- a-end a-begin)) | |
472 (setq a-end-pt (point) | |
473 a-prev a-end) | |
474 (if (eq longlines-mode-val 1) | |
475 (longlines-mode longlines-mode-val)) | |
476 )) | |
467 (ediff-with-current-buffer B-buffer | 477 (ediff-with-current-buffer B-buffer |
468 (forward-line (- b-begin b-prev)) | 478 (let ((longlines-mode-val |
469 (setq b-begin-pt (point)) | 479 (if (and (boundp 'longlines-mode) longlines-mode) 1 0))) |
470 (forward-line (- b-end b-begin)) | 480 (if (eq longlines-mode-val 1) |
471 (setq b-end-pt (point) | 481 (longlines-mode 0)) |
472 b-prev b-end)) | 482 (forward-line (- b-begin b-prev)) |
483 (setq b-begin-pt (point)) | |
484 (forward-line (- b-end b-begin)) | |
485 (setq b-end-pt (point) | |
486 b-prev b-end) | |
487 (if (eq longlines-mode-val 1) | |
488 (longlines-mode longlines-mode-val)) | |
489 )) | |
473 (if (ediff-buffer-live-p C-buffer) | 490 (if (ediff-buffer-live-p C-buffer) |
474 (ediff-with-current-buffer C-buffer | 491 (ediff-with-current-buffer C-buffer |
475 (forward-line (- c-begin c-prev)) | 492 (let ((longlines-mode-val |
476 (setq c-begin-pt (point)) | 493 (if (and (boundp 'longlines-mode) longlines-mode) 1 0))) |
477 (forward-line (- c-end c-begin)) | 494 (if (eq longlines-mode-val 1) |
478 (setq c-end-pt (point) | 495 (longlines-mode 0)) |
479 c-prev c-end))) | 496 (forward-line (- c-begin c-prev)) |
497 (setq c-begin-pt (point)) | |
498 (forward-line (- c-end c-begin)) | |
499 (setq c-end-pt (point) | |
500 c-prev c-end) | |
501 (if (eq longlines-mode-val 1) | |
502 (longlines-mode longlines-mode-val)) | |
503 ))) | |
480 (setq diff-list | 504 (setq diff-list |
481 (nconc | 505 (nconc |
482 diff-list | 506 diff-list |
483 (list | 507 (list |
484 (if (ediff-buffer-live-p C-buffer) | 508 (if (ediff-buffer-live-p C-buffer) |
532 | 556 |
533 | 557 |
534 (defun ediff-set-diff-overlays-in-one-buffer (buf-type diff-list) | 558 (defun ediff-set-diff-overlays-in-one-buffer (buf-type diff-list) |
535 (let* ((current-diff -1) | 559 (let* ((current-diff -1) |
536 (buff (ediff-get-buffer buf-type)) | 560 (buff (ediff-get-buffer buf-type)) |
561 (ctl-buf ediff-control-buffer) | |
537 ;; ediff-extract-diffs puts the type of diff-list as the first elt | 562 ;; ediff-extract-diffs puts the type of diff-list as the first elt |
538 ;; of this list. The type is either 'points or 'words | 563 ;; of this list. The type is either 'points or 'words |
539 (diff-list-type (car diff-list)) | 564 (diff-list-type (car diff-list)) |
540 (shift (ediff-overlay-start | 565 (shift (ediff-overlay-start |
541 (ediff-get-value-according-to-buffer-type | 566 (ediff-get-value-according-to-buffer-type |
578 ;; Put overlays at appropriate places in buffer | 603 ;; Put overlays at appropriate places in buffer |
579 ;; convert word numbers to points, if necessary | 604 ;; convert word numbers to points, if necessary |
580 (if (eq diff-list-type 'words) | 605 (if (eq diff-list-type 'words) |
581 (progn | 606 (progn |
582 (ediff-with-current-buffer buff (goto-char pt-saved)) | 607 (ediff-with-current-buffer buff (goto-char pt-saved)) |
583 (setq begin (ediff-goto-word (1+ begin) buff) | 608 (ediff-with-current-buffer ctl-buf |
584 end (ediff-goto-word end buff 'end)) | 609 (setq begin (ediff-goto-word (1+ begin) buff) |
610 end (ediff-goto-word end buff 'end))) | |
585 (if (> end limit) (setq end limit)) | 611 (if (> end limit) (setq end limit)) |
586 (if (> begin end) (setq begin end)) | 612 (if (> begin end) (setq begin end)) |
587 (setq pt-saved (ediff-with-current-buffer buff (point))))) | 613 (setq pt-saved (ediff-with-current-buffer buff (point))))) |
588 (setq overlay (ediff-make-bullet-proof-overlay begin end buff)) | 614 (setq overlay (ediff-make-bullet-proof-overlay begin end buff)) |
589 | 615 |
862 ;; in buffer of type BUF-TYPE | 888 ;; in buffer of type BUF-TYPE |
863 (defun ediff-set-fine-overlays-in-one-buffer (buf-type diff-list region-num) | 889 (defun ediff-set-fine-overlays-in-one-buffer (buf-type diff-list region-num) |
864 (let* ((current-diff -1) | 890 (let* ((current-diff -1) |
865 (reg-start (ediff-get-diff-posn buf-type 'beg region-num)) | 891 (reg-start (ediff-get-diff-posn buf-type 'beg region-num)) |
866 (buff (ediff-get-buffer buf-type)) | 892 (buff (ediff-get-buffer buf-type)) |
893 (ctl-buf ediff-control-buffer) | |
867 combined-merge-diff-list | 894 combined-merge-diff-list |
868 diff-overlay-list list-element | 895 diff-overlay-list list-element |
869 begin end overlay) | 896 begin end overlay) |
870 | 897 |
871 (ediff-clear-fine-differences-in-one-buffer region-num buf-type) | 898 (ediff-clear-fine-differences-in-one-buffer region-num buf-type) |
890 (t 5)))) ; buf C | 917 (t 5)))) ; buf C |
891 (if (not (or begin end)) | 918 (if (not (or begin end)) |
892 () ; skip this diff | 919 () ; skip this diff |
893 ;; Put overlays at appropriate places in buffers | 920 ;; Put overlays at appropriate places in buffers |
894 ;; convert lines to points, if necessary | 921 ;; convert lines to points, if necessary |
895 (setq begin (ediff-goto-word (1+ begin) buff) | 922 (ediff-with-current-buffer ctl-buf |
896 end (ediff-goto-word end buff 'end)) | 923 (setq begin (ediff-goto-word (1+ begin) buff) |
924 end (ediff-goto-word end buff 'end))) | |
897 (setq overlay (ediff-make-bullet-proof-overlay begin end buff)) | 925 (setq overlay (ediff-make-bullet-proof-overlay begin end buff)) |
898 ;; record all overlays for this difference region | 926 ;; record all overlays for this difference region |
899 (setq diff-overlay-list (nconc diff-overlay-list (list overlay)))) | 927 (setq diff-overlay-list (nconc diff-overlay-list (list overlay)))) |
900 | 928 |
901 (setq diff-list (cdr diff-list)) | 929 (setq diff-list (cdr diff-list)) |
928 ;; treatment depends on whether it is an "a" group or a "c" group | 956 ;; treatment depends on whether it is an "a" group or a "c" group |
929 (if (string-equal (buffer-substring (match-beginning 4) (match-end 4)) "c") | 957 (if (string-equal (buffer-substring (match-beginning 4) (match-end 4)) "c") |
930 ;; it is a "c" group | 958 ;; it is a "c" group |
931 (if (match-beginning 2) | 959 (if (match-beginning 2) |
932 ;; it has two numbers | 960 ;; it has two numbers |
933 (list (string-to-int | 961 (list (string-to-number |
934 (buffer-substring (match-beginning 1) (match-end 1))) | 962 (buffer-substring (match-beginning 1) (match-end 1))) |
935 (1+ (string-to-int | 963 (1+ (string-to-number |
936 (buffer-substring (match-beginning 3) (match-end 3))))) | 964 (buffer-substring (match-beginning 3) (match-end 3))))) |
937 ;; it has one number | 965 ;; it has one number |
938 (let ((x (string-to-int | 966 (let ((x (string-to-number |
939 (buffer-substring (match-beginning 1) (match-end 1))))) | 967 (buffer-substring (match-beginning 1) (match-end 1))))) |
940 (list x (1+ x)))) | 968 (list x (1+ x)))) |
941 ;; it is an "a" group | 969 ;; it is an "a" group |
942 (let ((x (1+ (string-to-int | 970 (let ((x (1+ (string-to-number |
943 (buffer-substring (match-beginning 1) (match-end 1)))))) | 971 (buffer-substring (match-beginning 1) (match-end 1)))))) |
944 (list x x))))) | 972 (list x x))))) |
945 | 973 |
946 | 974 |
947 ;; If WORD-MODE, construct vector of diffs using word numbers. | 975 ;; If WORD-MODE, construct vector of diffs using word numbers. |
1054 a-prev a-end | 1082 a-prev a-end |
1055 b-prev b-end | 1083 b-prev b-end |
1056 c-prev c-end) | 1084 c-prev c-end) |
1057 ;; else convert lines to points | 1085 ;; else convert lines to points |
1058 (ediff-with-current-buffer A-buffer | 1086 (ediff-with-current-buffer A-buffer |
1059 (forward-line (- a-begin a-prev)) | 1087 (let ((longlines-mode-val |
1060 (setq a-begin-pt (point)) | 1088 (if (and (boundp 'longlines-mode) longlines-mode) 1 0))) |
1061 (forward-line (- a-end a-begin)) | 1089 ;; we must disable and then restore longlines-mode |
1062 (setq a-end-pt (point) | 1090 (if (eq longlines-mode-val 1) |
1063 a-prev a-end)) | 1091 (longlines-mode 0)) |
1092 (forward-line (- a-begin a-prev)) | |
1093 (setq a-begin-pt (point)) | |
1094 (forward-line (- a-end a-begin)) | |
1095 (setq a-end-pt (point) | |
1096 a-prev a-end) | |
1097 (if (eq longlines-mode-val 1) | |
1098 (longlines-mode longlines-mode-val)) | |
1099 )) | |
1064 (ediff-with-current-buffer B-buffer | 1100 (ediff-with-current-buffer B-buffer |
1065 (forward-line (- b-begin b-prev)) | 1101 (let ((longlines-mode-val |
1066 (setq b-begin-pt (point)) | 1102 (if (and (boundp 'longlines-mode) longlines-mode) 1 0))) |
1067 (forward-line (- b-end b-begin)) | 1103 (if (eq longlines-mode-val 1) |
1068 (setq b-end-pt (point) | 1104 (longlines-mode 0)) |
1069 b-prev b-end)) | 1105 (forward-line (- b-begin b-prev)) |
1106 (setq b-begin-pt (point)) | |
1107 (forward-line (- b-end b-begin)) | |
1108 (setq b-end-pt (point) | |
1109 b-prev b-end) | |
1110 (if (eq longlines-mode-val 1) | |
1111 (longlines-mode longlines-mode-val)) | |
1112 )) | |
1070 (ediff-with-current-buffer C-buffer | 1113 (ediff-with-current-buffer C-buffer |
1071 (forward-line (- c-begin c-prev)) | 1114 (let ((longlines-mode-val |
1072 (setq c-begin-pt (point)) | 1115 (if (and (boundp 'longlines-mode) longlines-mode) 1 0))) |
1073 (forward-line (- c-end c-begin)) | 1116 (if (eq longlines-mode-val 1) |
1074 (setq c-end-pt (point) | 1117 (longlines-mode 0)) |
1075 c-prev c-end)) | 1118 (forward-line (- c-begin c-prev)) |
1119 (setq c-begin-pt (point)) | |
1120 (forward-line (- c-end c-begin)) | |
1121 (setq c-end-pt (point) | |
1122 c-prev c-end) | |
1123 (if (eq longlines-mode-val 1) | |
1124 (longlines-mode longlines-mode-val)) | |
1125 )) | |
1076 (if (ediff-buffer-live-p anc-buffer) | 1126 (if (ediff-buffer-live-p anc-buffer) |
1077 (ediff-with-current-buffer anc-buffer | 1127 (ediff-with-current-buffer anc-buffer |
1078 (forward-line (- c-or-anc-begin anc-prev)) | 1128 (let ((longlines-mode-val |
1079 (setq anc-begin-pt (point)) | 1129 (if (and (boundp 'longlines-mode) longlines-mode) 1 0))) |
1080 (forward-line (- c-or-anc-end c-or-anc-begin)) | 1130 (if (eq longlines-mode-val 1) |
1081 (setq anc-end-pt (point) | 1131 (longlines-mode 0)) |
1082 anc-prev c-or-anc-end))) | 1132 (forward-line (- c-or-anc-begin anc-prev)) |
1133 (setq anc-begin-pt (point)) | |
1134 (forward-line (- c-or-anc-end c-or-anc-begin)) | |
1135 (setq anc-end-pt (point) | |
1136 anc-prev c-or-anc-end) | |
1137 (if (eq longlines-mode-val 1) | |
1138 (longlines-mode longlines-mode-val)) | |
1139 ))) | |
1083 (setq diff-list | 1140 (setq diff-list |
1084 (nconc | 1141 (nconc |
1085 diff-list | 1142 diff-list |
1086 ;; if comparing with ancestor, then there also is a | 1143 ;; if comparing with ancestor, then there also is a |
1087 ;; state-of-difference marker | 1144 ;; state-of-difference marker |
1324 (skip-chars-forward ediff-whitespace) | 1381 (skip-chars-forward ediff-whitespace) |
1325 (ediff-with-syntax-table syntax-tbl | 1382 (ediff-with-syntax-table syntax-tbl |
1326 (while (> n 1) | 1383 (while (> n 1) |
1327 (funcall fwd-word-fun) | 1384 (funcall fwd-word-fun) |
1328 (skip-chars-forward ediff-whitespace) | 1385 (skip-chars-forward ediff-whitespace) |
1329 (setq n (1- n)))) | 1386 (setq n (1- n))) |
1330 (if (and flag (> n 0)) | 1387 (if (and flag (> n 0)) |
1331 (funcall fwd-word-fun)) | 1388 (funcall fwd-word-fun))) |
1332 (point)))) | 1389 (point)))) |
1333 | 1390 |
1334 (defun ediff-same-file-contents (f1 f2) | 1391 (defun ediff-same-file-contents (f1 f2) |
1335 "Return t if F1 and F2 have identical contents." | 1392 "Return t if files F1 and F2 have identical contents." |
1336 (let ((res | 1393 (if (and (not (file-directory-p f1)) |
1337 (apply 'call-process ediff-cmp-program nil nil nil | 1394 (not (file-directory-p f2))) |
1338 (append ediff-cmp-options (list f1 f2))))) | 1395 (let ((res |
1339 (and (numberp res) (eq res 0)))) | 1396 (apply 'call-process ediff-cmp-program nil nil nil |
1397 (append ediff-cmp-options (list f1 f2))))) | |
1398 (and (numberp res) (eq res 0)))) | |
1399 ) | |
1400 | |
1401 | |
1402 (defun ediff-same-contents (d1 d2 &optional filter-re) | |
1403 "Returns t iff D1 and D2 have the same content. | |
1404 D1 and D2 can either be both directories or both regular files. | |
1405 Symlinks and the likes are not handled. | |
1406 If FILTER-RE is non-nil, recursive checking in directories | |
1407 affects only files whose names match the expression." | |
1408 ;; Normalize empty filter RE to nil. | |
1409 (unless (> (length filter-re) 0) (setq filter-re nil)) | |
1410 ;; Indicate progress | |
1411 (message "Comparing '%s' and '%s' modulo '%s'" d1 d2 filter-re) | |
1412 (cond | |
1413 ;; D1 & D2 directories => recurse | |
1414 ((and (file-directory-p d1) | |
1415 (file-directory-p d2)) | |
1416 (if (null ediff-recurse-to-subdirectories) | |
1417 (if (y-or-n-p "Compare subdirectories recursively? ") | |
1418 (setq ediff-recurse-to-subdirectories 'yes) | |
1419 (setq ediff-recurse-to-subdirectories 'no))) | |
1420 (if (eq ediff-recurse-to-subdirectories 'yes) | |
1421 (let* ((all-entries-1 (directory-files d1 t filter-re)) | |
1422 (all-entries-2 (directory-files d2 t filter-re)) | |
1423 (entries-1 (ediff-delete-all-matches "^\\.\\.?$" all-entries-1)) | |
1424 (entries-2 (ediff-delete-all-matches "^\\.\\.?$" all-entries-2)) | |
1425 ) | |
1426 | |
1427 (ediff-same-file-contents-lists entries-1 entries-2 filter-re) | |
1428 )) | |
1429 ) ; end of the directories case | |
1430 ;; D1 & D2 are both files => compare directly | |
1431 ((and (file-regular-p d1) | |
1432 (file-regular-p d2)) | |
1433 (ediff-same-file-contents d1 d2)) | |
1434 ;; Otherwise => false: unequal contents | |
1435 ) | |
1436 ) | |
1437 | |
1438 ;; If lists have the same length and names of files are pairwise equal | |
1439 ;; (removing the directories) then compare contents pairwise. | |
1440 ;; True if all contents are the same; false otherwise | |
1441 (defun ediff-same-file-contents-lists (entries-1 entries-2 filter-re) | |
1442 ;; First, check only the names (works quickly and ensures a | |
1443 ;; precondition for subsequent code) | |
1444 (if (and (= (length entries-1) (length entries-2)) | |
1445 (equal (mapcar 'file-name-nondirectory entries-1) | |
1446 (mapcar 'file-name-nondirectory entries-2))) | |
1447 ;; With name equality established, compare the entries | |
1448 ;; through recursion. | |
1449 (let ((continue t)) | |
1450 (while (and entries-1 continue) | |
1451 (if (ediff-same-contents | |
1452 (car entries-1) (car entries-2) filter-re) | |
1453 (setq entries-1 (cdr entries-1) | |
1454 entries-2 (cdr entries-2)) | |
1455 (setq continue nil)) | |
1456 ) | |
1457 ;; if reached the end then lists are equal | |
1458 (null entries-1)) | |
1459 ) | |
1460 ) | |
1461 | |
1462 | |
1463 ;; ARG1 is a regexp, ARG2 is a list of full-filenames | |
1464 ;; Delete all entries that match the regexp | |
1465 (defun ediff-delete-all-matches (regex file-list-list) | |
1466 (let (result elt) | |
1467 (while file-list-list | |
1468 (setq elt (car file-list-list)) | |
1469 (or (string-match regex (file-name-nondirectory elt)) | |
1470 (setq result (cons elt result))) | |
1471 (setq file-list-list (cdr file-list-list))) | |
1472 (reverse result))) | |
1340 | 1473 |
1341 | 1474 |
1342 ;;; Local Variables: | 1475 ;;; Local Variables: |
1343 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) | 1476 ;;; eval: (put 'ediff-defvar-local 'lisp-indent-hook 'defun) |
1344 ;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1) | 1477 ;;; eval: (put 'ediff-with-current-buffer 'lisp-indent-hook 1) |
1345 ;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body)) | 1478 ;;; eval: (put 'ediff-with-current-buffer 'edebug-form-spec '(form body)) |
1346 ;;; End: | 1479 ;;; End: |
1347 | 1480 |
1348 | 1481 ;;; arch-tag: a86d448e-58d7-4572-a1d9-fdedfa22f648 |
1349 ;;; ediff-diff.el ends here | 1482 ;;; ediff-diff.el ends here |