changeset 46306:66cce4969490

(tramp-default-method): New default method "sm" which I guess to be good for most people. (tramp-default-method-alist): Use "ftp" method (ie, forwarding to Ange-FTP) for some user/host combinations. (tramp-file-name-structure, tramp-file-name-regexp) (tramp-make-tramp-file-format) (tramp-make-tramp-file-user-nil-format) (tramp-multi-file-name-structure) (tramp-multi-file-name-hop-structure) (tramp-make-multi-tramp-file-format): New default value which unifies the filename syntax between Tramp and Ange-FTP. The new syntax is "/method:user@host:path". Note the colon after the method. (tramp-handle-file-name-directory): Don't return "/" when completing a remote root directory (where the filename looks like "/method:user@host:/"). (tramp-handle-ange-ftp): Deleted. (tramp-disable-ange-ftp): New function, called at toplevel, deletes Ange-FTP from file-name-handler-alist.
author Kai Großjohann <kgrossjo@eu.uu.net>
date Thu, 11 Jul 2002 19:59:07 +0000
parents fed6b815dbeb
children a2d047d50fb9
files lisp/ChangeLog lisp/net/tramp.el
diffstat 2 files changed, 187 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Jul 11 17:44:22 2002 +0000
+++ b/lisp/ChangeLog	Thu Jul 11 19:59:07 2002 +0000
@@ -1,3 +1,25 @@
+2002-07-11  Kai Gro,b_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+	* net/tramp.el (tramp-default-method): New default method "sm"
+	which I guess to be good for most people.
+	(tramp-default-method-alist): Use "ftp" method (ie, forwarding to
+	Ange-FTP) for some user/host combinations.
+	(tramp-file-name-structure, tramp-file-name-regexp) 
+	(tramp-make-tramp-file-format) 
+	(tramp-make-tramp-file-user-nil-format) 
+	(tramp-multi-file-name-structure) 
+	(tramp-multi-file-name-hop-structure) 
+	(tramp-make-multi-tramp-file-format): New default value which
+	unifies the filename syntax between Tramp and Ange-FTP.  The new
+	syntax is "/method:user@host:path".  Note the colon after the
+	method.
+	(tramp-handle-file-name-directory): Don't return "/" when
+	completing a remote root directory (where the filename looks like
+	"/method:user@host:/").
+	(tramp-handle-ange-ftp): Deleted.
+	(tramp-disable-ange-ftp): New function, called at toplevel,
+	deletes Ange-FTP from file-name-handler-alist.
+
 2002-07-10  Juanma Barranquero  <lektu@terra.es>
 
 	* ido.el (ido-enter-single-matching-directory): Delete leftover comment.
--- a/lisp/net/tramp.el	Thu Jul 11 17:44:22 2002 +0000
+++ b/lisp/net/tramp.el	Thu Jul 11 19:59:07 2002 +0000
@@ -774,14 +774,24 @@
   :group 'tramp
   :type '(repeat (list string function string)))
 
