comparison lisp/ediff.el @ 20206:f44ff2c52fac

new version
author Michael Kifer <kifer@cs.stonybrook.edu>
date Sat, 01 Nov 1997 01:46:51 +0000
parents 9bc6a4017c8c
children f7e788ea680b
comparison
equal deleted inserted replaced
20205:cdaddfc03fe8 20206:f44ff2c52fac
4 4
5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu> 5 ;; Author: Michael Kifer <kifer@cs.sunysb.edu>
6 ;; Created: February 2, 1994 6 ;; Created: February 2, 1994
7 ;; Keywords: comparing, merging, patching, version control. 7 ;; Keywords: comparing, merging, patching, version control.
8 8
9 (defconst ediff-version "2.671" "The current version of Ediff") 9 (defconst ediff-version "2.69" "The current version of Ediff")
10 (defconst ediff-date "September 23, 1997" "Date of last update") 10 (defconst ediff-date "October 10, 1997" "Date of last update")
11 11
12 12
13 ;; This file is part of GNU Emacs. 13 ;; This file is part of GNU Emacs.
14 14
15 ;; GNU Emacs is free software; you can redistribute it and/or modify 15 ;; GNU Emacs is free software; you can redistribute it and/or modify
312 (symbol-value hooks-var)))) 312 (symbol-value hooks-var))))
313 (t ;; plain file---just check that the file matches the buffer 313 (t ;; plain file---just check that the file matches the buffer
314 (ediff-verify-file-buffer)))) 314 (ediff-verify-file-buffer))))
315 (set file-var file))) 315 (set file-var file)))
316 316
317 (defun ediff-files-internal (file-A file-B file-C startup-hooks job-name) 317 ;; MERGE-BUFFER-FILE is the file to be associated with the merge buffer
318 (defun ediff-files-internal (file-A file-B file-C startup-hooks job-name
319 &optional merge-buffer-file)
318 (let (buf-A buf-B buf-C) 320 (let (buf-A buf-B buf-C)
319 (message "Reading file %s ... " file-A) 321 (message "Reading file %s ... " file-A)
320 ;;(sit-for 0) 322 ;;(sit-for 0)
321 (ediff-find-file 'file-A 'buf-A 'ediff-last-dir-A 'startup-hooks) 323 (ediff-find-file 'file-A 'buf-A 'ediff-last-dir-A 'startup-hooks)
322 (message "Reading file %s ... " file-B) 324 (message "Reading file %s ... " file-B)
333 'startup-hooks))) 335 'startup-hooks)))
334 (ediff-setup buf-A file-A 336 (ediff-setup buf-A file-A
335 buf-B file-B 337 buf-B file-B
336 buf-C file-C 338 buf-C file-C
337 startup-hooks 339 startup-hooks
338 (list (cons 'ediff-job-name job-name))))) 340 (list (cons 'ediff-job-name job-name))
341 merge-buffer-file)))
339 342
340 343
341 ;;;###autoload 344 ;;;###autoload
342 (defalias 'ediff 'ediff-files) 345 (defalias 'ediff 'ediff-files)
343 346
392 ;;;###autoload 395 ;;;###autoload
393 (defalias 'ebuffers3 'ediff-buffers3) 396 (defalias 'ebuffers3 'ediff-buffers3)
394 397
395 398
396 399
397 (defun ediff-buffers-internal (buf-A buf-B buf-C startup-hooks job-name) 400 ;; MERGE-BUFFER-FILE is the file to be associated with the merge buffer
401 (defun ediff-buffers-internal (buf-A buf-B buf-C startup-hooks job-name
402 &optional merge-buffer-file)
398 (let* ((buf-A-file-name (buffer-file-name (get-buffer buf-A))) 403 (let* ((buf-A-file-name (buffer-file-name (get-buffer buf-A)))
399 (buf-B-file-name (buffer-file-name (get-buffer buf-B))) 404 (buf-B-file-name (buffer-file-name (get-buffer buf-B)))
400 (buf-C-is-alive (ediff-buffer-live-p buf-C)) 405 (buf-C-is-alive (ediff-buffer-live-p buf-C))
401 (buf-C-file-name (if buf-C-is-alive 406 (buf-C-file-name (if buf-C-is-alive
402 (buffer-file-name (get-buffer buf-B)))) 407 (buffer-file-name (get-buffer buf-B))))
430 (delete-file (, file-B)) 435 (delete-file (, file-B))
431 (if (stringp (, file-C)) (delete-file (, file-C))) 436 (if (stringp (, file-C)) (delete-file (, file-C)))
432 )) 437 ))
433 startup-hooks) 438 startup-hooks)
434 (list (cons 'ediff-job-name job-name)) 439 (list (cons 'ediff-job-name job-name))
435 ))) 440 merge-buffer-file)))
436 441
437 442
438 ;;; Directory and file group operations 443 ;;; Directory and file group operations
439 444
440 ;; Get appropriate default name for directory: 445 ;; Get appropriate default name for directory:
936 startup-hooks) 941 startup-hooks)
937 (append 942 (append
938 (list (cons 'ediff-word-mode word-mode) 943 (list (cons 'ediff-word-mode word-mode)
939 (cons 'ediff-narrow-bounds (list overl-A overl-B)) 944 (cons 'ediff-narrow-bounds (list overl-A overl-B))
940 (cons 'ediff-job-name job-name)) 945 (cons 'ediff-job-name job-name))
941 setup-parameters) 946 setup-parameters))
942 )
943 )) 947 ))
944 948
945 949
946 ;;; Merge files and buffers 950 ;;; Merge files and buffers
947 951
952 (ediff-do-merge 0) 956 (ediff-do-merge 0)
953 (ediff-with-current-buffer ediff-buffer-C 957 (ediff-with-current-buffer ediff-buffer-C
954 (set-buffer-modified-p nil))) 958 (set-buffer-modified-p nil)))
955 959
956 ;;;###autoload 960 ;;;###autoload
957 (defun ediff-merge-files (file-A file-B &optional startup-hooks) 961 (defun ediff-merge-files (file-A file-B
962 ;; MERGE-BUFFER-FILE is the file to be
963 ;; associated with the merge buffer
964 &optional startup-hooks merge-buffer-file)
958 "Merge two files without ancestor." 965 "Merge two files without ancestor."
959 (interactive 966 (interactive
960 (let ((dir-A (if ediff-use-last-dir 967 (let ((dir-A (if ediff-use-last-dir
961 ediff-last-dir-A 968 ediff-last-dir-A
962 default-directory)) 969 default-directory))
984 (expand-file-name 991 (expand-file-name
985 (file-name-nondirectory file-A) file-B) 992 (file-name-nondirectory file-A) file-B)
986 file-B) 993 file-B)
987 nil ; file-C 994 nil ; file-C
988 startup-hooks 995 startup-hooks
989 'ediff-merge-files)) 996 'ediff-merge-files
997 merge-buffer-file))
990 998
991 ;;;###autoload 999 ;;;###autoload
992 (defun ediff-merge-files-with-ancestor (file-A file-B file-ancestor 1000 (defun ediff-merge-files-with-ancestor (file-A file-B file-ancestor
993 &optional startup-hooks) 1001 &optional
1002 startup-hooks
1003 ;; MERGE-BUFFER-FILE is the file
1004 ;; to be associated with the
1005 ;; merge buffer
1006 merge-buffer-file)
994 "Merge two files with ancestor." 1007 "Merge two files with ancestor."
995 (interactive 1008 (interactive
996 (let ((dir-A (if ediff-use-last-dir 1009 (let ((dir-A (if ediff-use-last-dir
997 ediff-last-dir-A 1010 ediff-last-dir-A
998 default-directory)) 1011 default-directory))
1034 (expand-file-name 1047 (expand-file-name
1035 (file-name-nondirectory file-A) file-B) 1048 (file-name-nondirectory file-A) file-B)
1036 file-B) 1049 file-B)
1037 file-ancestor 1050 file-ancestor
1038 startup-hooks 1051 startup-hooks
1039 'ediff-merge-files-with-ancestor)) 1052 'ediff-merge-files-with-ancestor
1053 merge-buffer-file))
1040 1054
1041 ;;;###autoload 1055 ;;;###autoload
1042 (defalias 'ediff-merge-with-ancestor 'ediff-merge-files-with-ancestor) 1056 (defalias 'ediff-merge-with-ancestor 'ediff-merge-files-with-ancestor)
1043 1057
1044 ;;;###autoload 1058 ;;;###autoload
1045 (defun ediff-merge-buffers (buffer-A buffer-B &optional startup-hooks job-name) 1059 (defun ediff-merge-buffers (buffer-A buffer-B
1060 &optional
1061 ;; MERGE-BUFFER-FILE is the file to be
1062 ;; associated with the merge buffer
1063 startup-hooks job-name merge-buffer-file)
1046 "Merge buffers without ancestor." 1064 "Merge buffers without ancestor."
1047 (interactive 1065 (interactive
1048 (let (bf) 1066 (let (bf)
1049 (list (setq bf (read-buffer "Buffer A to merge: " 1067 (list (setq bf (read-buffer "Buffer A to merge: "
1050 (ediff-other-buffer "") t)) 1068 (ediff-other-buffer "") t))
1057 t)))) 1075 t))))
1058 1076
1059 (setq startup-hooks (cons 'ediff-merge-on-startup startup-hooks)) 1077 (setq startup-hooks (cons 'ediff-merge-on-startup startup-hooks))
1060 (or job-name (setq job-name 'ediff-merge-buffers)) 1078 (or job-name (setq job-name 'ediff-merge-buffers))
1061 (ediff-buffers-internal 1079 (ediff-buffers-internal
1062 buffer-A buffer-B nil startup-hooks job-name)) 1080 buffer-A buffer-B nil startup-hooks job-name merge-buffer-file))
1063 1081
1064 ;;;###autoload 1082 ;;;###autoload
1065 (defun ediff-merge-buffers-with-ancestor (buffer-A 1083 (defun ediff-merge-buffers-with-ancestor (buffer-A buffer-B buffer-ancestor
1066 buffer-B buffer-ancestor 1084 &optional
1067 &optional startup-hooks job-name) 1085 startup-hooks
1086 job-name
1087 ;; MERGE-BUFFER-FILE is the
1088 ;; file to be associated
1089 ;; with the merge buffer
1090 merge-buffer-file)
1068 "Merge buffers with ancestor." 1091 "Merge buffers with ancestor."
1069 (interactive 1092 (interactive
1070 (let (bf bff) 1093 (let (bf bff)
1071 (list (setq bf (read-buffer "Buffer A to merge: " 1094 (list (setq bf (read-buffer "Buffer A to merge: "
1072 (ediff-other-buffer "") t)) 1095 (ediff-other-buffer "") t))
1087 ))) 1110 )))
1088 1111
1089 (setq startup-hooks (cons 'ediff-merge-on-startup startup-hooks)) 1112 (setq startup-hooks (cons 'ediff-merge-on-startup startup-hooks))
1090 (or job-name (setq job-name 'ediff-merge-buffers-with-ancestor)) 1113 (or job-name (setq job-name 'ediff-merge-buffers-with-ancestor))
1091 (ediff-buffers-internal 1114 (ediff-buffers-internal
1092 buffer-A buffer-B buffer-ancestor startup-hooks job-name)) 1115 buffer-A buffer-B buffer-ancestor startup-hooks job-name merge-buffer-file))
1093 1116
1094 1117
1095 ;;;###autoload 1118 ;;;###autoload
1096 (defun ediff-merge-revisions (&optional file startup-hooks) 1119 (defun ediff-merge-revisions (&optional file startup-hooks merge-buffer-file)
1120 ;; MERGE-BUFFER-FILE is the file to be associated with the merge buffer
1097 "Run Ediff by merging two revisions of a file. 1121 "Run Ediff by merging two revisions of a file.
1098 The file is the optional FILE argument or the file visited by the current 1122 The file is the optional FILE argument or the file visited by the current
1099 buffer." 1123 buffer."
1100 (interactive) 1124 (interactive)
1101 (if (stringp file) (find-file file)) 1125 (if (stringp file) (find-file file))
1114 (file-name-nondirectory file) "current buffer")))) 1138 (file-name-nondirectory file) "current buffer"))))
1115 (ediff-load-version-control) 1139 (ediff-load-version-control)
1116 ;; ancestor-revision=nil 1140 ;; ancestor-revision=nil
1117 (funcall 1141 (funcall
1118 (intern (format "ediff-%S-merge-internal" ediff-version-control-package)) 1142 (intern (format "ediff-%S-merge-internal" ediff-version-control-package))
1119 rev1 rev2 nil startup-hooks))) 1143 rev1 rev2 nil startup-hooks merge-buffer-file)))
1120 1144
1121 1145
1122 ;;;###autoload 1146 ;;;###autoload
1123 (defun ediff-merge-revisions-with-ancestor (&optional file startup-hooks) 1147 (defun ediff-merge-revisions-with-ancestor (&optional
1148 file startup-hooks
1149 ;; MERGE-BUFFER-FILE is the file to
1150 ;; be associated with the merge
1151 ;; buffer
1152 merge-buffer-file)
1124 "Run Ediff by merging two revisions of a file with a common ancestor. 1153 "Run Ediff by merging two revisions of a file with a common ancestor.
1125 The file is the the optional FILE argument or the file visited by the current 1154 The file is the the optional FILE argument or the file visited by the current
1126 buffer." 1155 buffer."
1127 (interactive) 1156 (interactive)
1128 (if (stringp file) (find-file file)) 1157 (if (stringp file) (find-file file))
1146 (if (stringp file) 1175 (if (stringp file)
1147 (file-name-nondirectory file) "current buffer")))) 1176 (file-name-nondirectory file) "current buffer"))))
1148 (ediff-load-version-control) 1177 (ediff-load-version-control)
1149 (funcall 1178 (funcall
1150 (intern (format "ediff-%S-merge-internal" ediff-version-control-package)) 1179 (intern (format "ediff-%S-merge-internal" ediff-version-control-package))
1151 rev1 rev2 ancestor-rev startup-hooks))) 1180 rev1 rev2 ancestor-rev startup-hooks merge-buffer-file)))
1152 1181
1153 ;;;###autoload 1182 ;;;###autoload
1154 (defun run-ediff-from-cvs-buffer (pos) 1183 (defun run-ediff-from-cvs-buffer (pos)
1155 "Run Ediff-merge on appropriate revisions of the selected file. 1184 "Run Ediff-merge on appropriate revisions of the selected file.
1156 First run after `M-x cvs-update'. Then place the cursor on a line describing a 1185 First run after `M-x cvs-update'. Then place the cursor on a line describing a