Sync with Tramp 2.2.6-pre.
[bpt/emacs.git] / lisp / net / tramp-compat.el
index 9984195..c3552ae 100644 (file)
@@ -29,8 +29,6 @@
 
 ;;; Code:
 
-(require 'tramp-loaddefs)
-
 (eval-when-compile
 
   ;; Pacify byte-compiler.
 
 (eval-and-compile
 
+  ;; Some packages must be required for XEmacs, because we compile
+  ;; with -no-autoloads.
+  (when (featurep 'xemacs)
+    (require 'cus-edit)
+    (require 'env)
+    (require 'executable)
+    (require 'outline)
+    (require 'passwd)
+    (require 'pp)
+    (require 'regexp-opt))
+
   (require 'advice)
   (require 'custom)
   (require 'format-spec)
   (require 'shell)
 
+  (require 'tramp-loaddefs)
+
   ;; As long as password.el is not part of (X)Emacs, it shouldn't be
   ;; mandatory.
   (if (featurep 'xemacs)
@@ -61,7 +72,8 @@
     (require 'timer))
 
   ;; We check whether `start-file-process' is bound.
-  (unless (fboundp 'start-file-process)
+  ;; Note: we deactivate this.  There are problems, at least in SXEmacs.
+  (unless t;(fboundp 'start-file-process)
 
     ;; tramp-util offers integration into other (X)Emacs packages like
     ;; compile.el, gud.el etc.  Not necessary in Emacs 23.
     (defalias 'file-remote-p
       (lambda (file &optional identification connected)
        (when (tramp-tramp-file-p file)
-         (tramp-file-name-handler
+         (tramp-compat-funcall
+          'tramp-file-name-handler
           'file-remote-p file identification connected)))))
 
   ;; `process-file' does not exist in XEmacs.
     (defalias 'set-file-times
       (lambda (filename &optional time)
        (when (tramp-tramp-file-p filename)
-         (tramp-file-name-handler
-          'set-file-times filename time)))))
+         (tramp-compat-funcall
+          'tramp-file-name-handler 'set-file-times filename time)))))
 
   ;; We currently use "[" and "]" in the filename format for IPv6
   ;; hosts of GNU Emacs.  This means that Emacs wants to expand
 For Emacs, this is the variable `temporary-file-directory', for XEmacs
 this is the function `temp-directory'."
   (let (file-name-handler-alist)
+    ;; We must return a local directory.  If it is remote, we could
+    ;; run into an infloop.
     (cond
-     ;; We must return a local directory.  If it is remote, we could
-     ;; run into an infloop.
-     ((boundp 'temporary-file-directory)
-      (eval (car (get 'temporary-file-directory 'standard-value))))
+     ((and (boundp 'temporary-file-directory)
+          (eval (car (get 'temporary-file-directory 'standard-value)))))
      ((fboundp 'temp-directory) (tramp-compat-funcall 'temp-directory))
      ((let ((d (getenv "TEMP"))) (and d (file-directory-p d)))
       (file-name-as-directory (getenv "TEMP")))
@@ -302,7 +315,8 @@ Not actually used.  Use `(format \"%o\" i)' instead?"
    ((or (null id-format) (eq id-format 'integer))
     (file-attributes filename))
    ((tramp-tramp-file-p filename)
-    (tramp-file-name-handler 'file-attributes filename id-format))
+    (tramp-compat-funcall
+     'tramp-file-name-handler 'file-attributes filename id-format))
    (t (condition-case nil
          (tramp-compat-funcall 'file-attributes filename id-format)
        (wrong-number-of-arguments (file-attributes filename))))))