diff lisp/files.el @ 1134:05c961416bb5

*** empty log message ***
author Richard M. Stallman <rms@gnu.org>
date Mon, 14 Sep 1992 01:39:31 +0000
parents c9feb3e64805
children 756152bcdbc0
line wrap: on
line diff
--- a/lisp/files.el	Mon Sep 14 01:33:12 1992 +0000
+++ b/lisp/files.el	Mon Sep 14 01:39:31 1992 +0000
@@ -221,6 +221,23 @@
 This is an interface to the function `load'."
   (interactive "sLoad library: ")
   (load library))
+
+;; OTHER is the other file to be compared.
+(defun file-local-copy (file)
+  "Copy the file FILE into a temporary file on this machine.
+Returns the name of the local copy, or nil, if FILE is directly
+accessible."
+  (let (handler (handlers file-name-handler-alist))
+    (save-match-data
+     (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 'file-local-copy file)
+      nil)))
 
 (defun switch-to-buffer-other-window (buffer)
   "Select buffer BUFFER in another window."
@@ -831,12 +848,13 @@
 If the optional argument KEEP-BACKUP-VERSION is non-nil,
 we do not remove backup version numbers, only true file version numbers."
   (let (handler (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)) name))
-	  (setq handler (cdr (car handlers))))
-      (setq handlers (cdr handlers)))
+    (save-match-data
+     (while (and (consp handlers) (null handler))
+       (if (and (consp (car handlers))
+		(stringp (car (car handlers)))
+		(string-match (car (car handlers)) name))
+	   (setq handler (cdr (car handlers))))
+       (setq handlers (cdr handlers))))
     (if handler
 	(funcall handler 'file-name-sans-versions name keep-backup-version)
       (substring name 0
@@ -1430,12 +1448,13 @@
 whose name is in the variable `ls-program'.
 If WILDCARD, it also runs the shell specified by `shell-file-name'."
   (let (handler (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)))
+    (save-match-data
+     (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 'insert-directory file switches
 		 wildcard full-directory-p)