changeset 54090:e83349d94786

* ediff-util.el (ediff-compute-custom-diffs-maybe): Avoid creating temporary file for buffer already visiting one. This change makes output likely to be directly usable by patch program. Suggested by Adrian Aichner <adrian@xemacs.org>
author Michael Kifer <kifer@cs.stonybrook.edu>
date Fri, 20 Feb 2004 02:41:02 +0000
parents b49761fd2929
children 15dabc5988ff
files lisp/ChangeLog lisp/ediff-util.el
diffstat 2 files changed, 23 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Feb 20 01:14:33 2004 +0000
+++ b/lisp/ChangeLog	Fri Feb 20 02:41:02 2004 +0000
@@ -1,3 +1,10 @@
+2003-02-19  Michael Kifer  <kifer@cs.stonybrook.edu>
+
+	* ediff-util.el (ediff-compute-custom-diffs-maybe): Avoid creating
+	temporary file for buffer already visiting one.  This change makes
+	output likely to be directly usable by patch program.
+	Suggested by Adrian Aichner  <adrian@xemacs.org>
+	
 2004-02-20  Nick Roberts  <nick@nick.uklinux.net>
 
 	* gdb-ui.el (gdb-use-colon-colon-notation): Set default to nil for
--- a/lisp/ediff-util.el	Fri Feb 20 01:14:33 2004 +0000
+++ b/lisp/ediff-util.el	Fri Feb 20 02:41:02 2004 +0000
@@ -3401,29 +3401,33 @@
   (let ((buf-A-file-name (buffer-file-name ediff-buffer-A))
 	(buf-B-file-name (buffer-file-name ediff-buffer-B))
 	file-A file-B)
-    (if (stringp buf-A-file-name)
-	(setq buf-A-file-name (file-name-nondirectory buf-A-file-name)))
-    (if (stringp buf-B-file-name)
-	(setq buf-B-file-name (file-name-nondirectory buf-B-file-name)))
-    (setq file-A (ediff-make-temp-file ediff-buffer-A buf-A-file-name)
-	  file-B (ediff-make-temp-file ediff-buffer-B buf-B-file-name))
-
+    (unless (and buf-A-file-name (file-exists-p buf-A-file-name))
+      (setq file-A
+	    (ediff-make-temp-file ediff-buffer-A)))
+    (unless (and buf-B-file-name (file-exists-p buf-B-file-name))
+      (setq file-B
+	    (ediff-make-temp-file ediff-buffer-B)))
     (or (ediff-buffer-live-p ediff-custom-diff-buffer)
 	(setq ediff-custom-diff-buffer
 	      (get-buffer-create
 	       (ediff-unique-buffer-name "*ediff-custom-diff" "*"))))
     (ediff-with-current-buffer ediff-custom-diff-buffer
-      (setq buffer-read-only nil)
-      (erase-buffer))
+			       (setq buffer-read-only nil)
+			       (erase-buffer))
     (ediff-exec-process
      ediff-custom-diff-program ediff-custom-diff-buffer 'synchronize
-     ediff-custom-diff-options file-A file-B)
+     ediff-custom-diff-options
+     ;; repetition of buf-A-file-name is needed so it'll return a file
+     (or (and buf-A-file-name (file-exists-p buf-A-file-name) buf-A-file-name)
+	 file-A)
+     (or (and buf-B-file-name (file-exists-p buf-B-file-name) buf-B-file-name)
+	 file-B))
     ;; put the diff file in diff-mode, if it is available
     (if (fboundp 'diff-mode)
 	(with-current-buffer ediff-custom-diff-buffer
 	  (diff-mode)))
-    (delete-file file-A)
-    (delete-file file-B)
+    (and file-A (file-exists-p file-A) (delete-file file-A))
+    (and file-B (file-exists-p file-B) (delete-file file-B))
     ))
 
 (defun ediff-show-diff-output (arg)