diff lisp/diff.el @ 1110:f165d900e06e

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Sun, 13 Sep 1992 06:01:19 +0000
parents 48ca3bf4b5f8
children 1dba066c1e0a
line wrap: on
line diff
--- a/lisp/diff.el	Sun Sep 13 04:35:22 1992 +0000
+++ b/lisp/diff.el	Sun Sep 13 06:01:19 1992 +0000
@@ -166,21 +166,48 @@
   (message "Comparing files %s %s..." new old)
   (setq new (expand-file-name new)
 	old (expand-file-name old))
-  (let ((buf (compile-internal (mapconcat 'identity
-					  (append '("diff")
-						  (if (consp diff-switches)
-						      diff-switches
-						    (list diff-switches))
-						  (list old)
-						  (list new))
-					  " ")
-			       "No more differences" "Diff"
-			       'diff-parse-differences)))
-    (save-excursion
-      (set-buffer buf)
-      (set (make-local-variable 'diff-old-file) old)
-      (set (make-local-variable 'diff-new-file) new))
-    buf))
+  (let ((old-alt (diff-prepare old new))
+	(new-alt (diff-prepare new old))
+	buf)
+    (unwind-protect
+	(let ((command
+	       (mapconcat 'identity
+			  (append '("diff")
+				  (if (consp diff-switches)
+				      diff-switches
+				    (list diff-switches))
+				  (if (or old-alt new-alt)
+				      (list "-L" old "-L" new))
+				  (list (or old-alt old))
+				  (list (or new-alt new)))
+			  " ")))
+	  (setq buf
+		(compile-internal command
+				  "No more differences" "Diff"
+				  'diff-parse-differences)))
+	  (save-excursion
+	    (set-buffer buf)
+	    (set (make-local-variable 'diff-old-file) old)
+	    (set (make-local-variable 'diff-new-file) new))
+	  buf)
+      (if old-alt (delete-file old-alt))
+      (if new-alt (delete-file new-alt)))))
+
+;; Copy the file FILE into a temporary file if that is necessary
+;; for comparison.  (This is only necessary if the file name has a handler.)
+;; OTHER is the other file to be compared.
+(defun diff-prepare (file other)
+  (let (handler handlers)
+    (setq handlers file-name-handler-alist)
+    (while (and (consp handlers) (null handler))
+      (if (and (consp (car handlers))
+	       (stringp (car (car handlers)))
+	       (string-match (car (car handlers)) file))
+	  (setq handler (cdr (car handlers))))
+      (setq handlers (cdr handlers)))
+    (if handler
+	(funcall handler 'diff-prepare file other)
+      nil)))
 
 ;;;###autoload
 (defun diff-backup (file &optional switches)