changeset 47576:b31c8ab7336a

Sync with version 2.0.20. Lengthy ChangeLog follows: 2002-09-22 Kai Gro?ohann <grossjoh@ls6.informatik.uni-dortmund.de> Version 2.0.20 released. 2002-09-20 Kai Gro?ohann <grossjoh@ls6.informatik.uni-dortmund.de> * net/tramp.el (tramp-completion-function-alist): Escape open paren in docstring. (tramp-user-regexp, tramp-host-regexp): Allow empty strings. (tramp-handle-insert-file-contents): Call tramp-message-for-buffer instead of tramp-message. (tramp-open-connection-rsh): Handle empty string as user name. (tramp-open-connection-su): Handle empty string as host name. Handle nil user name. (tramp-handle-file-local-copy, tramp-handle-write-region) (tramp-completion-handle-file-name-all-completions) (tramp-open-connection-telnet, tramp-open-connection-rsh) (tramp-open-connection-su, tramp-post-connection) (tramp-maybe-open-connection, tramp-method-out-of-band-p) (tramp-get-connection-function, tramp-get-remote-sh) (tramp-get-rsh-program, tramp-get-rsh-args) (tramp-get-rcp-program, tramp-get-rcp-args) (tramp-get-rcp-keep-date-arg, tramp-get-su-program) (tramp-get-su-args, tramp-get-telnet-program) (tramp-get-telnet-args): Use `tramp-find-method', perhaps require additional args USER, HOST. (tramp-action-password, tramp-open-connection-telnet) (tramp-open-connection-su, tramp-open-connection-multi) (tramp-method-out-of-band-p): `tramp-method-out-of-band-p' now takes USER and HOST arguments, to be able to use `tramp-find-method'. Update callers. (tramp-find-method): New function. 2002-09-20 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-handle-insert-directory): Handle "--dired" in SWITCHES (by removing it). 2002-09-18 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-file-name-handler): Add `file-remote-p' property. 2002-09-17 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (top-level): Maybe autoload uudecode-decode-region. 2002-09-16 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-bug): Add tramp-methods. 2002-09-16 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-methods): Update docstring: tramp-encoding-command, tramp-decoding-command, tramp-encoding-function and tramp-decoding-function are not parameters anymore. (tramp-uuencode-region): Autoload it. 2002-09-13 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> Version 2.0.19 released. * net/tramp-uu.el: New file, implements uuencode in Lisp. * net/tramp.el (tramp-coding-commands): Use `tramp-uuencode-region' as local encoder for the uuencode based entries. 2002-09-13 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-handle-write-region): Wrong parens. 2002-09-13 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> Version 2.0.18 released. * net/tramp.el (tramp-perl-decode): Perl changes to accomodate older versions of Perl. Now tested with 5.004. Suggestion from Michael Albinus. 2002-09-12 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-find-inline-encoding): Call tramp-call-local-coding-command with nil for INPUT and OUTPUT. (tramp-call-local-coding-command): OUTPUT equals nil means to discard the output. INPUT equals nil means /dev/null. 2002-09-12 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-encoding-shell): Default to environment variable COMSPEC on Windows. (tramp-handle-write-region): More debugging output. (tramp-find-inline-encoding): Ditto. 2002-09-11 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-completion-handle-file-name-all-completions): Define `result1'. (tramp-parse-hosts-group): Discard IPv6 entries. 2002-09-11 Kai Gro?ohann <grossjoh@ls6.informatik.uni-dortmund.de> * net/tramp.el (tramp-post-connection): Only send Perl mime-encode/decode implementations when using inline method. (tramp-handle-file-local-copy) (tramp-handle-write-region, tramp-post-connection) (tramp-coding-commands, tramp-find-inline-encoding): For the inline encodings, distinguish between local and remote commands, instead of between commands and functions. (The local commands can be functions, too.) If the local host is a Windows machine, we can't expect the same commands to work there as on the remote host. (tramp-call-local-coding-command): New function for calling local encoding and decoding commands. (tramp-set-remote-encoding, tramp-get-remote-encoding) (tramp-set-remote-decoding, tramp-get-remote-decoding) (tramp-set-local-encoding, tramp-get-local-encoding) (tramp-set-local-decoding, tramp-get-local-decoding): New functions. (tramp-get-encoding-command, tramp-set-encoding-command) (tramp-get-decoding-command, tramp-set-decoding-command) (tramp-get-encoding-function, tramp-set-encoding-function) (tramp-get-decoding-function, tramp-set-decoding-function): Old functions, removed. 2002-09-10 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-open-connection-setup-interactive-shell): Change command to invoke /bin/sh slightly to make it compatible with the `rc' shell. Suggested by Daniel Pittman. 2002-09-10 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-handle-write-region): Added missing `)'. Hope it's the right place. 2002-09-09 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-open-connection-setup-interactive-shell): Do "exec env PS1='$ ' /bin/sh" instead of just "exec /bin/sh" in order to get a sane shell prompt. If people have ${CWD}, say, in their shell prompt, then the default login shell might display something harmless, but the /bin/sh will display a dollar sign which confused the subsequent prompt recognition. (tramp-multi-action-password): More debugging output. (tramp-encoding-shell): Renamed from tramp-sh-program. More documentation. Default to cmd.exe on Windows NT. (tramp-encoding-command-switch): New variable. Use instead of hard-wired "-c" which is only good for /bin/sh. (tramp-encoding-reads-stdin): New variable. If t, commands are called like "/bin/sh -c COMMAND <INPUT", if nil, they are called like "/bin/sh -c COMMAND INPUT", ie the input file is the last argument. (tramp-multi-sh-program): Always default to tramp-encoding-shell. (tramp-handle-file-local-copy, tramp-handle-write-region): Respect tramp-encoding-shell and friends. (tramp-find-inline-encoding): Use new-style calls for checking if the local commands work. 2002-09-07 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-methods): Remove `tramp-completion-function' entries. They are handled now by `tramp-completion-function-alist'. (tramp-completion-function): Defvar removed. I've never used it. Hmm. (tramp-get-completion-function) (tramp-get-completion-rsh, tramp-get-completion-ssh) (tramp-get-completion-telnet, tramp-get-completion-su): Functions removed as well. Not necessary any longer due to extended customization means. (tramp-completion-function-alist): New defcustom. Holds all FUNCTION FILE pairs used for user and host name completion relevant for METHOD. (tramp-completion-function-alist-rsh) (tramp-completion-function-alist-ssh) (tramp-completion-function-alist-telnet) (tramp-completion-function-alist-su): Defconst for initializing `tramp-completion-function-alist'. Unfortunately, mainly UNIX-like values are known for me until now. Needs to be completed for at least VMS++ like operating systems. (tramp-set-completion-function) (tramp-get-completion-function): New functions for configuration of `tramp-completion-function-alist'. The old definition of `tramp-get-completion-function' has been discarded. (tramp-completion-handle-file-name-all-completions): Change function call for user/host completion according to definition in `tramp-completion-function-alist'. (tramp-parse-passwd): Added exception handling for "root", because `tramp-get-completion-su' (the previous place for this stuff) doesn't exist any longer. 2002-09-07 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-enter-password): Use `tramp-password-end-of-line' to terminate the line. (tramp-bug): Include new variable `tramp-password-end-of-line'. (tramp-password-end-of-line): New variable. People who use plink under Windows might have to issue "\r\n" after the password, but they need to send just "\n" after the other commands. So this variable was introduced to complement `tramp-rsh-end-of-line'. (tramp-wait-for-output, tramp-post-connection): Allow "\r" at end of line of the output delimiter. 2002-09-06 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-handle-file-local-copy, tramp-find-shell) (tramp-open-connection-setup-interactive-shell): Add some comments about Douglas Grey Stephen's suggestions to make Tramp work better with plink under Windows. I'm not sure what to think of them, but now I have a guinea pig to try it out on. Said guinea pig is having other problems, though... Also remove some commented-out code. 2002-09-06 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-get-completion-methods): Algorithm slightly tuned. (tramp-get-completion-user-host): Accept user names as they are if typed until "@". (tramp-completion-mode): Replace `last-input-char' by modern `last-input-event'. Check for `event-modifiers'. 2002-09-06 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (file-expand-wildcards): Corrected check to see if advising is necessary. 2002-09-05 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-postfix-single-method-format) (tramp-postfix-multi-method-format) (tramp-postfix-multi-hop-format) (tramp-postfix-user-format): New format strings. (tramp-postfix-single-method-regexp) (tramp-postfix-multi-method-regexp) (tramp-postfix-multi-hop-regexp) (tramp-postfix-user-regexp) (tramp-make-multi-tramp-file-format) (tramp-make-tramp-file-name): Apply them. (tramp-completion-handle-file-name-all-completions): Fix for invoking ange-ftp in case of "/ftp:xxx" file names. 2002-09-04 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-prefix-format) (tramp-postfix-host-format): New format strings. (tramp-prefix-regexp, tramp-method-regexp) (tramp-postfix-single-method-regexp) (tramp-postfix-multi-method-regexp) (tramp-postfix-multi-hop-regexp) (tramp-user-regexp, tramp-postfix-user-regexp) (tramp-host-regexp, tramp-postfix-host-regexp) (tramp-path-regexp): New atomar regular expressions. If corresponding format strings exist, derived from them. (tramp-file-name-structure) (tramp-multi-file-name-structure) (tramp-multi-file-name-hop-structure) (tramp-make-multi-tramp-file-format) (tramp-completion-mode) (tramp-completion-dissect-file-name) (tramp-parse-rhosts-group) (tramp-parse-shosts-group) (tramp-parse-hosts-group) (tramp-parse-passwd-group): Apply these expressions. (tramp-file-name-structure-unified) (tramp-file-name-structure-separate) (tramp-make-tramp-file-format-unified) (tramp-make-tramp-file-format-separate) (tramp-make-tramp-file-format) (tramp-make-tramp-file-user-nil-format-unified) (tramp-make-tramp-file-user-nil-format-separate) (tramp-make-tramp-file-user-nil-format) (tramp-multi-file-name-structure-unified) (tramp-multi-file-name-structure-separate) (tramp-multi-file-name-hop-structure-unified) (tramp-multi-file-name-hop-structure-separate) (tramp-make-multi-tramp-file-format-unified) (tramp-make-multi-tramp-file-format-separate): Removed. (tramp-make-tramp-file-name): Allow partial tramp file names. Generate tramp file format on-the-fly depending on parameters. Apply atomar format strings resp expressions. (tramp-get-completion-methods) (tramp-get-completion-user-host): Apply `tramp-make-tramp-file-name'. (tramp-parse-hosts-group): Take all host names and IP addresses into account. (tramp-bug): Remove `tramp-make-tramp-file-format'. 2002-09-01 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-methods): Add `tramp-completion-function' for "su" and "sudo". (tramp-get-completion-telnet): Implement it. (tramp-parse-hosts) (tramp-parse-hosts-group) (tramp-get-completion-su) (tramp-parse-passwd) (tramp-parse-passwd-group): New functions. 2002-08-31 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-completion-mode): Check for `last-input-char'. (tramp-completion-file-name-handler-alist): Add handler for `file-exists-p. (tramp-completion-handle-file-exists-p): New function. (tramp-completion-handle-file-name-completion): Simplified. (tramp-completion-dissect-file-name): Regexp's reorganised. (tramp-completion-handle-file-name-all-completions): Call completion-function only if `user' or `host' is given. (tramp-get-completion-user-host): New function. (tramp-get-completion-rsh) (tramp-get-completion-ssh): Apply it. 2002-08-29 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-completion-file-name-handler-alist): Add handler for `expand-file-name'. (tramp-completion-handle-expand-file-name): New function. 2002-08-26 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-completion-mode): New function. (tramp-completion-handle-file-name-directory) (tramp-completion-handle-file-name-all-completions): Apply it. (tramp-methods): Remove double definition of `ssh1-old' and `ssh2-old'. (tramp-point-at-eol): New defalias. (tramp-parse-rhosts-group) (tramp-parse-shosts-group):: Apply it. 2002-08-25 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-get-completion-methods) (tramp-get-completion-rsh) (tramp-get-completion-ssh): Add "[" for Xemacs. (tramp-completion-file-name-regexp-separate): Expression adapted. (tramp-completion-file-name-handler-alist): Add handler for `file-name-directory' and `file-name-nondirectory'. (tramp-completion-handle-file-name-directory) (tramp-completion-handle-file-name-nondirectory) (tramp-completion-run-real-handler): New functions. (tramp-completion-file-name-handler) (tramp-completion-handle-file-name-all-completions): Apply `tramp-completion-run-real-handler'. (tramp-parse-rhosts) (tramp-parse-shosts): Use `with-temp-buffer'. `result? renamed to `res' (otherwise side effects in XEmacs). 2002-08-24 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-completion-file-name-regexp) (tramp-completion-file-name-handler-alist) (tramp-flatten-list) (tramp-completion-dissect-file-name) (tramp-get-completion-rsh) (tramp-parse-rhosts) (tramp-parse-rhosts-group) (tramp-get-completion-ssh): Doc string tuned. (tramp-methods): Doc string and custom type extended for `tramp-completion-function'. (tramp-completion-function): Variable added. Is it really used? Other variables like `tramp-completion-function' aren't used. (tramp-completion-file-name-handler-alist): Add handler for `file-name-completion'. (tramp-completion-handle-file-name-completion): New function. 2002-08-18 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-parse-rhosts) (tramp-parse-rhosts-group) (tramp-parse-shosts) (tramp-parse-shosts-group): New functions. 2002-08-17 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-completion-dissect-file-name) (tramp-completion-dissect-file-name1): New functions. 2002-08-16 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-get-completion-function) (tramp-get-completion-rsh) (tramp-get-completion-ssh) (tramp-get-completion-telnet): New functions. (tramp-methods): Add `tramp-completion-function' for all methods. 2002-08-15 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-get-completion-methods): New function. (tramp-find-default-method): Allow host to be nil (like user). 2002-08-14 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-completion-file-name-regexp-unified) (tramp-completion-file-name-regexp-separate) (tramp-completion-file-name-regexp) (tramp-completion-file-name-handler-alist): New defcustoms. (tramp-completion-file-name-handler): New function. Add `tramp-completion-file-name-handler' to `file-name-handler-alist'. (tramp-run-real-handler): Add `tramp-completion-file-name-handler' to `inhibit-file-name-handlers'. (tramp-completion-handle-file-name-all-completions) (tramp-completion-handle-file-name-completion): New functions. 2002-08-12 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-invoke-ange-ftp): `tramp-disable-ange-ftp' must be called again after activating `ange-ftp'. (tramp-ange-ftp-file-name-p): Check for Xemacs. 2002-08-08 Michael Albinus <Michael.Albinus@alcatel.de> * net/tramp.el (tramp-do-copy-or-rename-file): Don't pass KEEP-DATE to tramp-invoke-ange-ftp 'rename. (tramp-handle-write-region): Don't pass LOCKNAME and CONFIRM to tramp-invoke-ange-ftp 'write-region. (tramp-handle-set-file-modes): Change order of FILENAME and MODE passing to tramp-invoke-ange-ftp 'set-file-modes. (tramp-flatten-list): New function. Maybe this functionality does exist already elsewhere in the libraries. (tramp-invoke-ange-ftp): Apply `tramp-flatten-list' to parameter list in order to avoid nested lists, f.e. when invoked from `tramp-handle-dired-call-process'. 2002-09-05 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-chunksize): New kluge variable. (tramp-send-region): If tramp-chunksize is non-nil, send region in parts and sleep 0.1 seconds between chunks. 2002-09-03 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-handle-insert-directory): Use `insert-buffer-substring' instead of `insert-buffer', which is not supposed to be used from Lisp. Remember old point in a variable instead of using `mark'. Suggestion from Stefan Monnier. (tramp-unified-filenames): New variable. Use it in default value of other filename variables. (file-expand-wildcards): Don't advise unless "[" and "]" are used in the filename format. 2002-09-01 Kai Gro?ohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> * net/tramp.el (tramp-methods): Remove duplicate definition of ssh1-old and ssh2-old.
author Kai Großjohann <kgrossjo@eu.uu.net>
date Sun, 22 Sep 2002 13:23:36 +0000
parents 4d9f899a5963
children 20336ef6b20a
files lisp/ChangeLog lisp/net/tramp-uu.el lisp/net/tramp.el man/tramp.texi
diffstat 4 files changed, 2303 insertions(+), 771 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sun Sep 22 13:01:10 2002 +0000
+++ b/lisp/ChangeLog	Sun Sep 22 13:23:36 2002 +0000
@@ -1,3 +1,452 @@
+2002-09-22  Kai Gro,b_(Bjohann  <grossjoh@ls6.informatik.uni-dortmund.de>
+
+	Version 2.0.20 released.
+
+2002-09-20  Kai Gro,b_(Bjohann  <grossjoh@ls6.informatik.uni-dortmund.de>
+
+	* net/tramp.el (tramp-completion-function-alist): Escape open
+	paren in docstring.
+	(tramp-user-regexp, tramp-host-regexp): Allow empty strings.
+	(tramp-handle-insert-file-contents): Call tramp-message-for-buffer
+	instead of tramp-message.
+	(tramp-open-connection-rsh): Handle empty string as user name.
+	(tramp-open-connection-su): Handle empty string as host name.
+	Handle nil user name.
+	(tramp-handle-file-local-copy, tramp-handle-write-region)
+	(tramp-completion-handle-file-name-all-completions)
+	(tramp-open-connection-telnet, tramp-open-connection-rsh)
+	(tramp-open-connection-su, tramp-post-connection)
+	(tramp-maybe-open-connection, tramp-method-out-of-band-p)
+	(tramp-get-connection-function, tramp-get-remote-sh)
+	(tramp-get-rsh-program, tramp-get-rsh-args)
+	(tramp-get-rcp-program, tramp-get-rcp-args)
+	(tramp-get-rcp-keep-date-arg, tramp-get-su-program)
+	(tramp-get-su-args, tramp-get-telnet-program)
+	(tramp-get-telnet-args): Use `tramp-find-method', perhaps require
+	additional args USER, HOST.
+	(tramp-action-password, tramp-open-connection-telnet)
+	(tramp-open-connection-su, tramp-open-connection-multi)
+	(tramp-method-out-of-band-p): `tramp-method-out-of-band-p' now
+	takes USER and HOST arguments, to be able to use
+	`tramp-find-method'.  Update callers.
+	(tramp-find-method): New function.
+
+2002-09-20  Kai Gro,b_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+	* net/tramp.el (tramp-handle-insert-directory): Handle "--dired"
+	in SWITCHES (by removing it).
+
+2002-09-18  Kai Gro,b_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+	* net/tramp.el (tramp-file-name-handler): Add `file-remote-p'
+	property.
+
+2002-09-17  Kai Gro,b_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+	* net/tramp.el (top-level): Maybe autoload uudecode-decode-region.
+
+2002-09-16  Kai Gro,b_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+	* net/tramp.el (tramp-bug): Add tramp-methods.
+
+2002-09-16  Kai Gro,b_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+	* net/tramp.el (tramp-methods): Update docstring:
+	tramp-encoding-command, tramp-decoding-command,
+	tramp-encoding-function and tramp-decoding-function are not
+	parameters anymore.
+	(tramp-uuencode-region): Autoload it.
+
+2002-09-13  Kai Gro,b_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+	Version 2.0.19 released.
+
+	* net/tramp-uu.el: New file, implements uuencode in Lisp.
+
+	* net/tramp.el (tramp-coding-commands): Use
+	`tramp-uuencode-region' as local encoder for the uuencode based
+	entries.
+
+2002-09-13  Kai Gro,b_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+	* net/tramp.el (tramp-handle-write-region): Wrong parens.
+
+2002-09-13  Kai Gro,b_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+	Version 2.0.18 released.
+
+	* net/tramp.el (tramp-perl-decode): Perl changes to accomodate
+	older versions of Perl.  Now tested with 5.004.  Suggestion from
+	Michael Albinus.
+
+2002-09-12  Kai Gro,b_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+	* net/tramp.el (tramp-find-inline-encoding): Call
+	tramp-call-local-coding-command with nil for INPUT and OUTPUT.
+	(tramp-call-local-coding-command): OUTPUT equals nil means to
+	discard the output.  INPUT equals nil means /dev/null.
+
+2002-09-12  Kai Gro,b_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+	* net/tramp.el (tramp-encoding-shell): Default to environment
+	variable COMSPEC on Windows.
+	(tramp-handle-write-region): More debugging output.
+	(tramp-find-inline-encoding): Ditto.
+
+2002-09-11  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	* net/tramp.el (tramp-completion-handle-file-name-all-completions):
+	Define `result1'.
+	(tramp-parse-hosts-group): Discard IPv6 entries.
+
+2002-09-11  Kai Gro,b_(Bjohann  <grossjoh@ls6.informatik.uni-dortmund.de>
+
+	* net/tramp.el (tramp-post-connection): Only send Perl
+	mime-encode/decode implementations when using inline method.
+	(tramp-handle-file-local-copy)
+	(tramp-handle-write-region, tramp-post-connection)
+	(tramp-coding-commands, tramp-find-inline-encoding): For the
+	inline encodings, distinguish between local and remote commands,
+	instead of between commands and functions.  (The local commands
+	can be functions, too.)  If the local host is a Windows machine,
+	we can't expect the same commands to work there as on the remote
+	host.
+	(tramp-call-local-coding-command): New function for calling local
+	encoding and decoding commands.
+	(tramp-set-remote-encoding, tramp-get-remote-encoding)
+	(tramp-set-remote-decoding, tramp-get-remote-decoding)
+	(tramp-set-local-encoding, tramp-get-local-encoding)
+	(tramp-set-local-decoding, tramp-get-local-decoding): New
+	functions.
+	(tramp-get-encoding-command, tramp-set-encoding-command)
+	(tramp-get-decoding-command, tramp-set-decoding-command)
+	(tramp-get-encoding-function, tramp-set-encoding-function)
+	(tramp-get-decoding-function, tramp-set-decoding-function): Old
+	functions, removed.
+
+2002-09-10  Kai Gro,b_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+	* net/tramp.el (tramp-open-connection-setup-interactive-shell):
+	Change command to invoke /bin/sh slightly to make it compatible
+	with the `rc' shell.  Suggested by Daniel Pittman.
+
+2002-09-10  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	* net/tramp.el (tramp-handle-write-region): Added missing
+	`)'. Hope it's the right place.
+
+2002-09-09  Kai Gro,b_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+	* net/tramp.el (tramp-open-connection-setup-interactive-shell): Do
+	"exec env PS1='$ ' /bin/sh" instead of just "exec /bin/sh" in
+	order to get a sane shell prompt.  If people have ${CWD}, say, in
+	their shell prompt, then the default login shell might display
+	something harmless, but the /bin/sh will display a dollar sign
+	which confused the subsequent prompt recognition.
+	(tramp-multi-action-password): More debugging output.
+	(tramp-encoding-shell): Renamed from tramp-sh-program.  More
+	documentation.  Default to cmd.exe on Windows NT.
+	(tramp-encoding-command-switch): New variable.  Use instead of
+	hard-wired "-c" which is only good for /bin/sh.
+	(tramp-encoding-reads-stdin): New variable.  If t, commands are
+	called like "/bin/sh -c COMMAND <INPUT", if nil, they are called
+	like "/bin/sh -c COMMAND INPUT", ie the input file is the last
+	argument.
+	(tramp-multi-sh-program): Always default to tramp-encoding-shell.
+	(tramp-handle-file-local-copy, tramp-handle-write-region): Respect
+	tramp-encoding-shell and friends.
+	(tramp-find-inline-encoding): Use new-style calls for checking if
+	the local commands work.
+
+2002-09-07  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	* net/tramp.el (tramp-methods): Remove `tramp-completion-function'
+	entries. They are handled now by
+	`tramp-completion-function-alist'.
+	(tramp-completion-function): Defvar removed. I've never used
+	it. Hmm.
+	(tramp-get-completion-function)
+	(tramp-get-completion-rsh, tramp-get-completion-ssh)
+	(tramp-get-completion-telnet, tramp-get-completion-su): Functions
+	removed as well. Not necessary any longer due to extended
+	customization means.
+	(tramp-completion-function-alist): New defcustom. Holds all
+	FUNCTION FILE pairs used for user and host name completion
+	relevant for METHOD.
+	(tramp-completion-function-alist-rsh)
+	(tramp-completion-function-alist-ssh)
+	(tramp-completion-function-alist-telnet)
+	(tramp-completion-function-alist-su): Defconst for initializing
+	`tramp-completion-function-alist'. Unfortunately, mainly UNIX-like
+	values are known for me until now. Needs to be completed for at
+	least VMS++ like operating systems.
+	(tramp-set-completion-function)
+	(tramp-get-completion-function): New functions for configuration
+	of `tramp-completion-function-alist'. The old definition of
+	`tramp-get-completion-function' has been discarded.
+	(tramp-completion-handle-file-name-all-completions): Change
+	function call for user/host completion according to definition in
+	`tramp-completion-function-alist'.
+	(tramp-parse-passwd): Added exception handling for "root", because
+	`tramp-get-completion-su' (the previous place for this stuff)
+	doesn't exist any longer.
+	
+2002-09-07  Kai Gro,b_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+	* net/tramp.el (tramp-enter-password): Use
+	`tramp-password-end-of-line' to terminate the line.
+	(tramp-bug): Include new variable `tramp-password-end-of-line'.
+	(tramp-password-end-of-line): New variable.  People who use plink
+	under Windows might have to issue "\r\n" after the password, but
+	they need to send just "\n" after the other commands.  So this
+	variable was introduced to complement `tramp-rsh-end-of-line'.
+	(tramp-wait-for-output, tramp-post-connection): Allow "\r" at end
+	of line of the output delimiter.
+
+2002-09-06  Kai Gro,b_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+	* net/tramp.el (tramp-handle-file-local-copy, tramp-find-shell)
+	(tramp-open-connection-setup-interactive-shell): Add some comments
+	about Douglas Grey Stephen's suggestions to make Tramp work better
+	with plink under Windows.  I'm not sure what to think of them, but
+	now I have a guinea pig to try it out on.  Said guinea pig is
+	having other problems, though...  Also remove some commented-out
+	code.
+
+2002-09-06  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	* net/tramp.el (tramp-get-completion-methods): Algorithm slightly
+	tuned.
+	(tramp-get-completion-user-host): Accept user names as they are if
+	typed until "@".
+	(tramp-completion-mode): Replace `last-input-char' by modern
+	`last-input-event'. Check for `event-modifiers'.
+
+2002-09-06  Kai Gro,b_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+	* net/tramp.el (file-expand-wildcards): Corrected check to see if
+	advising is necessary.
+
+2002-09-05  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	* net/tramp.el (tramp-postfix-single-method-format)
+	(tramp-postfix-multi-method-format)
+	(tramp-postfix-multi-hop-format)
+	(tramp-postfix-user-format): New format strings.
+	(tramp-postfix-single-method-regexp)
+	(tramp-postfix-multi-method-regexp)
+	(tramp-postfix-multi-hop-regexp)
+	(tramp-postfix-user-regexp)
+	(tramp-make-multi-tramp-file-format)
+	(tramp-make-tramp-file-name): Apply them.
+	(tramp-completion-handle-file-name-all-completions): Fix for
+	invoking ange-ftp in case of "/ftp:xxx" file names.
+
+2002-09-04  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	* net/tramp.el (tramp-prefix-format)
+	(tramp-postfix-host-format): New format strings.
+	(tramp-prefix-regexp, tramp-method-regexp)
+	(tramp-postfix-single-method-regexp)
+	(tramp-postfix-multi-method-regexp)
+	(tramp-postfix-multi-hop-regexp)
+	(tramp-user-regexp, tramp-postfix-user-regexp)
+	(tramp-host-regexp, tramp-postfix-host-regexp)
+	(tramp-path-regexp): New atomar regular expressions. If
+	corresponding format strings exist, derived from them.
+	(tramp-file-name-structure)
+	(tramp-multi-file-name-structure)
+	(tramp-multi-file-name-hop-structure)
+	(tramp-make-multi-tramp-file-format)
+	(tramp-completion-mode)
+	(tramp-completion-dissect-file-name)
+	(tramp-parse-rhosts-group)
+	(tramp-parse-shosts-group)
+	(tramp-parse-hosts-group)
+	(tramp-parse-passwd-group): Apply these expressions.
+	(tramp-file-name-structure-unified)
+	(tramp-file-name-structure-separate)
+	(tramp-make-tramp-file-format-unified)
+	(tramp-make-tramp-file-format-separate)
+	(tramp-make-tramp-file-format)
+	(tramp-make-tramp-file-user-nil-format-unified)
+	(tramp-make-tramp-file-user-nil-format-separate)
+	(tramp-make-tramp-file-user-nil-format)
+	(tramp-multi-file-name-structure-unified)
+	(tramp-multi-file-name-structure-separate)
+	(tramp-multi-file-name-hop-structure-unified)
+	(tramp-multi-file-name-hop-structure-separate)
+	(tramp-make-multi-tramp-file-format-unified)
+	(tramp-make-multi-tramp-file-format-separate): Removed.
+	(tramp-make-tramp-file-name): Allow partial tramp file
+	names. Generate tramp file format on-the-fly depending on
+	parameters. Apply atomar format strings resp expressions.
+	(tramp-get-completion-methods)
+	(tramp-get-completion-user-host): Apply
+	`tramp-make-tramp-file-name'.
+	(tramp-parse-hosts-group): Take all host names and IP addresses
+	into account.
+	(tramp-bug): Remove `tramp-make-tramp-file-format'.
+
+2002-09-01  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	* net/tramp.el (tramp-methods): Add `tramp-completion-function'
+	for "su" and "sudo".
+	(tramp-get-completion-telnet): Implement it.
+	(tramp-parse-hosts)
+	(tramp-parse-hosts-group)
+	(tramp-get-completion-su)
+	(tramp-parse-passwd)
+	(tramp-parse-passwd-group): New functions.
+
+2002-08-31  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	* net/tramp.el (tramp-completion-mode): Check for
+	`last-input-char'.
+	(tramp-completion-file-name-handler-alist): Add handler for
+	`file-exists-p.
+	(tramp-completion-handle-file-exists-p): New function.
+	(tramp-completion-handle-file-name-completion): Simplified.
+	(tramp-completion-dissect-file-name): Regexp's reorganised.
+	(tramp-completion-handle-file-name-all-completions): Call
+	completion-function only if `user' or `host' is given.
+	(tramp-get-completion-user-host): New function.
+	(tramp-get-completion-rsh)
+	(tramp-get-completion-ssh): Apply it.
+	
+2002-08-29  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	* net/tramp.el (tramp-completion-file-name-handler-alist): Add
+	handler for `expand-file-name'.
+	(tramp-completion-handle-expand-file-name): New function.
+
+2002-08-26  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	* net/tramp.el (tramp-completion-mode): New function.
+	(tramp-completion-handle-file-name-directory)
+	(tramp-completion-handle-file-name-all-completions): Apply it.
+	(tramp-methods): Remove double definition of `ssh1-old' and
+	`ssh2-old'.
+	(tramp-point-at-eol): New defalias.
+	(tramp-parse-rhosts-group)
+	(tramp-parse-shosts-group):: Apply it.
+
+2002-08-25  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	* net/tramp.el (tramp-get-completion-methods)
+	(tramp-get-completion-rsh)
+	(tramp-get-completion-ssh): Add "[" for Xemacs.
+	(tramp-completion-file-name-regexp-separate): Expression adapted.
+	(tramp-completion-file-name-handler-alist): Add handler for
+	`file-name-directory' and `file-name-nondirectory'.
+	(tramp-completion-handle-file-name-directory)
+	(tramp-completion-handle-file-name-nondirectory)
+	(tramp-completion-run-real-handler): New functions.
+	(tramp-completion-file-name-handler)
+	(tramp-completion-handle-file-name-all-completions): Apply
+	`tramp-completion-run-real-handler'.
+	(tramp-parse-rhosts)
+	(tramp-parse-shosts): Use `with-temp-buffer'. `result,b4(B renamed to
+	`res' (otherwise side effects in XEmacs).
+
+2002-08-24  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	* net/tramp.el (tramp-completion-file-name-regexp)
+	(tramp-completion-file-name-handler-alist)
+	(tramp-flatten-list)
+	(tramp-completion-dissect-file-name)
+	(tramp-get-completion-rsh)
+	(tramp-parse-rhosts)
+	(tramp-parse-rhosts-group)
+	(tramp-get-completion-ssh): Doc string tuned.
+	(tramp-methods): Doc string and custom type extended for
+	`tramp-completion-function'.
+	(tramp-completion-function): Variable added. Is it really used?
+	Other variables like `tramp-completion-function' aren't used.
+	(tramp-completion-file-name-handler-alist): Add handler for
+	`file-name-completion'.
+	(tramp-completion-handle-file-name-completion): New function.
+
+2002-08-18  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	* net/tramp.el (tramp-parse-rhosts)
+	(tramp-parse-rhosts-group)
+	(tramp-parse-shosts)
+	(tramp-parse-shosts-group): New functions.
+
+2002-08-17  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	* net/tramp.el (tramp-completion-dissect-file-name)
+	(tramp-completion-dissect-file-name1): New functions.
+
+2002-08-16  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	* net/tramp.el (tramp-get-completion-function)
+	(tramp-get-completion-rsh)
+	(tramp-get-completion-ssh)
+	(tramp-get-completion-telnet): New functions.
+	(tramp-methods): Add `tramp-completion-function' for all methods.
+
+2002-08-15  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	* net/tramp.el (tramp-get-completion-methods): New function.
+	(tramp-find-default-method): Allow host to be nil (like user).
+
+2002-08-14  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	* net/tramp.el (tramp-completion-file-name-regexp-unified)
+	(tramp-completion-file-name-regexp-separate)
+	(tramp-completion-file-name-regexp)
+	(tramp-completion-file-name-handler-alist): New defcustoms.
+	(tramp-completion-file-name-handler): New function. Add
+	`tramp-completion-file-name-handler' to `file-name-handler-alist'.
+	(tramp-run-real-handler): Add `tramp-completion-file-name-handler'
+	to `inhibit-file-name-handlers'.
+	(tramp-completion-handle-file-name-all-completions)
+	(tramp-completion-handle-file-name-completion): New functions.
+	
+2002-08-12  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	* net/tramp.el (tramp-invoke-ange-ftp): `tramp-disable-ange-ftp'
+	must be called again after activating `ange-ftp'.
+	(tramp-ange-ftp-file-name-p): Check for Xemacs.
+
+2002-08-08  Michael Albinus  <Michael.Albinus@alcatel.de>
+
+	* net/tramp.el (tramp-do-copy-or-rename-file): Don't pass
+	KEEP-DATE to tramp-invoke-ange-ftp 'rename.
+	(tramp-handle-write-region): Don't pass LOCKNAME and CONFIRM to
+	tramp-invoke-ange-ftp 'write-region.
+	(tramp-handle-set-file-modes): Change order of FILENAME and MODE
+	passing to tramp-invoke-ange-ftp 'set-file-modes.
+	(tramp-flatten-list): New function. Maybe this functionality does
+	exist already elsewhere in the libraries.
+	(tramp-invoke-ange-ftp): Apply `tramp-flatten-list' to parameter
+	list in order to avoid nested lists, f.e. when invoked from
+	`tramp-handle-dired-call-process'.
+
+2002-09-05  Kai Gro,b_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+	* net/tramp.el (tramp-chunksize): New kluge variable.
+	(tramp-send-region): If tramp-chunksize is non-nil, send region in
+	parts and sleep 0.1 seconds between chunks.
+
+2002-09-03  Kai Gro,b_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+	* net/tramp.el (tramp-handle-insert-directory): Use
+	`insert-buffer-substring' instead of `insert-buffer', which is not
+	supposed to be used from Lisp.  Remember old point in a variable
+	instead of using `mark'.  Suggestion from Stefan Monnier.
+	(tramp-unified-filenames): New variable.  Use it in default value
+	of other filename variables.
+	(file-expand-wildcards): Don't advise unless "[" and "]" are used
+	in the filename format.
+
+2002-09-01  Kai Gro,b_(Bjohann  <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+
+	* net/tramp.el (tramp-methods): Remove duplicate definition of
+	ssh1-old and ssh2-old.
+
 2002-09-22  Kai Gro,b_(Bjohann  <grossjoh@ls6.informatik.uni-dortmund.de>
 
 	* dired.el (dired-insert-directory): Always add "--dired" to to
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lisp/net/tramp-uu.el	Sun Sep 22 13:23:36 2002 +0000
@@ -0,0 +1,89 @@
+;;; tramp-uu.el --- uuencode in Lisp
+
+;; Copyright (C) 2002  Free Software Foundation, Inc.
+
+;; Author: Kai Großjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
+;; Keywords: comm, terminals
+
+;; This file 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 2, or (at your option)
+;; any later version.
+
+;; This file is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; 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, write to
+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;; An implementation of "uuencode" in Lisp.  Uses the function
+;; base64-encode-region which is built-in to modern Emacsen.
+
+;;; Code:
+
+(defvar tramp-uu-b64-alphabet
+  "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
+  "Mapping from base64-encoded character to the byte it represents.")
+
+(defvar tramp-uu-b64-char-to-byte
+  (let ((i 0))
+    (mapcar (lambda (c)
+	      (prog1
+		  (cons c i)
+		(incf i)))
+	    tramp-uu-b64-alphabet))
+  "Alist of mapping from base64 character to its byte.")
+
+(defun tramp-uu-byte-to-uu-char (byte)
+  "Return the character encoding BYTE."
+  (if (zerop byte) ?` (+ byte 32)))
+
+(defun tramp-uu-b64-char-to-byte (char)
+  "Return the byte that is encoded as CHAR."
+  (cdr (assq char tramp-uu-b64-char-to-byte)))
+
+(defun tramp-uuencode-region (beg end)
+  "UU-encode the region between BEG and END."
+  ;; First we base64 encode the region, then we transmogrify that into
+  ;; uu encoding.
+  (let ((len (base64-encode-region beg end t))
+	(padding 0)
+	i c)
+    (save-excursion
+      (goto-char beg)
+      (setq i 0)
+      (while (< i len)
+	(setq c (char-after (point)))
+	(delete-char 1)
+	(if (equal c ?=)
+	    ;; "=" means padding.  Insert "`" instead.
+	    (insert "`")
+	  (insert (tramp-uu-byte-to-uu-char (tramp-uu-b64-char-to-byte c))))
+	(incf i)
+	;; Every 60 characters, add "M" at beginning of line (as
+	;; length byte) and insert a newline.
+	(when (zerop (% i 60))
+	  (save-excursion
+	    (beginning-of-line)
+	    (insert (char-to-string (+ 32 (/ (* 3 60) 4)))))
+	  (insert "\n")))
+      ;; If there is something leftover, we compute the length byte
+      ;; for that stuff and insert it and a trailing newline.
+      (unless (zerop (% i 60))
+	(save-excursion
+	  (beginning-of-line)
+	  (insert (char-to-string (+ 32 (% (- end beg) 45)))))
+	(insert "\n"))
+      ;; Why is there always a "`" line at the end?
+      (insert "`\nend\n")
+      (goto-char beg)
+      (insert "begin 600 xxx\n"))))
+
+(provide 'tramp-uu)
+;;; tramp-uu.el ends here
--- a/lisp/net/tramp.el	Sun Sep 22 13:01:10 2002 +0000
+++ b/lisp/net/tramp.el	Sun Sep 22 13:23:36 2002 +0000
@@ -72,7 +72,7 @@
 ;; In the Tramp CVS repository, the version numer is auto-frobbed from
 ;; the Makefile, so you should edit the top-level Makefile to change
 ;; the version number.
-(defconst tramp-version "2.0.15"
+(defconst tramp-version "2.0.20"
   "This version of tramp.")
 
 (defconst tramp-bug-report-address "tramp-devel@mail.freesoftware.fsf.org"
@@ -89,6 +89,12 @@
 (require 'shell)
 (require 'advice)
 
+(autoload 'tramp-uuencode-region "tramp-uu"
+  "Implementation of `uuencode' in Lisp.")
+
+(unless (fboundp 'uudecode-decode-region)
+  (autoload 'uudecode-decode-region "uudecode"))
+
 ;; ;; It does not work to load EFS after loading TRAMP.  
 ;; (when (fboundp 'efs-file-handler-function)
 ;;   (require 'efs))
@@ -103,6 +109,18 @@
 (unless (boundp 'custom-print-functions)
   (defvar custom-print-functions nil))	; not autoloaded before Emacs 20.4
 
+;; XEmacs is distributed with few Lisp packages.  Further packages are
+;; installed using EFS.  If we use a unified filename format, then
+;; Tramp is required in addition to EFS.  (But why can't Tramp just
+;; disable EFS when Tramp is loaded?  Then XEmacs can ship with EFS
+;; just like before.)  Another reason for using a separate filename
+;; syntax on XEmacs is that EFS hooks into XEmacs in many places, but
+;; Tramp only knows how to deal with `file-name-handler-alist', not
+;; the other places.
+(defvar tramp-unified-filenames (not (featurep 'xemacs))
+  "Non-nil means to use unified Ange-FTP/Tramp filename syntax.
+Nil means to use a separate filename syntax for Tramp.")
+
 ;;; User Customizable Internal Variables:
 
 (defgroup tramp nil
@@ -126,13 +144,24 @@
   :type '(choice (const nil)
                  string))
 
-(defcustom tramp-sh-program "/bin/sh"
-  "*Use this program for shell commands on the local host.
-This MUST be a Bourne-like shell.  This shell is used to execute
-the encoding and decoding command on the local host, so if you
-want to use `~' in those commands, you should choose a shell here
-which groks tilde expansion.  `/bin/sh' normally does not
-understand tilde expansion.
+(defcustom tramp-encoding-shell
+  (if (memq system-type '(windows-nt))
+      (getenv "COMSPEC")
+    "/bin/sh")
+  "*Use this program for encoding and decoding commands on the local host.
+This shell is used to execute the encoding and decoding command on the
+local host, so if you want to use `~' in those commands, you should
+choose a shell here which groks tilde expansion.  `/bin/sh' normally
+does not understand tilde expansion.
+
+For encoding and deocding, commands like the following are executed:
+
+    /bin/sh -c COMMAND < INPUT > OUTPUT
+
+This variable can be used to change the \"/bin/sh\" part.  See the
+variable `tramp-encoding-command-switch' for the \"-c\" part.  Also, see the
+variable `tramp-encoding-reads-stdin' to specify whether the commands read
+standard input or a file.
 
 Note that this variable is not used for remote commands.  There are
 mechanisms in tramp.el which automatically determine the right shell to
@@ -140,12 +169,27 @@
   :group 'tramp
   :type '(file :must-match t))
 
+(defcustom tramp-encoding-command-switch
+  (if (string-match "cmd\\.exe" tramp-encoding-shell)
+      "/c"
+    "-c")
+  "*Use this switch together with `tramp-encoding-shell' for local commands.
+See the variable `tramp-encoding-shell' for more information."
+  :group 'tramp
+  :type 'string)
+
+(defcustom tramp-encoding-reads-stdin t
+  "*If non-nil, encoding commands read from standard input.
+If nil, the filename is the last argument.
+
+Note that the commands always must write to standard output."
+  :group 'tramp
+  :type 'boolean)
+
 (defcustom tramp-multi-sh-program
-  (if (memq system-type '(windows-nt))
-      "cmd.exe"
-    tramp-sh-program)
+  tramp-encoding-shell
   "*Use this program for bootstrapping multi-hop connections.
-This variable is similar to `tramp-sh-program', but it is only used
+This variable is similar to `tramp-encoding-shell', but it is only used
 when initializing a multi-hop connection.  Therefore, the set of
 commands sent to this shell is quite restricted, and if you are
 careful it works to use CMD.EXE under Windows (instead of a Bourne-ish
@@ -154,8 +198,7 @@
 To use multi-hop methods from Windows, you also need suitable entries
 in `tramp-multi-connection-function-alist' for the first hop.
 
-This variable defaults to CMD.EXE on Windows NT, and to the value of
-`tramp-sh-program' on other systems."
+This variable defaults to the value of `tramp-encoding-shell'."
   :group 'tramp
   :type '(file :must-match t))
 
@@ -440,7 +483,7 @@
 This is a list of entries of the form (NAME PARAM1 PARAM2 ...).
 Each NAME stands for a remote access method.  Each PARAM is a
 pair of the form (KEY VALUE).  The following KEYs are defined:
-  * `tramp-connection-function'
+ * `tramp-connection-function'
     This specifies the function to use to connect to the remote host.
     Currently, `tramp-open-connection-rsh', `tramp-open-connection-telnet'
     and `tramp-open-connection-su' are defined.  See the documentation
@@ -477,24 +520,6 @@
     This specifies the list of arguments to pass to `su'.
     \"%u\" is replaced by the user name, use \"%%\" for a literal
     percent character.
-  * `tramp-encoding-command'
-    This specifies a command to use to encode the file contents for
-    transfer.  The command should read the raw file contents from
-    standard input and write the encoded file contents to standard
-    output.  In this string, the percent escape \"%f\" should be used
-    to indicate the file to convert.  Use \"%%\" if you need a literal
-    percent character in your command.
-  * `tramp-decoding-command'
-    This specifies a command to use to decode file contents encoded
-    with `tramp-encoding-command'.  The command should read from standard
-    input and write to standard output.
-  * `tramp-encoding-function'
-    This specifies a function to be called to encode the file contents
-    on the local side.  This function should accept two arguments
-    START and END, the beginning and end of the region to encode.  The
-    region should be replaced with the encoded contents.
-  * `tramp-decoding-function'
-    Same for decoding on the local side.
   * `tramp-telnet-program'
     Specifies the telnet program to use when using
     `tramp-open-connection-telnet' to log in.
@@ -514,28 +539,13 @@
 this case, the file contents need to be protected since the
 `tramp-rsh-program' might use escape codes or the connection might not
 be eight-bit clean.  Therefore, file contents are encoded for transit.
-
-Two possibilities for encoding are uuencode/uudecode and mimencode.
-For uuencode/uudecode you want to set `tramp-encoding-command' to
-something like \"uuencode\" and `tramp-decoding-command' to \"uudecode
--p\".  For mimencode you want to set `tramp-encoding-command' to
-something like \"mimencode -b\" and `tramp-decoding-command' to
-\"mimencode -b -u\".
-
-When using inline transfer, you can use a program or a Lisp function
-on the local side to encode or decode the file contents.  Set the
-`tramp-encoding-function' and `tramp-decoding-function' parameters to nil
-in order to use the commands or to the function to use.  It is
-possible to specify one function and the other parameter as nil.
-
-So, to summarize: if the method is an inline method, you must specify
-`tramp-encoding-command' and `tramp-decoding-command', and
-`tramp-rcp-program' must be nil.  If the method is out of band, then
-you must specify `tramp-rcp-program' and `tramp-rcp-args' and
-`tramp-encoding-command' and `tramp-decoding-command' must be nil.
-Every method, inline or out of band, must specify
-`tramp-connection-function' plus the associated arguments (for
-example, the telnet program if you chose
+See the variable `tramp-coding-commands' for details.
+
+So, to summarize: if the method is an out-of-band method, then you
+must specify `tramp-rcp-program' and `tramp-rcp-args'.  If it is an
+inline method, then these two parameters should be nil.  Every method,
+inline or out of band, must specify `tramp-connection-function' plus
+the associated arguments (for example, the telnet program if you chose
 `tramp-open-connection-telnet').
 
 Notes:
@@ -544,19 +554,7 @@
 remote host' sounds strange, but it is used nevertheless, for
 consistency.  No connection is opened to a remote host, but `su' is
 started on the local host.  You are not allowed to specify a remote
-host other than `localhost' or the name of the local host.
-
-Using a uuencode/uudecode inline method is discouraged, please use one
-of the base64 methods instead since base64 encoding is much more
-reliable and the commands are more standardized between the different
-Unix versions.  But if you can't use base64 for some reason, please
-note that the default uudecode command does not work well for some
-Unices, in particular AIX and Irix.  For AIX, you might want to use
-the following command for uudecode:
-
-    sed '/^begin/d;/^[` ]$/d;/^end/d' | iconv -f uucode -t ISO8859-1
-
-For Irix, no solution is known yet."
+host other than `localhost' or the name of the local host."
   :group 'tramp
   :type '(repeat
           (cons string
@@ -629,8 +627,7 @@
   :type 'string)
 
 (defcustom tramp-default-method-alist
-  (if (featurep 'xemacs)
-      nil
+  (when tramp-unified-filenames
     '(("\\`ftp\\." "" "ftp")
       ("" "\\`\\(anonymous\\|ftp\\)\\'" "ftp")))
   "*Default method to use for specific user/host pairs.
@@ -654,10 +651,102 @@
   :group 'tramp
   :type 'string)
 
+;; Default values for non-Unices seeked
+(defconst tramp-completion-function-alist-rsh
+  (unless (memq system-type '(windows-nt))
+    '((tramp-parse-rhosts "/etc/hosts.equiv")
+      (tramp-parse-rhosts "~/.rhosts")))
+  "Default list of (FUNNCTION FILE) pairs to be examined for rsh methods."
+)
+
+;; Default values for non-Unices seeked
+(defconst tramp-completion-function-alist-ssh
+  (unless (memq system-type '(windows-nt))
+    '((tramp-parse-rhosts "/etc/hosts.equiv")
+      (tramp-parse-rhosts "/etc/shosts.equiv")
+      (tramp-parse-shosts "/etc/ssh_known_hosts")
+      (tramp-parse-rhosts "~/.rhosts")
+      (tramp-parse-rhosts "~/.shosts")
+      (tramp-parse-shosts "~/.ssh/known_hosts")))
+  "Default list of (FUNNCTION FILE) pairs to be examined for ssh methods."
+)
+
+;; Default values for non-Unices seeked
+(defconst tramp-completion-function-alist-telnet
+  (unless (memq system-type '(windows-nt))
+    '((tramp-parse-hosts "/etc/hosts")))
+  "Default list of (FUNNCTION FILE) pairs to be examined for telnet methods."
+)
+
+;; Default values for non-Unices seeked
+(defconst tramp-completion-function-alist-su
+  (unless (memq system-type '(windows-nt))
+    '((tramp-parse-passwd "/etc/passwd")))
+  "Default list of (FUNNCTION FILE) pairs to be examined for su methods."
+)
+
+(defcustom tramp-completion-function-alist
+  (list (cons "rcp"      tramp-completion-function-alist-rsh)
+	(cons "scp"      tramp-completion-function-alist-ssh)
+	(cons "scp1"     tramp-completion-function-alist-ssh)
+	(cons "scp2"     tramp-completion-function-alist-ssh)
+	(cons "scp1-old" tramp-completion-function-alist-ssh)
+	(cons "scp2-old" tramp-completion-function-alist-ssh)
+	(cons "rsync"    tramp-completion-function-alist-rsh)
+	(cons "rsh"      tramp-completion-function-alist-rsh)
+ 	(cons "ssh"      tramp-completion-function-alist-ssh)
+ 	(cons "ssh1"     tramp-completion-function-alist-ssh)
+ 	(cons "ssh2"     tramp-completion-function-alist-ssh)
+ 	(cons "ssh1-old" tramp-completion-function-alist-ssh)
+ 	(cons "ssh2-old" tramp-completion-function-alist-ssh)
+ 	(cons "telnet"   tramp-completion-function-alist-telnet)
+ 	(cons "su"       tramp-completion-function-alist-su)
+ 	(cons "sudo"     tramp-completion-function-alist-su)
+ 	(cons "multi"    nil)
+ 	(cons "scpx"     tramp-completion-function-alist-ssh)
+ 	(cons "sshx"     tramp-completion-function-alist-ssh)
+	(cons "krlogin"  tramp-completion-function-alist-rsh)
+ 	(cons "plink"    tramp-completion-function-alist-ssh)
+ 	(cons "pscp"     tramp-completion-function-alist-ssh)
+ 	(cons "fcp"      nil)
+     )
+  "*Alist of methods for remote files.
+This is a list of entries of the form (NAME PAIR1 PAIR2 ...).
+Each NAME stands for a remote access method.  Each PAIR is of the form
+\(FUNCTION FILE).  FUNCTION is responsible to extract user names and host
+names from FILE for completion.  The following predefined FUNCTIONs exists:
+
+ * `tramp-parse-rhosts' for \".rhosts\" like files,
+ * `tramp-parse-shosts' for \"ssh_known_hosts\" like files,
+ * `tramp-parse-hosts'  for \"/etc/hosts\" like files, and
+ * `tramp-parse-passwd' for \"/etc/passwd\" like files.
+
+A FUNCTION parsing \".netrc\" file syntax doesn't exist in TRAMP. This
+task is delegated to ange-ftp; its customization should be used instead.
+
+FUNCTION can also see a customer defined function.  For more details see
+the info pages."
+  :group 'tramp
+  :type '(repeat
+          (cons string
+                (choice (const nil) (repeat (list function file))))))
+
 (defcustom tramp-rsh-end-of-line "\n"
   "*String used for end of line in rsh connections.
 I don't think this ever needs to be changed, so please tell me about it
-if you need to change this."
+if you need to change this.
+Also see `tramp-password-end-of-line'."
+  :group 'tramp
+  :type 'string)
+
+(defcustom tramp-password-end-of-line tramp-rsh-end-of-line
+  "*String used for end of line after sending a password.
+It seems that people using plink under Windows need to send
+\"\\r\\n\" (carriage-return, then newline) after a password, but just
+\"\\n\" after all other lines.  This variable can be used for the
+password, see `tramp-rsh-end-of-line' for the other cases.
+
+The default value is to use the same value as `tramp-rsh-end-of-line'."
   :group 'tramp
   :type 'string)
 
@@ -774,33 +863,134 @@
   :group 'tramp
   :type '(alist :key-type string :value-type string))
 
+(defcustom tramp-prefix-format
+  (if tramp-unified-filenames "/" "/[")
+  "*String matching the very beginning of tramp file names.
+Used in `tramp-make-tramp-file-name' and `tramp-make-tramp-multi-file-name'."
+  :group 'tramp
+  :type 'string)
+
+(defcustom tramp-prefix-regexp
+  (concat "^" (regexp-quote tramp-prefix-format))
+  "*Regexp matching the very beginning of tramp file names.
+Should always start with \"^\". Derived from `tramp-prefix-format'."
+  :group 'tramp
+  :type 'regexp)
+
+(defcustom tramp-method-regexp
+  "[a-zA-Z_0-9-]+"
+  "*Regexp matching methods identifiers."
+  :group 'tramp
+  :type 'regexp)
+
+;; It is a little bit annoying that in XEmacs case this delimeter is different
+;; for single-hop and multi-hop cases.
+(defcustom tramp-postfix-single-method-format
+  (if tramp-unified-filenames ":" "/")
+  "*String matching delimeter between method and user or host names.
+Applicable for single-hop methods.
+Used in `tramp-make-tramp-file-name'."
+  :group 'tramp
+  :type 'string)
+
+(defcustom tramp-postfix-single-method-regexp
+  (regexp-quote tramp-postfix-single-method-format)
+  "*Regexp matching delimeter between method and user or host names.
+Applicable for single-hop methods.
+Derived from `tramp-postfix-single-method-format'."
+  :group 'tramp
+  :type 'regexp)
+
+(defcustom tramp-postfix-multi-method-format
+  ":"
+  "*String matching delimeter between method and user or host names.
+Applicable for multi-hop methods.
+Used in `tramp-make-tramp-multi-file-name'."
+  :group 'tramp
+  :type 'string)
+
+(defcustom tramp-postfix-multi-method-regexp
+  (regexp-quote tramp-postfix-multi-method-format)
+  "*Regexp matching delimeter between method and user or host names.
+Applicable for multi-hop methods.
+Derived from `tramp-postfix-multi-method-format'."
+  :group 'tramp
+  :type 'regexp)
+
+(defcustom tramp-postfix-multi-hop-format
+  (if tramp-unified-filenames ":" "/")
+  "*String matching delimeter between path and next method.
+Applicable for multi-hop methods.
+Used in `tramp-make-tramp-multi-file-name'."
+  :group 'tramp
+  :type 'string)
+
+(defcustom tramp-postfix-multi-hop-regexp
+  (regexp-quote tramp-postfix-multi-hop-format)
+  "*Regexp matching delimeter between path and next method.
+Applicable for multi-hop methods.
+Derived from `tramp-postfix-multi-hop-format'."
+  :group 'tramp
+  :type 'regexp)
+
+(defcustom tramp-user-regexp
+  "[^:@/]*"
+  "*Regexp matching user names."
+  :group 'tramp
+  :type 'regexp)
+
+(defcustom tramp-postfix-user-format
+  "@"
+  "*String matching delimeter between user and host names.
+Used in `tramp-make-tramp-file-name' and `tramp-make-tramp-multi-file-name'."
+  :group 'tramp
+  :type 'string)
+
+(defcustom tramp-postfix-user-regexp
+  (regexp-quote tramp-postfix-user-format)
+  "*Regexp matching delimeter between user and host names.
+Derived from `tramp-postfix-user-format'."
+  :group 'tramp
+  :type 'regexp)
+
+(defcustom tramp-host-regexp
+  "[a-zA-Z0-9_.-]*"
+  "*Regexp matching host names."
+  :group 'tramp
+  :type 'regexp)
+
+(defcustom tramp-postfix-host-format
+  (if tramp-unified-filenames ":" "]")
+  "*String matching delimeter between host names and paths.
+Used in `tramp-make-tramp-file-name' and `tramp-make-tramp-multi-file-name'."
+  :group 'tramp
+  :type 'string)
+
+(defcustom tramp-postfix-host-regexp
+  (regexp-quote tramp-postfix-host-format)
+  "*Regexp matching delimeter between host names and paths.
+Derived from `tramp-postfix-host-format'."
+  :group 'tramp
+  :type 'regexp)
+
+(defcustom tramp-path-regexp
+  ".*$"
+  "*Regexp matching paths."
+  :group 'tramp
+  :type 'regexp)
+
 ;; File name format.
 
-(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
+   (concat
+    tramp-prefix-regexp
+    "\\(" "\\(" tramp-method-regexp "\\)" tramp-postfix-single-method-regexp "\\)?"
+    "\\(" "\\(" tramp-user-regexp   "\\)" tramp-postfix-user-regexp   "\\)?"
+          "\\(" tramp-host-regexp   "\\)" tramp-postfix-host-regexp
+	  "\\(" tramp-path-regexp   "\\)")
+   2 4 5 6)
+
   "*List of five elements (REGEXP METHOD USER HOST FILE), detailing \
 the tramp file name structure.
 
@@ -815,7 +1005,7 @@
 These numbers are passed directly to `match-string', which see.  That
 means the opening parentheses are counted to identify the pair.
 
-See also `tramp-file-name-regexp' and `tramp-make-tramp-file-format'."
+See also `tramp-file-name-regexp'."
   :group 'tramp
   :type '(list (regexp :tag "File name regexp")
                (integer :tag "Paren pair for method name")
@@ -839,9 +1029,9 @@
 
 ;;;###autoload
 (defcustom tramp-file-name-regexp
-  (if (featurep 'xemacs)
-      tramp-file-name-regexp-separate
-    tramp-file-name-regexp-unified)
+  (if tramp-unified-filenames
+      tramp-file-name-regexp-unified
+    tramp-file-name-regexp-separate)
   "*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
@@ -855,91 +1045,49 @@
 before loading tramp.el.  Alternatively, `file-name-handler-alist' can be
 updated after changing this variable.
 
-Also see `tramp-file-name-structure' and `tramp-make-tramp-file-format'."
+Also see `tramp-file-name-structure'."
   :group 'tramp
   :type 'regexp)
 
-(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.
-`%h' is replaced by the host name.
-`%p' is replaced by the file name.
-`%%' is replaced by %.
-
-Also see `tramp-file-name-structure' and `tramp-file-name-regexp'."
+;;;###autoload
+(defconst tramp-completion-file-name-regexp-unified
+  "^/[^/]*$"
+  "Value for `tramp-completion-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-completion-file-name-regexp-separate
+  "^/\\([[][^]]*\\)?$"
+  "Value for `tramp-completion-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-completion-file-name-regexp
+  (if tramp-unified-filenames
+      tramp-completion-file-name-regexp-unified
+    tramp-completion-file-name-regexp-separate)
+  "*Regular expression matching file names handled by tramp completion.
+This regexp should match partial tramp file names only.
+
+Please note that the entry in `file-name-handler-alist' is made when
+this file (tramp.el) is loaded.  This means that this variable must be set
+before loading tramp.el.  Alternatively, `file-name-handler-alist' can be
+updated after changing this variable.
+
+Also see `tramp-file-name-structure'."
   :group 'tramp
-  :type 'string)
-
-(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.
-`%p' is replaced by the file name.
-`%%' is replaced by %.
-
-Also see `tramp-make-tramp-file-format', `tramp-file-name-structure', and `tramp-file-name-regexp'."
-  :group 'tramp
-  :type 'string)
-
-(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-multi-file-name-structure-separate
-  (list (concat
-         ;; prefix
-         "\\`/\\[\\(\\([a-z0-9]+\\)?\\)"
-         ;; regexp specifying the hops
-         "\\(\\(%s\\)+\\)"
-         ;; path name
-         "\\]\\(.*\\)\\'")
-        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.")
+  :type 'regexp)
 
 (defcustom tramp-multi-file-name-structure
-  (if (featurep 'xemacs)
-      tramp-multi-file-name-structure-separate
-    tramp-multi-file-name-structure-unified)
+  (list
+   (concat
+    tramp-prefix-regexp
+    "\\(" "\\(" tramp-method-regexp "\\)" "\\)?"
+    "\\(" "\\(" tramp-postfix-multi-hop-regexp "%s" "\\)+" "\\)?"
+    tramp-postfix-host-regexp "\\(" tramp-path-regexp "\\)")
+   2 3 -1)
   "*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).
@@ -967,28 +1115,13 @@
                (integer :tag "Paren pair for hops")
                (integer :tag "Paren pair to match path")))
 
-(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)
+  (list
+   (concat
+    "\\(" tramp-method-regexp "\\)" tramp-postfix-multi-method-regexp
+    "\\(" tramp-user-regexp   "\\)" tramp-postfix-user-regexp
+    "\\(" tramp-host-regexp   "\\)")
+   1 2 3)
   "*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
@@ -1002,22 +1135,14 @@
                (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
-  (if (featurep 'xemacs)
-      tramp-make-multi-tramp-file-format-separate
-    tramp-make-multi-tramp-file-format-unified)
+  (list
+   (concat tramp-prefix-format "%m")
+   (concat tramp-postfix-multi-hop-format
+    "%m" tramp-postfix-multi-method-format
+    "%u" tramp-postfix-user-format
+    "%h")
+   (concat tramp-postfix-host-format "%p"))
   "*Describes how to construct a `multi' file name.
 This is a list of three elements PREFIX, HOP and PATH.
 
@@ -1327,7 +1452,7 @@
 
 my %%trans = do {
     my $i = 0;
-    map {($_, sprintf(q(%%06b), $i++))}
+    map {($_, substr(unpack(q(B8), chr $i++), 2, 6))}
       split //, q(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/)
 };
 
@@ -1348,7 +1473,7 @@
     $pending .= $data;
 
     my $len = length($pending);
-    my $chunk = substr($pending, 0, $len & ~3, q());
+    my $chunk = substr($pending, 0, $len & ~3);
 
     # Easy method: translate from chars to (pregenerated) six-bit packets, join,
     # split in 8-bit chunks and convert back to char.
@@ -1398,7 +1523,7 @@
 ;; This variable does not have the right value in XEmacs.  What should
 ;; I use instead of find-operation-coding-system in XEmacs?
 (defvar tramp-feature-write-region-fix
-  (unless (featurep 'xemacs)
+  (when (fboundp 'find-operation-coding-system)
     (let ((file-coding-system-alist '(("test" emacs-mule))))
       (find-operation-coding-system 'write-region 0 0 "" nil "test")))
     "Internal variable to say if `write-region' chooses the right coding.
@@ -1455,6 +1580,22 @@
         "Alist of handler functions.
 Operations not mentioned here will be handled by the normal Emacs functions.")
 
+;; Handlers for partial tramp file names. For GNU Emacs just
+;; `file-name-all-completions' is needed. The other ones are necessary
+;; for XEmacs.
+(defconst tramp-completion-file-name-handler-alist
+  '(
+    (file-name-directory . tramp-completion-handle-file-name-directory)
+    (file-name-nondirectory . tramp-completion-handle-file-name-nondirectory)
+    (file-exists-p . tramp-completion-handle-file-exists-p)
+    (file-name-all-completions . tramp-completion-handle-file-name-all-completions)
+    (file-name-completion . tramp-completion-handle-file-name-completion)
+    (expand-file-name . tramp-completion-handle-expand-file-name))
+  "Alist of completion handler functions.
+Used for file names matching `tramp-file-name-regexp'. Operations not
+mentioned here will be handled by `tramp-file-name-handler-alist' or the
+normal Emacs functions.")
+
 ;;; Internal functions which must come first.
 
 (defsubst tramp-message (level fmt-string &rest args)
@@ -1527,6 +1668,30 @@
 
 (put 'with-parsed-tramp-file-name 'lisp-indent-function 2)
 
+;;; Config Manipulation Functions:
+
+(defun tramp-set-completion-function (method function-list)
+  "Sets the list of completion functions for METHOD.
+FUNCTION-LIST is a list of entries of the form (FUNCTION FILE).
+The FUNCTION is intended to parse FILE according its syntax.
+It might be a predefined FUNCTION, or a user defined FUNCTION.
+Predefined FUNCTIONs are `tramp-parse-rhosts', `tramp-parse-shosts',
+`tramp-parse-hosts', and `tramp-parse-passwd'.
+Example:
+
+    (tramp-set-completion-function
+     \"ssh\"
+     '((tramp-parse-shosts \"/etc/ssh_known_hosts\")
+       (tramp-parse-shosts \"~/.ssh/known_hosts\")))"
+
+  (let ((v (cdr (assoc method tramp-completion-function-alist))))
+    (when v (setcdr v function-list))))
+
+(defun tramp-get-completion-function (method)
+  "Returns list of completion functions for METHOD.
+For definition of that list see `tramp-set-completion-function'."
+ (cdr (assoc method tramp-completion-function-alist)))
+
 ;;; File Name Handler Functions:
 
 (defun tramp-handle-make-symbolic-link
@@ -2556,6 +2721,11 @@
 (defun tramp-handle-insert-directory
   (filename switches &optional wildcard full-directory-p)
   "Like `insert-directory' for tramp files."
+  ;; For the moment, we assume that the remote "ls" program does not
+  ;; grok "--dired".  In the future, we should detect this on
+  ;; connection setup.
+  (when (string-match "^--dired\\s-+" switches)
+    (setq switches (replace-match "" nil t switches)))
   (setq filename (expand-file-name filename))
   (with-parsed-tramp-file-name filename nil
     (when (tramp-ange-ftp-file-name-p multi-method method)
@@ -2607,23 +2777,25 @@
 		   (file-name-nondirectory path)))))
       (sit-for 1)			;needed for rsh but not ssh?
       (tramp-wait-for-output))
-    (insert-buffer (tramp-get-buffer multi-method method user host))
-    ;; On XEmacs, we want to call (exchange-point-and-mark t), but
-    ;; that doesn't exist on Emacs, so we use this workaround instead.
-    ;; Since zmacs-region-stays doesn't exist in Emacs, this ought to
-    ;; be safe.  Thanks to Daniel Pittman <daniel@danann.net>.
-    (let ((zmacs-region-stays t))
-      (exchange-point-and-mark))
-    (save-excursion
-      (tramp-send-command multi-method method user host "cd")
-      (tramp-wait-for-output))
-    ;; Another XEmacs specialty follows.  What's the right way to do
-    ;; it?
-    (when (and (featurep 'xemacs)
-	       (eq major-mode 'dired-mode))
+    (let ((old-pos (point)))
+      (insert-buffer-substring
+       (tramp-get-buffer multi-method method user host))
+      ;; On XEmacs, we want to call (exchange-point-and-mark t), but
+      ;; that doesn't exist on Emacs, so we use this workaround instead.
+      ;; Since zmacs-region-stays doesn't exist in Emacs, this ought to
+      ;; be safe.  Thanks to Daniel Pittman <daniel@danann.net>.
+      ;;     (let ((zmacs-region-stays t))
+      ;;       (exchange-point-and-mark))
       (save-excursion
-	(require 'dired)
-	(dired-insert-set-properties (point) (mark t))))))
+	(tramp-send-command multi-method method user host "cd")
+	(tramp-wait-for-output))
+      ;; Another XEmacs specialty follows.  What's the right way to do
+      ;; it?
+      (when (and (featurep 'xemacs)
+		 (eq major-mode 'dired-mode))
+	(save-excursion
+	  (require 'dired)
+	  (dired-insert-set-properties old-pos (point)))))))
 
 ;; Continuation of kluge to pacify byte-compiler.
 ;;(eval-when-compile
@@ -2778,12 +2950,18 @@
     (when (tramp-ange-ftp-file-name-p multi-method method)
       (tramp-invoke-ange-ftp 'file-local-copy filename))
     (let ((trampbuf (get-buffer-create "*tramp output*"))
+	  (rcp-program (tramp-get-rcp-program
+			multi-method
+			(tramp-find-method multi-method method user host)))
+	  (rcp-args (tramp-get-rcp-args
+		     multi-method
+		     (tramp-find-method multi-method method user host)))
 	  tmpfil)
       (unless (file-exists-p filename)
 	(error "Cannot make local copy of non-existing file `%s'"
 	       filename))
       (setq tmpfil (tramp-make-temp-file))
-      (cond ((tramp-get-rcp-program multi-method method)
+      (cond (rcp-program
 	     ;; Use rcp-like program for file transfer.
 	     (tramp-message-for-buffer
 	      multi-method method user host
@@ -2792,9 +2970,9 @@
 	     (unless (equal
 		      0
 		      (apply #'call-process
-			     (tramp-get-rcp-program multi-method method)
+			     rcp-program
 			     nil trampbuf nil
-			     (append (tramp-get-rcp-args multi-method method)
+			     (append rcp-args
 				     (list
 				      (tramp-make-rcp-program-file-name
 				       user host
@@ -2804,12 +2982,12 @@
 	       (error
 		(concat "tramp-handle-file-local-copy: `%s' didn't work, "
 			"see buffer `%s' for details")
-		(tramp-get-rcp-program multi-method method) trampbuf))
+		rcp-program trampbuf))
 	     (tramp-message-for-buffer
 	      multi-method method user host
 	      5 "Fetching %s to tmp file %s...done" filename tmpfil))
-	    ((and (tramp-get-encoding-command multi-method method user host)
-		  (tramp-get-decoding-command multi-method method user host))
+	    ((and (tramp-get-remote-encoding multi-method method user host)
+		  (tramp-get-remote-decoding multi-method method user host))
 	     ;; Use inline encoding for file transfer.
 	     (save-excursion
 	       ;; Following line for setting tramp-current-method,
@@ -2818,7 +2996,8 @@
 	       (tramp-message 5 "Encoding remote file %s..." filename)
 	       (tramp-barf-unless-okay
 		multi-method method user host
-		(concat (tramp-get-encoding-command multi-method method user host)
+		(concat (tramp-get-remote-encoding
+			 multi-method method user host)
 			" < " (tramp-shell-quote-argument path))
 		nil 'file-error
 		"Encoding remote file failed, see buffer `%s' for details"
@@ -2828,11 +3007,13 @@
 	       (delete-region (point) (progn (forward-line -1) (point)))
 
 	       (tramp-message 5 "Decoding remote file %s..." filename)
-	       (if (and (tramp-get-decoding-function multi-method method user host)
-			(fboundp (tramp-get-decoding-function
-				  multi-method method user host)))
-		   ;; If tramp-decoding-function is defined for this
-		   ;; method, we call it.
+
+	       (let ((loc-enc (tramp-get-local-encoding
+			       multi-method method user host))
+		     (loc-dec (tramp-get-local-decoding
+			       multi-method method user host)))
+	       (if (and (symbolp loc-dec) (fboundp loc-dec))
+		   ;; If local decoding is a function, we call it.
 		   (let ((tmpbuf (get-buffer-create " *tramp tmp*")))
 		     (set-buffer tmpbuf)
 		     (erase-buffer)
@@ -2841,14 +3022,15 @@
 		     (tramp-message-for-buffer
 		      multi-method method user host
 		      6 "Decoding remote file %s with function %s..."
-		      filename
-		      (tramp-get-decoding-function multi-method method user host))
+		      filename loc-dec)
 		     (set-buffer tmpbuf)
+		     ;; Douglas Gray Stephens <DGrayStephens@slb.com>
+		     ;; says that we need to strip tramp_exit_status
+		     ;; line from the output here.  Go to point-max,
+		     ;; search backward for tramp_exit_status, delete
+		     ;; between point and point-max if found.
 		     (let ((coding-system-for-write 'no-conversion))
-		       (funcall (tramp-get-decoding-function
-				 multi-method method user host)
-				(point-min)
-				(point-max))
+		       (funcall loc-dec (point-min) (point-max))
 		       (write-region (point-min) (point-max) tmpfil))
 		     (kill-buffer tmpbuf))
 		 ;; If tramp-decoding-function is not defined for this
@@ -2857,20 +3039,13 @@
 		   (write-region (point-min) (point-max) tmpfil2)
 		   (tramp-message
 		    6 "Decoding remote file %s with command %s..."
-		    filename
-		    (tramp-get-decoding-command multi-method method user host))
-		   (call-process
-		    tramp-sh-program
-		    tmpfil2		;input
-		    nil			;output
-		    nil			;display
-		    "-c" (concat (tramp-get-decoding-command
-				  multi-method method user host)
-				 " > " tmpfil))
+		    filename loc-dec)
+		   (tramp-call-local-coding-command
+		    loc-dec tmpfil2 tmpfil)
 		   (delete-file tmpfil2)))
 	       (tramp-message-for-buffer
 		multi-method method user host
-		5 "Decoding remote file %s...done" filename)))
+		5 "Decoding remote file %s...done" filename))))
 
 	    (t (error "Wrong method specification for `%s'" method)))
       tmpfil)))
@@ -2910,7 +3085,9 @@
 	;; Now `last-coding-system-used' has right value.  Remember it.
 	(when (boundp 'last-coding-system-used)
 	  (setq coding-system-used last-coding-system-used))
-	(tramp-message 9 "Inserting local temp file `%s'...done" local-copy)
+	(tramp-message-for-buffer
+	 multi-method method user host
+	 9 "Inserting local temp file `%s'...done" local-copy)
 	(delete-file local-copy)
 	(when (boundp 'last-coding-system-used)
 	  (setq last-coding-system-used coding-system-used))
@@ -2944,14 +3121,15 @@
       (tramp-invoke-ange-ftp 'write-region
 			     start end filename append visit))
     (let ((curbuf (current-buffer))
-	  (rcp-program (tramp-get-rcp-program multi-method method))
-	  (rcp-args (tramp-get-rcp-args multi-method method))
-	  (encoding-command
-	   (tramp-get-encoding-command multi-method method user host))
-	  (encoding-function
-	   (tramp-get-encoding-function multi-method method user host))
-	  (decoding-command
-	   (tramp-get-decoding-command multi-method method user host))
+	  (rcp-program (tramp-get-rcp-program
+			multi-method (tramp-find-method multi-method method user host)))
+	  (rcp-args (tramp-get-rcp-args
+		     multi-method
+		     (tramp-find-method multi-method method user host)))
+	  (rem-enc (tramp-get-remote-encoding multi-method method user host))
+	  (rem-dec (tramp-get-remote-decoding multi-method method user host))
+	  (loc-enc (tramp-get-local-encoding multi-method method user host))
+	  (loc-dec (tramp-get-local-decoding multi-method method user host))
 	  (trampbuf (get-buffer-create "*tramp output*"))
 	  ;; We use this to save the value of `last-coding-system-used'
 	  ;; after writing the tmp file.  At the end of the function,
@@ -3013,7 +3191,7 @@
 		multi-method method user host
 		6 "Transferring file using `%s'...done"
 		rcp-program)))
-	    ((and encoding-command decoding-command)
+	    ((and rem-enc rem-dec)
 	     ;; Use inline file transfer
 	     (let ((tmpbuf (get-buffer-create " *tramp file transfer*")))
 	       (save-excursion
@@ -3023,8 +3201,7 @@
 		 (set-buffer tmpbuf)
 		 (erase-buffer)
 		 ;; Use encoding function or command.
-		 (if (and encoding-function
-			  (fboundp encoding-function))
+		 (if (and (symbolp loc-enc) (fboundp loc-enc))
 		     (progn
 		       (tramp-message-for-buffer
 			multi-method method user host
@@ -3041,25 +3218,19 @@
 		       ;; tmp file anyway.
 		       (let ((default-directory
 			       (tramp-temporary-file-directory)))
-			 (funcall encoding-function (point-min) (point-max)))
+			 (funcall loc-enc (point-min) (point-max)))
 		       (goto-char (point-max))
 		       (unless (bolp)
 			 (newline)))
 		   (tramp-message-for-buffer
 		    multi-method method user host
-		    6 "Encoding region using command...")
-		   (unless (equal 0
-				  (call-process
-				   tramp-sh-program
-				   tmpfil ;input = local tmp file
-				   t	;output is current buffer
-				   nil	;don't redisplay
-				   "-c"
-				   encoding-command))
+		    6 "Encoding region using command `%s'..." loc-enc)
+		   (unless (equal 0 (tramp-call-local-coding-command
+				     loc-enc tmpfil t))
 		     (pop-to-buffer trampbuf)
 		     (error (concat "Cannot write to `%s', local encoding"
 				    " command `%s' failed")
-			    filename encoding-command)))
+			    filename loc-enc)))
 		 ;; Send tmpbuf into remote decoding command which
 		 ;; writes to remote file.  Because this happens on the
 		 ;; remote host, we cannot use the function.
@@ -3069,7 +3240,7 @@
 		 (tramp-send-command
 		  multi-method method user host
 		  (format "%s >%s <<'EOF'"
-			  decoding-command
+			  rem-dec
 			  (tramp-shell-quote-argument path)))
 		 (set-buffer tmpbuf)
 		 (tramp-message-for-buffer
@@ -3092,7 +3263,7 @@
 		  multi-method method user host nil nil 'file-error
 		  (concat "Couldn't write region to `%s',"
 			  " decode using `%s' failed")
-		  filename decoding-command)
+		  filename rem-dec)
 		 (tramp-message 5 "Decoding region into remote file %s...done"
 				filename)
 		 (kill-buffer tmpbuf))))
@@ -3155,6 +3326,25 @@
 	       operation))
 	 (inhibit-file-name-handlers
 	  (list 'tramp-file-name-handler
+		'tramp-completion-file-name-handler
+		(and (eq inhibit-file-name-operation op)
+		     inhibit-file-name-handlers)))
+	 (inhibit-file-name-operation op))
+    (apply operation args)))
+
+;; This function is used from `tramp-completion-file-name-handler' functions
+;; only, if `tramp-completion-mode' is true. But this cannot be checked here
+;; because the check is based on a full filename, not available for all
+;; basic I/O operations.
+(defun tramp-completion-run-real-handler (operation args)
+  "Invoke `tramp-file-name-handler' for OPERATION.
+First arg specifies the OPERATION, second arg is a list of arguments to
+pass to the OPERATION."
+  (let* ((op (if (eq operation 'ange-ftp-hook-function)
+		 (car args)
+	       operation))
+	 (inhibit-file-name-handlers
+	  (list 'tramp-completion-file-name-handler
 		(and (eq inhibit-file-name-operation op)
 		     inhibit-file-name-handlers)))
 	 (inhibit-file-name-operation op))
@@ -3171,10 +3361,29 @@
 	  (save-match-data (apply (cdr fn) args)))
       (tramp-run-real-handler operation args))))
 
+(put 'tramp-file-name-handler 'file-remote-p t)	;for file-remote-p
+
+;;;###autoload
+(defun tramp-completion-file-name-handler (operation &rest args)
+  "Invoke tramp file name completion handler.
+Falls back to normal file name handler if no tramp file name handler exists."
+;;   (setq tramp-debug-buffer t)
+;;   (tramp-message 1 "%s %s" operation args)
+;;   (tramp-message 1 "%s %s\n%s"
+;; 		 operation args (with-output-to-string (backtrace)))
+  (let ((fn (assoc operation tramp-completion-file-name-handler-alist)))
+    (if fn
+	(catch 'tramp-forward-to-ange-ftp
+	  (save-match-data (apply (cdr fn) args)))
+      (tramp-completion-run-real-handler operation args))))
+
 ;; Register in file name handler alist
 ;;;###autoload
 (add-to-list 'file-name-handler-alist
 	     (cons tramp-file-name-regexp 'tramp-file-name-handler))
+(add-to-list 'file-name-handler-alist
+	     (cons tramp-completion-file-name-regexp
+		   'tramp-completion-file-name-handler))
 
 ;; To handle EFS, the following functions need to be dealt with:
 ;;
@@ -3212,6 +3421,20 @@
 	    (cons jka (delete jka file-name-handler-alist))))))
 (tramp-repair-jka-compr)
 
+(defun tramp-flatten-list (arg)
+  "Expands all lists inside ARG to a sequential list.
+Return (nil) if arg is nil."
+  (let ((car (car arg))
+	(cdr (cdr arg)))
+    (cond
+     ((eq arg nil) '(nil))
+     ((listp car)
+      (if (null cdr)
+	  (tramp-flatten-list car)
+	(append (tramp-flatten-list car) (tramp-flatten-list cdr))))
+     ((null cdr) (list car))
+     (t (cons car (tramp-flatten-list cdr))))))
+
 (defun tramp-invoke-ange-ftp (operation &rest args)
   "Invoke the Ange-FTP handler function and throw."
   (or (boundp 'ange-ftp-name-format)
@@ -3228,7 +3451,7 @@
 
 (defun tramp-ange-ftp-file-name-p (multi-method method)
   "Check if it's a filename that should be forwarded to Ange-FTP."
-  (and (not (featurep 'xemacs))
+  (and tramp-unified-filenames
        (null multi-method)
        (string= method tramp-ftp-method)))
 
@@ -3300,8 +3523,447 @@
     (tramp-setup-complete)
   (eval-after-load "complete" '(tramp-setup-complete)))
 
-
-
+;;; File name handler functions for completion mode
+
+;; Necessary because `tramp-file-name-regexp-unified' and
+;; `tramp-completion-file-name-regexp-unified' aren't different.
+;; If nil, `tramp-completion-run-real-handler' is called (i.e. forwarding to
+;; `tramp-file-name-handler'). Otherwise, it takes `tramp-run-real-handler'.
+;; Using `last-input-event' is a little bit risky, because completing a file 
+;; might require loading other files, like "~/.netrc", and for them it
+;; shouldn't be decided based on that variable. On the other hand, those files
+;; shouldn't have partial tramp file name syntax. Maybe another variable should
+;; be introduced overwriting this check in such cases. Or we change tramp
+;; file name syntax in order to avoid ambiguities, like in XEmacs ...
+;; In case of XEmacs it can be always true (and wouldn't be necessary).
+(defun tramp-completion-mode (file)
+  "Checks whether method / user name / host name completion is active."
+  (cond
+   ((featurep 'xemacs) t)
+   ((string-match "^/.*:.*:$" file) nil)
+   ((string-match
+     (concat
+      tramp-prefix-regexp
+      tramp-method-regexp tramp-postfix-single-method-regexp "$")
+     file)
+    (member (match-string 1 file)
+	    (cons tramp-ftp-method (mapcar 'car tramp-methods))))
+   ((or (equal last-input-event 'tab)
+	(and (not (event-modifiers last-input-event))
+	     (integerp last-input-event)
+	     (or (char-equal last-input-event ?\?)
+		 (char-equal last-input-event ?\t) ; handled by 'tab already?
+		 (char-equal last-input-event ?\ ))))
+    t)))
+
+(defun tramp-completion-handle-file-exists-p (filename)
+  "Like `file-exists-p' for tramp files."
+  (if (tramp-completion-mode filename)
+      (tramp-run-real-handler
+       'file-exists-p (list filename))
+    (tramp-completion-run-real-handler
+     'file-exists-p (list filename))))
+
+;; Path manipulation in case of partial TRAMP file names.
+(defun tramp-completion-handle-file-name-directory (file)
+  "Like `file-name-directory' but aware of TRAMP files."
+  (if (tramp-completion-mode file)
+      "/"
+    (tramp-completion-run-real-handler
+     'file-name-directory (list file))))
+
+;; Path manipulation in case of partial TRAMP file names.
+(defun tramp-completion-handle-file-name-nondirectory (file)
+  "Like `file-name-nondirectory' but aware of TRAMP files."
+  (substring
+   file (length (tramp-completion-handle-file-name-directory file))))
+
+;; Method, host name and user name completion.
+;; `tramp-completion-dissect-file-name' returns a list of
+;; tramp-file-name structures. For all of them we return possible completions.
+(defun tramp-completion-handle-file-name-all-completions (filename directory)
+  "Like `file-name-all-completions' for partial tramp files."
+
+  (let*
+      ((fullname (concat directory filename))
+       ;; prepare ange-ftp fix
+       (fix-ange-ftp-string
+	(concat tramp-ftp-method tramp-postfix-single-method-format))
+       (fix-ange-ftp (string-match (concat "^" fix-ange-ftp-string) filename))
+       ;; local files
+       (result
+	(if (tramp-completion-mode fullname)
+	    (tramp-run-real-handler
+	     'file-name-all-completions (list filename directory))
+	  (tramp-completion-run-real-handler
+	   'file-name-all-completions (list filename directory))))
+       ;; possible completion structures
+       (v (tramp-completion-dissect-file-name fullname)))
+
+    (while v
+      (let* ((car (car v))
+	     (multi-method (tramp-file-name-multi-method car))
+	     (method (tramp-file-name-method car))
+	     (user (tramp-file-name-user car))
+	     (host (tramp-file-name-host car))
+	     (path (tramp-file-name-path car))
+	     (m (tramp-find-method multi-method method user host))
+	     all-user-hosts)
+
+	(unless (or multi-method ;; Not handled (yet).
+		    path)        ;; Nothing to complete
+
+	  (if (or user host)
+
+	    ;; Method dependent user / host combinations
+	    (progn
+	      (mapcar
+	       '(lambda (x)
+		  (setq all-user-hosts
+			(append all-user-hosts
+				(funcall (nth 0 x) (nth 1 x)))))
+	       (tramp-get-completion-function m))
+
+	      (setq result (append result 
+	        (mapcar
+		 '(lambda (x)
+		    (tramp-get-completion-user-host
+		     method user host (nth 0 x) (nth 1 x)))
+		 (delq nil all-user-hosts)))))
+
+	    ;; Possible methods
+	    (setq result
+		  (append result (tramp-get-completion-methods m))))
+
+	  ;; Ange-ftp completions.
+	  ;; Filename might have the form "ftp:xxx". Ange-ftp isn't able to
+	  ;; handle the prefix "ftp:" correctly in
+	  ;; `ange-ftp-file-name-all-completions'; it simply calls 
+	  ;;`(all-completions file (ange-ftp-generate-root-prefixes))'.
+	  ;; So we must wrap around.
+	  (when (tramp-ange-ftp-file-name-p nil m)
+	    (setq result (append result
+	      (mapcar
+	       '(lambda (x) (if fix-ange-ftp (concat fix-ange-ftp-string x) x))
+	       (catch 'tramp-forward-to-ange-ftp
+		 (tramp-invoke-ange-ftp
+		  'file-name-all-completions
+		  (if fix-ange-ftp
+		      (substring filename (length fix-ange-ftp-string))
+		    filename)
+		  directory)))))))
+
+      (setq v (delq car v))))
+
+    ;;; unify list, remove nil elements
+    (let (result1)
+      (while result
+	(let ((car (car result)))
+	  (when car (add-to-list 'result1 car))
+	  (setq result (delq car result))))
+
+      result1)))
+
+;; Method, host name and user name completion for a file.
+(defun tramp-completion-handle-file-name-completion (filename directory)
+  "Like `file-name-completion' for tramp files."
+  (try-completion filename
+   (mapcar 'list (file-name-all-completions filename directory))))
+
+;; I misuse a little bit the tramp-file-name structure in order to handle
+;; completion possibilities for partial methods / user names / host names.
+;; Return value is a list of tramp-file-name structures according to possible
+;; completions. If "multi-method" or "path" is non-nil it means there
+;; shouldn't be a completion anymore.
+
+;; Expected results:
+
+;; "/x" "/[x"               "/x@" "/[x@"             "/x@y" "/[x@y"
+;; [nil nil nil "x" nil]    [nil nil "x" nil nil]    [nil nil "x" "y" nil]
+;; [nil nil "x" nil nil]
+;; [nil "x" nil nil nil]
+
+;; "/x:"                    "/x:y"                   "/x:y:"		      
+;; [nil nil nil "x" ""]     [nil nil nil "x" "y"]    [nil "x" nil "y" ""]
+;;       "/[x/"                   "/[x/y"
+;; [nil "x" nil "" nil]     [nil "x" nil "y" nil]
+;; [nil "x" "" nil nil]     [nil "x" "y" nil nil]
+
+;; "/x:y@"                  "/x:y@z"                 "/x:y@z:"
+;; [nil nil nil "x" "y@"]   [nil nil nil "x" "y@z"]  [nil "x" "y" "z" ""]
+;;       "/[x/y@"                 "/[x/y@z"
+;; [nil "x" nil "y" nil]    [nil "x" "y" "z" nil]
+(defun tramp-completion-dissect-file-name (name)
+  "Returns a list of `tramp-file-name' structures.
+They are collected by `tramp-completion-dissect-file-name1'."
+
+  (let* ((result)
+	 (x-nil "\\|\\(\\)"))
+
+    ;; "/method" "/[method"
+    (defconst tramp-completion-file-name-structure1
+      (list (concat tramp-prefix-regexp "\\(" tramp-method-regexp x-nil "\\)$")
+	    1 9 9 9))
+    ;; "/user" "/[user"
+    (defconst tramp-completion-file-name-structure2
+      (list (concat tramp-prefix-regexp "\\(" tramp-user-regexp x-nil   "\\)$")
+	    9 1 9 9))
+    ;; "/host" "/[host"
+    (defconst tramp-completion-file-name-structure3
+      (list (concat tramp-prefix-regexp "\\(" tramp-host-regexp x-nil   "\\)$")
+	    9 9 1 9))
+    ;; "/user@host" "/[user@host"
+    (defconst tramp-completion-file-name-structure4
+      (list (concat tramp-prefix-regexp
+		    "\\(" tramp-user-regexp "\\)"   tramp-postfix-user-regexp
+		    "\\(" tramp-host-regexp x-nil   "\\)$")
+	    9 1 2 9))
+    ;; "/method:user" "/[method/user"
+    (defconst tramp-completion-file-name-structure5
+      (list (concat tramp-prefix-regexp
+		    "\\(" tramp-method-regexp "\\)" tramp-postfix-single-method-regexp
+		    "\\(" tramp-user-regexp x-nil   "\\)$")
+	    1 2 9 9))
+    ;; "/method:host" "/[method/host"
+    (defconst tramp-completion-file-name-structure6
+      (list (concat tramp-prefix-regexp
+		    "\\(" tramp-method-regexp "\\)" tramp-postfix-single-method-regexp
+		    "\\(" tramp-host-regexp x-nil   "\\)$")
+	    1 9 2 9))
+    ;; "/method:user@host" "/[method/user@host"
+    (defconst tramp-completion-file-name-structure7
+      (list (concat tramp-prefix-regexp
+		    "\\(" tramp-method-regexp "\\)" tramp-postfix-single-method-regexp
+		    "\\(" tramp-user-regexp "\\)"   tramp-postfix-user-regexp
+		    "\\(" tramp-host-regexp x-nil   "\\)$")
+	    1 2 3 9))
+  
+    (mapcar '(lambda (regexp)
+      (add-to-list 'result
+	(tramp-completion-dissect-file-name1 regexp name)))
+      (list
+       tramp-completion-file-name-structure1
+       tramp-completion-file-name-structure2
+       tramp-completion-file-name-structure3
+       tramp-completion-file-name-structure4
+       tramp-completion-file-name-structure5
+       tramp-completion-file-name-structure6
+       tramp-completion-file-name-structure7
+       tramp-file-name-structure))
+
+    (delq nil result)))
+
+(defun tramp-completion-dissect-file-name1 (structure name)
+  "Returns a `tramp-file-name' structure matching STRUCTURE.
+The structure consists of multi-method, remote method, remote user,
+remote host and remote path name."
+
+  (let (method)
+    (save-match-data
+      (when (string-match (nth 0 structure) name)
+	(setq method (match-string (nth 1 structure) name))
+	(if (and method (member method tramp-multi-methods))
+	    ;; Not handled (yet).
+	    (make-tramp-file-name
+	     :multi-method method
+	     :method nil
+	     :user nil
+	     :host nil
+	     :path nil)
+	  (let ((user   (match-string (nth 2 structure) name))
+		(host   (match-string (nth 3 structure) name))
+		(path   (match-string (nth 4 structure) name)))
+	    (make-tramp-file-name
+	     :multi-method nil
+	     :method method
+	     :user user
+	     :host host
+	     :path path)))))))
+
+;; This function returns all possible method completions, adding the
+;; trailing method delimeter.
+;; In case of Emacs, `tramp-ftp-method' is handled as well because it doesn't
+;; belong to `tramp-methods'.
+(defun tramp-get-completion-methods (partial-method)
+  "Returns all method completions for PARTIAL-METHOD."
+  (let ((all-methods (delete "multi" (mapcar 'car tramp-methods))))
+
+    (mapcar
+     '(lambda (method)
+	(and method
+	 (string-match (concat "^" (regexp-quote partial-method)) method)
+	 ;; we must remove leading "/".
+	 (substring (tramp-make-tramp-file-name nil method nil nil nil) 1)))
+
+     (add-to-list 'all-methods
+		  (when tramp-unified-filenames tramp-ftp-method)))))
+
+;; Compares partial user and host names with possible completions.
+(defun tramp-get-completion-user-host (method partial-user partial-host user host)
+  "Returns the most expanded string for user and host name completion.
+PARTIAL-USER must match USER, PARTIAL-HOST must match HOST."
+  (cond
+
+   ((and partial-user partial-host)
+    (if	(and host
+	     (string-match (concat "^" (regexp-quote partial-host)) host)
+	     (string-equal partial-user (or user partial-user)))
+	(setq user partial-user)
+      (setq user nil
+	    host nil)))
+
+   (partial-user
+    (setq host nil)
+    (unless
+	(and user (string-match (concat "^" (regexp-quote partial-user)) user))
+      (setq user nil)))
+
+   (partial-host
+    (setq user nil)
+    (unless
+	(and host (string-match (concat "^" (regexp-quote partial-host)) host))
+      (setq host nil)))
+
+   (t (setq user nil
+	    host nil)))
+
+  (when (or user host)
+    ;; we must remove leading "/".
+    (substring (tramp-make-tramp-file-name nil method user host nil) 1)))
+
+(defun tramp-parse-rhosts (filename)
+  "Return a list of (user host) tuples allowed to access.
+Either user or host may be nil"
+
+  (let (res)
+    (when (file-exists-p filename)
+      (with-temp-buffer
+	(insert-file-contents filename)
+	(goto-char (point-min))
+	(while (not (eobp))
+	  (add-to-list 'res (tramp-parse-rhosts-group)))))
+    res))
+
+;; Taken from gnus/netrc.el
+(eval-and-compile
+  (defalias 'tramp-point-at-eol
+    (if (fboundp 'point-at-eol)
+	'point-at-eol
+      'line-end-position)))
+
+(defun tramp-parse-rhosts-group ()
+   "Return a (user host) tuple allowed to access.
+Either user or host may be nil"
+
+   (let ((result)
+	 (regexp
+	  (concat
+	   "^\\(" tramp-host-regexp "\\)"
+	   "\\([ \t]+" "\\(" tramp-user-regexp "\\)" "\\)?")))
+
+     (narrow-to-region (point) (tramp-point-at-eol))
+     (when (re-search-forward regexp nil t)
+       (setq result (append (list (match-string 3) (match-string 1)))))
+     (widen)
+     (forward-line 1)
+     result))
+
+(defun tramp-parse-shosts (filename)
+  "Return a list of (user host) tuples allowed to access.
+User is always nil."
+
+  (let (res)
+    (when (file-exists-p filename)
+      (with-temp-buffer
+	(insert-file-contents filename)
+	(goto-char (point-min))
+	(while (not (eobp))
+	  (add-to-list 'res (tramp-parse-shosts-group)))))
+    res))
+
+(defun tramp-parse-shosts-group ()
+   "Return a (user host) tuple allowed to access.
+User is always nil."
+
+   (let ((result)
+	 (regexp (concat "^\\(" tramp-host-regexp "\\)")))
+
+     (narrow-to-region (point) (tramp-point-at-eol))
+     (when (re-search-forward regexp nil t)
+       (setq result (list nil (match-string 1))))
+     (widen)
+     (or
+      (> (skip-chars-forward ",") 0)
+      (forward-line 1))
+     result))
+
+(defun tramp-parse-hosts (filename)
+  "Return a list of (user host) tuples allowed to access.
+User is always nil."
+
+  (let (res)
+    (when (file-exists-p filename)
+      (with-temp-buffer
+	(insert-file-contents filename)
+	(goto-char (point-min))
+	(while (not (eobp))
+	  (add-to-list 'res (tramp-parse-hosts-group)))))
+    res))
+
+(defun tramp-parse-hosts-group ()
+   "Return a (user host) tuple allowed to access.
+User is always nil."
+
+   (let ((result)
+	 (regexp (concat "^\\(" tramp-host-regexp "\\)")))
+
+     (narrow-to-region (point) (tramp-point-at-eol))
+     (when (re-search-forward regexp nil t)
+       (unless (char-equal (or (char-after) ?\n) ?:) ; no IPv6
+	 (setq result (list nil (match-string 1)))))
+     (widen)
+     (or
+      (> (skip-chars-forward " \t") 0)
+      (forward-line 1))
+     result))
+
+(defun tramp-parse-passwd (filename)
+  "Return a list of (user host) tuples allowed to access.
+Host is always \"localhost\"."
+
+  (let (res)
+    (if (and (symbolp 'user) (zerop (length user)))
+	'(("root" nil))
+      (when (file-exists-p filename)
+	(with-temp-buffer
+	  (insert-file-contents filename)
+	  (goto-char (point-min))
+	  (while (not (eobp))
+	    (add-to-list 'res (tramp-parse-passwd-group)))))
+      res)))
+
+(defun tramp-parse-passwd-group ()
+   "Return a (user host) tuple allowed to access.
+User is always nil."
+
+   (let ((result)
+	 (regexp (concat "^\\(" tramp-user-regexp "\\):")))
+
+     (narrow-to-region (point) (tramp-point-at-eol))
+     (when (re-search-forward regexp nil t)
+       (setq result (list (match-string 1) "localhost")))
+     (widen)
+     (forward-line 1)
+     result))
+
+(defun tramp-completion-handle-expand-file-name (name &optional dir)
+  "Like `expand-file-name' for tramp files."
+  (let ((fullname (concat (or dir default-directory) name)))
+    (if (tramp-completion-mode fullname)
+	(tramp-run-real-handler
+	 'expand-file-name (list name dir))
+      (tramp-completion-run-real-handler
+       'expand-file-name (list name dir)))))
 
 ;;; Internal Functions:
 
@@ -3551,22 +4213,18 @@
         (error "Couldn't find remote `%s' prompt." shell))
       (tramp-message
        9 "Setting remote shell prompt...")
+      ;; Douglas Gray Stephens <DGrayStephens@slb.com> says that we
+      ;; must use "\n" here, not tramp-rsh-end-of-line.  Kai left the
+      ;; last tramp-rsh-end-of-line, Douglas wanted to replace that,
+      ;; as well.
       (process-send-string nil (format "PS1='%s%s%s'; PS2=''; PS3=''%s"
-                                       tramp-rsh-end-of-line
+				       tramp-rsh-end-of-line
                                        tramp-end-of-output
-                                       tramp-rsh-end-of-line
+				       tramp-rsh-end-of-line
                                        tramp-rsh-end-of-line))
       (tramp-wait-for-output)
       (tramp-message
        9 "Setting remote shell prompt...done")
-;;       (tramp-send-command multi-method method user host "echo hello")
-;;       (tramp-message 5 "Waiting for remote `%s' to start up..." shell)
-;;       (unless (tramp-wait-for-output 5)
-;;         (unless (tramp-wait-for-output 5)
-;;           (pop-to-buffer (buffer-name))
-;;           (error "Couldn't start remote `%s', see buffer `%s' for details"
-;;                  shell (buffer-name))))
-;;       (tramp-message 5 "Waiting for remote `%s' to start up...done" shell)
       )
      (t (tramp-message 5 "Remote `%s' groks tilde expansion, good"
 		       (tramp-get-remote-sh multi-method method))))))
@@ -3634,11 +4292,12 @@
 
 (defun tramp-action-password (p multi-method method user host)
   "Query the user for a password."
-  (when (tramp-method-out-of-band-p multi-method method)
+  (when (tramp-method-out-of-band-p multi-method method user host)
     (kill-process (get-buffer-process (current-buffer)))
     (error (concat "Out of band method `%s' not applicable "
 		   "for remote shell asking for a password")
 	   method))
+  (tramp-message 9 "Sending password")
   (tramp-enter-password p (match-string 0)))
 
 (defun tramp-action-succeed (p multi-method method user host)
@@ -3689,6 +4348,7 @@
 
 (defun tramp-multi-action-password (p method user host)
   "Query the user for a password."
+  (tramp-message 9 "Sending password")
   (tramp-enter-password p (match-string 0)))
 
 (defun tramp-multi-action-succeed (p method user host)
@@ -3799,7 +4459,7 @@
 * Actually, the telnet program as well as the args to be used can be
   specified in the method parameters, see the variable `tramp-methods'."
   (save-match-data
-    (when (tramp-method-out-of-band-p multi-method method)
+    (when (tramp-method-out-of-band-p multi-method method user host)
       (error "Cannot use out-of-band method `%s' with telnet connection method"
              method))
     (when multi-method
@@ -3810,15 +4470,22 @@
     (let ((process-environment (copy-sequence process-environment)))
       (setenv "TERM" tramp-terminal-type)
       (let* ((default-directory (tramp-temporary-file-directory))
+	     ;; If we omit the conditional here, then we would use
+	     ;; `undecided-dos' in some cases.  With the conditional,
+	     ;; we use nil in these cases.  Which one is right?
              (coding-system-for-read (unless (and (not (featurep 'xemacs))
                                                   (> emacs-major-version 20))
                                        tramp-dos-coding-system))
              (p (apply 'start-process
                        (tramp-buffer-name multi-method method user host)
                        (tramp-get-buffer multi-method method user host)
-                       (tramp-get-telnet-program multi-method method)
+		       (tramp-get-telnet-program
+			multi-method
+			(tramp-find-method multi-method method user host))
                        host
-                       (tramp-get-telnet-args multi-method method)))
+		       (tramp-get-telnet-args
+			multi-method
+			(tramp-find-method multi-method method user host))))
              (found nil)
              (pw nil))
         (process-kill-without-query p)
@@ -3860,15 +4527,19 @@
     (when multi-method
       (error "Cannot multi-connect using rsh connection method"))
     (tramp-pre-connection multi-method method user host)
-    (if user 
+    (if (and user (not (string= user "")))
 	(tramp-message 7 "Opening connection for %s@%s using %s..." 
 		       user host method)
       (tramp-message 7 "Opening connection at %s using %s..." host method))
     (let ((process-environment (copy-sequence process-environment))
 	  (bufnam (tramp-buffer-name multi-method method user host))
 	  (buf (tramp-get-buffer multi-method method user host))
-	  (rsh-program (tramp-get-rsh-program multi-method method))
-	  (rsh-args (tramp-get-rsh-args multi-method method)))
+	  (rsh-program (tramp-get-rsh-program
+			multi-method
+			(tramp-find-method multi-method method user host)))
+	  (rsh-args (tramp-get-rsh-args
+		     multi-method
+		     (tramp-find-method multi-method method user host))))
       ;; The following should be changed.  We need a more general
       ;; mechanism to parse extra host args.
       (when (string-match "\\([^#]*\\)#\\(.*\\)" host)
@@ -3876,10 +4547,13 @@
 	(setq host (match-string 1 host)))
       (setenv "TERM" tramp-terminal-type)
       (let* ((default-directory (tramp-temporary-file-directory))
+	     ;; If we omit the conditional, we would use
+	     ;; `undecided-dos' in some cases.  With the conditional,
+	     ;; we use nil in these cases.  Which one is right?
              (coding-system-for-read (unless (and (not (featurep 'xemacs))
                                                   (> emacs-major-version 20))
                                        tramp-dos-coding-system))
-             (p (if user
+             (p (if (and user (not (string= user "")))
                     (apply #'start-process bufnam buf rsh-program  
                            host "-l" user rsh-args)
                   (apply #'start-process bufnam buf rsh-program 
@@ -3908,33 +4582,40 @@
 prompt than you do, so it is not at all unlikely that the variable
 `shell-prompt-pattern' is set up wrongly!"
   (save-match-data
-    (when (tramp-method-out-of-band-p multi-method method)
+    (when (tramp-method-out-of-band-p multi-method method user host)
       (error "Cannot use out-of-band method `%s' with `su' connection method"
              method))
     (unless (or (string-match (concat "^" (regexp-quote host))
                               (system-name))
-                (string= "localhost" host))
+                (string= "localhost" host)
+		(string= "" host))
       (error
        "Cannot connect to different host `%s' with `su' connection method"
        host))
-    (when (not user)
-      (setq user "root"))
     (tramp-pre-connection multi-method method user host)
-    (tramp-message 7 "Opening connection for `%s' using `%s'..." user method)
+    (tramp-message 7 "Opening connection for `%s' using `%s'..."
+		   (or user "<root>") method)
     (let ((process-environment (copy-sequence process-environment)))
       (setenv "TERM" tramp-terminal-type)
       (let* ((default-directory (tramp-temporary-file-directory))
+	     ;; If we omit the conditional, we use `undecided-dos' in
+	     ;; some cases.  With the conditional, we use nil in these
+	     ;; cases.  What's the difference?  Which one is right?
              (coding-system-for-read (unless (and (not (featurep 'xemacs))
                                                   (> emacs-major-version 20))
                                        tramp-dos-coding-system))
              (p (apply 'start-process
                        (tramp-buffer-name multi-method method user host)
                        (tramp-get-buffer multi-method method user host)
-                       (tramp-get-su-program multi-method method)
+		       (tramp-get-su-program
+			multi-method
+			(tramp-find-method multi-method method user host))
                        (mapcar
                         '(lambda (x)
-                           (format-spec x `((?u . ,user))))
-                        (tramp-get-su-args multi-method method))))
+                           (format-spec x `((?u . ,(or user "root")))))
+                        (tramp-get-su-args
+			 multi-method
+			 (tramp-find-method multi-method method user host)))))
              (found nil)
              (pw nil))
         (process-kill-without-query p)
@@ -3963,7 +4644,7 @@
   (save-match-data
     (unless multi-method
       (error "Multi-hop open connection function called on non-multi method"))
-    (when (tramp-method-out-of-band-p multi-method method)
+    (when (tramp-method-out-of-band-p multi-method method user host)
       (error "No out of band multi-hop connections"))
     (unless (and (arrayp method) (not (stringp method)))
       (error "METHOD must be an array of strings for multi methods"))
@@ -3979,6 +4660,9 @@
     (let ((process-environment (copy-sequence process-environment)))
       (setenv "TERM" tramp-terminal-type)
       (let* ((default-directory (tramp-temporary-file-directory))
+	     ;; If we omit the conditional, we use `undecided-dos' in
+	     ;; some cases.  With the conditional, we use nil in these
+	     ;; cases.  What's the difference?  Which one is right?
              (coding-system-for-read (unless (and (not (featurep 'xemacs))
                                                   (> emacs-major-version 20))
                                        tramp-dos-coding-system))
@@ -4137,7 +4821,7 @@
 Uses PROMPT as a prompt and sends the password to process P."
   (let ((pw (tramp-read-passwd prompt)))
     (erase-buffer)
-    (process-send-string p (concat pw tramp-rsh-end-of-line))))
+    (process-send-string p (concat pw tramp-password-end-of-line))))
 
 ;; HHH: Not Changed.  This might handle the case where USER is not
 ;;      given in the "File name" very poorly.  Then, the local
@@ -4163,7 +4847,16 @@
   ;; a Kerberos login.
   (sit-for 1)
   (tramp-discard-garbage-erase-buffer p multi-method method user host)
-  (process-send-string nil (format "exec %s%s"
+  ;; It is useful to set the prompt in the following command because
+  ;; some people have a setting for $PS1 which /bin/sh doesn't know
+  ;; about and thus /bin/sh will display a strange prompt.  For
+  ;; example, if $PS1 has "${CWD}" in the value, then ksh will display
+  ;; the current working directory but /bin/sh will display a dollar
+  ;; sign.  The following command line sets $PS1 to a sane value, and
+  ;; works under Bourne-ish shells as well as csh-like shells.  Daniel
+  ;; Pittman reports that the unusual positioning of the single quotes
+  ;; makes it work under `rc', too.
+  (process-send-string nil (format "exec env 'PS1=$ ' %s%s"
                                    (tramp-get-remote-sh multi-method method)
                                    tramp-rsh-end-of-line))
   (when tramp-debug-buffer
@@ -4171,7 +4864,8 @@
       (set-buffer (tramp-get-debug-buffer multi-method method user host))
       (goto-char (point-max))
       (tramp-insert-with-face
-       'bold (format "$ exec %s\n" (tramp-get-remote-sh multi-method method)))))
+       'bold (format "$ exec env PS1='$ ' %s\n"
+		     (tramp-get-remote-sh multi-method method)))))
   (tramp-message 9 "Waiting 30s for remote `%s' to come up..."
                (tramp-get-remote-sh multi-method method))
   (unless (tramp-wait-for-regexp
@@ -4285,24 +4979,15 @@
            (buffer-name)))
   (erase-buffer)
   (tramp-message 9 "Setting shell prompt")
+  ;; Douglas Gray Stephens <DGrayStephens@slb.com> says that we must
+  ;; use "\n" here, not tramp-rsh-end-of-line.
   (tramp-send-command
    multi-method method user host
    (format "PS1='%s%s%s'; PS2=''; PS3=''"
-           tramp-rsh-end-of-line
+	   tramp-rsh-end-of-line
            tramp-end-of-output
-           tramp-rsh-end-of-line))
-  (tramp-wait-for-output)
-;;   (tramp-send-command multi-method method user host "echo hello")
-;;   (tramp-message 9 "Waiting for remote `%s' to come up..."
-;;                (tramp-get-remote-sh multi-method method))
-;;   (unless (tramp-wait-for-output 5)
-;;     (unless (tramp-wait-for-output 5)
-;;       (pop-to-buffer (buffer-name))
-;;       (error "Couldn't set remote shell prompt.  See buffer `%s' for details"
-;;              (buffer-name))))
-;;   (tramp-message 7 "Waiting for remote `%s' to come up...done"
-;;                (tramp-get-remote-sh multi-method method))
-  )
+	   tramp-rsh-end-of-line))
+  (tramp-wait-for-output))
 
 (defun tramp-post-connection (multi-method method user host)
   "Prepare a remote shell before being able to work on it.
@@ -4380,7 +5065,7 @@
   (tramp-wait-for-output)
   (goto-char (point-min))
   (setq tramp-test-groks-nt
-        (looking-at (format "\n%s\n" (regexp-quote tramp-end-of-output))))
+        (looking-at (format "\n%s\r?\n" (regexp-quote tramp-end-of-output))))
   (unless tramp-test-groks-nt
     (tramp-send-command
      multi-method method user host
@@ -4412,36 +5097,39 @@
 		 " -e '" tramp-perl-file-attributes "' $1 2>/dev/null\n"
 		 "}"))
 	(tramp-wait-for-output)
-	(tramp-message 5 "Sending the Perl `mime-encode' implementations.")
-	(tramp-send-linewise
-	 multi-method method user host
-	 (concat "tramp_encode () {\n"
-		 (format tramp-perl-encode tramp-remote-perl)
-		 " 2>/dev/null"
-		 "\n}"))
-	(tramp-wait-for-output)
-	(tramp-send-linewise
-	 multi-method method user host
-	 (concat "tramp_encode_with_module () {\n"
-		 (format tramp-perl-encode-with-module tramp-remote-perl)
-		 " 2>/dev/null"
-		 "\n}"))
-	(tramp-wait-for-output)
-	(tramp-message 5 "Sending the Perl `mime-decode' implementations.")
-	(tramp-send-linewise
-	 multi-method method user host
-	 (concat "tramp_decode () {\n"
-		 (format tramp-perl-decode tramp-remote-perl)
-		 " 2>/dev/null"
-		 "\n}"))
-	(tramp-wait-for-output)
-	(tramp-send-linewise
-	 multi-method method user host
-	 (concat "tramp_decode_with_module () {\n"
-		 (format tramp-perl-decode-with-module tramp-remote-perl)
-		 " 2>/dev/null"
-		 "\n}"))
-	(tramp-wait-for-output))))
+	(unless (tramp-get-rcp-program
+		 multi-method
+		 (tramp-find-method multi-method method user host))
+	  (tramp-message 5 "Sending the Perl `mime-encode' implementations.")
+	  (tramp-send-linewise
+	   multi-method method user host
+	   (concat "tramp_encode () {\n"
+		   (format tramp-perl-encode tramp-remote-perl)
+		   " 2>/dev/null"
+		   "\n}"))
+	  (tramp-wait-for-output)
+	  (tramp-send-linewise
+	   multi-method method user host
+	   (concat "tramp_encode_with_module () {\n"
+		   (format tramp-perl-encode-with-module tramp-remote-perl)
+		   " 2>/dev/null"
+		   "\n}"))
+	  (tramp-wait-for-output)
+	  (tramp-message 5 "Sending the Perl `mime-decode' implementations.")
+	  (tramp-send-linewise
+	   multi-method method user host
+	   (concat "tramp_decode () {\n"
+		   (format tramp-perl-decode tramp-remote-perl)
+		   " 2>/dev/null"
+		   "\n}"))
+	  (tramp-wait-for-output)
+	  (tramp-send-linewise
+	   multi-method method user host
+	   (concat "tramp_decode_with_module () {\n"
+		   (format tramp-perl-decode-with-module tramp-remote-perl)
+		   " 2>/dev/null"
+		   "\n}"))
+	  (tramp-wait-for-output)))))
   ;; Find ln(1)
   (erase-buffer)
   (let ((ln (tramp-find-executable multi-method method user host
@@ -4450,26 +5138,29 @@
       (tramp-set-connection-property "ln" ln multi-method method user host)))
   (erase-buffer)
   ;; Find the right encoding/decoding commands to use.
-  (unless (tramp-get-rcp-program multi-method method)
+  (unless (tramp-get-rcp-program
+	   multi-method
+	   (tramp-find-method multi-method method user host))
     (tramp-find-inline-encoding multi-method method user host))
   ;; If encoding/decoding command are given, test to see if they work.
   ;; CCC: Maybe it would be useful to run the encoder both locally and
   ;; remotely to see if they produce the same result.
-  (let ((decoding (tramp-get-decoding-command multi-method method user host))
-	(encoding (tramp-get-encoding-command multi-method method user host))
+  (let ((rem-enc (tramp-get-remote-encoding multi-method method user host))
+	(rem-dec (tramp-get-remote-decoding multi-method method user host))
 	(magic-string "xyzzy"))
-    (when (and (or decoding encoding) (not (and decoding encoding)))
+    (when (and (or rem-dec rem-enc) (not (and rem-dec rem-enc)))
       (tramp-kill-process multi-method method user host)
+      ;; Improve error message and/or error check.
       (error
        "Must give both decoding and encoding command in method definition"))
-    (when (and decoding encoding)
+    (when (and rem-enc rem-dec)
       (tramp-message
        5
        "Checking to see if encoding/decoding commands work on remote host...")
       (tramp-send-command
        multi-method method user host
        (format "echo %s | %s | %s"
-	       (tramp-shell-quote-argument magic-string) encoding decoding))
+	       (tramp-shell-quote-argument magic-string) rem-enc rem-dec))
       (tramp-wait-for-output)
       (unless (looking-at (regexp-quote magic-string))
 	(tramp-kill-process multi-method method user host)
@@ -4483,6 +5174,20 @@
 ;; and decoding.  Then we just use that in the last item.  The other
 ;; alternative is to use the Perl version of UU encoding.  But then
 ;; we need a Lisp version of uuencode.
+;;
+;; Old text from documentation of tramp-methods:
+;; Using a uuencode/uudecode inline method is discouraged, please use one
+;; of the base64 methods instead since base64 encoding is much more
+;; reliable and the commands are more standardized between the different
+;; Unix versions.  But if you can't use base64 for some reason, please
+;; note that the default uudecode command does not work well for some
+;; Unices, in particular AIX and Irix.  For AIX, you might want to use
+;; the following command for uudecode:
+;;
+;;     sed '/^begin/d;/^[` ]$/d;/^end/d' | iconv -f uucode -t ISO8859-1
+;;
+;; For Irix, no solution is known yet.
+
 (defvar tramp-coding-commands
   '(("mimencode -b" "mimencode -u -b"
      base64-encode-region base64-decode-region)
@@ -4491,31 +5196,36 @@
     ("recode data..base64" "recode base64..data"
      base64-encode-region base64-decode-region)
     ("uuencode xxx" "uudecode -o -"
-     nil uudecode-decode-region)
+     tramp-uuencode-region uudecode-decode-region)
     ("uuencode xxx" "uudecode -p"
-     nil uudecode-decode-region)
+     tramp-uuencode-region uudecode-decode-region)
     ("uuencode xxx" "tramp_uudecode"
-     nil uudecode-decode-region)
+     tramp-uuencode-region uudecode-decode-region)
     ("tramp_encode_with_module" "tramp_decode_with_module"
      base64-encode-region base64-decode-region)
     ("tramp_encode" "tramp_decode"
      base64-encode-region base64-decode-region))
   "List of coding commands for inline transfer.
-Each item is a list (ENCODING-COMMAND DECODING-COMMAND
-ENCODING-FUNCTION DECODING-FUNCTION).
-
-Each item can be a string, giving a command, or a symbol, giving
-a function.
-
-The ENCODING-COMMAND should be a command accepting a plain file on
-standard input and writing the encoded file to standard output.  The
-DECODING-COMMAND should be a command accepting an encoded file on
-standard input and writing the decoded file to standard output.
-
-The ENCODING-FUNCTION and DECODING-FUNCTION functions will be called
-with two arguments, start and end of region, and are expected to
-replace the region contents with the encoded or decoded results,
-respectively.")
+Each item is a list that looks like this:
+
+\(REMOTE-ENCODING REMOTE-DECODING LOCAL-ENCODING LOCAL-DECODING)
+
+The REMOTE-ENCODING should be a string, giving a command accepting a
+plain file on standard input and writing the encoded file to standard
+output.  The REMOTE-DECODING should also be a string, giving a command
+accepting an encoded file on standard input and writing the decoded
+file to standard output.
+
+LOCAL-ENCODING and LOCAL-DECODING can be strings, giving commands, or
+symbols, giving functions.  If they are strings, then they can contain
+the \"%s\" format specifier.  If that specifier is present, the input
+filename will be put into the command line at that spot.  If the
+specifier is not present, the input should be read from standard
+input.
+
+If they are functions, they will be called with two arguments, start
+and end of region, and are expected to replace the region contents
+with the encoded or decoded results, respectively.")
 
 (defun tramp-find-inline-encoding (multi-method method user host)
   "Find an inline transfer encoding that works.
@@ -4525,53 +5235,44 @@
     (while (and commands (null found))
       (setq item (pop commands))
       (catch 'wont-work
-	(let ((ec (nth 0 item))
-	      (dc (nth 1 item))
-	      (ef (nth 2 item))
-	      (df (nth 3 item)))
-	  ;; Check if encoding and decoding commands can be called
-	  ;; remotely with null input and output.  This makes sure there
-	  ;; are no syntax errors and the command is really found.
+	(let ((rem-enc (nth 0 item))
+	      (rem-dec (nth 1 item))
+	      (loc-enc (nth 2 item))
+	      (loc-dec (nth 3 item)))
+	  ;; Check if remote encoding and decoding commands can be
+	  ;; called remotely with null input and output.  This makes
+	  ;; sure there are no syntax errors and the command is really
+	  ;; found.
 	  (tramp-message-for-buffer
 	   multi-method method user host 9
-	   "Checking remote encoding command `%s' for sanity" ec)
+	   "Checking remote encoding command `%s' for sanity" rem-enc)
 	  (unless (zerop (tramp-send-command-and-check
 			  multi-method method user host
-			  (format "%s </dev/null >/dev/null" ec) t))
+			  (format "%s </dev/null >/dev/null" rem-enc) t))
 	    (throw 'wont-work nil))
 	  (tramp-message-for-buffer
 	   multi-method method user host 9
-	   "Checking remote decoding command `%s' for sanity" dc)
+	   "Checking remote decoding command `%s' for sanity" rem-dec)
 	  (unless (zerop (tramp-send-command-and-check
 			  multi-method method user host
-			  (format "echo xyzzy | %s | %s >/dev/null" ec dc) t))
+			  (format "echo xyzzy | %s | %s >/dev/null"
+				  rem-enc rem-dec) t))
 	    (throw 'wont-work nil))
-	  ;; If no encoding/decoding function is given, the
-	  ;; corresponding encoding/decoding command also has to work
-	  ;; locally.
-	  (when (not (fboundp ef))
+	  ;; If the local encoder or decoder is a string, the
+	  ;; corresponding command has to work locally.
+	  (when (stringp loc-enc)
 	    (tramp-message-for-buffer
 	     multi-method method user host 9
-	     "Checking local encoding command `%s' for sanity" ec)
-	    (unless (zerop (call-process
-			    tramp-sh-program ;program
-			    nil		;input
-			    nil		;output buffer
-			    nil		;redisplay
-			    "-c"
-			    (format "%s </dev/null >/dev/null" ec)))
+	     "Checking local encoding command `%s' for sanity" loc-enc)
+	    (unless (zerop (tramp-call-local-coding-command
+			    loc-enc nil nil))
 	      (throw 'wont-work nil)))
-	  (when (not (fboundp df))
+	  (when (stringp loc-dec)
 	    (tramp-message-for-buffer
 	     multi-method method user host 9
-	     "Checking local decoding command `%s' for sanity" dc)
-	    (unless (zerop (call-process
-			    tramp-sh-program ;program
-			    nil		;input file
-			    nil		;output buffer
-			    nil		;redisplay
-			    "-c"
-			    (format "%s </dev/null >/dev/null" dc)))
+	     "Checking local decoding command `%s' for sanity" loc-dec)
+	    (unless (zerop (tramp-call-local-coding-command
+			    loc-dec nil nil))
 	      (throw 'wont-work nil)))
 	  ;; CCC: At this point, maybe we should check that the output
 	  ;; of the commands is correct.  But for the moment we will
@@ -4582,21 +5283,45 @@
     ;; set connection properties.
     (unless found
       (error "Couldn't find an inline transfer encoding"))
-    (let ((ec (nth 0 found))
-	  (dc (nth 1 found))
-	  (ef (nth 2 found))
-	  (df (nth 3 found)))
-      (tramp-set-encoding-command multi-method method user host ec)
-      (tramp-set-decoding-command multi-method method user host dc)
-      (tramp-set-encoding-function multi-method method user host ef)
-      (tramp-set-decoding-function multi-method method user host df))))
-	  
+    (let ((rem-enc (nth 0 found))
+	  (rem-dec (nth 1 found))
+	  (loc-enc (nth 2 found))
+	  (loc-dec (nth 3 found)))
+      (tramp-message 10 "Using remote encoding %s" rem-enc)
+      (tramp-set-remote-encoding multi-method method user host rem-enc)
+      (tramp-message 10 "Using remote decoding %s" rem-dec)
+      (tramp-set-remote-decoding multi-method method user host rem-dec)
+      (tramp-message 10 "Using local encoding %s" loc-enc)
+      (tramp-set-local-encoding multi-method method user host loc-enc)
+      (tramp-message 10 "Using local decoding %s" loc-dec)
+      (tramp-set-local-decoding multi-method method user host loc-dec))))
+
+(defun tramp-call-local-coding-command (cmd input output)
+  "Call the local encoding or decoding command.
+If CMD contains \"%s\", provide input file INPUT there in command.
+Otherwise, INPUT is passed via standard input.
+INPUT can also be nil which means `/dev/null'.
+OUTPUT can be a string (which specifies a filename), or t (which
+means standard output and thus the current buffer), or nil (which
+means discard it)."
+  (call-process
+   tramp-encoding-shell			;program
+   (when (and input (not (string-match "%s" cmd)))
+     input)				;input
+   (if (eq output t) t nil)		;output
+   nil					;redisplay
+   tramp-encoding-command-switch
+   ;; actual shell command
+   (concat
+    (if (string-match "%s" cmd) (format cmd input) cmd)
+    (if (stringp output) (concat "> " output) ""))))
 
 (defun tramp-maybe-open-connection (multi-method method user host)
   "Maybe open a connection to HOST, logging in as USER, using METHOD.
 Does not do anything if a connection is already open, but re-opens the
 connection if a previous connection has died for some reason."
-  (let ((p (get-buffer-process (tramp-get-buffer multi-method method user host)))
+  (let ((p (get-buffer-process
+	    (tramp-get-buffer multi-method method user host)))
 	last-cmd-time)
     ;; If too much time has passed since last command was sent, look
     ;; whether process is still alive.  If it isn't, kill it.  When
@@ -4618,7 +5343,9 @@
     (unless (and p (processp p) (memq (process-status p) '(run open)))
       (when (and p (processp p))
         (delete-process p))
-      (funcall (tramp-get-connection-function multi-method method)
+      (funcall (tramp-get-connection-function
+		multi-method
+		(tramp-find-method multi-method method user host))
                multi-method method user host))))
 
 (defun tramp-send-command
@@ -4681,7 +5408,7 @@
         (start-time (current-time))
         (end-of-output (concat "^"
                                (regexp-quote tramp-end-of-output)
-                               "$")))
+                               "\r?$")))
     ;; Algorithm: get waiting output.  See if last line contains
     ;; end-of-output sentinel.  If not, wait a bit and again get
     ;; waiting output.  Repeat until timeout expires or end-of-output
@@ -4778,6 +5505,10 @@
     (pop-to-buffer (current-buffer))
     (funcall 'signal signal (apply 'format fmt args))))
 
+;; Chunked sending kluge.
+(defvar tramp-chunksize nil
+  "If non-nil, chunksize for sending things to remote host.")
+
 (defun tramp-send-region (multi-method method user host start end)
   "Send the region from START to END to remote command
 running as USER on HOST using METHOD."
@@ -4785,7 +5516,19 @@
                (tramp-get-buffer multi-method method user host))))
     (unless proc
       (error "Can't send region to remote host -- not logged in"))
-    (process-send-region proc start end)
+    (if tramp-chunksize
+	(let ((pos start))
+	  (while (< pos end)
+	    (tramp-message-for-buffer
+	     multi-method method user host 10
+	     "Sending chunk from %s to %s" pos end)
+	    (process-send-region proc
+				 pos
+				 (min (+ pos tramp-chunksize)
+				      end))
+	    (setq pos (+ pos tramp-chunksize))
+	    (sleep-for 0.1)))
+      (process-send-region proc start end))
     (when tramp-debug-buffer
       (append-to-buffer
        (tramp-get-debug-buffer multi-method method user host)
@@ -4978,8 +5721,6 @@
 	(let ((user (match-string (nth 2 tramp-file-name-structure) name))
 	      (host (match-string (nth 3 tramp-file-name-structure) name))
 	      (path (match-string (nth 4 tramp-file-name-structure) name)))
-	  (when (not method)
-	    (setq method (tramp-find-default-method user host)))
 	  (make-tramp-file-name
 	   :multi-method nil
 	   :method method
@@ -4994,11 +5735,18 @@
 	item)
     (while choices
       (setq item (pop choices))
-      (when (and (string-match (nth 0 item) host)
+      (when (and (string-match (nth 0 item) (or host ""))
 		 (string-match (nth 1 item) (or user "")))
 	(setq method (nth 2 item))
 	(setq choices nil)))
     method))
+
+(defun tramp-find-method (multi-method method user host)
+  "Return the right method string to use.
+This is MULTI-METHOD, if non-nil.  Otherwise, it is METHOD, if non-nil.
+If both MULTI-METHOD and METHOD are nil, do a lookup in
+`tramp-default-method-alist'."
+  (or multi-method method (tramp-find-default-method user host)))
     
 ;; HHH: Not Changed.  Multi method.  Will probably not handle the case where
 ;;      a user name is not provided in the "file name" very well.
@@ -5038,15 +5786,15 @@
 
 (defun tramp-make-tramp-file-name (multi-method method user host path)
   "Constructs a tramp file name from METHOD, USER, HOST and PATH."
-  (unless tramp-make-tramp-file-format
-    (error "`tramp-make-tramp-file-format' is nil"))
   (if multi-method
       (tramp-make-tramp-multi-file-name multi-method method user host path)
-    (if user
-        (format-spec tramp-make-tramp-file-format
-                     `((?m . ,method) (?u . ,user) (?h . ,host) (?p . ,path)))
-      (format-spec tramp-make-tramp-file-user-nil-format
-                   `((?m . ,method) (?h . ,host) (?p . ,path))))))
+    (format-spec
+     (concat tramp-prefix-format
+      (when method (concat "%m" tramp-postfix-single-method-format))
+      (when user   (concat "%u" tramp-postfix-user-format))
+      (when host   (concat "%h" tramp-postfix-host-format))
+      (when path   (concat "%p")))
+    `((?m . ,method) (?u . ,user) (?h . ,host) (?p . ,path)))))
 
 ;; CCC: Henrik Holm: Not Changed.  Multi Method.  What should be done
 ;; with this when USER is nil?
@@ -5081,11 +5829,13 @@
       (format "/%s@%s:%s" user host path)
     (format "/%s:%s" host path)))
 
-(defun tramp-method-out-of-band-p (multi-method method)
+(defun tramp-method-out-of-band-p (multi-method method user host)
   "Return t if this is an out-of-band method, nil otherwise.
 It is important to check for this condition, since it is not possible
 to enter a password for the `tramp-rcp-program'."
-  (tramp-get-rcp-program multi-method method))
+  (tramp-get-rcp-program
+   multi-method
+   (tramp-find-method multi-method method user host)))
 
 ;; Variables local to connection.
 
@@ -5136,136 +5886,113 @@
 	  value)))
 
 ;; Some predefined connection properties.
-(defun tramp-get-encoding-command (multi-method method user host)
-  (tramp-get-connection-property "encoding-command" nil
+(defun tramp-set-remote-encoding (multi-method method user host rem-enc)
+  (tramp-set-connection-property "remote-encoding" rem-enc
 				 multi-method method user host))
-(defun tramp-set-encoding-command (multi-method method user host command)
-  (tramp-set-connection-property "encoding-command" command
+(defun tramp-get-remote-encoding (multi-method method user host)
+  (tramp-get-connection-property "remote-encoding" nil
 				 multi-method method user host))
-(defun tramp-get-decoding-command (multi-method method user host)
-  (tramp-get-connection-property "decoding-command" nil
+
+(defun tramp-set-remote-decoding (multi-method method user host rem-dec)
+  (tramp-set-connection-property "remote-decoding" rem-dec
 				 multi-method method user host))
-(defun tramp-set-decoding-command (multi-method method user host command)
-  (tramp-set-connection-property "decoding-command" command
+(defun tramp-get-remote-decoding (multi-method method user host)
+  (tramp-get-connection-property "remote-decoding" nil
 				 multi-method method user host))
-(defun tramp-get-encoding-function (multi-method method user host)
-  (tramp-get-connection-property "encoding-function" nil
+
+(defun tramp-set-local-encoding (multi-method method user host loc-enc)
+  (tramp-set-connection-property "local-encoding" loc-enc
 				 multi-method method user host))
-(defun tramp-set-encoding-function (multi-method method user host func)
-  (tramp-set-connection-property "encoding-function" func
+(defun tramp-get-local-encoding (multi-method method user host)
+  (tramp-get-connection-property "local-encoding" nil
 				 multi-method method user host))
-(defun tramp-get-decoding-function (multi-method method user host)
-  (tramp-get-connection-property "decoding-function" nil
+
+(defun tramp-set-local-decoding (multi-method method user host loc-dec)
+  (tramp-set-connection-property "local-decoding" loc-dec
 				 multi-method method user host))
-(defun tramp-set-decoding-function (multi-method method user host func)
-  (tramp-set-connection-property "decoding-function" func
+(defun tramp-get-local-decoding (multi-method method user host)
+  (tramp-get-connection-property "local-decoding" nil
 				 multi-method method user host))
 
 
-(defun tramp-get-connection-function (multi-method method)
+
+(defun tramp-get-connection-function (multi-method method user host)
   (second (or (assoc 'tramp-connection-function
-                     (assoc (or multi-method method tramp-default-method)
+                     (assoc (tramp-find-method multi-method method user host)
                             tramp-methods))
               (error "Method `%s' didn't specify a connection function"
                      (or multi-method method)))))
 
-(defun tramp-get-remote-sh (multi-method method)
+(defun tramp-get-remote-sh (multi-method method user host)
   (second (or (assoc 'tramp-remote-sh
-                     (assoc (or multi-method method tramp-default-method)
+                     (assoc (tramp-find-method multi-method method user host)
                             tramp-methods))
               (error "Method `%s' didn't specify a remote shell"
                      (or multi-method method)))))
 
-(defun tramp-get-rsh-program (multi-method method)
+(defun tramp-get-rsh-program (multi-method method user host)
   (second (or (assoc 'tramp-rsh-program
-                     (assoc (or multi-method method tramp-default-method)
+                     (assoc (tramp-find-method multi-method method user host)
                             tramp-methods))
               (error "Method `%s' didn't specify an rsh program"
                      (or multi-method method)))))
 
-(defun tramp-get-rsh-args (multi-method method)
+(defun tramp-get-rsh-args (multi-method method user host)
   (second (or (assoc 'tramp-rsh-args
-                     (assoc (or multi-method method tramp-default-method)
+                     (assoc (tramp-find-method multi-method method user host)
                             tramp-methods))
               (error "Method `%s' didn't specify rsh args"
                      (or multi-method method)))))
 
-(defun tramp-get-rcp-program (multi-method method)
+(defun tramp-get-rcp-program (multi-method method user host)
   (second (or (assoc 'tramp-rcp-program
-                     (assoc (or multi-method method tramp-default-method)
+                     (assoc (tramp-find-method multi-method method user host)
                             tramp-methods))
               (error "Method `%s' didn't specify an rcp program"
                      (or multi-method method)))))
 
-(defun tramp-get-rcp-args (multi-method method)
+(defun tramp-get-rcp-args (multi-method method user host)
   (second (or (assoc 'tramp-rcp-args
-                     (assoc (or multi-method method tramp-default-method)
+                     (assoc (tramp-find-method multi-method method user host)
                             tramp-methods))
               (error "Method `%s' didn't specify rcp args"
                      (or multi-method method)))))
 
-(defun tramp-get-rcp-keep-date-arg (multi-method method)
+(defun tramp-get-rcp-keep-date-arg (multi-method method user host)
   (second (or (assoc 'tramp-rcp-keep-date-arg
-                     (assoc (or multi-method method tramp-default-method)
+                     (assoc (tramp-find-method multi-method method user host)
                             tramp-methods))
               (error "Method `%s' didn't specify `keep-date' arg for tramp"
                      (or multi-method method)))))
 
-(defun tramp-get-su-program (multi-method method)
+(defun tramp-get-su-program (multi-method method user host)
   (second (or (assoc 'tramp-su-program
-                     (assoc (or multi-method method tramp-default-method)
+                     (assoc (tramp-find-method multi-method method user host)
                             tramp-methods))
               (error "Method `%s' didn't specify a su program"
                      (or multi-method method)))))
 
-(defun tramp-get-su-args (multi-method method)
+(defun tramp-get-su-args (multi-method method user host)
   (second (or (assoc 'tramp-su-args
-                     (assoc (or multi-method method tramp-default-method)
+                     (assoc (tramp-find-method multi-method method user host)
                             tramp-methods))
               (error "Method `%s' didn't specify su args"
                      (or multi-method method)))))
 
-(defun tramp-get-telnet-program (multi-method method)
+(defun tramp-get-telnet-program (multi-method method user host)
   (second (or (assoc 'tramp-telnet-program
-                     (assoc (or multi-method method tramp-default-method)
+                     (assoc (tramp-find-method multi-method method user host)
                             tramp-methods))
               (error "Method `%s' didn't specify a telnet program"
                      (or multi-method method)))))
 
-(defun tramp-get-telnet-args (multi-method method)
+(defun tramp-get-telnet-args (multi-method method user host)
   (second (or (assoc 'tramp-telnet-args
-                     (assoc (or multi-method method tramp-default-method)
+                     (assoc (tramp-find-method multi-method method user host)
                             tramp-methods))
               (error "Method `%s' didn't specify telnet args"
                      (or multi-method method)))))
 
-;; (defun tramp-get-encoding-command (multi-method method)
-;;   (second (or (assoc 'tramp-encoding-command
-;;                      (assoc (or multi-method method tramp-default-method)
-;;                             tramp-methods))
-;;               (error "Method `%s' didn't specify an encoding command"
-;;                      (or multi-method method)))))
-
-;; (defun tramp-get-decoding-command (multi-method method)
-;;   (second (or (assoc 'tramp-decoding-command
-;;                      (assoc (or multi-method method tramp-default-method)
-;;                             tramp-methods))
-;;               (error "Method `%s' didn't specify a decoding command"
-;;                      (or multi-method method)))))
-
-;; (defun tramp-get-encoding-function (multi-method method)
-;;   (second (or (assoc 'tramp-encoding-function
-;;                      (assoc (or multi-method method tramp-default-method)
-;;                             tramp-methods))
-;;               (error "Method `%s' didn't specify an encoding function"
-;;                      (or multi-method method)))))
-
-;; (defun tramp-get-decoding-function (multi-method method)
-;;   (second (or (assoc 'tramp-decoding-function
-;;                      (assoc (or multi-method method tramp-default-method)
-;;                             tramp-methods))
-;;               (error "Method `%s' didn't specify a decoding function"
-;;                      (or multi-method method)))))
 
 ;; Auto saving to a special directory.
 
@@ -5463,20 +6190,16 @@
 ;;       nil
 ;;     ad-do-it))
 
-;; We currently use "[" and "]" in the filename format.  In Emacs
-;; 20.x, this means that Emacs wants to expand wildcards if
+;; We currently (sometimes) use "[" and "]" in the filename format.
+;; This means that Emacs wants to expand wildcards if
 ;; `find-file-wildcards' is non-nil, and then barfs because no
 ;; expansion could be found.  We detect this situation and do
 ;; something really awful: we have `file-expand-wildcards' return the
 ;; original filename if it can't expand anything.  Let's just hope
 ;; that this doesn't break anything else.
-;;
-;; Another problem is that the check is done by Emacs version, which
-;; is really not what we want to do.  Oh, well.
-
-;;(when (and (not (featurep 'xemacs))
-;;	   (= emacs-major-version 20))
-;; It seems that this advice is needed in Emacs 21, too.
+;; CCC: This check is now also really awful; we should search all
+;; of the filename format, not just the prefix.
+(when (string-match "\\[" tramp-prefix-format)
 (defadvice file-expand-wildcards (around tramp-fix activate)
   (let ((name (ad-get-arg 0)))
     (if (tramp-tramp-file-p name)
@@ -5490,7 +6213,7 @@
       ;; If it is not a Tramp file, just run the original function.
       (let ((res ad-do-it))
 	(setq ad-return-value (or res (list name)))))))
-;;  )
+)
 
 ;; Tramp version is useful in a number of situations.
 
@@ -5526,6 +6249,7 @@
        tramp-auto-save-directory        ; vars to dump
        tramp-default-method
        tramp-rsh-end-of-line
+       tramp-password-end-of-line
        tramp-remote-path
        tramp-login-prompt-regexp
        tramp-password-prompt-regexp
@@ -5539,7 +6263,7 @@
        tramp-multi-file-name-hop-structure
        tramp-multi-methods
        tramp-multi-connection-function-alist
-       tramp-make-tramp-file-format
+       tramp-methods
        tramp-end-of-output
        tramp-coding-commands
        tramp-actions-before-shell
@@ -5587,6 +6311,7 @@
 
 ;;; TODO:
 
+;; * Autodetect if remote `ls' groks the "--dired" switch.
 ;; * Add fallback for inline encodings.  This should be used
 ;;   if the remote end doesn't support mimencode or a similar program.
 ;;   For reading files from the remote host, we can just parse the output
@@ -5599,6 +6324,9 @@
 ;;   two commands to write a null byte:
 ;;   dd if=/dev/zero bs=1 count=1
 ;;   echo | tr '\n' '\000'
+;; * Separate local `tramp-coding-commands' from remote ones.  Connect
+;;   the two via a format which can be `uu' or `b64'.  Then we can search
+;;   for the right local commands and the right remote commands separately.
 ;; * Cooperate with PCL-CVS.  It uses start-process, which doesn't
 ;;   work for remote files.
 ;; * Rewrite `tramp-shell-quote-argument' to abstain from using
@@ -5684,6 +6412,25 @@
 ;;   about Tramp, it does not do the right thing if the target file
 ;;   name is a Tramp name.
 ;; * Username and hostname completion.
+;; ** If `partial-completion-mode' isn't loaded, "/foo:bla" tries to
+;;    connect to host "blabla" already if that host is unique. No idea
+;;    how to suppress. Maybe not an essential problem.
+;; ** For "/ssh1-old:", `(file-name-all-completions "ssh1" "/")' is called
+;;    only. Likely due to word delimeter property of "-". Maybe we can remove
+;;    all the "*-old" methods? Or rename them to "*_old"?
+;; ** Try to avoid usage of `last-input-event' in `tramp-completion-mode'.
+;; ** Handle quoted file names, starting with "/:". Problem is that
+;;    `file-name-non-special' calls later on `file-name-all-completions'
+;;    without ":". Hmm. Worth a bug report?
+;; ** Acknowledge port numbers.
+;; ** Extend `tramp-get-completion-su' for NIS and shadow passwords.
+;; ** Unify `tramp-parse-{rhosts,shosts,hosts,passwd}'.
+;;    Code is nearly identical.
+;; ** Decide whiche files to take for searching user/host names depending on
+;;    operating system (windows-nt) in `tramp-completion-function-alist'.
+;; ** Enhance variables for debug.
+;; ** Implement "/multi:" completion.
+;; ** Add a learning mode for completion. Make results persistent.
 
 ;; Functions for file-name-handler-alist:
 ;; diff-latest-backup-file -- in diff.el
--- a/man/tramp.texi	Sun Sep 22 13:01:10 2002 +0000
+++ b/man/tramp.texi	Sun Sep 22 13:23:36 2002 +0000
@@ -8,6 +8,12 @@
 @c This is *so* much nicer :)
 @footnotestyle end
 
+@c In the Tramp CVS, the version number is auto-frobbed from the
+@c Makefile, so you should edit the top-level Makefile to change
+@c the version number.
+@macro trampver{}
+2.0.20
+@end macro
 
 @c Entries for @command{install-info} to use
 @dircategory Emacs
@@ -21,39 +27,46 @@
 @sc{tramp}
 @end macro
 
-@c Copying permissions, et al
-@copying
-This file documents @tramp{}, a remote file editing package for Emacs and
-XEmacs.
-     
-Copyright @copyright{} 1999, 2000, 2001, 2002 Free Software
-Foundation, Inc.
-
-@quotation     
-Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.1 or
-any later version published by the Free Software Foundation; with no
-Invariant Sections, with the Front-Cover texts being ``A GNU
-Manual'', and with the Back-Cover Texts as in (a) below.  A copy of the
-license is included in the section entitled ``GNU Free Documentation
-License'' in the Emacs manual.
-
-(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
-this GNU Manual, like GNU software.  Copies published by the Free
-Software Foundation raise funds for GNU development.''
-
-This document is part of a collection distributed under the GNU Free
-Documentation License.  If you want to distribute this document
-separately from the collection, you can do so by adding a copy of the
-license to the document, as described in section 6 of the license.
-@end quotation
-@end copying
-
+@c Distinguish between GNU Emacs and XEmacs.  Derived from the
+@c Makefile variable $(EMACS-ID).  Valid values are `emacs' and `xemacs'.
+@set emacs
+
+@c Some flags which make the text independent on the (X)Emacs flavor.
+@c GNU Emacs values.
+@ifset emacs
+@set emacs-name               Emacs
+@set emacs-dir                emacs
+@set ftp-package-name         Ange-FTP
+@set tramp-prefix             /
+@set tramp-prefix-single-hop
+@set tramp-postfix            :
+@set tramp-postfix-single-hop :
+@set tramp-postfix-multi-hop  :
+@end ifset
+
+@c XEmacs counterparts.
+@ifset xemacs
+@set emacs-name               XEmacs
+@set emacs-dir                xemacs
+@set ftp-package-name         EFS
+@set tramp-prefix             /[
+@set tramp-prefix-single-hop  [
+@set tramp-postfix            ]
+@set tramp-postfix-single-hop /
+@set tramp-postfix-multi-hop  :
+@end ifset
+
+@c Macros for formatting a filename.
+@c trampfn is for a full filename, trampfnmhp means method, host, path
+@c were given, and so on.
+@macro trampfn(method, user, host, path)
+@value{tramp-prefix}@value{method}@value{user}@@@value{host}@value{tramp-postfix}@value{path}
+@end macro
 
 @tex
 
 @titlepage
-@title @tramp{} User Manual
+@title @tramp{} version @trampver{} User Manual
 
 @author by Daniel Pittman
 @author based on documentation by Kai Gro@ss{}johann
@@ -66,16 +79,19 @@
 
 @ifnottex
 @node Top, Overview, (dir), (dir)
-@top @tramp{} User Manual
+@top @tramp{} version @trampver{} User Manual
+
+This file documents @tramp{} version @trampver{}, a remote file
+editing package for @value{emacs-name}.
 
 @tramp{} stands for `Transparent Remote (file) Access, Multiple
 Protocol'.  This package provides remote file editing, similar to
-@cite{Ange-FTP} and @cite{EFS}.
-
-The difference is that Ange-FTP uses FTP to transfer files between the
-local and the remote host, whereas @tramp{} uses a combination of
-@command{rsh} and @command{rcp} or other work-alike programs, such as
-@command{ssh}/@command{scp}.
+@value{ftp-package-name}.
+
+The difference is that @value{ftp-package-name} uses FTP to transfer
+files between the local and the remote host, whereas @tramp{} uses a
+combination of @command{rsh} and @command{rcp} or other work-alike
+programs, such as @command{ssh}/@command{scp}.
 
 You can find the latest version of this document on the web at
 @uref{http://www.freesoftware.fsf.org/tramp/}.
@@ -102,20 +118,21 @@
 
 @menu
 * Overview::                    What @tramp{} can and cannot do.
+* Copying::                     The license for this documentation.
 
 For the end user:
 * Obtaining @tramp{}::          How to obtain @tramp{}.
-* History::                     History of @tramp{}
-* Installation::                Installing @tramp{} with your (X)Emacs.
+* History::                     History of @tramp{}.
+* Installation::                Installing @tramp{} with your @value{emacs-name}.
 * Configuration::               Configuring @tramp{} for use.
 * Usage::                       An overview of the operation of @tramp{}.
-* Bug Reports::                 Reporting Bugs and Problems
+* Bug Reports::                 Reporting Bugs and Problems.
 * Frequently Asked Questions::  Questions and answers from the mailing list.
 
 For the developer:
 * Version Control::             The inner workings of remote version control.
 * Files directories and paths::  How file names, directories and paths are mangled and managed.
-* Issues::                      
+* Issues::                      Debatable Issues and What Was Decided.
 
 @detailmenu
  --- The Detailed Node Listing ---
@@ -128,14 +145,17 @@
 * Multi-hop Methods::           Connecting to a remote host using multiple hops.
 * Default Method::              Selecting a default method.
 * Customizing Methods::         Using Non-Standard Methods.
+* Customizing Completion::      Selecting config files for user/host name completion.
 * Remote Programs::             How @tramp{} finds and uses programs on the remote machine.
-* Remote shell setup::          
+* Remote shell setup::          Remote shell setup hints.
+* Windows setup hints::         Issues with Cygwin ssh.
 
 Using @tramp
 
 * Filename Syntax::             @tramp{} filename conventions.
-* Multi-hop filename syntax::   Multi-hop filename conventions
-* Dired::                       Dired and filename completion.
+* Multi-hop filename syntax::   Multi-hop filename conventions.
+* Filename completion::         Filename completion.
+* Dired::                       Dired.
 
 The inner workings of remote version control
 
@@ -143,7 +163,7 @@
 * Remote Commands::             Executing the version control commands on the remote machine.
 * Changed workfiles::           Detecting if the working file has changed.
 * Checking out files::          Bringing the workfile out of the repository.
-* Miscellaneous Version Control::  Things related to Version Control that don't fit elsewhere
+* Miscellaneous Version Control::  Things related to Version Control that don't fit elsewhere.
 
 Things related to Version Control that don't fit elsewhere
 
@@ -157,15 +177,14 @@
 @end detailmenu
 @end menu
 
-
 @node Overview
 @chapter An overview of @tramp
 @cindex overview
 
-After the installation of @tramp{} into your Emacs, you will be able
-to access files on remote machines as though they were local.  Access
-to the remote file system for editing files, version control, and
-@command{dired} are transparently enabled.
+After the installation of @tramp{} into your @value{emacs-name}, you
+will be able to access files on remote machines as though they were
+local.  Access to the remote file system for editing files, version
+control, and @command{dired} are transparently enabled.
 
 Your access to the remote machine can be with the @command{rsh},
 @command{rlogin}, @command{telnet} programs or with any similar
@@ -229,8 +248,9 @@
 @tramp{} discovers that it needs a connection to the host.  So it
 invokes @samp{telnet @var{host}} or @samp{rsh @var{host} -l
 @var{user}} or a similar tool to connect to the remote host.
-Communication with this process happens through an Emacs buffer, that
-is, the output from the remote end goes into a buffer.
+Communication with this process happens through an
+@value{emacs-name} buffer, that is, the output from the remote end
+goes into a buffer.
 
 @item
 The remote host may prompt for a login name (for @command{telnet}).  The
@@ -254,8 +274,8 @@
 say), then it issues an error message saying that it couldn't find the
 remote shell prompt and shows you what the remote host has sent.
 
-If @tramp{} sees a `login failed' message, it tells you so, aborts the
-login attempt and allows you to try again.
+If @tramp{} sees a @samp{login failed} message, it tells you so,
+aborts the login attempt and allows you to try again.
 
 @item
 Suppose that the login was successful and @tramp{} sees the shell prompt
@@ -293,10 +313,12 @@
 buffer that's used for communication, then decodes that output to
 produce the file contents.
 
-For out-of-band transfers, @tramp{} issues a command like @samp{rcp
-user@@host:/path/to/remote/file /tmp/tramp.4711} and then reads the local
-temporary file @file{/tmp/tramp.4711} into a buffer and deletes the
-temporary file.
+For out-of-band transfers, @tramp{} issues a command like the following:
+@example
+rcp user@@host:/path/to/remote/file /tmp/tramp.4711
+@end example
+It then reads the local temporary file @file{/tmp/tramp.4711} into a
+buffer and deletes the temporary file.
 
 @item
 You now edit the buffer contents, blithely unaware of what has happened
@@ -314,6 +336,36 @@
 behind the scenes when you open a file with @tramp{}.
 
 
+@c Copying permissions, et al
+@node Copying
+@chapter Copying.
+@cindex copying
+
+@copying
+Copyright @copyright{} 1999, 2000, 2001, 2002 Free Software
+Foundation, Inc.
+
+@quotation     
+Permission is granted to copy, distribute and/or modify this document
+under the terms of the GNU Free Documentation License, Version 1.1 or
+any later version published by the Free Software Foundation; with no
+Invariant Sections, with the Front-Cover texts being ``A GNU
+Manual'', and with the Back-Cover Texts as in (a) below.  A copy of the
+license is included in the section entitled ``GNU Free Documentation
+License'' in the Emacs manual.
+
+(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
+this GNU Manual, like GNU software.  Copies published by the Free
+Software Foundation raise funds for GNU development.''
+
+This document is part of a collection distributed under the GNU Free
+Documentation License.  If you want to distribute this document
+separately from the collection, you can do so by adding a copy of the
+license to the document, as described in section 6 of the license.
+@end quotation
+@end copying
+
+
 @c For the end user
 @node Obtaining @tramp{}
 @chapter Obtaining @tramp{}.
@@ -333,13 +385,18 @@
 new issues. Use these versions at your own risk.
 
 Instructions for obtaining the latest development version of @tramp{}
-from CVS can be found by going to the Savannah project page at
-@uref{http://savannah.gnu.org/projects/tramp/} and then clicking on the
-CVS link in the navigation bar at the top.  Or follow the example
-session below:
+from CVS can be found by going to the Savannah project page at the
+following URL and then clicking on the CVS link in the navigation bar at
+the top.
+
+@noindent
+@uref{http://savannah.gnu.org/projects/tramp/}
+
+@noindent
+Or follow the example session below:
 
 @example
-] @strong{cd ~/lisp}
+] @strong{cd ~/@value{emacs-dir}}
 ] @strong{cvs -d:pserver:anoncvs@@subversions.gnu.org:/cvsroot/tramp login}
 
 (Logging in to anoncvs@@subversions.gnu.org)
@@ -349,12 +406,13 @@
 ] @strong{cvs -z3 -d:pserver:anoncvs@@subversions.gnu.org:/cvsroot/tramp co tramp}
 @end example
 
-You should now have a directory @file{~/lisp/tramp} containing the latest
+@noindent
+You should now have a directory @file{~/@value{emacs-dir}/tramp} containing the latest
 version of @tramp{}. You can fetch the latest updates from the repository
 by issuing the command:
 
 @example
-] @strong{cd ~/lisp/tramp}
+] @strong{cd ~/@value{emacs-dir}/tramp}
 ] @strong{cvs update -d}
 @end example
 
@@ -378,111 +436,122 @@
 
 
 @node Installation
-@chapter Installing @tramp{} into Emacs or XEmacs
+@chapter Installing @tramp{} into @value{emacs-name}.
 @cindex installation
 
-If you use the version that comes with your Emacs or the XEmacs
-package, the following information is not necessary.  Installing
-@tramp{} into your Emacs or XEmacs is a relatively easy process, at
-least compared to rebuilding your machine from scratch. ;)
+If you use the version that comes with your @value{emacs-name}, the
+following information is not necessary.  Installing @tramp{} into your
+@value{emacs-name} is a relatively easy process, at least compared
+to rebuilding your machine from scratch. ;)
 
 Seriously though, the installation should be a fairly simple matter.
 
 The easiest way to proceed is as follows:
 
-@itemize
+@itemize @bullet
 @item
-Choose a directory, say @file{~/emacs/}.  Change into that directory and
+Choose a directory, say @file{~/@value{emacs-dir}/}.  Change into that directory and
 unpack the tarball.  This will give you a directory
-@file{~/emacs/tramp/} which contains subdirectories @file{lisp} for the
+@file{~/@value{emacs-dir}/tramp/} which contains subdirectories @file{lisp} for the
 Lisp code and @file{texi} for the documentation.
 
 @item
 Optionally byte-compile all files in the Lisp directory,
-@file{~/emacs/tramp/lisp/}, by issuing a command like the following from
-the top level directory @file{~/emacs/tramp/}:
+@file{~/@value{emacs-dir}/tramp/lisp/}, by issuing a command like the following from
+the top level directory @file{~/@value{emacs-dir}/tramp/}:
+
 @example
-make EMACS=emacs all            # for Emacs users
-make EMACS=xemacs all           # for XEmacs users
+make EMACS=@value{emacs-dir} all
 @end example
 
 @item
-NOTE:
-@example
-If you run into problems running the example @command{make}
-commands, don't dispare.  You can still byte compile the
-@file{*.el} files by opening emacs in @command{dired}
-(@command{C-x d}) mode, at @file{~/tramp/lisp}.  Mark the lisp
-files with @kbd{m}, then press @kbd{B} to byte compile
-your selections.
-
-Something similar can be done to create the info manual.  
-Just cd to @file{~/emacs/tramp/texi} and load the @file{tramp.texi}
-file in emacs.  Then press @kbd{M-x makeinfo-buffer <RET>}
-to generate @file{tramp.info}.
-@end example     
+NOTE: If you run into problems running the example @command{make}
+command, don't dispare.  You can still byte compile the @file{*.el}
+files by opening @value{emacs-name} in @command{dired} (@command{C-x
+d}) mode, at @file{~/@value{emacs-dir}/tramp/lisp}.  Mark the lisp files with
+@kbd{m}, then press @kbd{B} to byte compile your selections.
+
+Something similar can be done to create the info manual.  Just change
+to directory @file{~/@value{emacs-dir}/tramp/texi} and load the
+@file{tramp.texi} file in @value{emacs-name}.  Then press @kbd{M-x
+makeinfo-buffer @key{RET}} to generate @file{tramp.info}.
 
 @item
-Tell Emacs about the new Lisp directory and the @tramp{} package 
-with the following lines in @file{~/.emacs}:
+Tell @value{emacs-name} about the new Lisp directory and the
+@tramp{} package with the following lines in @file{~/.emacs}:
+
 @lisp
-(add-to-list 'load-path "~/emacs/tramp/lisp/")
+(add-to-list 'load-path "~/@value{emacs-dir}/tramp/lisp/")
 (require 'tramp)
 @end lisp
 
 @item
 To be able to read the Info documentation, create a file
-@file{~/emacs/tramp/texi/dir} using for example the
-@command{install-info} command, and add the directory to the search 
+@file{~/@value{emacs-dir}/tramp/texi/dir} using the
+@command{install-info} command, and add the directory to the search
 path for Info.
 
-@item
 NOTE:
+On systems using the @cite{gnu} version of @command{install-info}, the
+@command{install-info} syntax is very direct and simple.  One can
+change to directory @file{~/@value{emacs-dir}/tramp/texi} and type:
+
 @example
-On systems using `gnu' @command{install-info}, the
-@command{install-info} syntax is very direct and simple.  One can 
-cd to @file{~/emacs/tramp/texi} and type:
-    @kbd{install-info tramp.info dir}
+install-info tramp.info dir
+@end example
+
 and a @file{dir} file will be created with the @tramp{}
 entry.  The info reader will know how to interpret it, but must
 be told where to find it (see below).  If you want anything fancier
 you'll need to look through @kbd{man install-info}.
 
-Debian gnu/linux doesn't default to `gnu' @command{install-info} and
-uses its own version.  This version does not create a @file{dir} file
-for you from scratch.  You must provide a skeleton dir file it
-recognizes.  One can be found in a default install at
-@file{/usr/info/dir}.  Copy the top of this file down to the first
-occurrence of `* Menu' including that line plus one more blank line,
-to your working directory @file{texi/dir}, or use the sample provided
-in the @file{texi} directory of this distribution.  See
-@file{texi/dir_sample}
-
-Once a @file{dir} file is in place, this command will make the entry.
-     install-info --infodir=. tramp.info
-If you want it in a specific category
-   (see @kbd{man install-info} for further details)
+Debian gnu/linux doesn't default to @cite{gnu} @command{install-info}
+and uses its own version.  This version does not create a @file{dir}
+file for you from scratch.  You must provide a skeleton @file{dir}
+file it recognizes.  One can be found in a default installation of
+@value{emacs-name} at @file{/usr/info/dir}.  Copy the top of this file
+down to the first occurrence of @code{* Menu} including that line plus
+one more blank line, to your working directory
+@file{~/@value{emacs-dir}/tramp/texi}, or use the sample
+@file{~/@value{emacs-dir}/tramp/texi/dir_sample}.
+
+Once a @file{dir} file is in place, this command will make the entry:
+
+@example
+install-info --infodir=. tramp.info
 @end example
 
+If you want it in a specific category see @kbd{man install-info} for
+further details.
+
 If the environment variable @env{INFOPATH} is set, add the directory
-@file{~/emacs/tramp/texi/} to it.  Else, add the directory to
+@file{~/@value{emacs-dir}/tramp/texi/} to it.  Else, add the directory to
+@ifset emacs
 @code{Info-default-directory-list}, as follows:
+
 @lisp
-(add-to-list 'Info-default-directory-list "~/emacs/tramp/texi/")
+(add-to-list 'Info-default-directory-list "~/@value{emacs-dir}/tramp/texi/")
 @end lisp
-XEmacs 21 users should use @code{Info-directory-list} rather than
-@code{Info-default-directory-list}.
+@end ifset
+@ifset xemacs
+@code{Info-directory-list}, as follows:
+@lisp
+(add-to-list 'Info-directory-list "~/@value{emacs-dir}/tramp/texi/")
+@end lisp
+@end ifset
 
 @end itemize
 
-
-For XEmacs users, the package @file{fsf-compat} must be installed.
+@ifset xemacs
+For @value{emacs-name}, the package @file{fsf-compat} must be installed.
 For details on package installation, see @ref{Packages, , ,xemacs}.
 @ifhtml
-(If the previous link doesn't work, try the XEmacs documentation at
-@uref{http://www.xemacs.org/Documentation/packageGuide.html,the XEmacs
-site}.)
+(If the previous link doesn't work, try the @value{emacs-name}
+documentation at
+@uref{http://www.xemacs.org/Documentation/packageGuide.html,the
+@value{emacs-name} site}.)
 @end ifhtml
+@end ifset
 
 @node Configuration
 @chapter Configuring @tramp{} for use
@@ -490,7 +559,7 @@
 
 @cindex default configuration
 @tramp{} is (normally) fully functional when it is initially
-installed.  It is initially configured to use the @command{sh} program
+installed.  It is initially configured to use the @command{ssh} program
 to connect to the remote host and to use base-64 encoding (on the
 remote host, via @command{mimencode}, and on the local host via the
 built-in support for base-64 encoding in Emacs).
@@ -513,6 +582,7 @@
 * Multi-hop Methods::           Connecting to a remote host using multiple hops.
 * Default Method::              Selecting a default method.
 * Customizing Methods::         Using Non-Standard Methods.
+* Customizing Completion::      Selecting config files for user/host name completion.
 * Remote Programs::             How @tramp{} finds and uses programs on the remote machine.
 * Remote shell setup::          Remote shell setup hints.
 * Windows setup hints::         Issues with Cygwin ssh.
@@ -541,9 +611,9 @@
 @cindex methods, external transfer
 @cindex methods, out-of-band
 Loading or saving a remote file requires that the content of the file
-be transferred between the two machines. The content of the file can be
-transferred over the same connection used to log in to the remote
-machine or the file can be transferred through another connection using
+be transfered between the two machines. The content of the file can be
+transfered over the same connection used to log in to the remote
+machine or the file can be transfered through another connection using
 a remote copy program such as @command{rcp}, @command{scp} or
 @command{rsync}.  The former are called @dfn{inline methods}, the
 latter are called @dfn{out-of-band methods} or @dfn{external transfer
@@ -643,7 +713,7 @@
 that use the @command{ssh1} and @command{ssh2} commands explicitly. If
 you don't know what these are, you do not need these options.
 
-All the methods based on @command{ssh} have an additional kludgey
+All the methods based on @command{ssh} have an additional kludgy
 feature: you can specify a host name which looks like @file{host#42}
 (the real host name, then a hash sign, then a port number).  This
 means to connect to the given host but to also pass @code{-p 42} as
@@ -776,7 +846,7 @@
 As you expect, this is similar to @option{sm}, only a little
 different.  Whereas @option{sm} opens a normal interactive shell on
 the remote host, this option uses @samp{ssh -t -t @var{host} -l
-@var{user} /bin/sh} tp open a connection.  This is useful for users
+@var{user} /bin/sh} to open a connection.  This is useful for users
 where the normal login shell is set up to ask them a number of
 questions when logging in.  This procedure avoids these questions, and
 just gives @tramp{} a more-or-less `standard' login shell to work
@@ -901,7 +971,7 @@
 session can begin to absorb the advantage that the lack of encoding and
 decoding presents.
 
-All the @command{ssh} based methods support the kludgey @samp{-p}
+All the @command{ssh} based methods support the kludgy @samp{-p}
 feature where you can specify a port number to connect to in the host
 name.  For example, the host name @file{host#42} tells Tramp to
 specify @samp{-p 42} in the argument list for @command{ssh}.
@@ -1097,11 +1167,12 @@
 example:
 
 @lisp
-(add-to-list 'tramp-multi-connection-function-alist
-             '("sshf" tramp-multi-connect-rlogin "ssh %h -l %u -p 4400%n"))
+(add-to-list
+ 'tramp-multi-connection-function-alist
+ '("sshf" tramp-multi-connect-rlogin "ssh %h -l %u -p 4400%n"))
 @end lisp
 
-Now you can use a @code{sshf} hop which connects to port 4400 instead of
+Now you can use an @code{sshf} hop which connects to port 4400 instead of
 the standard port.
 
 
@@ -1175,6 +1246,105 @@
 variable, accessible with @kbd{C-h v tramp-methods @key{RET}}.
 
 
+@node Customizing Completion
+@section Selecting config files for user/host name completion
+@cindex customizing completion
+@cindex selecting config files
+@vindex tramp-completion-function-alist
+
+The variable @code{tramp-completion-function-alist} is intended to
+customize, which files are taken into account for user and host name
+completion (@pxref{Filename completion}).  For every method, it keeps
+a set of configuration files, accompanied by a Lisp function able to
+parse that file.  Entries in @code{tramp-completion-function-alist}
+have the form (@var{method} @var{pair1} @var{pair2} ...).
+
+Each @var{pair} is composed of (@var{function} @var{file}).
+@var{function} is responsible to extract user names and host names
+from @var{file} for completion.  There are two functions which access
+this variable:
+
+@defun tramp-get-completion-function method
+This function returns the list of completion functions for @var{method}.
+
+Example:
+@example
+(tramp-get-completion-function "rsh")
+
+     @result{} ((tramp-parse-rhosts "/etc/hosts.equiv")
+         (tramp-parse-rhosts "~/.rhosts"))
+@end example
+@end defun
+
+@defun tramp-set-completion-function method function-list
+This function sets @var{function-list} as list of completion functions
+for @var{method}. 
+
+Example:
+@example
+(tramp-set-completion-function "ssh"
+ '((tramp-parse-shosts "/etc/ssh_known_hosts")
+   (tramp-parse-shosts "~/.ssh/known_hosts")))
+
+     @result{} ((tramp-parse-shosts "/etc/ssh_known_hosts")
+         (tramp-parse-shosts "~/.ssh/known_hosts"))
+@end example
+@end defun
+
+The following predefined functions parsing configuration files exists:
+
+@table @asis
+@item @code{tramp-parse-rhosts}
+@findex tramp-parse-rhosts
+
+This function parses files which are syntactical equivalent to
+@file{~/.rhosts}.  It returns both host names and user names, if
+specified.
+
+@item @code{tramp-parse-shosts}
+@findex tramp-parse-shosts
+
+This function parses files which are syntactical equivalent to
+@file{/etc/ssh_known_hosts}.  Since there are no user names specified
+in such files, it can return host names only.
+
+@item @code{tramp-parse-hosts}
+@findex tramp-parse-hosts
+
+A function dedicated to @file{/etc/hosts} style files.  It returns
+host names only.
+
+@item @code{tramp-parse-passwd}
+@findex tramp-parse-passwd
+
+Finally a method which parses @file{/etc/passwd} like files.
+Obviously, it can return user names only.
+@end table
+
+@ifset emacs
+A function which parses @file{~/.netrc"} file syntax doesn't exist in
+@tramp{}, because this task is delegated to
+@value{ftp-package-name}. Its customization should be used instead.
+@end ifset
+
+If you want to keep your own data in a file, with your own structure,
+you might provide such a function as well.  This function must meet
+the following conventions:
+
+@defun my-tramp-parse file
+@var{file} must be either a file name on your host, or @code{nil}. The
+function must return a list of (@var{user} @var{host}), which are
+taken as candidates for user and host name completion.
+
+Example:
+@example
+(my-tramp-parse "~/.my-tramp-hosts")
+
+     @result{} ((nil "toto") ("daniel" "melancholia"))
+@end example
+@end defun
+
+
 @node Remote Programs
 @section How @tramp{} finds and uses programs on the remote machine.
 
@@ -1209,13 +1379,13 @@
 To add a directory to the remote search path, you could use code such
 as:
 
-@example
-(require 'tramp)                @i{; @tramp{} must be loaded before this}
-                                @i{; happens.}
-
-@i{; We have @command{perl} in "/usr/local/perl/bin"}
+@lisp
+@i{;; We load @tramp{} to define the variable.}
+(require 'tramp)
+@i{;; We have @command{perl} in "/usr/local/perl/bin"}
 (add-to-list 'tramp-remote-path "/usr/local/perl/bin")
-@end example
+@end lisp
+
 
 @node Remote shell setup
 @comment  node-name,  next,  previous,  up
@@ -1228,7 +1398,7 @@
 As explained in the @ref{Overview} section, @tramp{} connects to the
 remote host and talks to the shell it finds there.  Of course, when you
 log in, the shell executes its init files.  Suppose your init file
-requires you to enter the birthdate of your mother; clearly @tramp{}
+requires you to enter the birth date of your mother; clearly @tramp{}
 does not know this and hence fails to log you in to that host.
 
 There are different possible strategies for pursuing this problem.  One
@@ -1270,25 +1440,39 @@
 recognizes the @code{>} character as the end of the prompt, but it is
 not at the end of the buffer.
 
+@item @var{tramp-shell-prompt-pattern}
+@vindex tramp-shell-prompt-pattern
+
+This regular expression is used by @tramp{} in the same way as
+@code{shell-prompt-pattern}, to match prompts from the remote shell.
+This second variable exists because the prompt from the remote shell
+might be different from the prompt from a local shell --- after all,
+the whole point of @tramp{} is to log in to remote hosts as a
+different user.  The default value of
+@code{tramp-shell-prompt-pattern} is the same as the default value of
+@code{shell-prompt-pattern}, which is reported to work well in many
+circumstances.
+
 @item @code{tset} and other questions
 @cindex Unix command tset
 @cindex tset Unix command
 
 Some people invoke the @code{tset} program from their shell startup
-scripts which asks the user about the terminal type of the shell.  Maybe
-some shells ask other questions when they are started.  @tramp{} does
-not know how to answer these questions.  (A facility for enabling
-@tramp{} to answer these questions is planned for some future version,
-but don't hold your breath.)
-
-Therefore, you should take care that the shell does not ask any
-questions when invoked from @tramp{}.  You can do this by checking the
-@code{TERM} environment variable, it will be set to @code{dumb} when
-connecting.
+scripts which asks the user about the terminal type of the shell.
+Maybe some shells ask other questions when they are started.  @tramp{}
+does not know how to answer these questions.  There are two approaches
+for dealing with this problem.  One approach is to take care that the
+shell does not ask any questions when invoked from @tramp{}.  You can
+do this by checking the @code{TERM} environment variable, it will be
+set to @code{dumb} when connecting.
 
 @vindex tramp-terminal-type
 The variable @code{tramp-terminal-type} can be used to change this value
-@code{dumb}.
+to @code{dumb}.
+
+The other approach is to teach @tramp{} about these questions.  See
+the variables @code{tramp-actions-before-shell} and
+@code{tramp-multi-actions} (for multi-hop connections).
 
 @end table
 
@@ -1317,13 +1501,24 @@
 
 Files are specified to @tramp{} using a formalized syntax specifying the
 details of the system to connect to.  This is similar to the syntax used
-by the @command{EFS} and @command{Ange-FTP} packages.
-
+by the @value{ftp-package-name} package.
+
+@cindex type-ahead
+Something that might happen which surprises you is that Emacs
+remembers all your keystrokes, so if you see a password prompt from
+Emacs, say, and hit @kbd{@key{RET}} twice instead of once, then the
+second keystroke will be processed by Emacs after @tramp{} has done
+its thing.  Why, this type-ahead is normal behavior, you say.  Right
+you are, but be aware that opening a remote file might take quite a
+while, maybe half a minute when a connection needs to be opened.
+Maybe after half a minute you have already forgotten that you hit that
+key!
 
 @menu
 * Filename Syntax::             @tramp{} filename conventions.
-* Multi-hop filename syntax::   Multi-hop filename conventions
-* Dired::                       Dired and filename completion.
+* Multi-hop filename syntax::   Multi-hop filename conventions.
+* Filename completion::         Filename completion.
+* Dired::                       Dired.
 @end menu
 
 
@@ -1332,79 +1527,70 @@
 @cindex filename syntax
 @cindex filename examples
 
-On Emacs, the Ange-FTP and Tramp filenames use a unified syntax.  On
-XEmacs, EFS and Tramp use different formats for the filenames.
-Therefore, the following will describe the Emacs and XEmacs cases
-separately.
-
-On Emacs, to access the file @var{path} on the remote machine
-@var{machine} you would specify the filename
-@file{/@var{machine}:@var{path}}.  This will connect to @var{machine}
-and transfer the file using the default method.  @xref{Default
-Method}.  On XEmacs, use @file{/[@var{machine}]@var{path}}.  (The
-square brackets are part of the file name.)
-
-Some examples of @tramp{} filenames are shown below.  In each case,
-the Emacs-style filename is shown first, then the XEmacs-style
-filename.
+To access the file @var{path} on the remote machine @var{machine} you
+would specify the filename
+@file{@value{tramp-prefix}@var{machine}@value{tramp-postfix}@var{path}}.
+This will connect to @var{machine} and transfer the file using the
+default method.  @xref{Default Method}.
+
+Some examples of @tramp{} filenames are shown below.
 
 @table @file
-@item /melancholia:.emacs
-@itemx /[melancholia].emacs
+@item @value{tramp-prefix}melancholia@value{tramp-postfix}.emacs
 Edit the file @file{.emacs} in your home directory on the machine
 @code{melancholia}.
 
-@item /melancholia.danann.net:.emacs
-@itemx /[melancholia.danann.net].emacs
+@item @value{tramp-prefix}melancholia.danann.net@value{tramp-postfix}.emacs
 This edits the same file, using the fully qualified domain name of
 the machine.
 
-@item /melancholia:~/.emacs
-@itemx /[melancholia]~/.emacs
+@item @value{tramp-prefix}melancholia@value{tramp-postfix}~/.emacs
 This also edits the same file --- the @file{~} is expanded to your
 home directory on the remote machine, just like it is locally.
 
-@item /melancholia:~daniel/.emacs
-@itemx /[melancholia]~daniel/.emacs
+@item @value{tramp-prefix}melancholia@value{tramp-postfix}~daniel/.emacs
 This edits the file @file{.emacs} in the home directory of the user
 @code{daniel} on the machine @code{melancholia}. The @file{~<user>}
 construct is expanded to the home directory of that user on the remote
 machine.
 
-@item /melancholia:/etc/squid.conf
-@itemx /[melancholia]/etc/squid.conf
+@item @value{tramp-prefix}melancholia@value{tramp-postfix}/etc/squid.conf
 This edits the file @file{/etc/squid.conf} on the machine
 @code{melancholia}.
 
 @end table
 
-Unless you specify a different name to use, @tramp{} will use the current
-local user name as the remote user name to log in with. If you need to
-log in as a different user, you can specify the user name as part of the
-filename.
-
-On Emacs, to log in to the remote machine as a specific user, you use
-the syntax @file{/@var{user}@@@var{machine}:/path/to.file}.  On
-XEmacs, use @file{/[@var{user}@@@var{machine}]/path/to.file}.  That
-means that connecting to @code{melancholia} as @code{daniel} and
+Unless you specify a different name to use, @tramp{} will use the
+current local user name as the remote user name to log in with. If you
+need to log in as a different user, you can specify the user name as
+part of the filename.
+
+To log in to the remote machine as a specific user, you use the syntax
+@file{@value{tramp-prefix}@var{user}@@@var{machine}@value{tramp-postfix}/@var{path/to.file}}.
+That means that connecting to @code{melancholia} as @code{daniel} and
 editing @file{.emacs} in your home directory you would specify
-@file{/daniel@@melancholia:.emacs} on Emacs and
-@file{/[daniel@@melancholia].emacs} on XEmacs.
-
+@file{@value{tramp-prefix}daniel@@melancholia@value{tramp-postfix}.emacs}.
 
 It is also possible to specify other file transfer methods
-(@pxref{Default Method}) as part of the filename.  On Emacs, this is
-done by puttig the method before the user and host name, as in
-@file{/@var{method}:} (note the trailing colon).  On XEmacs, it is
-done by replacing the initial @file{/[} with @file{/[<method>/}.
-(Note the trailing slash!)  The user, machine and file specification
-remain the same.
+(@pxref{Default Method}) as part of the filename.
+@ifset emacs
+This is done by putting the method before the user and host name, as
+in
+@file{@value{tramp-prefix}@var{method}@value{tramp-postfix-single-hop}}
+(note the trailing colon).
+@end ifset
+@ifset xemacs
+This is done by replacing the initial
+@file{@value{tramp-prefix}} with
+@file{@value{tramp-prefix}<method>@value{tramp-postfix-single-hop}}.
+(Note the trailing slash!).
+@end ifset
+The user, machine and file specification remain the same.
 
 So, to connect to the machine @code{melancholia} as @code{daniel},
 using the @option{su} method to transfer files, and edit @file{.emacs}
 in my home directory I would specify the filename
-@file{/su:daniel@@melancholia:.emacs} on Emacs and
-@file{/[su/daniel@@melancholia].emacs} on XEmacs.
+@file{@value{tramp-prefix}su@value{tramp-postfix-single-hop}daniel@@melancholia@value{tramp-postfix}.emacs}.
 
 
 @node Multi-hop filename syntax
@@ -1413,64 +1599,116 @@
 @cindex multi-hop filename syntax
 
 The syntax of multi-hop file names is necessarily slightly different
-than the syntax of other @tramp{} file names.  Here's an example multi-hop
-file name, first in Emacs syntax and then in XEmacs syntax:
-
-@file{/multi:rsh:out@@gate:telnet:kai@@real.host:/path/to.file}
-@file{/[multi/rsh:out@@gate/telnet:kai@@real.host]/path/to.file}
+than the syntax of other @tramp{} file names.  Here's an example
+multi-hop file name, first in Emacs syntax and then in XEmacs syntax:
+
+@example
+@value{tramp-prefix}multi@value{tramp-postfix-single-hop}rsh@value{tramp-postfix-multi-hop}out@@gate@value{tramp-postfix-single-hop}telnet@value{tramp-postfix-multi-hop}kai@@real.host@value{tramp-postfix}/path/to.file
+@end example
 
 This is quite a mouthful.  So let's go through it step by step.  The
-file name consists of three parts.  On Emacs, the parts are separated
-by colons, on XEmacs they are separated by slashes and square
-brackets.  The first part is @file{/multi:} (or @file{/[multi}), the
-method specification.  The second part is
-@file{rsh:out@@gate:telnet:kai@@real.host} (or
-@file{rsh:out@@gate/telnet:kai@@real.host}) and specifies the hops.
-(Yes, on Emacs the second part may contain even more colons, so that's why
-this file name has more than two colons in it.)  The final part is
-@file{/path/to.file} and specifies the file name on the remote host.
+file name consists of three parts.
+@ifset emacs
+The parts are separated by colons
+@end ifset
+@ifset xemacs
+The parts are separated by slashes and square brackets.
+@end ifset
+The first part is @file{@value{tramp-prefix}multi}, the method
+specification.  The second part is
+@file{rsh@value{tramp-postfix-multi-hop}out@@gate@value{tramp-postfix-single-hop}telnet@value{tramp-postfix-multi-hop}kai@@real.host}
+and specifies the hops.  The final part is @file{/path/to.file} and
+specifies the file name on the remote host.
 
 The first part and the final part should be clear.  @ref{Multi-hop
 Methods}, for a list of alternatives for the method specification.
 
-The second part can be subdivided again into components, so-called hops.
-In the above file name, there are two hops, @file{rsh:out@@gate} and
-@file{telnet:kai@@real.host}.
+The second part can be subdivided again into components, so-called
+hops.  In the above file name, there are two hops,
+@file{rsh@value{tramp-postfix-multi-hop}out@@gate} and
+@file{telnet@value{tramp-postfix-multi-hop}kai@@real.host}.
 
 Each hop can @emph{again} be subdivided into (three) components, the
 @dfn{hop method}, the @dfn{user name} and the @dfn{host name}.  The
 meaning of the second and third component should be clear, and the hop
 method says what program to use to perform that hop.
 
-The first hop, @file{rsh:out@@gate}, says to use @command{rsh} to log in
-as user @code{out} to the host @code{gate}.  Starting at that host, the
-second hop, @file{telnet:kai@@real.host}, says to use @command{telnet}
-to log in as user @code{kai} to host @code{real.host}.
-
-@xref{Multi-hop Methods}, for a list of possible hop method values.  The
-variable @var{tramp-multi-connection-function-alist} contains the list of
-possible hop methods and information on how to execute them, should you
-want to add your own.
+The first hop, @file{rsh@value{tramp-postfix-multi-hop}out@@gate},
+says to use @command{rsh} to log in as user @code{out} to the host
+@code{gate}.  Starting at that host, the second hop,
+@file{telnet@value{tramp-postfix-multi-hop}kai@@real.host}, says to
+use @command{telnet} to log in as user @code{kai} to host
+@code{real.host}.
+
+@xref{Multi-hop Methods}, for a list of possible hop method values.
+The variable @code{tramp-multi-connection-function-alist} contains the
+list of possible hop methods and information on how to execute them,
+should you want to add your own.
+
+
+@node Filename completion
+@section Filename completion
+@cindex filename completion
+
+Filename completion works with @tramp{} for both completing methods,
+user names and machine names (except multi hop methods) as well as for
+files on remote machines.
+
+If you, for example, type @kbd{C-x C-f @value{tramp-prefix}t
+@key{TAB}}, @tramp{} might give you as result the choice for
+
+@example
+@ifset emacs
+@value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}				   tmp/
+@value{tramp-prefix-single-hop}toto@value{tramp-postfix}
+@end ifset
+@ifset xemacs
+@value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}				   @value{tramp-prefix-single-hop}toto@value{tramp-postfix}
+@end ifset
+@end example
+     
+@samp{@value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}}
+is a possible completion for the respective method,
+@ifset emacs
+@samp{tmp/} stands for the directory @file{/tmp} on your local
+machine,
+@end ifset
+and @samp{@value{tramp-prefix-single-hop}toto@value{tramp-postfix}}
+might be a host @tramp has detected in your @file{~/.ssh/known_hosts}
+file (given you're using default method @option{ssh}).
+
+If you go on to type @kbd{e @key{TAB}}, the minibuffer is completed to
+@samp{@value{tramp-prefix}telnet@value{tramp-postfix-single-hop}}.
+Next @kbd{@key{TAB}} brings you all machine names @tramp{} detects in
+your @file{/etc/hosts} file, let's say
+
+@example
+@value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}127.0.0.1@value{tramp-postfix}		   @value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}192.168.0.1@value{tramp-postfix}
+@value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}localhost@value{tramp-postfix}		   @value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}melancholia.danann.net@value{tramp-postfix}
+@value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}melancholia@value{tramp-postfix}
+@end example
+
+Now you can choose the desired machine, and you can continue to
+complete file names on that machine.
+
+As filename completion needs to fetch the listing of files from the
+remote machine, this feature is sometimes fairly slow.  As @tramp{}
+does not yet cache the results of directory listing, there is no gain
+in performance the second time you complete filenames.
+
+If the configuration files (@pxref{Customizing Completion}), which
+@tramp{} uses for analysis of completion, offer user names, those user
+names will be taken into account as well.
 
 
 @node Dired
-@section Dired and filename completion
+@section Dired
 @cindex dired
-@cindex filename completion
 
 @tramp{} works transparently with dired, enabling you to use this powerful
 file management tool to manage files on any machine you have access to
 over the Internet.
 
-Filename completion also works with @tramp{} for files on remote machines
-although there is no completion for user names or machine names at this
-stage.
-
-As filename completion needs to fetch the listing of files from the
-remote machine, this feature is sometimes fairly slow.  As @tramp{} does not
-yet cache the results of directory listing, there is no gain in
-performance the second time you complete filenames.
-
 If you need to browse a directory tree, Dired is a better choice, at
 present, than filename completion.  Dired has its own cache mechanism
 and will only fetch the directory listing once.
@@ -1516,11 +1754,16 @@
 @item
 Where can I get the latest @tramp{}?
 
-@tramp{} is available at
-@uref{ftp://ls6-ftp.cs.uni-dortmund.de/pub/src/emacs/tramp.tar.gz}.
-There is also a Savannah project page, at
-@uref{https://savannah.gnu.org/projects/tramp/}.
-
+@tramp{} is available under the URL below.
+
+@noindent
+@uref{ftp://ls6-ftp.cs.uni-dortmund.de/pub/src/emacs/tramp.tar.gz}
+
+@noindent
+There is also a Savannah project page.
+
+@noindent
+@uref{https://savannah.gnu.org/projects/tramp/}
 
 @item
 Which systems does it work on?
@@ -1555,10 +1798,10 @@
 @tramp{} installed.
 
 If you do, please try and find out exactly the conditions required for
-the @code{EFS} handlers to fire. If you can, putting a breakpoint on
+the EFS handlers to fire. If you can, putting a breakpoint on
 @code{efs-ftp-path} and sending in the stack trace along with your bug
-report would make it easier for the developers to work out what is going
-wrong.
+report would make it easier for the developers to work out what is
+going wrong.
 
 
 @item
@@ -1657,9 +1900,9 @@
 @node Version Control
 @chapter The inner workings of remote version control
 
-Unlike EFS and Ange-FTP, @tramp{} has full shell access to the remote
-machine. This makes it possible to provide version control for files
-accessed under @tramp{}.
+Unlike @value{ftp-package-name}, @tramp{} has full shell access to the
+remote machine. This makes it possible to provide version control for
+files accessed under @tramp{}.
 
 The actual version control binaries must be installed on the remote
 machine, accessible in the directories specified in
@@ -1674,7 +1917,7 @@
 * Remote Commands::             Executing the version control commands on the remote machine.
 * Changed workfiles::           Detecting if the working file has changed.
 * Checking out files::          Bringing the workfile out of the repository.
-* Miscellaneous Version Control::  Things related to Version Control that don't fit elsewhere
+* Miscellaneous Version Control::  Things related to Version Control that don't fit elsewhere.
 @end menu
 
 
@@ -1880,3 +2123,7 @@
 @c * Make terminology "inline" vs "out-of-band" consistent.
 @c   It seems that "external" is also used instead of "out-of-band".
 
+@c * M. Albinus
+@c ** Use `filename' resp. `file name' consistently.
+@c ** Use `host' resp. `machine' consistently.
+@c ** Consistent small or capitalized words especially in menues.