aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kifer1997-09-06 04:16:05 +0000
committerMichael Kifer1997-09-06 04:16:05 +0000
commitbd698e987e71743196eb0b317e8df3d39da228d9 (patch)
tree384fc23f1f1313eded01883014cac7a05c69ddea
parenta18ed1290d36e933724c5e789328195f4f9c2aff (diff)
downloademacs-bd698e987e71743196eb0b317e8df3d39da228d9.tar.gz
emacs-bd698e987e71743196eb0b317e8df3d39da228d9.zip
new version
-rw-r--r--lisp/ediff-diff.el14
-rw-r--r--lisp/ediff-mult.el77
-rw-r--r--lisp/ediff-ptch.el187
-rw-r--r--lisp/ediff-util.el42
-rw-r--r--lisp/ediff.el9
5 files changed, 200 insertions, 129 deletions
diff --git a/lisp/ediff-diff.el b/lisp/ediff-diff.el
index 6a9bc8d51f8..fffd99a96ef 100644
--- a/lisp/ediff-diff.el
+++ b/lisp/ediff-diff.el
@@ -68,8 +68,7 @@ to a shell that you are not using or, better, fix your shell's startup file."
68 "*Options to pass to `ediff-diff-program'. 68 "*Options to pass to `ediff-diff-program'.
69If diff\(1\) is used as `ediff-diff-program', then the most useful options are 69If diff\(1\) is used as `ediff-diff-program', then the most useful options are
70`-w', to ignore space, and `-i', to ignore case of letters. 70`-w', to ignore space, and `-i', to ignore case of letters.
71At present, the option `-c' is ignored, since Ediff doesn't understand this 71At present, the option `-c' is not allowed."
72type of output."
73 :type 'string 72 :type 'string
74 :group 'ediff-diff) 73 :group 'ediff-diff)
75 74
@@ -158,9 +157,8 @@ one optional arguments, diff-number to refine.")
158;; ediff-setup-diff-regions-function, which can also have the value 157;; ediff-setup-diff-regions-function, which can also have the value
159;; ediff-setup-diff-regions3, which takes 4 arguments. 158;; ediff-setup-diff-regions3, which takes 4 arguments.
160(defun ediff-setup-diff-regions (file-A file-B file-C) 159(defun ediff-setup-diff-regions (file-A file-B file-C)
161;;; ;; Force all minibuffers to display ediff's messages. 160 (if (string-match "c" ediff-diff-options)
162;;; ;; When xemacs implements minibufferless frames, this won't be necessary 161 (error "Option `-c' is not allowed in `ediff-diff-options'"))
163;;; (if ediff-xemacs-p (setq synchronize-minibuffers t))
164 162
165 ;; create, if it doesn't exist 163 ;; create, if it doesn't exist
166 (or (ediff-buffer-live-p ediff-diff-buffer) 164 (or (ediff-buffer-live-p ediff-diff-buffer)
@@ -210,7 +208,6 @@ one optional arguments, diff-number to refine.")
210 diff-buffer 208 diff-buffer
211 'synchronize 209 'synchronize
212 ediff-diff-options file1 file2) 210 ediff-diff-options file1 file2)
213 ;;(message "Computing differences ... done")
214 (message "") 211 (message "")
215 (ediff-with-current-buffer diff-buffer 212 (ediff-with-current-buffer diff-buffer
216 (buffer-size)))))) 213 (buffer-size))))))
@@ -1043,11 +1040,6 @@ one optional arguments, diff-number to refine.")
1043;; File-C is either the third file to compare (in case of 3-way comparison) 1040;; File-C is either the third file to compare (in case of 3-way comparison)
1044;; or it is the ancestor file. 1041;; or it is the ancestor file.
1045(defun ediff-setup-diff-regions3 (file-A file-B file-C) 1042(defun ediff-setup-diff-regions3 (file-A file-B file-C)
1046
1047;;; ;; force all minibuffers to display ediff's messages.
1048;;; ;; when xemacs implements minibufferless frames, this won't be necessary
1049;;; (if ediff-xemacs-p (setq synchronize-minibuffers t))
1050
1051 (or (ediff-buffer-live-p ediff-diff-buffer) 1043 (or (ediff-buffer-live-p ediff-diff-buffer)
1052 (setq ediff-diff-buffer 1044 (setq ediff-diff-buffer
1053 (get-buffer-create (ediff-unique-buffer-name "*ediff-diff" "*")))) 1045 (get-buffer-create (ediff-unique-buffer-name "*ediff-diff" "*"))))
diff --git a/lisp/ediff-mult.el b/lisp/ediff-mult.el
index 7fce125bc8e..223573a2a25 100644
--- a/lisp/ediff-mult.el
+++ b/lisp/ediff-mult.el
@@ -155,10 +155,15 @@ directories.")
155;; history var to use for filtering groups 155;; history var to use for filtering groups
156(defvar ediff-filtering-regexp-history nil "") 156(defvar ediff-filtering-regexp-history nil "")
157 157
158;; This has the form ((ctl-buf file1 file2) (stl-buf file1 file2) ...) 158;; This has the form ((meta-buf regexp dir1 dir2 dir3 merge-auto-store-dir)
159;; If ctl-buf is nil, the file-pair wasn't processed yet. If it is 159;; (ctl-buf session-status (file1 . eq-status) (file2 . eq-status) (file3
160;; . eq-status)) (ctl-buf session-status (file1 . eq-status) (file2
161;; . eq-status)) ...)
162;; If ctl-buf is nil, the file-pair hasn't processed yet. If it is
160;; killed-buffer object, the file pair has been processed. If it is a live 163;; killed-buffer object, the file pair has been processed. If it is a live
161;; buffer, this means ediff is still working on the pair 164;; buffer, this means ediff is still working on the pair.
165;; Eq-status of a file is t if the file equals some other file in the same
166;; group.
162(ediff-defvar-local ediff-meta-list nil "") 167(ediff-defvar-local ediff-meta-list nil "")
163 168
164 169
@@ -204,40 +209,40 @@ buffers."
204;;; API for ediff-meta-list 209;;; API for ediff-meta-list
205 210
206;; group buffer/regexp 211;; group buffer/regexp
207(defun ediff-get-group-buffer (meta-list) 212(defsubst ediff-get-group-buffer (meta-list)
208 (nth 0 (car meta-list))) 213 (nth 0 (car meta-list)))
209 214
210(defun ediff-get-group-regexp (meta-list) 215(defsubst ediff-get-group-regexp (meta-list)
211 (nth 1 (car meta-list))) 216 (nth 1 (car meta-list)))
212;; group objects 217;; group objects
213(defun ediff-get-group-objA (meta-list) 218(defsubst ediff-get-group-objA (meta-list)
214 (nth 2 (car meta-list))) 219 (nth 2 (car meta-list)))
215(defun ediff-get-group-objB (meta-list) 220(defsubst ediff-get-group-objB (meta-list)
216 (nth 3 (car meta-list))) 221 (nth 3 (car meta-list)))
217(defun ediff-get-group-objC (meta-list) 222(defsubst ediff-get-group-objC (meta-list)
218 (nth 4 (car meta-list))) 223 (nth 4 (car meta-list)))
219(defun ediff-get-group-merge-autostore-dir (meta-list) 224(defsubst ediff-get-group-merge-autostore-dir (meta-list)
220 (nth 5 (car meta-list))) 225 (nth 5 (car meta-list)))
221 226
222;; session buffer 227;; session buffer
223(defun ediff-get-session-buffer (elt) 228(defsubst ediff-get-session-buffer (elt)
224 (nth 0 elt)) 229 (nth 0 elt))
225(defun ediff-get-session-status (elt) 230(defsubst ediff-get-session-status (elt)
226 (nth 1 elt)) 231 (nth 1 elt))
227(defun ediff-set-session-status (session-info new-status) 232(defsubst ediff-set-session-status (session-info new-status)
228 (setcar (cdr session-info) new-status)) 233 (setcar (cdr session-info) new-status))
229;; session objects 234;; session objects
230(defun ediff-get-session-objA (elt) 235(defsubst ediff-get-session-objA (elt)
231 (nth 2 elt)) 236 (nth 2 elt))
232(defun ediff-get-session-objB (elt) 237(defsubst ediff-get-session-objB (elt)
233 (nth 3 elt)) 238 (nth 3 elt))
234(defun ediff-get-session-objC (elt) 239(defsubst ediff-get-session-objC (elt)
235 (nth 4 elt)) 240 (nth 4 elt))
236(defun ediff-get-session-objA-name (elt) 241(defsubst ediff-get-session-objA-name (elt)
237 (car (nth 2 elt))) 242 (car (nth 2 elt)))
238(defun ediff-get-session-objB-name (elt) 243(defsubst ediff-get-session-objB-name (elt)
239 (car (nth 3 elt))) 244 (car (nth 3 elt)))
240(defun ediff-get-session-objC-name (elt) 245(defsubst ediff-get-session-objC-name (elt)
241 (car (nth 4 elt))) 246 (car (nth 4 elt)))
242;; equality indicators 247;; equality indicators
243(defsubst ediff-get-file-eqstatus (elt) 248(defsubst ediff-get-file-eqstatus (elt)
@@ -245,6 +250,15 @@ buffers."
245(defsubst ediff-set-file-eqstatus (elt value) 250(defsubst ediff-set-file-eqstatus (elt value)
246 (setcar (cdr elt) value)) 251 (setcar (cdr elt) value))
247 252
253;; checks if the session is a meta session
254(defun ediff-meta-session-p (session-info)
255 (and (stringp (ediff-get-session-objA-name session-info))
256 (file-directory-p (ediff-get-session-objA-name session-info))
257 (stringp (ediff-get-session-objB-name session-info))
258 (file-directory-p (ediff-get-session-objB-name session-info))
259 (if (stringp (ediff-get-session-objC-name session-info))
260 (file-directory-p (ediff-get-session-objC-name session-info)) t)))
261
248;; set up the keymap in the meta buffer 262;; set up the keymap in the meta buffer
249(defun ediff-setup-meta-map() 263(defun ediff-setup-meta-map()
250 (setq ediff-meta-buffer-map (make-sparse-keymap)) 264 (setq ediff-meta-buffer-map (make-sparse-keymap))
@@ -1122,22 +1136,33 @@ Useful commands:
1122 (marksym ?*) 1136 (marksym ?*)
1123 (numMarked 0) 1137 (numMarked 0)
1124 (sessionNum 0) 1138 (sessionNum 0)
1125 elt) 1139 (diff-buffer ediff-meta-diff-buffer)
1140 session-buf elt)
1126 (while meta-list 1141 (while meta-list
1127 (setq elt (car meta-list) 1142 (setq elt (car meta-list)
1128 meta-list (cdr meta-list) 1143 meta-list (cdr meta-list)
1129 sessionNum (1+ sessionNum)) 1144 sessionNum (1+ sessionNum))
1130 (if (eq (ediff-get-session-status elt) marksym) 1145 (cond ((eq (ediff-get-session-status elt) marksym)
1131 (save-excursion 1146 (save-excursion
1132 (setq numMarked (1+ numMarked)) 1147 (setq numMarked (1+ numMarked))
1133 (funcall operation elt sessionNum)))) 1148 (funcall operation elt sessionNum)))
1149 ((and (ediff-meta-session-p elt)
1150 (ediff-buffer-live-p
1151 (setq session-buf (ediff-get-session-buffer elt))))
1152 (setq numMarked
1153 (+ numMarked
1154 (ediff-with-current-buffer session-buf
1155 ;; pass meta-diff along
1156 (setq ediff-meta-diff-buffer diff-buffer)
1157 ;; collect diffs in child group
1158 (ediff-operate-on-marked-sessions operation)))))))
1134 (ediff-update-meta-buffer grp-buf) ; just in case 1159 (ediff-update-meta-buffer grp-buf) ; just in case
1135 numMarked 1160 numMarked
1136 )) 1161 ))
1137 1162
1138(defun ediff-append-custom-diff (session sessionNum) 1163(defun ediff-append-custom-diff (session sessionNum)
1139 (or (ediff-collect-diffs-metajob) 1164 (or (ediff-collect-diffs-metajob)
1140 (error "Sorry, I don't do this for everyone...")) 1165 (error "Hmm, I'd hate to do it to you ..."))
1141 (let ((session-buf (ediff-get-session-buffer session)) 1166 (let ((session-buf (ediff-get-session-buffer session))
1142 (meta-diff-buff ediff-meta-diff-buffer) 1167 (meta-diff-buff ediff-meta-diff-buffer)
1143 (metajob ediff-metajob-name) 1168 (metajob ediff-metajob-name)
@@ -1256,9 +1281,7 @@ all marked sessions must be active."
1256 ;; First handle sessions involving directories (which are themselves 1281 ;; First handle sessions involving directories (which are themselves
1257 ;; session groups) 1282 ;; session groups)
1258 ;; After that handle individual sessions 1283 ;; After that handle individual sessions
1259 (cond ((and (file-directory-p file1) 1284 (cond ((ediff-meta-session-p info)
1260 (stringp file2) (file-directory-p file2)
1261 (if (stringp file3) (file-directory-p file1) t))
1262 ;; do ediff/ediff-merge on subdirectories 1285 ;; do ediff/ediff-merge on subdirectories
1263 (if (ediff-buffer-live-p session-buf) 1286 (if (ediff-buffer-live-p session-buf)
1264 (ediff-show-meta-buffer session-buf) 1287 (ediff-show-meta-buffer session-buf)
diff --git a/lisp/ediff-ptch.el b/lisp/ediff-ptch.el
index 901e6053986..dc6330492eb 100644
--- a/lisp/ediff-ptch.el
+++ b/lisp/ediff-ptch.el
@@ -81,18 +81,26 @@ See also `ediff-backup-specs'."
81 :type 'string 81 :type 'string
82 :group 'ediff-ptch) 82 :group 'ediff-ptch)
83 83
84(defun ediff-test-patch-utility ()
85 (cond ((zerop (call-process ediff-patch-program nil nil nil "-z." "-b"))
86 ;; GNU `patch' v. >= 2.2
87 'gnu)
88 ((zerop (call-process ediff-patch-program nil nil nil "-b"))
89 'posix)
90 (t 'traditional)))
91
84(defcustom ediff-backup-specs 92(defcustom ediff-backup-specs
85 (cond 93 (let ((type (ediff-test-patch-utility)))
86 ((zerop (call-process ediff-patch-program nil nil nil "-z." "-b")) 94 (cond ((eq type 'gnu)
87 ;; GNU `patch' v. >= 2.2 95 ;; GNU `patch' v. >= 2.2
88 (format "-z%s -b" ediff-backup-extension)) 96 (format "-z%s -b" ediff-backup-extension))
89 ((zerop (call-process ediff-patch-program nil nil nil "-b")) 97 ((eq type 'posix)
90 ;; POSIX `patch' -- ediff-backup-extension must be ".orig" 98 ;; POSIX `patch' -- ediff-backup-extension must be ".orig"
91 (setq ediff-backup-extension ediff-default-backup-extension) 99 (setq ediff-backup-extension ediff-default-backup-extension)
92 "-b") 100 "-b")
93 (t 101 (t
94 ;; traditional `patch' 102 ;; traditional `patch'
95 (format "-b %s" ediff-backup-extension))) 103 (format "-b %s" ediff-backup-extension))))
96 "*Backup directives to pass to the patch program. 104 "*Backup directives to pass to the patch program.
97Ediff requires that the old version of the file \(before applying the patch\) 105Ediff requires that the old version of the file \(before applying the patch\)
98be saved in a file named `the-patch-file.extension'. Usually `extension' is 106be saved in a file named `the-patch-file.extension'. Usually `extension' is
@@ -107,7 +115,11 @@ versions of GNU patch require `-b -z backup-extension'.
107Note that both `ediff-backup-extension' and `ediff-backup-specs' 115Note that both `ediff-backup-extension' and `ediff-backup-specs'
108must be set properly. If your patch program takes the option `-b', 116must be set properly. If your patch program takes the option `-b',
109but not `-b extension', the variable `ediff-backup-extension' must 117but not `-b extension', the variable `ediff-backup-extension' must
110still be set so Ediff will know which extension to use." 118still be set so Ediff will know which extension to use.
119
120Ediff tries to guess the appropriate value for this variables. It is believed
121to be working for `traditional' patch, all versions of GNU patch, and for POSIX
122patch. So, don't change these variables, unless the default doesn't work."
111 :type 'string 123 :type 'string
112 :group 'ediff-ptch) 124 :group 'ediff-ptch)
113 125
@@ -278,10 +290,8 @@ program."
278 (princ 290 (princ
279 (format " 291 (format "
280The patch file contains a context diff for 292The patch file contains a context diff for
281
282 %s 293 %s
283 %s 294 %s
284
285However, Ediff cannot infer the name of the actual file 295However, Ediff cannot infer the name of the actual file
286to be patched on your system. If you know the correct file name, 296to be patched on your system. If you know the correct file name,
287please enter it now. 297please enter it now.
@@ -336,7 +346,7 @@ other files, enter /dev/null
336Ediff has inferred that 346Ediff has inferred that
337 %s 347 %s
338 %s 348 %s
339are possible targets for applying the patch. 349are two possible targets for applying the patch.
340Both files seem to be plausible alternatives. 350Both files seem to be plausible alternatives.
341 351
342Please advice: 352Please advice:
@@ -351,17 +361,19 @@ Please advice:
351 (f1-exists (setcar triple file1)) 361 (f1-exists (setcar triple file1))
352 (t 362 (t
353 (with-output-to-temp-buffer ediff-msg-buffer 363 (with-output-to-temp-buffer ediff-msg-buffer
354 (princ (format " 364 (princ "\nEdiff has inferred that")
355Ediff inferred that 365 (if (string= file1 file2)
366 (princ (format "
356 %s 367 %s
368is the target for this patch. However, this file does not exist."
369 file1))
370 (princ (format "
357 %s 371 %s
358are possible alternative targets for this patch. 372 %s
359 373are two possible targets for this patch. However, these files do not exist."
360However, these files do not exist. 374 file1 file2)))
361 375 (princ "
362Please enter an alternative patch target ... 376\nPlease enter an alternative patch target ...\n"))
363"
364 file1 file2)))
365 (let ((directory t) 377 (let ((directory t)
366 target) 378 target)
367 (while directory 379 (while directory
@@ -392,12 +404,21 @@ Else, read patch file into a new buffer."
392 (ediff-use-last-dir ediff-last-dir-patch) 404 (ediff-use-last-dir ediff-last-dir-patch)
393 (t default-directory))) 405 (t default-directory)))
394 patch-buf) 406 patch-buf)
395 (if (y-or-n-p "Is the patch already in a buffer? ") 407 (if (let ((last-nonmenu-event t) ; Emacs: don't use dialog box
408 last-command-event) ; XEmacs: don't use dialog box
409 (y-or-n-p "Is the patch already in a buffer? "))
396 (setq patch-buf 410 (setq patch-buf
397 (get-buffer 411 (get-buffer
398 (read-buffer 412 (read-buffer
399 "Which buffer contains the patch? " 413 "Which buffer contains the patch? "
400 (current-buffer) 'must-match))) 414 (ediff-other-buffer
415 (if (eq (next-window (selected-window)) (selected-window))
416 ;; only one window in frame --- don't skip current buff
417 ""
418 ;; >1 window --- skip current buff, assuming this is the one
419 ;; to patch, not the one that has the patch
420 (current-buffer)))
421 'must-match)))
401 (setq patch-buf 422 (setq patch-buf
402 (find-file-noselect 423 (find-file-noselect
403 (read-file-name "Which file contains the patch? " 424 (read-file-name "Which file contains the patch? "
@@ -433,56 +454,71 @@ Else, read patch file into a new buffer."
433 )) 454 ))
434 455
435 456
436(defun ediff-patch-buffer-internal (patch-buf buf-to-patch-name 457;; When patching a buffer, never change the orig file. Instead, create a new
437 &optional startup-hooks) 458;; buffer, ***_patched, even if the buff visits a file.
459;; Users who want to actually patch the buffer should use
460;; ediff-patch-file, not ediff-patch-buffer.
461(defun ediff-patch-buffer-internal (patch-buf
462 buf-to-patch-name
463 &optional startup-hooks)
438 (let* ((buf-to-patch (get-buffer buf-to-patch-name)) 464 (let* ((buf-to-patch (get-buffer buf-to-patch-name))
439 (file-name-ok (if buf-to-patch (buffer-file-name buf-to-patch))) 465 (visited-file (if buf-to-patch (buffer-file-name buf-to-patch)))
440 (buf-mod-status (buffer-modified-p buf-to-patch)) 466 (buf-mod-status (buffer-modified-p buf-to-patch))
441 (multifile-patch-p (> (length (ediff-with-current-buffer patch-buf 467 (multifile-patch-p (> (length (ediff-with-current-buffer patch-buf
442 ediff-patch-map)) 1)) 468 ediff-patch-map)) 1))
443 default-dir file-name ctl-buf) 469 default-dir file-name ctl-buf)
444 (if file-name-ok 470 (if multifile-patch-p
445 (setq file-name file-name-ok) 471 (error
446 (if multifile-patch-p 472 "Can't apply multi-file patches to buffers that visit no files"))
447 (error 473
448 "Can't apply multi-file patches to buffers that visit no files")) 474 ;; create a temp file to patch
449 (ediff-with-current-buffer buf-to-patch 475 (ediff-with-current-buffer buf-to-patch
450 (setq default-dir default-directory) 476 (setq default-dir default-directory)
451 (setq file-name (ediff-make-temp-file buf-to-patch)) 477 (setq file-name (ediff-make-temp-file buf-to-patch))
452 (set-visited-file-name file-name) 478 ;; temporarily switch visited file name, if any
453 (setq buffer-auto-save-file-name nil) ; don't create auto-save file 479 (set-visited-file-name file-name)
454 ;;don't confuse the user with a new bufname 480 ;; don't create auto-save file, if buff was visiting a file
455 (rename-buffer buf-to-patch-name) 481 (or visited-file
456 (set-buffer-modified-p nil) 482 (setq buffer-auto-save-file-name nil))
457 (set-visited-file-modtime) ; sync buffer and temp file 483 ;; don't confuse the user with a new bufname
458 (setq default-directory default-dir) 484 (rename-buffer buf-to-patch-name)
459 )) 485 (set-buffer-modified-p nil)
460 486 (set-visited-file-modtime) ; sync buffer and temp file
487 (setq default-directory default-dir)
488 )
489
461 ;; dispatch a patch function 490 ;; dispatch a patch function
462 (setq ctl-buf (ediff-dispatch-file-patching-job 491 (setq ctl-buf (ediff-dispatch-file-patching-job
463 patch-buf file-name startup-hooks)) 492 patch-buf file-name startup-hooks))
464 493
465 (if file-name-ok 494 (ediff-with-current-buffer ctl-buf
466 () 495 (delete-file (buffer-file-name ediff-buffer-A))
467 ;; buffer wasn't visiting any file, 496 (delete-file (buffer-file-name ediff-buffer-B))
468 ;; so we will not run meta-level ediff here 497 (ediff-with-current-buffer ediff-buffer-A
469 (ediff-with-current-buffer ctl-buf 498 (if default-dir (setq default-directory default-dir))
470 (delete-file (buffer-file-name ediff-buffer-A)) 499 (set-visited-file-name visited-file) ; visited-file might be nil
471 (delete-file (buffer-file-name ediff-buffer-B)) 500 (rename-buffer buf-to-patch-name)
472 (ediff-with-current-buffer ediff-buffer-A 501 (set-buffer-modified-p buf-mod-status))
473 (if default-dir (setq default-directory default-dir)) 502 (ediff-with-current-buffer ediff-buffer-B
474 (set-visited-file-name nil) 503 (setq buffer-auto-save-file-name nil) ; don't create auto-save file
475 (rename-buffer buf-to-patch-name) 504 (if default-dir (setq default-directory default-dir))
476 (set-buffer-modified-p buf-mod-status)) 505 (set-visited-file-name nil)
477 (ediff-with-current-buffer ediff-buffer-B 506 (rename-buffer (ediff-unique-buffer-name
478 (setq buffer-auto-save-file-name nil) ; don't create auto-save file 507 (concat buf-to-patch-name "_patched") ""))
479 (if default-dir (setq default-directory default-dir)) 508 (set-buffer-modified-p t)))
480 (set-visited-file-name nil)
481 (rename-buffer (ediff-unique-buffer-name
482 (concat buf-to-patch-name "_patched") ""))
483 (set-buffer-modified-p t))))
484 )) 509 ))
485 510
511
512;; Traditional patch has weird return codes.
513;; GNU and Posix return 1 if some hanks failed and 2 in case of trouble.
514;; 0 is a good code in all cases.
515;; We'll do the concervative thing.
516(defun ediff-patch-return-code-ok (code)
517 (eq code 0))
518;;; (if (eq (ediff-test-patch-utility) 'traditional)
519;;; (eq code 0)
520;;; (not (eq code 2))))
521
486(defun ediff-patch-file-internal (patch-buf source-filename 522(defun ediff-patch-file-internal (patch-buf source-filename
487 &optional startup-hooks) 523 &optional startup-hooks)
488 (setq source-filename (expand-file-name source-filename)) 524 (setq source-filename (expand-file-name source-filename))
@@ -498,7 +534,7 @@ Else, read patch file into a new buffer."
498 target-buf buf-to-patch file-name-magic-p 534 target-buf buf-to-patch file-name-magic-p
499 patch-return-code ctl-buf backup-style aux-wind) 535 patch-return-code ctl-buf backup-style aux-wind)
500 536
501 (if (string-match "-V" ediff-patch-options) 537 (if (string-match "V" ediff-patch-options)
502 (error 538 (error
503 "Ediff doesn't take the -V option in `ediff-patch-options'--sorry")) 539 "Ediff doesn't take the -V option in `ediff-patch-options'--sorry"))
504 540
@@ -550,26 +586,29 @@ Else, read patch file into a new buffer."
550 (switch-to-buffer patch-diagnostics) 586 (switch-to-buffer patch-diagnostics)
551 (sit-for 0) ; synchronize - let the user see diagnostics 587 (sit-for 0) ; synchronize - let the user see diagnostics
552 588
553 (or (and (eq patch-return-code 0) ; patch reported success 589 (or (and (ediff-patch-return-code-ok patch-return-code)
554 (file-exists-p 590 (file-exists-p
555 (concat true-source-filename ediff-backup-extension))) 591 (concat true-source-filename ediff-backup-extension)))
556 (progn 592 (progn
557 (with-output-to-temp-buffer ediff-msg-buffer 593 (with-output-to-temp-buffer ediff-msg-buffer
558 (princ (format 594 (princ (format
559 "Patch program has failed due to a bad patch file OR 595 "Patch program has failed due to a bad patch file,
560because it couldn't create the backup for the file to be patched. 596it couldn't apply all hunks, OR
597it couldn't create the backup for the file being patched.
561 598
562The former could be caused by a corrupt patch file or because the %S 599The former could be caused by a corrupt patch file or because the %S
563program doesn't understand the format of the patch file in use. 600program doesn't understand the format of the patch file in use.
564 601
565The second problem might be due to an incompatibility among these settings: 602The second problem might be due to an incompatibility among these settings:
566 ediff-patch-program = %S 603 ediff-patch-program = %S ediff-patch-options = %S
567 ediff-patch-options = %S 604 ediff-backup-extension = %S ediff-backup-specs = %S
568 ediff-backup-extension = %S
569 ediff-backup-specs = %S
570 605
571See Ediff on-line manual for more details on these variables. 606See Ediff on-line manual for more details on these variables.
572In particular, check the documentation for `ediff-backup-specs'. " 607In particular, check the documentation for `ediff-backup-specs'.
608
609In any of the above cases, Ediff doesn't compare files automatically.
610However, if the patch was applied partially and the backup file was created,
611you can still examine the changes via M-x ediff-files"
573 ediff-patch-program 612 ediff-patch-program
574 ediff-patch-program 613 ediff-patch-program
575 ediff-patch-options 614 ediff-patch-options
diff --git a/lisp/ediff-util.el b/lisp/ediff-util.el
index 0d0cf25a903..0d11f7b33cb 100644
--- a/lisp/ediff-util.el
+++ b/lisp/ediff-util.el
@@ -145,10 +145,11 @@ to invocation.")
145 145
146 (define-key ediff-mode-map "p" 'ediff-previous-difference) 146 (define-key ediff-mode-map "p" 'ediff-previous-difference)
147 (define-key ediff-mode-map "\C-?" 'ediff-previous-difference) 147 (define-key ediff-mode-map "\C-?" 'ediff-previous-difference)
148 (define-key ediff-mode-map [backspace] 'ediff-previous-difference)
149 (define-key ediff-mode-map [delete] 'ediff-previous-difference) 148 (define-key ediff-mode-map [delete] 'ediff-previous-difference)
150 (define-key ediff-mode-map "\C-h" (if ediff-no-emacs-help-in-control-buffer 149 (define-key ediff-mode-map "\C-h" (if ediff-no-emacs-help-in-control-buffer
151 'ediff-previous-difference nil)) 150 'ediff-previous-difference nil))
151 ;; must come after C-h, or else C-h wipes out backspace's binding in XEmacs
152 (define-key ediff-mode-map [backspace] 'ediff-previous-difference)
152 (define-key ediff-mode-map "n" 'ediff-next-difference) 153 (define-key ediff-mode-map "n" 'ediff-next-difference)
153 (define-key ediff-mode-map " " 'ediff-next-difference) 154 (define-key ediff-mode-map " " 'ediff-next-difference)
154 (define-key ediff-mode-map "j" 'ediff-jump-to-difference) 155 (define-key ediff-mode-map "j" 'ediff-jump-to-difference)
@@ -687,10 +688,6 @@ if necessary."
687Reestablish the default three-window display." 688Reestablish the default three-window display."
688 (interactive) 689 (interactive)
689 (ediff-barf-if-not-control-buffer) 690 (ediff-barf-if-not-control-buffer)
690
691;; ;; No longer needed: XEmacs has surrogate minibuffers now.
692;; (if ediff-xemacs-p (setq synchronize-minibuffers t))
693
694 (let (buffer-read-only) 691 (let (buffer-read-only)
695 (if (and (ediff-buffer-live-p ediff-buffer-A) 692 (if (and (ediff-buffer-live-p ediff-buffer-A)
696 (ediff-buffer-live-p ediff-buffer-B) 693 (ediff-buffer-live-p ediff-buffer-B)
@@ -2918,6 +2915,15 @@ Hit \\[ediff-recenter] to reset the windows afterward."
2918 (error "Buffer out of sync for file %s" buffer-file-name)))) 2915 (error "Buffer out of sync for file %s" buffer-file-name))))
2919 2916
2920 2917
2918(defun ediff-file-compressed-p (file)
2919 (require 'jka-compr)
2920 (string-match (jka-compr-build-file-regexp) file))
2921
2922(defun ediff-filename-magic-p (file)
2923 (or (ediff-file-compressed-p file)
2924 (ediff-file-remote-p file)))
2925
2926
2921(defun ediff-save-buffer (arg) 2927(defun ediff-save-buffer (arg)
2922 "Safe way of saving buffers A, B, C, and the diff output. 2928 "Safe way of saving buffers A, B, C, and the diff output.
2923`wa' saves buffer A, `wb' saves buffer B, `wc' saves buffer C, 2929`wa' saves buffer A, `wb' saves buffer B, `wc' saves buffer C,
@@ -3314,17 +3320,23 @@ Ediff Control Panel to restore highlighting."
3314;; other insignificant buffers (those beginning with "^[ *]"). 3320;; other insignificant buffers (those beginning with "^[ *]").
3315;; Gets one arg--buffer name or a list of buffer names (it won't return 3321;; Gets one arg--buffer name or a list of buffer names (it won't return
3316;; these buffers). 3322;; these buffers).
3317(defun ediff-other-buffer (buff) 3323(defun ediff-other-buffer (buff-lst)
3318 (if (not (listp buff)) (setq buff (list buff))) 3324 (or (listp buff-lst) (setq buff-lst (list buff-lst)))
3319 (let* ((frame-buffers (buffer-list)) 3325 (let* ((frame-buffers (buffer-list))
3326 (buff-name-list
3327 (mapcar
3328 (function (lambda (b)
3329 (cond ((stringp b) b)
3330 ((bufferp b) (buffer-name b)))))
3331 buff-lst))
3320 (significant-buffers 3332 (significant-buffers
3321 (mapcar 3333 (mapcar
3322 (function (lambda (x) 3334 (function (lambda (x)
3323 (cond ((member (buffer-name x) buff) 3335 (cond ((member (buffer-name x) buff-name-list) nil)
3324 nil) 3336 ((not (ediff-get-visible-buffer-window x)) nil)
3325 ((not (ediff-get-visible-buffer-window x)) 3337 ((string-match "^[ *]" (buffer-name x)) nil)
3326 nil) 3338 ((memq (ediff-with-current-buffer x major-mode)
3327 ((string-match "^ " (buffer-name x)) 3339 '(dired-mode))
3328 nil) 3340 nil)
3329 (t x)))) 3341 (t x))))
3330 frame-buffers)) 3342 frame-buffers))
@@ -3338,8 +3350,12 @@ Ediff Control Panel to restore highlighting."
3338 (mapcar 3350 (mapcar
3339 (function 3351 (function
3340 (lambda (x) 3352 (lambda (x)
3341 (cond ((member (buffer-name x) buff) nil) 3353 (cond ((member (buffer-name x) buff-name-list) nil)
3342 ((string-match "^[ *]" (buffer-name x)) nil) 3354 ((string-match "^[ *]" (buffer-name x)) nil)
3355 ((memq
3356 (ediff-with-current-buffer x major-mode)
3357 '(dired-mode))
3358 nil)
3343 (t x)))) 3359 (t x))))
3344 frame-buffers))) 3360 frame-buffers)))
3345 (car less-significant-buffers)) 3361 (car less-significant-buffers))
diff --git a/lisp/ediff.el b/lisp/ediff.el
index ea7d747a70a..2cbbc90164b 100644
--- a/lisp/ediff.el
+++ b/lisp/ediff.el
@@ -7,7 +7,7 @@
7;; Keywords: comparing, merging, patching, version control. 7;; Keywords: comparing, merging, patching, version control.
8 8
9(defconst ediff-version "2.67" "The current version of Ediff") 9(defconst ediff-version "2.67" "The current version of Ediff")
10(defconst ediff-date "August 7, 1997" "Date of last update") 10(defconst ediff-date "September 3, 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.
@@ -275,7 +275,7 @@
275;; deleted. 275;; deleted.
276(defun ediff-find-file (file-var buffer-name &optional last-dir hooks-var) 276(defun ediff-find-file (file-var buffer-name &optional last-dir hooks-var)
277 (let* ((file (symbol-value file-var)) 277 (let* ((file (symbol-value file-var))
278 (file-magic (find-file-name-handler file 'find-file-noselect)) 278 (file-magic (ediff-filename-magic-p file))
279 (temp-file-name-prefix (file-name-nondirectory file))) 279 (temp-file-name-prefix (file-name-nondirectory file)))
280 (cond ((not (file-readable-p file)) 280 (cond ((not (file-readable-p file))
281 (error "File `%s' does not exist or is not readable" file)) 281 (error "File `%s' does not exist or is not readable" file))
@@ -1182,7 +1182,8 @@ file and then run `run-ediff-from-cvs-buffer'."
1182 (t default-directory))) 1182 (t default-directory)))
1183 (setq source-file 1183 (setq source-file
1184 ;; the default is the directory, not the visited file name 1184 ;; the default is the directory, not the visited file name
1185 (ediff-read-file-name "Which file to patch? " source-dir source-dir)) 1185 (ediff-read-file-name
1186 "Which file to patch? " source-dir (ediff-get-default-file-name)))
1186 (ediff-dispatch-file-patching-job patch-buf source-file))) 1187 (ediff-dispatch-file-patching-job patch-buf source-file)))
1187 1188
1188;;;###autoload 1189;;;###autoload
@@ -1196,7 +1197,7 @@ file and then run `run-ediff-from-cvs-buffer'."
1196 patch-buf 1197 patch-buf
1197 (read-buffer "Which buffer to patch? " 1198 (read-buffer "Which buffer to patch? "
1198 (cond ((eq patch-buf (current-buffer)) 1199 (cond ((eq patch-buf (current-buffer))
1199 (window-buffer (other-window 1))) 1200 (ediff-other-buffer (current-buffer)))
1200 (t (current-buffer))) 1201 (t (current-buffer)))
1201 'must-match)))) 1202 'must-match))))
1202 1203