-(defcustom tramp-default-method "rcp"
+(defcustom tramp-default-method "sm"
+  ;;(if (featurep 'xemacs) "sm" "ftp")
   "*Default method to use for transferring files.
 See `tramp-methods' for possibilities.
-Also see `tramp-default-method-alist'."
+Also see `tramp-default-method-alist'.
+
+Emacs uses a unified filename syntax for Tramp and Ange-FTP.
+For backward compatibility, the default value of this variable
+is \"ftp\" on Emacs.  But XEmacs uses a separate filename syntax
+for Tramp and EFS, so there the default method is \"sm\"."
   :group 'tramp
   :type 'string)
 
-(defcustom tramp-default-method-alist nil
+(defcustom tramp-default-method-alist
+  (if (featurep 'xemacs)
+      nil
+    '(("\\`ftp\\." "" "ftp")
+      ("" "\\`\\(anonymous\\|ftp\\)\\'" "ftp")))
   "*Default method to use for specific user/host pairs.
 This is an alist of items (HOST USER METHOD).  The first matching item
 specifies the method to use for a file name which does not specify a
@@ -877,12 +887,31 @@
 
 ;; File name format.
 
-(defcustom tramp-file-name-structure
+(defconst tramp-file-name-structure-unified
+  (list (concat "\\`/\\(\\([a-zA-Z0-9]+\\):\\)?" ;method
+		      "\\(\\([^:@/]+\\)@\\)?" ;user
+		      "\\([^:/]+\\):"	;host
+		      "\\(.*\\)\\'")	;path
+	      2 4 5 6)
+  "Default value for `tramp-file-name-structure' for unified remoting.
+On Emacs (not XEmacs), the Tramp and Ange-FTP packages use a unified
+filename space.  This value is used for this unified namespace.")
+
+(defconst tramp-file-name-structure-separate
   (list (concat "\\`/\\[\\(\\([a-zA-Z0-9]+\\)/\\)?" ;method
 		"\\(\\([-a-zA-Z0-9_#/:]+\\)@\\)?" ;user
 		"\\([-a-zA-Z0-9_#/:@.]+\\)\\]" ;host
 		"\\(.*\\)\\'")		;path
         2 4 5 6)
+  "Default value for `tramp-file-name-structure' for separate remoting.
+On XEmacs, the Tramp and EFS packages use a separate namespace for
+remote filenames.  This value is used in that case.  It is designed
+not to clash with the EFS filename syntax.")
+
+(defcustom tramp-file-name-structure
+  (if (featurep 'xemacs)
+      tramp-file-name-structure-separate
+    tramp-file-name-structure-unified)
   "*List of five elements (REGEXP METHOD USER HOST FILE), detailing \
 the tramp file name structure.
 
@@ -906,7 +935,24 @@
                (integer :tag "Paren pair for file name  ")))
 
 ;;;###autoload
-(defcustom tramp-file-name-regexp "\\`/\\[.*\\]"
+(defconst tramp-file-name-regexp-unified
+  "\\`/[^/:]+:"
+  "Value for `tramp-file-name-regexp' for unified remoting.
+Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and
+Tramp.  See `tramp-file-name-structure-unified' for more explanations.")
+
+;;;###autoload
+(defconst tramp-file-name-regexp-separate
+  "\\`/\\[.*\\]"
+  "Value for `tramp-file-name-regexp' for separate remoting.
+XEmacs uses a separate filename syntax for Tramp and EFS.
+See `tramp-file-name-structure-separate' for more explanations.")
+
+;;;###autoload
+(defcustom tramp-file-name-regexp
+  (if (featurep 'xemacs)
+      tramp-file-name-regexp-separate
+    tramp-file-name-regexp-unified)
   "*Regular expression matching file names handled by tramp.
 This regexp should match tramp file names but no other file names.
 \(When tramp.el is loaded, this regular expression is prepended to
@@ -924,7 +970,22 @@
   :group 'tramp
   :type 'regexp)
 
-(defcustom tramp-make-tramp-file-format "/[%m/%u@%h]%p"
+(defconst tramp-make-tramp-file-format-unified
+   "/%m:%u@%h:%p"
+   "Value for `tramp-make-tramp-file-format' for unified remoting.
+Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and Tramp.
+See `tramp-file-name-structure-unified' for more details.")
+
+(defconst tramp-make-tramp-file-format-separate
+  "/[%m/%u@%h]%p"
+  "Value for `tramp-make-tramp-file-format' for separate remoting.
+XEmacs uses a separate filename syntax for EFS and Tramp.
+See `tramp-file-name-structure-separate' for more details.")
+
+(defcustom tramp-make-tramp-file-format
+  (if (featurep 'xemacs)
+      tramp-make-tramp-file-format-separate
+    tramp-make-tramp-file-format-unified)
   "*Format string saying how to construct tramp file name.
 `%m' is replaced by the method name.
 `%u' is replaced by the user name.
@@ -936,7 +997,22 @@
   :group 'tramp
   :type 'string)
 
-(defcustom tramp-make-tramp-file-user-nil-format "/[%m/%h]%p"
+(defconst tramp-make-tramp-file-user-nil-format-unified
+  "/%m:%h:%p"
+  "Value of `tramp-make-tramp-file-user-nil-format' for unified remoting.
+Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and Tramp.
+See `tramp-file-name-structure-unified' for details.")
+
+(defconst tramp-make-tramp-file-user-nil-format-separate
+  "/[%m/%h]%p"
+  "Value of `tramp-make-tramp-file-user-nil-format' for separate remoting.
+XEmacs uses a separate filename syntax for EFS and Tramp.
+See `tramp-file-name-structure-separate' for details.")
+
+(defcustom tramp-make-tramp-file-user-nil-format
+  (if (featurep 'xemacs)
+      tramp-make-tramp-file-user-nil-format-separate
+    tramp-make-tramp-file-user-nil-format-unified)
   "*Format string saying how to construct tramp file name when the user name is not known.
 `%m' is replaced by the method name.
 `%h' is replaced by the host name.
@@ -947,7 +1023,16 @@
   :group 'tramp
   :type 'string)
 
-(defcustom tramp-multi-file-name-structure
+(defconst tramp-multi-file-name-structure-unified
+  (list (concat "\\`\\([a-zA-Z0-9]+\\)\\)?" ;method
+		"\\(\\(%s\\)+\\)"	;hops
+		":\\(.*\\)\\'")		;path
+	2 3 -1)
+  "Value for `tramp-multi-file-name-structure' for unified remoting.
+Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and Tramp.
+See `tramp-file-name-structure-unified' for details.")
+
+(defconst tramp-file-name-structure-separate
   (list (concat
          ;; prefix
          "\\`/\\[\\(\\([a-z0-9]+\\)\\)?"
@@ -958,6 +1043,14 @@
         2                               ;number of pair to match method
         3                               ;number of pair to match hops
         -1)                             ;number of pair to match path
+  "Value of `tramp-multi-file-name-structure' for separate remoting.
+XEmacs uses a separate filename syntax for EFS and Tramp.
+See `tramp-file-name-structure-separate' for details.")
+
+(defcustom tramp-multi-file-name-structure
+  (if (featurep 'xemacs)
+      tramp-multi-file-name-structure-separate
+    tramp-multi-file-name-structure-unified)
   "*Describes the file name structure of `multi' files.
 Multi files allow you to contact a remote host in several hops.
 This is a list of four elements (REGEXP METHOD HOP PATH).
@@ -985,11 +1078,28 @@
                (integer :tag "Paren pair for hops")
                (integer :tag "Paren pair to match path")))
 
-(defcustom tramp-multi-file-name-hop-structure
+(defconst tramp-multi-file-name-hop-structure-unified
+  (list (concat ":\\([a-zA-z0-9_]+\\):" ;hop method
+		"\\([^@:/]+\\)@"	;user
+		"\\([^:/]+\\)")		;host
+	1 2 3)
+  "Value of `tramp-multi-file-name-hop-structure' for unified remoting.
+Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and Tramp.
+See `tramp-file-name-structure-unified' for details.")
+
+(defconst tramp-multi-file-name-hop-structure-separate
   (list (concat "/\\([a-z0-9_]+\\):"	;hop method
 		"\\([a-z0-9_]+\\)@"	;user
 		"\\([a-z0-9.-]+\\)")	;host
         1 2 3)
+  "Value of `tramp-multi-file-name-hop-structure' for separate remoting.
+XEmacs uses a separate filename syntax for EFS and Tramp.
+See `tramp-file-name-structure-separate' for details.")
+
+(defcustom tramp-multi-file-name-hop-structure
+  (if (featurep 'xemacs)
+      tramp-multi-file-name-hop-structure-separate
+    tramp-multi-file-name-hop-structure-unified)
   "*Describes the structure of a hop in multi files.
 This is a list of four elements (REGEXP METHOD USER HOST).  First
 element REGEXP is used to match against the hop.  Pair number METHOD
@@ -1003,8 +1113,22 @@
                (integer :tag "Paren pair for user name")
                (integer :tag "Paren pair for host name")))
 
+(defconst tramp-make-multi-tramp-file-format-unified
+  (list "/%m" ":%m:%u@%h" ":%p")
+  "Value of `tramp-make-multi-tramp-file-format' for unified remoting.
+Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and Tramp.
+See `tramp-file-name-structure-unified' for details.")
+
+(defconst tramp-make-multi-tramp-file-format-separate
+  (list "/[%m" "/%m:%u@%h" "]%p")
+  "Value of `tramp-make-multi-tramp-file-format' for separate remoting.
+XEmacs uses a separate filename syntax for EFS and Tramp.
+See `tramp-file-name-structure-separate' for details.")
+
 (defcustom tramp-make-multi-tramp-file-format
-  (list "/[%m" "/%m:%u@%h" "]%p")
+  (if (featurep 'xemacs)
+      tramp-make-multi-tramp-file-format-separate
+    tramp-make-multi-tramp-file-format-unified)
   "*Describes how to construct a `multi' file name.
 This is a list of three elements PREFIX, HOP and PATH.
 
@@ -1469,7 +1593,14 @@
   (with-parsed-tramp-file-name file nil
     (when (tramp-ange-ftp-file-name-p multi-method method)
       (tramp-invoke-ange-ftp 'file-name-directory file))
-    (if (or (string= path "") (string= path "/"))
+    ;; For the following condition, two possibilities should be tried:
+    ;; (1) (string= path "")
+    ;; (2) (or (string= path "") (string= path "/"))
+    ;; The second variant fails when completing a "/" directory on
+    ;; the remote host, that is a filename which looks like
+    ;; "/user@host:/".  But maybe wildcards fail with the first variant.
+    ;; We should do some investigation.
+    (if (string= path "")
 	;; For a filename like "/[foo]", we return "/".  The `else'
 	;; case would return "/[foo]" unchanged.  But if we do that,
 	;; then `file-expand-wildcards' ceases to work.  It's not
@@ -2971,42 +3102,31 @@
 (add-to-list 'file-name-handler-alist
 	     (cons tramp-file-name-regexp 'tramp-file-name-handler))
 
-;;;###autoload
-(defun tramp-handle-ange-ftp ()
-  "Turn Ange-FTP off and an Ange-FTP-like filename format.
-Requests suitable for Ange-FTP will be forwarded to Ange-FTP.
-Also see the variables `tramp-ftp-method', `tramp-default-method',
-and `tramp-default-method-alist'."
-  (interactive)
+;; To handle EFS, the following functions need to be dealt with:
+;;
+;; * dired-before-readin-hook contains efs-dired-before-readin
+;; * file-name-handler-alist contains efs-file-handler-function
+;;   and efs-root-handler-function and efs-sifn-handler-function
+;; * find-file-hooks contains efs-set-buffer-mode
+;;
+;; But it won't happen for EFS since the XEmacs maintainers
+;; don't want to use a unified filename syntax.
+(defun tramp-disable-ange-ftp ()
+  "Turn Ange-FTP off.
+This is useful for unified remoting.  See
+`tramp-file-name-structure-unified' and
+`tramp-file-name-structure-separate' for details.  Requests suitable
+for Ange-FTP will be forwarded to Ange-FTP.  Also see the variables
+`tramp-ftp-method', `tramp-default-method', and
+`tramp-default-method-alist'.
+
+This function is not needed in Emacsen which include Tramp, but is
+present for backward compatibility."
   (let ((a1 (rassq 'ange-ftp-hook-function file-name-handler-alist))
-	(a2 (rassq 'ange-ftp-completion-hook-function file-name-handler-alist))
-	(a3 (rassq 'tramp-file-name-handler file-name-handler-alist)))
+	(a2 (rassq 'ange-ftp-completion-hook-function file-name-handler-alist)))
     (setq file-name-handler-alist
-	  (delete a1 (delete a2 (delete a3 file-name-handler-alist)))))
-  (setq tramp-file-name-structure
-	(list (concat "\\`/\\(\\([a-zA-Z0-9]+\\)#\\)?" ;method
-		      "\\(\\([^:@/]+\\)@\\)?" ;user
-		      "\\([^:/]+\\):"	;host
-		      "\\(.*\\)\\'")	;path
-	      2 4 5 6)
-	tramp-file-name-regexp "\\`/[^/:]+:"
-	tramp-make-tramp-file-format "/%m#%u@%h:%p"
-	tramp-make-tramp-file-user-nil-format "/%m#%h:%p"
-	tramp-multi-file-name-structure
-	(list (concat "\\`\\([a-zA-Z0-9]+\\)\\)?" ;method
-		      "\\(\\(%s\\)+\\)"	;hops
-		      ":\\(.*\\)\\'")	;path
-	      2 3 -1)
-	tramp-multi-file-name-hop-structure
-	(list (concat ":\\([a-zA-z0-9_]+\\):" ;hop method
-		      "\\([^@:/]+\\)@"	;user
-		      "\\([^:/]+\\)")	;host
-	      1 2 3)
-	tramp-make-multi-tramp-file-format
-	(list "/%m" ":%m:%u@%h" ":%p"))
-  (add-to-list 'file-name-handler-alist
-	       (cons tramp-file-name-regexp 'tramp-file-name-handler))
-  (tramp-repair-jka-compr))
+	  (delete a1 (delete a2 file-name-handler-alist)))))
+(tramp-disable-ange-ftp)
 
 (defun tramp-repair-jka-compr ()
   "If jka-compr is already loaded, move it to the front of