]> code.delx.au - gnu-emacs/blobdiff - lisp/net/tramp-ftp.el
* net/tramp.el (tramp-default-user-alist): Do not add "ssh" based
[gnu-emacs] / lisp / net / tramp-ftp.el
index 894fef4a43b03da9f84a786122edcca5bcf0445f..a0db0199412e5b288a87e78e7a886992c8b3af98 100644 (file)
@@ -1,17 +1,18 @@
 ;;; tramp-ftp.el --- Tramp convenience functions for Ange-FTP
 
-;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007,
-;;   2008 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+;;   2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: Michael Albinus <michael.albinus@gmx.de>
 ;; Keywords: comm, processes
+;; Package: tramp
 
 ;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,8 +20,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, see
-;; <http://www.gnu.org/licenses/>.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
@@ -30,7 +30,6 @@
 ;;; Code:
 
 (require 'tramp)
-(autoload 'tramp-set-connection-property "tramp-cache")
 
 (eval-when-compile
 
@@ -99,19 +98,20 @@ present for backward compatibility."
 (add-hook 'tramp-ftp-unload-hook 'tramp-ftp-enable-ange-ftp)
 
 ;; Define FTP method ...
-(defcustom tramp-ftp-method "ftp"
-  "*When this method name is used, forward all calls to Ange-FTP."
-  :group 'tramp
-  :type 'string)
+;;;###tramp-autoload
+(defconst tramp-ftp-method "ftp"
+  "*When this method name is used, forward all calls to Ange-FTP.")
 
 ;; ... and add it to the method list.
-(add-to-list 'tramp-methods (cons tramp-ftp-method nil))
+;;;###tramp-autoload
+(unless (featurep 'xemacs)
+  (add-to-list 'tramp-methods (cons tramp-ftp-method nil)))
 
-;; Add some defaults for `tramp-default-method-alist'
+;; Add some defaults for `tramp-default-method-alist'.
 (add-to-list 'tramp-default-method-alist
-            (list "\\`ftp\\." "" tramp-ftp-method))
+            (list "\\`ftp\\." nil tramp-ftp-method))
 (add-to-list 'tramp-default-method-alist
-            (list "" "\\`\\(anonymous\\|ftp\\)\\'" tramp-ftp-method))
+            (list nil "\\`\\(anonymous\\|ftp\\)\\'" tramp-ftp-method))
 
 ;; Add completion function for FTP method.
 (tramp-set-completion-function
@@ -121,14 +121,22 @@ present for backward compatibility."
 ;; If there is URL syntax, `substitute-in-file-name' needs special
 ;; handling.
 (put 'substitute-in-file-name 'ange-ftp 'tramp-handle-substitute-in-file-name)
-
+(add-hook 'tramp-ftp-unload-hook
+         '(lambda ()
+            (setplist 'substitute-in-file-name
+                      (delete 'ange-ftp
+                              (delete 'tramp-handle-substitute-in-file-name
+                                      (symbol-plist
+                                       'substitute-in-file-name))))))
+
+;;;###tramp-autoload
 (defun tramp-ftp-file-name-handler (operation &rest args)
   "Invoke the Ange-FTP handler for OPERATION.
 First arg specifies the OPERATION, second arg is a list of arguments to
 pass to the OPERATION."
   (save-match-data
     (or (boundp 'ange-ftp-name-format)
-       (require 'ange-ftp))
+       (let (file-name-handler-alist) (require 'ange-ftp)))
     (let ((ange-ftp-name-format
           (list (nth 0 tramp-file-name-structure)
                 (nth 3 tramp-file-name-structure)
@@ -179,7 +187,12 @@ pass to the OPERATION."
            (ignore-errors (delete-file tmpfile)))))
 
        ;; Normally, the handlers must be discarded.
-       (t (let* ((inhibit-file-name-handlers
+       ;; `inhibit-file-name-handlers' isn't sufficient, because the
+       ;; local file name could be in Tramp syntax as well (for
+       ;; example, returning VMS file names like "/DISK$CAM:/AAA").
+       ;; That's why we set also `tramp-mode' to nil.
+       (t (let* (;(tramp-mode nil)
+                (inhibit-file-name-handlers
                  (list 'tramp-file-name-handler
                        'tramp-completion-file-name-handler
                        (and (eq inhibit-file-name-operation operation)
@@ -187,23 +200,25 @@ pass to the OPERATION."
                 (inhibit-file-name-operation operation))
            (apply 'ange-ftp-hook-function operation args)))))))
 
-(defun tramp-ftp-file-name-p (filename)
+;;;###tramp-autoload
+(defsubst tramp-ftp-file-name-p (filename)
   "Check if it's a filename that should be forwarded to Ange-FTP."
   (let ((v (tramp-dissect-file-name filename)))
     (string= (tramp-file-name-method v) tramp-ftp-method)))
 
-(add-to-list 'tramp-foreign-file-name-handler-alist
-            (cons 'tramp-ftp-file-name-p 'tramp-ftp-file-name-handler))
+;;;###tramp-autoload
+(unless (featurep 'xemacs)
+  (add-to-list 'tramp-foreign-file-name-handler-alist
+              (cons 'tramp-ftp-file-name-p 'tramp-ftp-file-name-handler)))
+
+(add-hook 'tramp-unload-hook
+         (lambda ()
+           (unload-feature 'tramp-ftp 'force)))
 
 (provide 'tramp-ftp)
 
 ;;; TODO:
 
-;; * In case of "/ftp:host:file" this works only for functions which
-;;   are defined in `tramp-file-name-handler-alist'.  Call has to be
-;;   pretended in `tramp-file-name-handler' otherwise.
-;;   Furthermore, there are no backup files on FTP hosts.
-;;   Worth further investigations.
+;; * There are no backup files on FTP hosts.
 
-;; arch-tag: 759fb338-5c63-4b99-bd36-b4d59db91cff
 ;;; tramp-ftp.el ends here