aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorKai Großjohann2002-09-22 13:23:36 +0000
committerKai Großjohann2002-09-22 13:23:36 +0000
commit16674e4f3b1e05ebece0b676fffe6119d9b2edd4 (patch)
tree6c207369992886f486d373b2f1d047cd83959174 /lisp
parent1fc85daee037058b772d7fa2726bc939fae4720c (diff)
downloademacs-16674e4f3b1e05ebece0b676fffe6119d9b2edd4.tar.gz
emacs-16674e4f3b1e05ebece0b676fffe6119d9b2edd4.zip
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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog449
-rw-r--r--lisp/net/tramp-uu.el89
-rw-r--r--lisp/net/tramp.el1777
3 files changed, 1800 insertions, 515 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a020a64bc27..3c1bb32bded 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,454 @@
12002-09-22 Kai Gro,b_(Bjohann <grossjoh@ls6.informatik.uni-dortmund.de> 12002-09-22 Kai Gro,b_(Bjohann <grossjoh@ls6.informatik.uni-dortmund.de>
2 2
3 Version 2.0.20 released.
4
52002-09-20 Kai Gro,b_(Bjohann <grossjoh@ls6.informatik.uni-dortmund.de>
6
7 * net/tramp.el (tramp-completion-function-alist): Escape open
8 paren in docstring.
9 (tramp-user-regexp, tramp-host-regexp): Allow empty strings.
10 (tramp-handle-insert-file-contents): Call tramp-message-for-buffer
11 instead of tramp-message.
12 (tramp-open-connection-rsh): Handle empty string as user name.
13 (tramp-open-connection-su): Handle empty string as host name.
14 Handle nil user name.
15 (tramp-handle-file-local-copy, tramp-handle-write-region)
16 (tramp-completion-handle-file-name-all-completions)
17 (tramp-open-connection-telnet, tramp-open-connection-rsh)
18 (tramp-open-connection-su, tramp-post-connection)
19 (tramp-maybe-open-connection, tramp-method-out-of-band-p)
20 (tramp-get-connection-function, tramp-get-remote-sh)
21 (tramp-get-rsh-program, tramp-get-rsh-args)
22 (tramp-get-rcp-program, tramp-get-rcp-args)
23 (tramp-get-rcp-keep-date-arg, tramp-get-su-program)
24 (tramp-get-su-args, tramp-get-telnet-program)
25 (tramp-get-telnet-args): Use `tramp-find-method', perhaps require
26 additional args USER, HOST.
27 (tramp-action-password, tramp-open-connection-telnet)
28 (tramp-open-connection-su, tramp-open-connection-multi)
29 (tramp-method-out-of-band-p): `tramp-method-out-of-band-p' now
30 takes USER and HOST arguments, to be able to use
31 `tramp-find-method'. Update callers.
32 (tramp-find-method): New function.
33
342002-09-20 Kai Gro,b_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
35
36 * net/tramp.el (tramp-handle-insert-directory): Handle "--dired"
37 in SWITCHES (by removing it).
38
392002-09-18 Kai Gro,b_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
40
41 * net/tramp.el (tramp-file-name-handler): Add `file-remote-p'
42 property.
43
442002-09-17 Kai Gro,b_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
45
46 * net/tramp.el (top-level): Maybe autoload uudecode-decode-region.
47
482002-09-16 Kai Gro,b_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
49
50 * net/tramp.el (tramp-bug): Add tramp-methods.
51
522002-09-16 Kai Gro,b_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
53
54 * net/tramp.el (tramp-methods): Update docstring:
55 tramp-encoding-command, tramp-decoding-command,
56 tramp-encoding-function and tramp-decoding-function are not
57 parameters anymore.
58 (tramp-uuencode-region): Autoload it.
59
602002-09-13 Kai Gro,b_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
61
62 Version 2.0.19 released.
63
64 * net/tramp-uu.el: New file, implements uuencode in Lisp.
65
66 * net/tramp.el (tramp-coding-commands): Use
67 `tramp-uuencode-region' as local encoder for the uuencode based
68 entries.
69
702002-09-13 Kai Gro,b_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
71
72 * net/tramp.el (tramp-handle-write-region): Wrong parens.
73
742002-09-13 Kai Gro,b_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
75
76 Version 2.0.18 released.
77
78 * net/tramp.el (tramp-perl-decode): Perl changes to accomodate
79 older versions of Perl. Now tested with 5.004. Suggestion from
80 Michael Albinus.
81
822002-09-12 Kai Gro,b_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
83
84 * net/tramp.el (tramp-find-inline-encoding): Call
85 tramp-call-local-coding-command with nil for INPUT and OUTPUT.
86 (tramp-call-local-coding-command): OUTPUT equals nil means to
87 discard the output. INPUT equals nil means /dev/null.
88
892002-09-12 Kai Gro,b_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
90
91 * net/tramp.el (tramp-encoding-shell): Default to environment
92 variable COMSPEC on Windows.
93 (tramp-handle-write-region): More debugging output.
94 (tramp-find-inline-encoding): Ditto.
95
962002-09-11 Michael Albinus <Michael.Albinus@alcatel.de>
97
98 * net/tramp.el (tramp-completion-handle-file-name-all-completions):
99 Define `result1'.
100 (tramp-parse-hosts-group): Discard IPv6 entries.
101
1022002-09-11 Kai Gro,b_(Bjohann <grossjoh@ls6.informatik.uni-dortmund.de>
103
104 * net/tramp.el (tramp-post-connection): Only send Perl
105 mime-encode/decode implementations when using inline method.
106 (tramp-handle-file-local-copy)
107 (tramp-handle-write-region, tramp-post-connection)
108 (tramp-coding-commands, tramp-find-inline-encoding): For the
109 inline encodings, distinguish between local and remote commands,
110 instead of between commands and functions. (The local commands
111 can be functions, too.) If the local host is a Windows machine,
112 we can't expect the same commands to work there as on the remote
113 host.
114 (tramp-call-local-coding-command): New function for calling local
115 encoding and decoding commands.
116 (tramp-set-remote-encoding, tramp-get-remote-encoding)
117 (tramp-set-remote-decoding, tramp-get-remote-decoding)
118 (tramp-set-local-encoding, tramp-get-local-encoding)
119 (tramp-set-local-decoding, tramp-get-local-decoding): New
120 functions.
121 (tramp-get-encoding-command, tramp-set-encoding-command)
122 (tramp-get-decoding-command, tramp-set-decoding-command)
123 (tramp-get-encoding-function, tramp-set-encoding-function)
124 (tramp-get-decoding-function, tramp-set-decoding-function): Old
125 functions, removed.
126
1272002-09-10 Kai Gro,b_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
128
129 * net/tramp.el (tramp-open-connection-setup-interactive-shell):
130 Change command to invoke /bin/sh slightly to make it compatible
131 with the `rc' shell. Suggested by Daniel Pittman.
132
1332002-09-10 Michael Albinus <Michael.Albinus@alcatel.de>
134
135 * net/tramp.el (tramp-handle-write-region): Added missing
136 `)'. Hope it's the right place.
137
1382002-09-09 Kai Gro,b_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
139
140 * net/tramp.el (tramp-open-connection-setup-interactive-shell): Do
141 "exec env PS1='$ ' /bin/sh" instead of just "exec /bin/sh" in
142 order to get a sane shell prompt. If people have ${CWD}, say, in
143 their shell prompt, then the default login shell might display
144 something harmless, but the /bin/sh will display a dollar sign
145 which confused the subsequent prompt recognition.
146 (tramp-multi-action-password): More debugging output.
147 (tramp-encoding-shell): Renamed from tramp-sh-program. More
148 documentation. Default to cmd.exe on Windows NT.
149 (tramp-encoding-command-switch): New variable. Use instead of
150 hard-wired "-c" which is only good for /bin/sh.
151 (tramp-encoding-reads-stdin): New variable. If t, commands are
152 called like "/bin/sh -c COMMAND <INPUT", if nil, they are called
153 like "/bin/sh -c COMMAND INPUT", ie the input file is the last
154 argument.
155 (tramp-multi-sh-program): Always default to tramp-encoding-shell.
156 (tramp-handle-file-local-copy, tramp-handle-write-region): Respect
157 tramp-encoding-shell and friends.
158 (tramp-find-inline-encoding): Use new-style calls for checking if
159 the local commands work.
160
1612002-09-07 Michael Albinus <Michael.Albinus@alcatel.de>
162
163 * net/tramp.el (tramp-methods): Remove `tramp-completion-function'
164 entries. They are handled now by
165 `tramp-completion-function-alist'.
166 (tramp-completion-function): Defvar removed. I've never used
167 it. Hmm.
168 (tramp-get-completion-function)
169 (tramp-get-completion-rsh, tramp-get-completion-ssh)
170 (tramp-get-completion-telnet, tramp-get-completion-su): Functions
171 removed as well. Not necessary any longer due to extended
172 customization means.
173 (tramp-completion-function-alist): New defcustom. Holds all
174 FUNCTION FILE pairs used for user and host name completion
175 relevant for METHOD.
176 (tramp-completion-function-alist-rsh)
177 (tramp-completion-function-alist-ssh)
178 (tramp-completion-function-alist-telnet)
179 (tramp-completion-function-alist-su): Defconst for initializing
180 `tramp-completion-function-alist'. Unfortunately, mainly UNIX-like
181 values are known for me until now. Needs to be completed for at
182 least VMS++ like operating systems.
183 (tramp-set-completion-function)
184 (tramp-get-completion-function): New functions for configuration
185 of `tramp-completion-function-alist'. The old definition of
186 `tramp-get-completion-function' has been discarded.
187 (tramp-completion-handle-file-name-all-completions): Change
188 function call for user/host completion according to definition in
189 `tramp-completion-function-alist'.
190 (tramp-parse-passwd): Added exception handling for "root", because
191 `tramp-get-completion-su' (the previous place for this stuff)
192 doesn't exist any longer.
193
1942002-09-07 Kai Gro,b_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
195
196 * net/tramp.el (tramp-enter-password): Use
197 `tramp-password-end-of-line' to terminate the line.
198 (tramp-bug): Include new variable `tramp-password-end-of-line'.
199 (tramp-password-end-of-line): New variable. People who use plink
200 under Windows might have to issue "\r\n" after the password, but
201 they need to send just "\n" after the other commands. So this
202 variable was introduced to complement `tramp-rsh-end-of-line'.
203 (tramp-wait-for-output, tramp-post-connection): Allow "\r" at end
204 of line of the output delimiter.
205
2062002-09-06 Kai Gro,b_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
207
208 * net/tramp.el (tramp-handle-file-local-copy, tramp-find-shell)
209 (tramp-open-connection-setup-interactive-shell): Add some comments
210 about Douglas Grey Stephen's suggestions to make Tramp work better
211 with plink under Windows. I'm not sure what to think of them, but
212 now I have a guinea pig to try it out on. Said guinea pig is
213 having other problems, though... Also remove some commented-out
214 code.
215
2162002-09-06 Michael Albinus <Michael.Albinus@alcatel.de>
217
218 * net/tramp.el (tramp-get-completion-methods): Algorithm slightly
219 tuned.
220 (tramp-get-completion-user-host): Accept user names as they are if
221 typed until "@".
222 (tramp-completion-mode): Replace `last-input-char' by modern
223 `last-input-event'. Check for `event-modifiers'.
224
2252002-09-06 Kai Gro,b_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
226
227 * net/tramp.el (file-expand-wildcards): Corrected check to see if
228 advising is necessary.
229
2302002-09-05 Michael Albinus <Michael.Albinus@alcatel.de>
231
232 * net/tramp.el (tramp-postfix-single-method-format)
233 (tramp-postfix-multi-method-format)
234 (tramp-postfix-multi-hop-format)
235 (tramp-postfix-user-format): New format strings.
236 (tramp-postfix-single-method-regexp)
237 (tramp-postfix-multi-method-regexp)
238 (tramp-postfix-multi-hop-regexp)
239 (tramp-postfix-user-regexp)
240 (tramp-make-multi-tramp-file-format)
241 (tramp-make-tramp-file-name): Apply them.
242 (tramp-completion-handle-file-name-all-completions): Fix for
243 invoking ange-ftp in case of "/ftp:xxx" file names.
244
2452002-09-04 Michael Albinus <Michael.Albinus@alcatel.de>
246
247 * net/tramp.el (tramp-prefix-format)
248 (tramp-postfix-host-format): New format strings.
249 (tramp-prefix-regexp, tramp-method-regexp)
250 (tramp-postfix-single-method-regexp)
251 (tramp-postfix-multi-method-regexp)
252 (tramp-postfix-multi-hop-regexp)
253 (tramp-user-regexp, tramp-postfix-user-regexp)
254 (tramp-host-regexp, tramp-postfix-host-regexp)
255 (tramp-path-regexp): New atomar regular expressions. If
256 corresponding format strings exist, derived from them.
257 (tramp-file-name-structure)
258 (tramp-multi-file-name-structure)
259 (tramp-multi-file-name-hop-structure)
260 (tramp-make-multi-tramp-file-format)
261 (tramp-completion-mode)
262 (tramp-completion-dissect-file-name)
263 (tramp-parse-rhosts-group)
264 (tramp-parse-shosts-group)
265 (tramp-parse-hosts-group)
266 (tramp-parse-passwd-group): Apply these expressions.
267 (tramp-file-name-structure-unified)
268 (tramp-file-name-structure-separate)
269 (tramp-make-tramp-file-format-unified)
270 (tramp-make-tramp-file-format-separate)
271 (tramp-make-tramp-file-format)
272 (tramp-make-tramp-file-user-nil-format-unified)
273 (tramp-make-tramp-file-user-nil-format-separate)
274 (tramp-make-tramp-file-user-nil-format)
275 (tramp-multi-file-name-structure-unified)
276 (tramp-multi-file-name-structure-separate)
277 (tramp-multi-file-name-hop-structure-unified)
278 (tramp-multi-file-name-hop-structure-separate)
279 (tramp-make-multi-tramp-file-format-unified)
280 (tramp-make-multi-tramp-file-format-separate): Removed.
281 (tramp-make-tramp-file-name): Allow partial tramp file
282 names. Generate tramp file format on-the-fly depending on
283 parameters. Apply atomar format strings resp expressions.
284 (tramp-get-completion-methods)
285 (tramp-get-completion-user-host): Apply
286 `tramp-make-tramp-file-name'.
287 (tramp-parse-hosts-group): Take all host names and IP addresses
288 into account.
289 (tramp-bug): Remove `tramp-make-tramp-file-format'.
290
2912002-09-01 Michael Albinus <Michael.Albinus@alcatel.de>
292
293 * net/tramp.el (tramp-methods): Add `tramp-completion-function'
294 for "su" and "sudo".
295 (tramp-get-completion-telnet): Implement it.
296 (tramp-parse-hosts)
297 (tramp-parse-hosts-group)
298 (tramp-get-completion-su)
299 (tramp-parse-passwd)
300 (tramp-parse-passwd-group): New functions.
301
3022002-08-31 Michael Albinus <Michael.Albinus@alcatel.de>
303
304 * net/tramp.el (tramp-completion-mode): Check for
305 `last-input-char'.
306 (tramp-completion-file-name-handler-alist): Add handler for
307 `file-exists-p.
308 (tramp-completion-handle-file-exists-p): New function.
309 (tramp-completion-handle-file-name-completion): Simplified.
310 (tramp-completion-dissect-file-name): Regexp's reorganised.
311 (tramp-completion-handle-file-name-all-completions): Call
312 completion-function only if `user' or `host' is given.
313 (tramp-get-completion-user-host): New function.
314 (tramp-get-completion-rsh)
315 (tramp-get-completion-ssh): Apply it.
316
3172002-08-29 Michael Albinus <Michael.Albinus@alcatel.de>
318
319 * net/tramp.el (tramp-completion-file-name-handler-alist): Add
320 handler for `expand-file-name'.
321 (tramp-completion-handle-expand-file-name): New function.
322
3232002-08-26 Michael Albinus <Michael.Albinus@alcatel.de>
324
325 * net/tramp.el (tramp-completion-mode): New function.
326 (tramp-completion-handle-file-name-directory)
327 (tramp-completion-handle-file-name-all-completions): Apply it.
328 (tramp-methods): Remove double definition of `ssh1-old' and
329 `ssh2-old'.
330 (tramp-point-at-eol): New defalias.
331 (tramp-parse-rhosts-group)
332 (tramp-parse-shosts-group):: Apply it.
333
3342002-08-25 Michael Albinus <Michael.Albinus@alcatel.de>
335
336 * net/tramp.el (tramp-get-completion-methods)
337 (tramp-get-completion-rsh)
338 (tramp-get-completion-ssh): Add "[" for Xemacs.
339 (tramp-completion-file-name-regexp-separate): Expression adapted.
340 (tramp-completion-file-name-handler-alist): Add handler for
341 `file-name-directory' and `file-name-nondirectory'.
342 (tramp-completion-handle-file-name-directory)
343 (tramp-completion-handle-file-name-nondirectory)
344 (tramp-completion-run-real-handler): New functions.
345 (tramp-completion-file-name-handler)
346 (tramp-completion-handle-file-name-all-completions): Apply
347 `tramp-completion-run-real-handler'.
348 (tramp-parse-rhosts)
349 (tramp-parse-shosts): Use `with-temp-buffer'. `result,b4(B renamed to
350 `res' (otherwise side effects in XEmacs).
351
3522002-08-24 Michael Albinus <Michael.Albinus@alcatel.de>
353
354 * net/tramp.el (tramp-completion-file-name-regexp)
355 (tramp-completion-file-name-handler-alist)
356 (tramp-flatten-list)
357 (tramp-completion-dissect-file-name)
358 (tramp-get-completion-rsh)
359 (tramp-parse-rhosts)
360 (tramp-parse-rhosts-group)
361 (tramp-get-completion-ssh): Doc string tuned.
362 (tramp-methods): Doc string and custom type extended for
363 `tramp-completion-function'.
364 (tramp-completion-function): Variable added. Is it really used?
365 Other variables like `tramp-completion-function' aren't used.
366 (tramp-completion-file-name-handler-alist): Add handler for
367 `file-name-completion'.
368 (tramp-completion-handle-file-name-completion): New function.
369
3702002-08-18 Michael Albinus <Michael.Albinus@alcatel.de>
371
372 * net/tramp.el (tramp-parse-rhosts)
373 (tramp-parse-rhosts-group)
374 (tramp-parse-shosts)
375 (tramp-parse-shosts-group): New functions.
376
3772002-08-17 Michael Albinus <Michael.Albinus@alcatel.de>
378
379 * net/tramp.el (tramp-completion-dissect-file-name)
380 (tramp-completion-dissect-file-name1): New functions.
381
3822002-08-16 Michael Albinus <Michael.Albinus@alcatel.de>
383
384 * net/tramp.el (tramp-get-completion-function)
385 (tramp-get-completion-rsh)
386 (tramp-get-completion-ssh)
387 (tramp-get-completion-telnet): New functions.
388 (tramp-methods): Add `tramp-completion-function' for all methods.
389
3902002-08-15 Michael Albinus <Michael.Albinus@alcatel.de>
391
392 * net/tramp.el (tramp-get-completion-methods): New function.
393 (tramp-find-default-method): Allow host to be nil (like user).
394
3952002-08-14 Michael Albinus <Michael.Albinus@alcatel.de>
396
397 * net/tramp.el (tramp-completion-file-name-regexp-unified)
398 (tramp-completion-file-name-regexp-separate)
399 (tramp-completion-file-name-regexp)
400 (tramp-completion-file-name-handler-alist): New defcustoms.
401 (tramp-completion-file-name-handler): New function. Add
402 `tramp-completion-file-name-handler' to `file-name-handler-alist'.
403 (tramp-run-real-handler): Add `tramp-completion-file-name-handler'
404 to `inhibit-file-name-handlers'.
405 (tramp-completion-handle-file-name-all-completions)
406 (tramp-completion-handle-file-name-completion): New functions.
407
4082002-08-12 Michael Albinus <Michael.Albinus@alcatel.de>
409
410 * net/tramp.el (tramp-invoke-ange-ftp): `tramp-disable-ange-ftp'
411 must be called again after activating `ange-ftp'.
412 (tramp-ange-ftp-file-name-p): Check for Xemacs.
413
4142002-08-08 Michael Albinus <Michael.Albinus@alcatel.de>
415
416 * net/tramp.el (tramp-do-copy-or-rename-file): Don't pass
417 KEEP-DATE to tramp-invoke-ange-ftp 'rename.
418 (tramp-handle-write-region): Don't pass LOCKNAME and CONFIRM to
419 tramp-invoke-ange-ftp 'write-region.
420 (tramp-handle-set-file-modes): Change order of FILENAME and MODE
421 passing to tramp-invoke-ange-ftp 'set-file-modes.
422 (tramp-flatten-list): New function. Maybe this functionality does
423 exist already elsewhere in the libraries.
424 (tramp-invoke-ange-ftp): Apply `tramp-flatten-list' to parameter
425 list in order to avoid nested lists, f.e. when invoked from
426 `tramp-handle-dired-call-process'.
427
4282002-09-05 Kai Gro,b_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
429
430 * net/tramp.el (tramp-chunksize): New kluge variable.
431 (tramp-send-region): If tramp-chunksize is non-nil, send region in
432 parts and sleep 0.1 seconds between chunks.
433
4342002-09-03 Kai Gro,b_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
435
436 * net/tramp.el (tramp-handle-insert-directory): Use
437 `insert-buffer-substring' instead of `insert-buffer', which is not
438 supposed to be used from Lisp. Remember old point in a variable
439 instead of using `mark'. Suggestion from Stefan Monnier.
440 (tramp-unified-filenames): New variable. Use it in default value
441 of other filename variables.
442 (file-expand-wildcards): Don't advise unless "[" and "]" are used
443 in the filename format.
444
4452002-09-01 Kai Gro,b_(Bjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
446
447 * net/tramp.el (tramp-methods): Remove duplicate definition of
448 ssh1-old and ssh2-old.
449
4502002-09-22 Kai Gro,b_(Bjohann <grossjoh@ls6.informatik.uni-dortmund.de>
451
3 * dired.el (dired-insert-directory): Always add "--dired" to to 452 * dired.el (dired-insert-directory): Always add "--dired" to to
4 SWITCHES for remote files. 453 SWITCHES for remote files.
5 * files.el (insert-directory): Comment saying that "--dired" 454 * files.el (insert-directory): Comment saying that "--dired"
diff --git a/lisp/net/tramp-uu.el b/lisp/net/tramp-uu.el
new file mode 100644
index 00000000000..324e45e95d3
--- /dev/null
+++ b/lisp/net/tramp-uu.el
@@ -0,0 +1,89 @@
1;;; tramp-uu.el --- uuencode in Lisp
2
3;; Copyright (C) 2002 Free Software Foundation, Inc.
4
5;; Author: Kai Großjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE>
6;; Keywords: comm, terminals
7
8;; This file is free software; you can redistribute it and/or modify
9;; it under the terms of the GNU General Public License as published by
10;; the Free Software Foundation; either version 2, or (at your option)
11;; any later version.
12
13;; This file is distributed in the hope that it will be useful,
14;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;; GNU General Public License for more details.
17
18;; You should have received a copy of the GNU General Public License
19;; along with GNU Emacs; see the file COPYING. If not, write to
20;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21;; Boston, MA 02111-1307, USA.
22
23;;; Commentary:
24
25;; An implementation of "uuencode" in Lisp. Uses the function
26;; base64-encode-region which is built-in to modern Emacsen.
27
28;;; Code:
29
30(defvar tramp-uu-b64-alphabet
31 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
32 "Mapping from base64-encoded character to the byte it represents.")
33
34(defvar tramp-uu-b64-char-to-byte
35 (let ((i 0))
36 (mapcar (lambda (c)
37 (prog1
38 (cons c i)
39 (incf i)))
40 tramp-uu-b64-alphabet))
41 "Alist of mapping from base64 character to its byte.")
42
43(defun tramp-uu-byte-to-uu-char (byte)
44 "Return the character encoding BYTE."
45 (if (zerop byte) ?` (+ byte 32)))
46
47(defun tramp-uu-b64-char-to-byte (char)
48 "Return the byte that is encoded as CHAR."
49 (cdr (assq char tramp-uu-b64-char-to-byte)))
50
51(defun tramp-uuencode-region (beg end)
52 "UU-encode the region between BEG and END."
53 ;; First we base64 encode the region, then we transmogrify that into
54 ;; uu encoding.
55 (let ((len (base64-encode-region beg end t))
56 (padding 0)
57 i c)
58 (save-excursion
59 (goto-char beg)
60 (setq i 0)
61 (while (< i len)
62 (setq c (char-after (point)))
63 (delete-char 1)
64 (if (equal c ?=)
65 ;; "=" means padding. Insert "`" instead.
66 (insert "`")
67 (insert (tramp-uu-byte-to-uu-char (tramp-uu-b64-char-to-byte c))))
68 (incf i)
69 ;; Every 60 characters, add "M" at beginning of line (as
70 ;; length byte) and insert a newline.
71 (when (zerop (% i 60))
72 (save-excursion
73 (beginning-of-line)
74 (insert (char-to-string (+ 32 (/ (* 3 60) 4)))))
75 (insert "\n")))
76 ;; If there is something leftover, we compute the length byte
77 ;; for that stuff and insert it and a trailing newline.
78 (unless (zerop (% i 60))
79 (save-excursion
80 (beginning-of-line)
81 (insert (char-to-string (+ 32 (% (- end beg) 45)))))
82 (insert "\n"))
83 ;; Why is there always a "`" line at the end?
84 (insert "`\nend\n")
85 (goto-char beg)
86 (insert "begin 600 xxx\n"))))
87
88(provide 'tramp-uu)
89;;; tramp-uu.el ends here
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index fb94491ae0c..259a52f583b 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -72,7 +72,7 @@
72;; In the Tramp CVS repository, the version numer is auto-frobbed from 72;; In the Tramp CVS repository, the version numer is auto-frobbed from
73;; the Makefile, so you should edit the top-level Makefile to change 73;; the Makefile, so you should edit the top-level Makefile to change
74;; the version number. 74;; the version number.
75(defconst tramp-version "2.0.15" 75(defconst tramp-version "2.0.20"
76 "This version of tramp.") 76 "This version of tramp.")
77 77
78(defconst tramp-bug-report-address "tramp-devel@mail.freesoftware.fsf.org" 78(defconst tramp-bug-report-address "tramp-devel@mail.freesoftware.fsf.org"
@@ -89,6 +89,12 @@
89(require 'shell) 89(require 'shell)
90(require 'advice) 90(require 'advice)
91 91
92(autoload 'tramp-uuencode-region "tramp-uu"
93 "Implementation of `uuencode' in Lisp.")
94
95(unless (fboundp 'uudecode-decode-region)
96 (autoload 'uudecode-decode-region "uudecode"))
97
92;; ;; It does not work to load EFS after loading TRAMP. 98;; ;; It does not work to load EFS after loading TRAMP.
93;; (when (fboundp 'efs-file-handler-function) 99;; (when (fboundp 'efs-file-handler-function)
94;; (require 'efs)) 100;; (require 'efs))
@@ -103,6 +109,18 @@
103(unless (boundp 'custom-print-functions) 109(unless (boundp 'custom-print-functions)
104 (defvar custom-print-functions nil)) ; not autoloaded before Emacs 20.4 110 (defvar custom-print-functions nil)) ; not autoloaded before Emacs 20.4
105 111
112;; XEmacs is distributed with few Lisp packages. Further packages are
113;; installed using EFS. If we use a unified filename format, then
114;; Tramp is required in addition to EFS. (But why can't Tramp just
115;; disable EFS when Tramp is loaded? Then XEmacs can ship with EFS
116;; just like before.) Another reason for using a separate filename
117;; syntax on XEmacs is that EFS hooks into XEmacs in many places, but
118;; Tramp only knows how to deal with `file-name-handler-alist', not
119;; the other places.
120(defvar tramp-unified-filenames (not (featurep 'xemacs))
121 "Non-nil means to use unified Ange-FTP/Tramp filename syntax.
122Nil means to use a separate filename syntax for Tramp.")
123
106;;; User Customizable Internal Variables: 124;;; User Customizable Internal Variables:
107 125
108(defgroup tramp nil 126(defgroup tramp nil
@@ -126,13 +144,24 @@ The idea is to use a local directory so that auto-saving is faster."
126 :type '(choice (const nil) 144 :type '(choice (const nil)
127 string)) 145 string))
128 146
129(defcustom tramp-sh-program "/bin/sh" 147(defcustom tramp-encoding-shell
130 "*Use this program for shell commands on the local host. 148 (if (memq system-type '(windows-nt))
131This MUST be a Bourne-like shell. This shell is used to execute 149 (getenv "COMSPEC")
132the encoding and decoding command on the local host, so if you 150 "/bin/sh")
133want to use `~' in those commands, you should choose a shell here 151 "*Use this program for encoding and decoding commands on the local host.
134which groks tilde expansion. `/bin/sh' normally does not 152This shell is used to execute the encoding and decoding command on the
135understand tilde expansion. 153local host, so if you want to use `~' in those commands, you should
154choose a shell here which groks tilde expansion. `/bin/sh' normally
155does not understand tilde expansion.
156
157For encoding and deocding, commands like the following are executed:
158
159 /bin/sh -c COMMAND < INPUT > OUTPUT
160
161This variable can be used to change the \"/bin/sh\" part. See the
162variable `tramp-encoding-command-switch' for the \"-c\" part. Also, see the
163variable `tramp-encoding-reads-stdin' to specify whether the commands read
164standard input or a file.
136 165
137Note that this variable is not used for remote commands. There are 166Note that this variable is not used for remote commands. There are
138mechanisms in tramp.el which automatically determine the right shell to 167mechanisms in tramp.el which automatically determine the right shell to
@@ -140,12 +169,27 @@ use for the remote host."
140 :group 'tramp 169 :group 'tramp
141 :type '(file :must-match t)) 170 :type '(file :must-match t))
142 171
172(defcustom tramp-encoding-command-switch
173 (if (string-match "cmd\\.exe" tramp-encoding-shell)
174 "/c"
175 "-c")
176 "*Use this switch together with `tramp-encoding-shell' for local commands.
177See the variable `tramp-encoding-shell' for more information."
178 :group 'tramp
179 :type 'string)
180
181(defcustom tramp-encoding-reads-stdin t
182 "*If non-nil, encoding commands read from standard input.
183If nil, the filename is the last argument.
184
185Note that the commands always must write to standard output."
186 :group 'tramp
187 :type 'boolean)
188
143(defcustom tramp-multi-sh-program 189(defcustom tramp-multi-sh-program
144 (if (memq system-type '(windows-nt)) 190 tramp-encoding-shell
145 "cmd.exe"
146 tramp-sh-program)
147 "*Use this program for bootstrapping multi-hop connections. 191 "*Use this program for bootstrapping multi-hop connections.
148This variable is similar to `tramp-sh-program', but it is only used 192This variable is similar to `tramp-encoding-shell', but it is only used
149when initializing a multi-hop connection. Therefore, the set of 193when initializing a multi-hop connection. Therefore, the set of
150commands sent to this shell is quite restricted, and if you are 194commands sent to this shell is quite restricted, and if you are
151careful it works to use CMD.EXE under Windows (instead of a Bourne-ish 195careful it works to use CMD.EXE under Windows (instead of a Bourne-ish
@@ -154,8 +198,7 @@ shell which does not normally exist on Windows anyway).
154To use multi-hop methods from Windows, you also need suitable entries 198To use multi-hop methods from Windows, you also need suitable entries
155in `tramp-multi-connection-function-alist' for the first hop. 199in `tramp-multi-connection-function-alist' for the first hop.
156 200
157This variable defaults to CMD.EXE on Windows NT, and to the value of 201This variable defaults to the value of `tramp-encoding-shell'."
158`tramp-sh-program' on other systems."
159 :group 'tramp 202 :group 'tramp
160 :type '(file :must-match t)) 203 :type '(file :must-match t))
161 204
@@ -440,7 +483,7 @@ This variable defaults to CMD.EXE on Windows NT, and to the value of
440This is a list of entries of the form (NAME PARAM1 PARAM2 ...). 483This is a list of entries of the form (NAME PARAM1 PARAM2 ...).
441Each NAME stands for a remote access method. Each PARAM is a 484Each NAME stands for a remote access method. Each PARAM is a
442pair of the form (KEY VALUE). The following KEYs are defined: 485pair of the form (KEY VALUE). The following KEYs are defined:
443 * `tramp-connection-function' 486 * `tramp-connection-function'
444 This specifies the function to use to connect to the remote host. 487 This specifies the function to use to connect to the remote host.
445 Currently, `tramp-open-connection-rsh', `tramp-open-connection-telnet' 488 Currently, `tramp-open-connection-rsh', `tramp-open-connection-telnet'
446 and `tramp-open-connection-su' are defined. See the documentation 489 and `tramp-open-connection-su' are defined. See the documentation
@@ -477,24 +520,6 @@ pair of the form (KEY VALUE). The following KEYs are defined:
477 This specifies the list of arguments to pass to `su'. 520 This specifies the list of arguments to pass to `su'.
478 \"%u\" is replaced by the user name, use \"%%\" for a literal 521 \"%u\" is replaced by the user name, use \"%%\" for a literal
479 percent character. 522 percent character.
480 * `tramp-encoding-command'
481 This specifies a command to use to encode the file contents for
482 transfer. The command should read the raw file contents from
483 standard input and write the encoded file contents to standard
484 output. In this string, the percent escape \"%f\" should be used
485 to indicate the file to convert. Use \"%%\" if you need a literal
486 percent character in your command.
487 * `tramp-decoding-command'
488 This specifies a command to use to decode file contents encoded
489 with `tramp-encoding-command'. The command should read from standard
490 input and write to standard output.
491 * `tramp-encoding-function'
492 This specifies a function to be called to encode the file contents
493 on the local side. This function should accept two arguments
494 START and END, the beginning and end of the region to encode. The
495 region should be replaced with the encoded contents.
496 * `tramp-decoding-function'
497 Same for decoding on the local side.
498 * `tramp-telnet-program' 523 * `tramp-telnet-program'
499 Specifies the telnet program to use when using 524 Specifies the telnet program to use when using
500 `tramp-open-connection-telnet' to log in. 525 `tramp-open-connection-telnet' to log in.
@@ -514,28 +539,13 @@ file is passed through the same buffer used by `tramp-rsh-program'. In
514this case, the file contents need to be protected since the 539this case, the file contents need to be protected since the
515`tramp-rsh-program' might use escape codes or the connection might not 540`tramp-rsh-program' might use escape codes or the connection might not
516be eight-bit clean. Therefore, file contents are encoded for transit. 541be eight-bit clean. Therefore, file contents are encoded for transit.
542See the variable `tramp-coding-commands' for details.
517 543
518Two possibilities for encoding are uuencode/uudecode and mimencode. 544So, to summarize: if the method is an out-of-band method, then you
519For uuencode/uudecode you want to set `tramp-encoding-command' to 545must specify `tramp-rcp-program' and `tramp-rcp-args'. If it is an
520something like \"uuencode\" and `tramp-decoding-command' to \"uudecode 546inline method, then these two parameters should be nil. Every method,
521-p\". For mimencode you want to set `tramp-encoding-command' to 547inline or out of band, must specify `tramp-connection-function' plus
522something like \"mimencode -b\" and `tramp-decoding-command' to 548the associated arguments (for example, the telnet program if you chose
523\"mimencode -b -u\".
524
525When using inline transfer, you can use a program or a Lisp function
526on the local side to encode or decode the file contents. Set the
527`tramp-encoding-function' and `tramp-decoding-function' parameters to nil
528in order to use the commands or to the function to use. It is
529possible to specify one function and the other parameter as nil.
530
531So, to summarize: if the method is an inline method, you must specify
532`tramp-encoding-command' and `tramp-decoding-command', and
533`tramp-rcp-program' must be nil. If the method is out of band, then
534you must specify `tramp-rcp-program' and `tramp-rcp-args' and
535`tramp-encoding-command' and `tramp-decoding-command' must be nil.
536Every method, inline or out of band, must specify
537`tramp-connection-function' plus the associated arguments (for
538example, the telnet program if you chose
539`tramp-open-connection-telnet'). 549`tramp-open-connection-telnet').
540 550
541Notes: 551Notes:
@@ -544,19 +554,7 @@ When using `tramp-open-connection-su' the phrase `open connection to a
544remote host' sounds strange, but it is used nevertheless, for 554remote host' sounds strange, but it is used nevertheless, for
545consistency. No connection is opened to a remote host, but `su' is 555consistency. No connection is opened to a remote host, but `su' is
546started on the local host. You are not allowed to specify a remote 556started on the local host. You are not allowed to specify a remote
547host other than `localhost' or the name of the local host. 557host other than `localhost' or the name of the local host."
548
549Using a uuencode/uudecode inline method is discouraged, please use one
550of the base64 methods instead since base64 encoding is much more
551reliable and the commands are more standardized between the different
552Unix versions. But if you can't use base64 for some reason, please
553note that the default uudecode command does not work well for some
554Unices, in particular AIX and Irix. For AIX, you might want to use
555the following command for uudecode:
556
557 sed '/^begin/d;/^[` ]$/d;/^end/d' | iconv -f uucode -t ISO8859-1
558
559For Irix, no solution is known yet."
560 :group 'tramp 558 :group 'tramp
561 :type '(repeat 559 :type '(repeat
562 (cons string 560 (cons string
@@ -629,8 +627,7 @@ for Tramp and EFS, so there the default method is \"sm\"."
629 :type 'string) 627 :type 'string)
630 628
631(defcustom tramp-default-method-alist 629(defcustom tramp-default-method-alist
632 (if (featurep 'xemacs) 630 (when tramp-unified-filenames
633 nil
634 '(("\\`ftp\\." "" "ftp") 631 '(("\\`ftp\\." "" "ftp")
635 ("" "\\`\\(anonymous\\|ftp\\)\\'" "ftp"))) 632 ("" "\\`\\(anonymous\\|ftp\\)\\'" "ftp")))
636 "*Default method to use for specific user/host pairs. 633 "*Default method to use for specific user/host pairs.
@@ -654,10 +651,102 @@ See `tramp-methods' for a list of possibilities for METHOD."
654 :group 'tramp 651 :group 'tramp
655 :type 'string) 652 :type 'string)
656 653
654;; Default values for non-Unices seeked
655(defconst tramp-completion-function-alist-rsh
656 (unless (memq system-type '(windows-nt))
657 '((tramp-parse-rhosts "/etc/hosts.equiv")
658 (tramp-parse-rhosts "~/.rhosts")))
659 "Default list of (FUNNCTION FILE) pairs to be examined for rsh methods."
660)
661
662;; Default values for non-Unices seeked
663(defconst tramp-completion-function-alist-ssh
664 (unless (memq system-type '(windows-nt))
665 '((tramp-parse-rhosts "/etc/hosts.equiv")
666 (tramp-parse-rhosts "/etc/shosts.equiv")
667 (tramp-parse-shosts "/etc/ssh_known_hosts")
668 (tramp-parse-rhosts "~/.rhosts")
669 (tramp-parse-rhosts "~/.shosts")
670 (tramp-parse-shosts "~/.ssh/known_hosts")))
671 "Default list of (FUNNCTION FILE) pairs to be examined for ssh methods."
672)
673
674;; Default values for non-Unices seeked
675(defconst tramp-completion-function-alist-telnet
676 (unless (memq system-type '(windows-nt))
677 '((tramp-parse-hosts "/etc/hosts")))
678 "Default list of (FUNNCTION FILE) pairs to be examined for telnet methods."
679)
680
681;; Default values for non-Unices seeked
682(defconst tramp-completion-function-alist-su
683 (unless (memq system-type '(windows-nt))
684 '((tramp-parse-passwd "/etc/passwd")))
685 "Default list of (FUNNCTION FILE) pairs to be examined for su methods."
686)
687
688(defcustom tramp-completion-function-alist
689 (list (cons "rcp" tramp-completion-function-alist-rsh)
690 (cons "scp" tramp-completion-function-alist-ssh)
691 (cons "scp1" tramp-completion-function-alist-ssh)
692 (cons "scp2" tramp-completion-function-alist-ssh)
693 (cons "scp1-old" tramp-completion-function-alist-ssh)
694 (cons "scp2-old" tramp-completion-function-alist-ssh)
695 (cons "rsync" tramp-completion-function-alist-rsh)
696 (cons "rsh" tramp-completion-function-alist-rsh)
697 (cons "ssh" tramp-completion-function-alist-ssh)
698 (cons "ssh1" tramp-completion-function-alist-ssh)
699 (cons "ssh2" tramp-completion-function-alist-ssh)
700 (cons "ssh1-old" tramp-completion-function-alist-ssh)
701 (cons "ssh2-old" tramp-completion-function-alist-ssh)
702 (cons "telnet" tramp-completion-function-alist-telnet)
703 (cons "su" tramp-completion-function-alist-su)
704 (cons "sudo" tramp-completion-function-alist-su)
705 (cons "multi" nil)
706 (cons "scpx" tramp-completion-function-alist-ssh)
707 (cons "sshx" tramp-completion-function-alist-ssh)
708 (cons "krlogin" tramp-completion-function-alist-rsh)
709 (cons "plink" tramp-completion-function-alist-ssh)
710 (cons "pscp" tramp-completion-function-alist-ssh)
711 (cons "fcp" nil)
712 )
713 "*Alist of methods for remote files.
714This is a list of entries of the form (NAME PAIR1 PAIR2 ...).
715Each NAME stands for a remote access method. Each PAIR is of the form
716\(FUNCTION FILE). FUNCTION is responsible to extract user names and host
717names from FILE for completion. The following predefined FUNCTIONs exists:
718
719 * `tramp-parse-rhosts' for \".rhosts\" like files,
720 * `tramp-parse-shosts' for \"ssh_known_hosts\" like files,
721 * `tramp-parse-hosts' for \"/etc/hosts\" like files, and
722 * `tramp-parse-passwd' for \"/etc/passwd\" like files.
723
724A FUNCTION parsing \".netrc\" file syntax doesn't exist in TRAMP. This
725task is delegated to ange-ftp; its customization should be used instead.
726
727FUNCTION can also see a customer defined function. For more details see
728the info pages."
729 :group 'tramp
730 :type '(repeat
731 (cons string
732 (choice (const nil) (repeat (list function file))))))
733
657(defcustom tramp-rsh-end-of-line "\n" 734(defcustom tramp-rsh-end-of-line "\n"
658 "*String used for end of line in rsh connections. 735 "*String used for end of line in rsh connections.
659I don't think this ever needs to be changed, so please tell me about it 736I don't think this ever needs to be changed, so please tell me about it
660if you need to change this." 737if you need to change this.
738Also see `tramp-password-end-of-line'."
739 :group 'tramp
740 :type 'string)
741
742(defcustom tramp-password-end-of-line tramp-rsh-end-of-line
743 "*String used for end of line after sending a password.
744It seems that people using plink under Windows need to send
745\"\\r\\n\" (carriage-return, then newline) after a password, but just
746\"\\n\" after all other lines. This variable can be used for the
747password, see `tramp-rsh-end-of-line' for the other cases.
748
749The default value is to use the same value as `tramp-rsh-end-of-line'."
661 :group 'tramp 750 :group 'tramp
662 :type 'string) 751 :type 'string)
663 752
@@ -774,33 +863,134 @@ shell from reading its init file."
774 :group 'tramp 863 :group 'tramp
775 :type '(alist :key-type string :value-type string)) 864 :type '(alist :key-type string :value-type string))
776 865
777;; File name format. 866(defcustom tramp-prefix-format
867 (if tramp-unified-filenames "/" "/[")
868 "*String matching the very beginning of tramp file names.
869Used in `tramp-make-tramp-file-name' and `tramp-make-tramp-multi-file-name'."
870 :group 'tramp
871 :type 'string)
872
873(defcustom tramp-prefix-regexp
874 (concat "^" (regexp-quote tramp-prefix-format))
875 "*Regexp matching the very beginning of tramp file names.
876Should always start with \"^\". Derived from `tramp-prefix-format'."
877 :group 'tramp
878 :type 'regexp)
879
880(defcustom tramp-method-regexp
881 "[a-zA-Z_0-9-]+"
882 "*Regexp matching methods identifiers."
883 :group 'tramp
884 :type 'regexp)
885
886;; It is a little bit annoying that in XEmacs case this delimeter is different
887;; for single-hop and multi-hop cases.
888(defcustom tramp-postfix-single-method-format
889 (if tramp-unified-filenames ":" "/")
890 "*String matching delimeter between method and user or host names.
891Applicable for single-hop methods.
892Used in `tramp-make-tramp-file-name'."
893 :group 'tramp
894 :type 'string)
895
896(defcustom tramp-postfix-single-method-regexp
897 (regexp-quote tramp-postfix-single-method-format)
898 "*Regexp matching delimeter between method and user or host names.
899Applicable for single-hop methods.
900Derived from `tramp-postfix-single-method-format'."
901 :group 'tramp
902 :type 'regexp)
903
904(defcustom tramp-postfix-multi-method-format
905 ":"
906 "*String matching delimeter between method and user or host names.
907Applicable for multi-hop methods.
908Used in `tramp-make-tramp-multi-file-name'."
909 :group 'tramp
910 :type 'string)
911
912(defcustom tramp-postfix-multi-method-regexp
913 (regexp-quote tramp-postfix-multi-method-format)
914 "*Regexp matching delimeter between method and user or host names.
915Applicable for multi-hop methods.
916Derived from `tramp-postfix-multi-method-format'."
917 :group 'tramp
918 :type 'regexp)
778 919
779(defconst tramp-file-name-structure-unified 920(defcustom tramp-postfix-multi-hop-format
780 (list (concat "\\`/\\(\\([a-zA-Z0-9-]+\\):\\)?" ;method 921 (if tramp-unified-filenames ":" "/")
781 "\\(\\([^:@/]+\\)@\\)?" ;user 922 "*String matching delimeter between path and next method.
782 "\\([^:/]+\\):" ;host 923Applicable for multi-hop methods.
783 "\\(.*\\)\\'") ;path 924Used in `tramp-make-tramp-multi-file-name'."
784 2 4 5 6) 925 :group 'tramp
785 "Default value for `tramp-file-name-structure' for unified remoting. 926 :type 'string)
786On Emacs (not XEmacs), the Tramp and Ange-FTP packages use a unified 927
787filename space. This value is used for this unified namespace.") 928(defcustom tramp-postfix-multi-hop-regexp
788 929 (regexp-quote tramp-postfix-multi-hop-format)
789(defconst tramp-file-name-structure-separate 930 "*Regexp matching delimeter between path and next method.
790 (list (concat "\\`/\\[\\(\\([a-zA-Z0-9-]+\\)/\\)?" ;method 931Applicable for multi-hop methods.
791 "\\(\\([-a-zA-Z0-9_#/:]+\\)@\\)?" ;user 932Derived from `tramp-postfix-multi-hop-format'."
792 "\\([-a-zA-Z0-9_#/:@.]+\\)\\]" ;host 933 :group 'tramp
793 "\\(.*\\)\\'") ;path 934 :type 'regexp)
794 2 4 5 6) 935
795 "Default value for `tramp-file-name-structure' for separate remoting. 936(defcustom tramp-user-regexp
796On XEmacs, the Tramp and EFS packages use a separate namespace for 937 "[^:@/]*"
797remote filenames. This value is used in that case. It is designed 938 "*Regexp matching user names."
798not to clash with the EFS filename syntax.") 939 :group 'tramp
940 :type 'regexp)
941
942(defcustom tramp-postfix-user-format
943 "@"
944 "*String matching delimeter between user and host names.
945Used in `tramp-make-tramp-file-name' and `tramp-make-tramp-multi-file-name'."
946 :group 'tramp
947 :type 'string)
948
949(defcustom tramp-postfix-user-regexp
950 (regexp-quote tramp-postfix-user-format)
951 "*Regexp matching delimeter between user and host names.
952Derived from `tramp-postfix-user-format'."
953 :group 'tramp
954 :type 'regexp)
955
956(defcustom tramp-host-regexp
957 "[a-zA-Z0-9_.-]*"
958 "*Regexp matching host names."
959 :group 'tramp
960 :type 'regexp)
961
962(defcustom tramp-postfix-host-format
963 (if tramp-unified-filenames ":" "]")
964 "*String matching delimeter between host names and paths.
965Used in `tramp-make-tramp-file-name' and `tramp-make-tramp-multi-file-name'."
966 :group 'tramp
967 :type 'string)
968
969(defcustom tramp-postfix-host-regexp
970 (regexp-quote tramp-postfix-host-format)
971 "*Regexp matching delimeter between host names and paths.
972Derived from `tramp-postfix-host-format'."
973 :group 'tramp
974 :type 'regexp)
975
976(defcustom tramp-path-regexp
977 ".*$"
978 "*Regexp matching paths."
979 :group 'tramp
980 :type 'regexp)
981
982;; File name format.
799 983
800(defcustom tramp-file-name-structure 984(defcustom tramp-file-name-structure
801 (if (featurep 'xemacs) 985 (list
802 tramp-file-name-structure-separate 986 (concat
803 tramp-file-name-structure-unified) 987 tramp-prefix-regexp
988 "\\(" "\\(" tramp-method-regexp "\\)" tramp-postfix-single-method-regexp "\\)?"
989 "\\(" "\\(" tramp-user-regexp "\\)" tramp-postfix-user-regexp "\\)?"
990 "\\(" tramp-host-regexp "\\)" tramp-postfix-host-regexp
991 "\\(" tramp-path-regexp "\\)")
992 2 4 5 6)
993
804 "*List of five elements (REGEXP METHOD USER HOST FILE), detailing \ 994 "*List of five elements (REGEXP METHOD USER HOST FILE), detailing \
805the tramp file name structure. 995the tramp file name structure.
806 996
@@ -815,7 +1005,7 @@ but for the host name. The fifth element FILE is for the file name.
815These numbers are passed directly to `match-string', which see. That 1005These numbers are passed directly to `match-string', which see. That
816means the opening parentheses are counted to identify the pair. 1006means the opening parentheses are counted to identify the pair.
817 1007
818See also `tramp-file-name-regexp' and `tramp-make-tramp-file-format'." 1008See also `tramp-file-name-regexp'."
819 :group 'tramp 1009 :group 'tramp
820 :type '(list (regexp :tag "File name regexp") 1010 :type '(list (regexp :tag "File name regexp")
821 (integer :tag "Paren pair for method name") 1011 (integer :tag "Paren pair for method name")
@@ -839,9 +1029,9 @@ See `tramp-file-name-structure-separate' for more explanations.")
839 1029
840;;;###autoload 1030;;;###autoload
841(defcustom tramp-file-name-regexp 1031(defcustom tramp-file-name-regexp
842 (if (featurep 'xemacs) 1032 (if tramp-unified-filenames
843 tramp-file-name-regexp-separate 1033 tramp-file-name-regexp-unified
844 tramp-file-name-regexp-unified) 1034 tramp-file-name-regexp-separate)
845 "*Regular expression matching file names handled by tramp. 1035 "*Regular expression matching file names handled by tramp.
846This regexp should match tramp file names but no other file names. 1036This regexp should match tramp file names but no other file names.
847\(When tramp.el is loaded, this regular expression is prepended to 1037\(When tramp.el is loaded, this regular expression is prepended to
@@ -855,91 +1045,49 @@ this file (tramp.el) is loaded. This means that this variable must be set
855before loading tramp.el. Alternatively, `file-name-handler-alist' can be 1045before loading tramp.el. Alternatively, `file-name-handler-alist' can be
856updated after changing this variable. 1046updated after changing this variable.
857 1047
858Also see `tramp-file-name-structure' and `tramp-make-tramp-file-format'." 1048Also see `tramp-file-name-structure'."
859 :group 'tramp 1049 :group 'tramp
860 :type 'regexp) 1050 :type 'regexp)
861 1051
862(defconst tramp-make-tramp-file-format-unified 1052;;;###autoload
863 "/%m:%u@%h:%p" 1053(defconst tramp-completion-file-name-regexp-unified
864 "Value for `tramp-make-tramp-file-format' for unified remoting. 1054 "^/[^/]*$"
865Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and Tramp. 1055 "Value for `tramp-completion-file-name-regexp' for unified remoting.
866See `tramp-file-name-structure-unified' for more details.") 1056Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and
867 1057Tramp. See `tramp-file-name-structure-unified' for more explanations.")
868(defconst tramp-make-tramp-file-format-separate
869 "/[%m/%u@%h]%p"
870 "Value for `tramp-make-tramp-file-format' for separate remoting.
871XEmacs uses a separate filename syntax for EFS and Tramp.
872See `tramp-file-name-structure-separate' for more details.")
873
874(defcustom tramp-make-tramp-file-format
875 (if (featurep 'xemacs)
876 tramp-make-tramp-file-format-separate
877 tramp-make-tramp-file-format-unified)
878 "*Format string saying how to construct tramp file name.
879`%m' is replaced by the method name.
880`%u' is replaced by the user name.
881`%h' is replaced by the host name.
882`%p' is replaced by the file name.
883`%%' is replaced by %.
884
885Also see `tramp-file-name-structure' and `tramp-file-name-regexp'."
886 :group 'tramp
887 :type 'string)
888 1058
889(defconst tramp-make-tramp-file-user-nil-format-unified 1059;;;###autoload
890 "/%m:%h:%p" 1060(defconst tramp-completion-file-name-regexp-separate
891 "Value of `tramp-make-tramp-file-user-nil-format' for unified remoting. 1061 "^/\\([[][^]]*\\)?$"
892Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and Tramp. 1062 "Value for `tramp-completion-file-name-regexp' for separate remoting.
893See `tramp-file-name-structure-unified' for details.") 1063XEmacs uses a separate filename syntax for Tramp and EFS.
894 1064See `tramp-file-name-structure-separate' for more explanations.")
895(defconst tramp-make-tramp-file-user-nil-format-separate
896 "/[%m/%h]%p"
897 "Value of `tramp-make-tramp-file-user-nil-format' for separate remoting.
898XEmacs uses a separate filename syntax for EFS and Tramp.
899See `tramp-file-name-structure-separate' for details.")
900
901(defcustom tramp-make-tramp-file-user-nil-format
902 (if (featurep 'xemacs)
903 tramp-make-tramp-file-user-nil-format-separate
904 tramp-make-tramp-file-user-nil-format-unified)
905 "*Format string saying how to construct tramp file name when the user name is not known.
906`%m' is replaced by the method name.
907`%h' is replaced by the host name.
908`%p' is replaced by the file name.
909`%%' is replaced by %.
910
911Also see `tramp-make-tramp-file-format', `tramp-file-name-structure', and `tramp-file-name-regexp'."
912 :group 'tramp
913 :type 'string)
914 1065
915(defconst tramp-multi-file-name-structure-unified 1066;;;###autoload
916 (list (concat "\\`/\\(\\([a-zA-Z0-9]+\\)?:\\)" ;method 1067(defcustom tramp-completion-file-name-regexp
917 "\\(\\(%s\\)+\\)" ;hops 1068 (if tramp-unified-filenames
918 "\\(.*\\)\\'") ;path 1069 tramp-completion-file-name-regexp-unified
919 2 3 -1) 1070 tramp-completion-file-name-regexp-separate)
920 "Value for `tramp-multi-file-name-structure' for unified remoting. 1071 "*Regular expression matching file names handled by tramp completion.
921Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and Tramp. 1072This regexp should match partial tramp file names only.
922See `tramp-file-name-structure-unified' for details.") 1073
923 1074Please note that the entry in `file-name-handler-alist' is made when
924(defconst tramp-multi-file-name-structure-separate 1075this file (tramp.el) is loaded. This means that this variable must be set
925 (list (concat 1076before loading tramp.el. Alternatively, `file-name-handler-alist' can be
926 ;; prefix 1077updated after changing this variable.
927 "\\`/\\[\\(\\([a-z0-9]+\\)?\\)" 1078
928 ;; regexp specifying the hops 1079Also see `tramp-file-name-structure'."
929 "\\(\\(%s\\)+\\)" 1080 :group 'tramp
930 ;; path name 1081 :type 'regexp)
931 "\\]\\(.*\\)\\'")
932 2 ;number of pair to match method
933 3 ;number of pair to match hops
934 -1) ;number of pair to match path
935 "Value of `tramp-multi-file-name-structure' for separate remoting.
936XEmacs uses a separate filename syntax for EFS and Tramp.
937See `tramp-file-name-structure-separate' for details.")
938 1082
939(defcustom tramp-multi-file-name-structure 1083(defcustom tramp-multi-file-name-structure
940 (if (featurep 'xemacs) 1084 (list
941 tramp-multi-file-name-structure-separate 1085 (concat
942 tramp-multi-file-name-structure-unified) 1086 tramp-prefix-regexp
1087 "\\(" "\\(" tramp-method-regexp "\\)" "\\)?"
1088 "\\(" "\\(" tramp-postfix-multi-hop-regexp "%s" "\\)+" "\\)?"
1089 tramp-postfix-host-regexp "\\(" tramp-path-regexp "\\)")
1090 2 3 -1)
943 "*Describes the file name structure of `multi' files. 1091 "*Describes the file name structure of `multi' files.
944Multi files allow you to contact a remote host in several hops. 1092Multi files allow you to contact a remote host in several hops.
945This is a list of four elements (REGEXP METHOD HOP PATH). 1093This is a list of four elements (REGEXP METHOD HOP PATH).
@@ -967,28 +1115,13 @@ string, but I haven't actually tried what happens if it doesn't..."
967 (integer :tag "Paren pair for hops") 1115 (integer :tag "Paren pair for hops")
968 (integer :tag "Paren pair to match path"))) 1116 (integer :tag "Paren pair to match path")))
969 1117
970(defconst tramp-multi-file-name-hop-structure-unified
971 (list (concat "\\([a-zA-z0-9_]+\\):" ;hop method
972 "\\([^@:/]+\\)@" ;user
973 "\\([^:/]+\\):") ;host
974 1 2 3)
975 "Value of `tramp-multi-file-name-hop-structure' for unified remoting.
976Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and Tramp.
977See `tramp-file-name-structure-unified' for details.")
978
979(defconst tramp-multi-file-name-hop-structure-separate
980 (list (concat "/\\([a-z0-9_]+\\):" ;hop method
981 "\\([a-z0-9_]+\\)@" ;user
982 "\\([a-z0-9.-]+\\)") ;host
983 1 2 3)
984 "Value of `tramp-multi-file-name-hop-structure' for separate remoting.
985XEmacs uses a separate filename syntax for EFS and Tramp.
986See `tramp-file-name-structure-separate' for details.")
987
988(defcustom tramp-multi-file-name-hop-structure 1118(defcustom tramp-multi-file-name-hop-structure
989 (if (featurep 'xemacs) 1119 (list
990 tramp-multi-file-name-hop-structure-separate 1120 (concat
991 tramp-multi-file-name-hop-structure-unified) 1121 "\\(" tramp-method-regexp "\\)" tramp-postfix-multi-method-regexp
1122 "\\(" tramp-user-regexp "\\)" tramp-postfix-user-regexp
1123 "\\(" tramp-host-regexp "\\)")
1124 1 2 3)
992 "*Describes the structure of a hop in multi files. 1125 "*Describes the structure of a hop in multi files.
993This is a list of four elements (REGEXP METHOD USER HOST). First 1126This is a list of four elements (REGEXP METHOD USER HOST). First
994element REGEXP is used to match against the hop. Pair number METHOD 1127element REGEXP is used to match against the hop. Pair number METHOD
@@ -1002,22 +1135,14 @@ This regular expression should match exactly all of one hop."
1002 (integer :tag "Paren pair for user name") 1135 (integer :tag "Paren pair for user name")
1003 (integer :tag "Paren pair for host name"))) 1136 (integer :tag "Paren pair for host name")))
1004 1137
1005(defconst tramp-make-multi-tramp-file-format-unified
1006 (list "/%m" ":%m:%u@%h" ":%p")
1007 "Value of `tramp-make-multi-tramp-file-format' for unified remoting.
1008Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and Tramp.
1009See `tramp-file-name-structure-unified' for details.")
1010
1011(defconst tramp-make-multi-tramp-file-format-separate
1012 (list "/[%m" "/%m:%u@%h" "]%p")
1013 "Value of `tramp-make-multi-tramp-file-format' for separate remoting.
1014XEmacs uses a separate filename syntax for EFS and Tramp.
1015See `tramp-file-name-structure-separate' for details.")
1016
1017(defcustom tramp-make-multi-tramp-file-format 1138(defcustom tramp-make-multi-tramp-file-format
1018 (if (featurep 'xemacs) 1139 (list
1019 tramp-make-multi-tramp-file-format-separate 1140 (concat tramp-prefix-format "%m")
1020 tramp-make-multi-tramp-file-format-unified) 1141 (concat tramp-postfix-multi-hop-format
1142 "%m" tramp-postfix-multi-method-format
1143 "%u" tramp-postfix-user-format
1144 "%h")
1145 (concat tramp-postfix-host-format "%p"))
1021 "*Describes how to construct a `multi' file name. 1146 "*Describes how to construct a `multi' file name.
1022This is a list of three elements PREFIX, HOP and PATH. 1147This is a list of three elements PREFIX, HOP and PATH.
1023 1148
@@ -1327,7 +1452,7 @@ use strict;
1327 1452
1328my %%trans = do { 1453my %%trans = do {
1329 my $i = 0; 1454 my $i = 0;
1330 map {($_, sprintf(q(%%06b), $i++))} 1455 map {($_, substr(unpack(q(B8), chr $i++), 2, 6))}
1331 split //, q(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/) 1456 split //, q(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/)
1332}; 1457};
1333 1458
@@ -1348,7 +1473,7 @@ while (my $data = <STDIN>) {
1348 $pending .= $data; 1473 $pending .= $data;
1349 1474
1350 my $len = length($pending); 1475 my $len = length($pending);
1351 my $chunk = substr($pending, 0, $len & ~3, q()); 1476 my $chunk = substr($pending, 0, $len & ~3);
1352 1477
1353 # Easy method: translate from chars to (pregenerated) six-bit packets, join, 1478 # Easy method: translate from chars to (pregenerated) six-bit packets, join,
1354 # split in 8-bit chunks and convert back to char. 1479 # split in 8-bit chunks and convert back to char.
@@ -1398,7 +1523,7 @@ This variable is buffer-local in every buffer.")
1398;; This variable does not have the right value in XEmacs. What should 1523;; This variable does not have the right value in XEmacs. What should
1399;; I use instead of find-operation-coding-system in XEmacs? 1524;; I use instead of find-operation-coding-system in XEmacs?
1400(defvar tramp-feature-write-region-fix 1525(defvar tramp-feature-write-region-fix
1401 (unless (featurep 'xemacs) 1526 (when (fboundp 'find-operation-coding-system)
1402 (let ((file-coding-system-alist '(("test" emacs-mule)))) 1527 (let ((file-coding-system-alist '(("test" emacs-mule))))
1403 (find-operation-coding-system 'write-region 0 0 "" nil "test"))) 1528 (find-operation-coding-system 'write-region 0 0 "" nil "test")))
1404 "Internal variable to say if `write-region' chooses the right coding. 1529 "Internal variable to say if `write-region' chooses the right coding.
@@ -1455,6 +1580,22 @@ on the FILENAME argument, even if VISIT was a string.")
1455 "Alist of handler functions. 1580 "Alist of handler functions.
1456Operations not mentioned here will be handled by the normal Emacs functions.") 1581Operations not mentioned here will be handled by the normal Emacs functions.")
1457 1582
1583;; Handlers for partial tramp file names. For GNU Emacs just
1584;; `file-name-all-completions' is needed. The other ones are necessary
1585;; for XEmacs.
1586(defconst tramp-completion-file-name-handler-alist
1587 '(
1588 (file-name-directory . tramp-completion-handle-file-name-directory)
1589 (file-name-nondirectory . tramp-completion-handle-file-name-nondirectory)
1590 (file-exists-p . tramp-completion-handle-file-exists-p)
1591 (file-name-all-completions . tramp-completion-handle-file-name-all-completions)
1592 (file-name-completion . tramp-completion-handle-file-name-completion)
1593 (expand-file-name . tramp-completion-handle-expand-file-name))
1594 "Alist of completion handler functions.
1595Used for file names matching `tramp-file-name-regexp'. Operations not
1596mentioned here will be handled by `tramp-file-name-handler-alist' or the
1597normal Emacs functions.")
1598
1458;;; Internal functions which must come first. 1599;;; Internal functions which must come first.
1459 1600
1460(defsubst tramp-message (level fmt-string &rest args) 1601(defsubst tramp-message (level fmt-string &rest args)
@@ -1527,6 +1668,30 @@ If VAR is nil, then we bind `v' to the structure and `multi-method',
1527 1668
1528(put 'with-parsed-tramp-file-name 'lisp-indent-function 2) 1669(put 'with-parsed-tramp-file-name 'lisp-indent-function 2)
1529 1670
1671;;; Config Manipulation Functions:
1672
1673(defun tramp-set-completion-function (method function-list)
1674 "Sets the list of completion functions for METHOD.
1675FUNCTION-LIST is a list of entries of the form (FUNCTION FILE).
1676The FUNCTION is intended to parse FILE according its syntax.
1677It might be a predefined FUNCTION, or a user defined FUNCTION.
1678Predefined FUNCTIONs are `tramp-parse-rhosts', `tramp-parse-shosts',
1679`tramp-parse-hosts', and `tramp-parse-passwd'.
1680Example:
1681
1682 (tramp-set-completion-function
1683 \"ssh\"
1684 '((tramp-parse-shosts \"/etc/ssh_known_hosts\")
1685 (tramp-parse-shosts \"~/.ssh/known_hosts\")))"
1686
1687 (let ((v (cdr (assoc method tramp-completion-function-alist))))
1688 (when v (setcdr v function-list))))
1689
1690(defun tramp-get-completion-function (method)
1691 "Returns list of completion functions for METHOD.
1692For definition of that list see `tramp-set-completion-function'."
1693 (cdr (assoc method tramp-completion-function-alist)))
1694
1530;;; File Name Handler Functions: 1695;;; File Name Handler Functions:
1531 1696
1532(defun tramp-handle-make-symbolic-link 1697(defun tramp-handle-make-symbolic-link
@@ -2556,6 +2721,11 @@ This is like `dired-recursive-delete-directory' for tramp files."
2556(defun tramp-handle-insert-directory 2721(defun tramp-handle-insert-directory
2557 (filename switches &optional wildcard full-directory-p) 2722 (filename switches &optional wildcard full-directory-p)
2558 "Like `insert-directory' for tramp files." 2723 "Like `insert-directory' for tramp files."
2724 ;; For the moment, we assume that the remote "ls" program does not
2725 ;; grok "--dired". In the future, we should detect this on
2726 ;; connection setup.
2727 (when (string-match "^--dired\\s-+" switches)
2728 (setq switches (replace-match "" nil t switches)))
2559 (setq filename (expand-file-name filename)) 2729 (setq filename (expand-file-name filename))
2560 (with-parsed-tramp-file-name filename nil 2730 (with-parsed-tramp-file-name filename nil
2561 (when (tramp-ange-ftp-file-name-p multi-method method) 2731 (when (tramp-ange-ftp-file-name-p multi-method method)
@@ -2607,23 +2777,25 @@ This is like `dired-recursive-delete-directory' for tramp files."
2607 (file-name-nondirectory path))))) 2777 (file-name-nondirectory path)))))
2608 (sit-for 1) ;needed for rsh but not ssh? 2778 (sit-for 1) ;needed for rsh but not ssh?
2609 (tramp-wait-for-output)) 2779 (tramp-wait-for-output))
2610 (insert-buffer (tramp-get-buffer multi-method method user host)) 2780 (let ((old-pos (point)))
2611 ;; On XEmacs, we want to call (exchange-point-and-mark t), but 2781 (insert-buffer-substring
2612 ;; that doesn't exist on Emacs, so we use this workaround instead. 2782 (tramp-get-buffer multi-method method user host))
2613 ;; Since zmacs-region-stays doesn't exist in Emacs, this ought to 2783 ;; On XEmacs, we want to call (exchange-point-and-mark t), but
2614 ;; be safe. Thanks to Daniel Pittman <daniel@danann.net>. 2784 ;; that doesn't exist on Emacs, so we use this workaround instead.
2615 (let ((zmacs-region-stays t)) 2785 ;; Since zmacs-region-stays doesn't exist in Emacs, this ought to
2616 (exchange-point-and-mark)) 2786 ;; be safe. Thanks to Daniel Pittman <daniel@danann.net>.
2617 (save-excursion 2787 ;; (let ((zmacs-region-stays t))
2618 (tramp-send-command multi-method method user host "cd") 2788 ;; (exchange-point-and-mark))
2619 (tramp-wait-for-output))
2620 ;; Another XEmacs specialty follows. What's the right way to do
2621 ;; it?
2622 (when (and (featurep 'xemacs)
2623 (eq major-mode 'dired-mode))
2624 (save-excursion 2789 (save-excursion
2625 (require 'dired) 2790 (tramp-send-command multi-method method user host "cd")
2626 (dired-insert-set-properties (point) (mark t)))))) 2791 (tramp-wait-for-output))
2792 ;; Another XEmacs specialty follows. What's the right way to do
2793 ;; it?
2794 (when (and (featurep 'xemacs)
2795 (eq major-mode 'dired-mode))
2796 (save-excursion
2797 (require 'dired)
2798 (dired-insert-set-properties old-pos (point)))))))
2627 2799
2628;; Continuation of kluge to pacify byte-compiler. 2800;; Continuation of kluge to pacify byte-compiler.
2629;;(eval-when-compile 2801;;(eval-when-compile
@@ -2778,12 +2950,18 @@ This will break if COMMAND prints a newline, followed by the value of
2778 (when (tramp-ange-ftp-file-name-p multi-method method) 2950 (when (tramp-ange-ftp-file-name-p multi-method method)
2779 (tramp-invoke-ange-ftp 'file-local-copy filename)) 2951 (tramp-invoke-ange-ftp 'file-local-copy filename))
2780 (let ((trampbuf (get-buffer-create "*tramp output*")) 2952 (let ((trampbuf (get-buffer-create "*tramp output*"))
2953 (rcp-program (tramp-get-rcp-program
2954 multi-method
2955 (tramp-find-method multi-method method user host)))
2956 (rcp-args (tramp-get-rcp-args
2957 multi-method
2958 (tramp-find-method multi-method method user host)))
2781 tmpfil) 2959 tmpfil)
2782 (unless (file-exists-p filename) 2960 (unless (file-exists-p filename)
2783 (error "Cannot make local copy of non-existing file `%s'" 2961 (error "Cannot make local copy of non-existing file `%s'"
2784 filename)) 2962 filename))
2785 (setq tmpfil (tramp-make-temp-file)) 2963 (setq tmpfil (tramp-make-temp-file))
2786 (cond ((tramp-get-rcp-program multi-method method) 2964 (cond (rcp-program
2787 ;; Use rcp-like program for file transfer. 2965 ;; Use rcp-like program for file transfer.
2788 (tramp-message-for-buffer 2966 (tramp-message-for-buffer
2789 multi-method method user host 2967 multi-method method user host
@@ -2792,9 +2970,9 @@ This will break if COMMAND prints a newline, followed by the value of
2792 (unless (equal 2970 (unless (equal
2793 0 2971 0
2794 (apply #'call-process 2972 (apply #'call-process
2795 (tramp-get-rcp-program multi-method method) 2973 rcp-program
2796 nil trampbuf nil 2974 nil trampbuf nil
2797 (append (tramp-get-rcp-args multi-method method) 2975 (append rcp-args
2798 (list 2976 (list
2799 (tramp-make-rcp-program-file-name 2977 (tramp-make-rcp-program-file-name
2800 user host 2978 user host
@@ -2804,12 +2982,12 @@ This will break if COMMAND prints a newline, followed by the value of
2804 (error 2982 (error
2805 (concat "tramp-handle-file-local-copy: `%s' didn't work, " 2983 (concat "tramp-handle-file-local-copy: `%s' didn't work, "
2806 "see buffer `%s' for details") 2984 "see buffer `%s' for details")
2807 (tramp-get-rcp-program multi-method method) trampbuf)) 2985 rcp-program trampbuf))
2808 (tramp-message-for-buffer 2986 (tramp-message-for-buffer
2809 multi-method method user host 2987 multi-method method user host
2810 5 "Fetching %s to tmp file %s...done" filename tmpfil)) 2988 5 "Fetching %s to tmp file %s...done" filename tmpfil))
2811 ((and (tramp-get-encoding-command multi-method method user host) 2989 ((and (tramp-get-remote-encoding multi-method method user host)
2812 (tramp-get-decoding-command multi-method method user host)) 2990 (tramp-get-remote-decoding multi-method method user host))
2813 ;; Use inline encoding for file transfer. 2991 ;; Use inline encoding for file transfer.
2814 (save-excursion 2992 (save-excursion
2815 ;; Following line for setting tramp-current-method, 2993 ;; Following line for setting tramp-current-method,
@@ -2818,7 +2996,8 @@ This will break if COMMAND prints a newline, followed by the value of
2818 (tramp-message 5 "Encoding remote file %s..." filename) 2996 (tramp-message 5 "Encoding remote file %s..." filename)
2819 (tramp-barf-unless-okay 2997 (tramp-barf-unless-okay
2820 multi-method method user host 2998 multi-method method user host
2821 (concat (tramp-get-encoding-command multi-method method user host) 2999 (concat (tramp-get-remote-encoding
3000 multi-method method user host)
2822 " < " (tramp-shell-quote-argument path)) 3001 " < " (tramp-shell-quote-argument path))
2823 nil 'file-error 3002 nil 'file-error
2824 "Encoding remote file failed, see buffer `%s' for details" 3003 "Encoding remote file failed, see buffer `%s' for details"
@@ -2828,11 +3007,13 @@ This will break if COMMAND prints a newline, followed by the value of
2828 (delete-region (point) (progn (forward-line -1) (point))) 3007 (delete-region (point) (progn (forward-line -1) (point)))
2829 3008
2830 (tramp-message 5 "Decoding remote file %s..." filename) 3009 (tramp-message 5 "Decoding remote file %s..." filename)
2831 (if (and (tramp-get-decoding-function multi-method method user host) 3010
2832 (fboundp (tramp-get-decoding-function 3011 (let ((loc-enc (tramp-get-local-encoding
2833 multi-method method user host))) 3012 multi-method method user host))
2834 ;; If tramp-decoding-function is defined for this 3013 (loc-dec (tramp-get-local-decoding
2835 ;; method, we call it. 3014 multi-method method user host)))
3015 (if (and (symbolp loc-dec) (fboundp loc-dec))
3016 ;; If local decoding is a function, we call it.
2836 (let ((tmpbuf (get-buffer-create " *tramp tmp*"))) 3017 (let ((tmpbuf (get-buffer-create " *tramp tmp*")))
2837 (set-buffer tmpbuf) 3018 (set-buffer tmpbuf)
2838 (erase-buffer) 3019 (erase-buffer)
@@ -2841,14 +3022,15 @@ This will break if COMMAND prints a newline, followed by the value of
2841 (tramp-message-for-buffer 3022 (tramp-message-for-buffer
2842 multi-method method user host 3023 multi-method method user host
2843 6 "Decoding remote file %s with function %s..." 3024 6 "Decoding remote file %s with function %s..."
2844 filename 3025 filename loc-dec)
2845 (tramp-get-decoding-function multi-method method user host))
2846 (set-buffer tmpbuf) 3026 (set-buffer tmpbuf)
3027 ;; Douglas Gray Stephens <DGrayStephens@slb.com>
3028 ;; says that we need to strip tramp_exit_status
3029 ;; line from the output here. Go to point-max,
3030 ;; search backward for tramp_exit_status, delete
3031 ;; between point and point-max if found.
2847 (let ((coding-system-for-write 'no-conversion)) 3032 (let ((coding-system-for-write 'no-conversion))
2848 (funcall (tramp-get-decoding-function 3033 (funcall loc-dec (point-min) (point-max))
2849 multi-method method user host)
2850 (point-min)
2851 (point-max))
2852 (write-region (point-min) (point-max) tmpfil)) 3034 (write-region (point-min) (point-max) tmpfil))
2853 (kill-buffer tmpbuf)) 3035 (kill-buffer tmpbuf))
2854 ;; If tramp-decoding-function is not defined for this 3036 ;; If tramp-decoding-function is not defined for this
@@ -2857,20 +3039,13 @@ This will break if COMMAND prints a newline, followed by the value of
2857 (write-region (point-min) (point-max) tmpfil2) 3039 (write-region (point-min) (point-max) tmpfil2)
2858 (tramp-message 3040 (tramp-message
2859 6 "Decoding remote file %s with command %s..." 3041 6 "Decoding remote file %s with command %s..."
2860 filename 3042 filename loc-dec)
2861 (tramp-get-decoding-command multi-method method user host)) 3043 (tramp-call-local-coding-command
2862 (call-process 3044 loc-dec tmpfil2 tmpfil)
2863 tramp-sh-program
2864 tmpfil2 ;input
2865 nil ;output
2866 nil ;display
2867 "-c" (concat (tramp-get-decoding-command
2868 multi-method method user host)
2869 " > " tmpfil))
2870 (delete-file tmpfil2))) 3045 (delete-file tmpfil2)))
2871 (tramp-message-for-buffer 3046 (tramp-message-for-buffer
2872 multi-method method user host 3047 multi-method method user host
2873 5 "Decoding remote file %s...done" filename))) 3048 5 "Decoding remote file %s...done" filename))))
2874 3049
2875 (t (error "Wrong method specification for `%s'" method))) 3050 (t (error "Wrong method specification for `%s'" method)))
2876 tmpfil))) 3051 tmpfil)))
@@ -2910,7 +3085,9 @@ This will break if COMMAND prints a newline, followed by the value of
2910 ;; Now `last-coding-system-used' has right value. Remember it. 3085 ;; Now `last-coding-system-used' has right value. Remember it.
2911 (when (boundp 'last-coding-system-used) 3086 (when (boundp 'last-coding-system-used)
2912 (setq coding-system-used last-coding-system-used)) 3087 (setq coding-system-used last-coding-system-used))
2913 (tramp-message 9 "Inserting local temp file `%s'...done" local-copy) 3088 (tramp-message-for-buffer
3089 multi-method method user host
3090 9 "Inserting local temp file `%s'...done" local-copy)
2914 (delete-file local-copy) 3091 (delete-file local-copy)
2915 (when (boundp 'last-coding-system-used) 3092 (when (boundp 'last-coding-system-used)
2916 (setq last-coding-system-used coding-system-used)) 3093 (setq last-coding-system-used coding-system-used))
@@ -2944,14 +3121,15 @@ This will break if COMMAND prints a newline, followed by the value of
2944 (tramp-invoke-ange-ftp 'write-region 3121 (tramp-invoke-ange-ftp 'write-region
2945 start end filename append visit)) 3122 start end filename append visit))
2946 (let ((curbuf (current-buffer)) 3123 (let ((curbuf (current-buffer))
2947 (rcp-program (tramp-get-rcp-program multi-method method)) 3124 (rcp-program (tramp-get-rcp-program
2948 (rcp-args (tramp-get-rcp-args multi-method method)) 3125 multi-method (tramp-find-method multi-method method user host)))
2949 (encoding-command 3126 (rcp-args (tramp-get-rcp-args
2950 (tramp-get-encoding-command multi-method method user host)) 3127 multi-method
2951 (encoding-function 3128 (tramp-find-method multi-method method user host)))
2952 (tramp-get-encoding-function multi-method method user host)) 3129 (rem-enc (tramp-get-remote-encoding multi-method method user host))
2953 (decoding-command 3130 (rem-dec (tramp-get-remote-decoding multi-method method user host))
2954 (tramp-get-decoding-command multi-method method user host)) 3131 (loc-enc (tramp-get-local-encoding multi-method method user host))
3132 (loc-dec (tramp-get-local-decoding multi-method method user host))
2955 (trampbuf (get-buffer-create "*tramp output*")) 3133 (trampbuf (get-buffer-create "*tramp output*"))
2956 ;; We use this to save the value of `last-coding-system-used' 3134 ;; We use this to save the value of `last-coding-system-used'
2957 ;; after writing the tmp file. At the end of the function, 3135 ;; after writing the tmp file. At the end of the function,
@@ -3013,7 +3191,7 @@ This will break if COMMAND prints a newline, followed by the value of
3013 multi-method method user host 3191 multi-method method user host
3014 6 "Transferring file using `%s'...done" 3192 6 "Transferring file using `%s'...done"
3015 rcp-program))) 3193 rcp-program)))
3016 ((and encoding-command decoding-command) 3194 ((and rem-enc rem-dec)
3017 ;; Use inline file transfer 3195 ;; Use inline file transfer
3018 (let ((tmpbuf (get-buffer-create " *tramp file transfer*"))) 3196 (let ((tmpbuf (get-buffer-create " *tramp file transfer*")))
3019 (save-excursion 3197 (save-excursion
@@ -3023,8 +3201,7 @@ This will break if COMMAND prints a newline, followed by the value of
3023 (set-buffer tmpbuf) 3201 (set-buffer tmpbuf)
3024 (erase-buffer) 3202 (erase-buffer)
3025 ;; Use encoding function or command. 3203 ;; Use encoding function or command.
3026 (if (and encoding-function 3204 (if (and (symbolp loc-enc) (fboundp loc-enc))
3027 (fboundp encoding-function))
3028 (progn 3205 (progn
3029 (tramp-message-for-buffer 3206 (tramp-message-for-buffer
3030 multi-method method user host 3207 multi-method method user host
@@ -3041,25 +3218,19 @@ This will break if COMMAND prints a newline, followed by the value of
3041 ;; tmp file anyway. 3218 ;; tmp file anyway.
3042 (let ((default-directory 3219 (let ((default-directory
3043 (tramp-temporary-file-directory))) 3220 (tramp-temporary-file-directory)))
3044 (funcall encoding-function (point-min) (point-max))) 3221 (funcall loc-enc (point-min) (point-max)))
3045 (goto-char (point-max)) 3222 (goto-char (point-max))
3046 (unless (bolp) 3223 (unless (bolp)
3047 (newline))) 3224 (newline)))
3048 (tramp-message-for-buffer 3225 (tramp-message-for-buffer
3049 multi-method method user host 3226 multi-method method user host
3050 6 "Encoding region using command...") 3227 6 "Encoding region using command `%s'..." loc-enc)
3051 (unless (equal 0 3228 (unless (equal 0 (tramp-call-local-coding-command
3052 (call-process 3229 loc-enc tmpfil t))
3053 tramp-sh-program
3054 tmpfil ;input = local tmp file
3055 t ;output is current buffer
3056 nil ;don't redisplay
3057 "-c"
3058 encoding-command))
3059 (pop-to-buffer trampbuf) 3230 (pop-to-buffer trampbuf)
3060 (error (concat "Cannot write to `%s', local encoding" 3231 (error (concat "Cannot write to `%s', local encoding"
3061 " command `%s' failed") 3232 " command `%s' failed")
3062 filename encoding-command))) 3233 filename loc-enc)))
3063 ;; Send tmpbuf into remote decoding command which 3234 ;; Send tmpbuf into remote decoding command which
3064 ;; writes to remote file. Because this happens on the 3235 ;; writes to remote file. Because this happens on the
3065 ;; remote host, we cannot use the function. 3236 ;; remote host, we cannot use the function.
@@ -3069,7 +3240,7 @@ This will break if COMMAND prints a newline, followed by the value of
3069 (tramp-send-command 3240 (tramp-send-command
3070 multi-method method user host 3241 multi-method method user host
3071 (format "%s >%s <<'EOF'" 3242 (format "%s >%s <<'EOF'"
3072 decoding-command 3243 rem-dec
3073 (tramp-shell-quote-argument path))) 3244 (tramp-shell-quote-argument path)))
3074 (set-buffer tmpbuf) 3245 (set-buffer tmpbuf)
3075 (tramp-message-for-buffer 3246 (tramp-message-for-buffer
@@ -3092,7 +3263,7 @@ This will break if COMMAND prints a newline, followed by the value of
3092 multi-method method user host nil nil 'file-error 3263 multi-method method user host nil nil 'file-error
3093 (concat "Couldn't write region to `%s'," 3264 (concat "Couldn't write region to `%s',"
3094 " decode using `%s' failed") 3265 " decode using `%s' failed")
3095 filename decoding-command) 3266 filename rem-dec)
3096 (tramp-message 5 "Decoding region into remote file %s...done" 3267 (tramp-message 5 "Decoding region into remote file %s...done"
3097 filename) 3268 filename)
3098 (kill-buffer tmpbuf)))) 3269 (kill-buffer tmpbuf))))
@@ -3155,6 +3326,25 @@ pass to the OPERATION."
3155 operation)) 3326 operation))
3156 (inhibit-file-name-handlers 3327 (inhibit-file-name-handlers
3157 (list 'tramp-file-name-handler 3328 (list 'tramp-file-name-handler
3329 'tramp-completion-file-name-handler
3330 (and (eq inhibit-file-name-operation op)
3331 inhibit-file-name-handlers)))
3332 (inhibit-file-name-operation op))
3333 (apply operation args)))
3334
3335;; This function is used from `tramp-completion-file-name-handler' functions
3336;; only, if `tramp-completion-mode' is true. But this cannot be checked here
3337;; because the check is based on a full filename, not available for all
3338;; basic I/O operations.
3339(defun tramp-completion-run-real-handler (operation args)
3340 "Invoke `tramp-file-name-handler' for OPERATION.
3341First arg specifies the OPERATION, second arg is a list of arguments to
3342pass to the OPERATION."
3343 (let* ((op (if (eq operation 'ange-ftp-hook-function)
3344 (car args)
3345 operation))
3346 (inhibit-file-name-handlers
3347 (list 'tramp-completion-file-name-handler
3158 (and (eq inhibit-file-name-operation op) 3348 (and (eq inhibit-file-name-operation op)
3159 inhibit-file-name-handlers))) 3349 inhibit-file-name-handlers)))
3160 (inhibit-file-name-operation op)) 3350 (inhibit-file-name-operation op))
@@ -3171,10 +3361,29 @@ Falls back to normal file name handler if no tramp file name handler exists."
3171 (save-match-data (apply (cdr fn) args))) 3361 (save-match-data (apply (cdr fn) args)))
3172 (tramp-run-real-handler operation args)))) 3362 (tramp-run-real-handler operation args))))
3173 3363
3364(put 'tramp-file-name-handler 'file-remote-p t) ;for file-remote-p
3365
3366;;;###autoload
3367(defun tramp-completion-file-name-handler (operation &rest args)
3368 "Invoke tramp file name completion handler.
3369Falls back to normal file name handler if no tramp file name handler exists."
3370;; (setq tramp-debug-buffer t)
3371;; (tramp-message 1 "%s %s" operation args)
3372;; (tramp-message 1 "%s %s\n%s"
3373;; operation args (with-output-to-string (backtrace)))
3374 (let ((fn (assoc operation tramp-completion-file-name-handler-alist)))
3375 (if fn
3376 (catch 'tramp-forward-to-ange-ftp
3377 (save-match-data (apply (cdr fn) args)))
3378 (tramp-completion-run-real-handler operation args))))
3379
3174;; Register in file name handler alist 3380;; Register in file name handler alist
3175;;;###autoload 3381;;;###autoload
3176(add-to-list 'file-name-handler-alist 3382(add-to-list 'file-name-handler-alist
3177 (cons tramp-file-name-regexp 'tramp-file-name-handler)) 3383 (cons tramp-file-name-regexp 'tramp-file-name-handler))
3384(add-to-list 'file-name-handler-alist
3385 (cons tramp-completion-file-name-regexp
3386 'tramp-completion-file-name-handler))
3178 3387
3179;; To handle EFS, the following functions need to be dealt with: 3388;; To handle EFS, the following functions need to be dealt with:
3180;; 3389;;
@@ -3212,6 +3421,20 @@ necessary anymore."
3212 (cons jka (delete jka file-name-handler-alist)))))) 3421 (cons jka (delete jka file-name-handler-alist))))))
3213(tramp-repair-jka-compr) 3422(tramp-repair-jka-compr)
3214 3423
3424(defun tramp-flatten-list (arg)
3425 "Expands all lists inside ARG to a sequential list.
3426Return (nil) if arg is nil."
3427 (let ((car (car arg))
3428 (cdr (cdr arg)))
3429 (cond
3430 ((eq arg nil) '(nil))
3431 ((listp car)
3432 (if (null cdr)
3433 (tramp-flatten-list car)
3434 (append (tramp-flatten-list car) (tramp-flatten-list cdr))))
3435 ((null cdr) (list car))
3436 (t (cons car (tramp-flatten-list cdr))))))
3437
3215(defun tramp-invoke-ange-ftp (operation &rest args) 3438(defun tramp-invoke-ange-ftp (operation &rest args)
3216 "Invoke the Ange-FTP handler function and throw." 3439 "Invoke the Ange-FTP handler function and throw."
3217 (or (boundp 'ange-ftp-name-format) 3440 (or (boundp 'ange-ftp-name-format)
@@ -3228,7 +3451,7 @@ necessary anymore."
3228 3451
3229(defun tramp-ange-ftp-file-name-p (multi-method method) 3452(defun tramp-ange-ftp-file-name-p (multi-method method)
3230 "Check if it's a filename that should be forwarded to Ange-FTP." 3453 "Check if it's a filename that should be forwarded to Ange-FTP."
3231 (and (not (featurep 'xemacs)) 3454 (and tramp-unified-filenames
3232 (null multi-method) 3455 (null multi-method)
3233 (string= method tramp-ftp-method))) 3456 (string= method tramp-ftp-method)))
3234 3457
@@ -3300,8 +3523,447 @@ necessary anymore."
3300 (tramp-setup-complete) 3523 (tramp-setup-complete)
3301 (eval-after-load "complete" '(tramp-setup-complete))) 3524 (eval-after-load "complete" '(tramp-setup-complete)))
3302 3525
3526;;; File name handler functions for completion mode
3527
3528;; Necessary because `tramp-file-name-regexp-unified' and
3529;; `tramp-completion-file-name-regexp-unified' aren't different.
3530;; If nil, `tramp-completion-run-real-handler' is called (i.e. forwarding to
3531;; `tramp-file-name-handler'). Otherwise, it takes `tramp-run-real-handler'.
3532;; Using `last-input-event' is a little bit risky, because completing a file
3533;; might require loading other files, like "~/.netrc", and for them it
3534;; shouldn't be decided based on that variable. On the other hand, those files
3535;; shouldn't have partial tramp file name syntax. Maybe another variable should
3536;; be introduced overwriting this check in such cases. Or we change tramp
3537;; file name syntax in order to avoid ambiguities, like in XEmacs ...
3538;; In case of XEmacs it can be always true (and wouldn't be necessary).
3539(defun tramp-completion-mode (file)
3540 "Checks whether method / user name / host name completion is active."
3541 (cond
3542 ((featurep 'xemacs) t)
3543 ((string-match "^/.*:.*:$" file) nil)
3544 ((string-match
3545 (concat
3546 tramp-prefix-regexp
3547 tramp-method-regexp tramp-postfix-single-method-regexp "$")
3548 file)
3549 (member (match-string 1 file)
3550 (cons tramp-ftp-method (mapcar 'car tramp-methods))))
3551 ((or (equal last-input-event 'tab)
3552 (and (not (event-modifiers last-input-event))
3553 (integerp last-input-event)
3554 (or (char-equal last-input-event ?\?)
3555 (char-equal last-input-event ?\t) ; handled by 'tab already?
3556 (char-equal last-input-event ?\ ))))
3557 t)))
3558
3559(defun tramp-completion-handle-file-exists-p (filename)
3560 "Like `file-exists-p' for tramp files."
3561 (if (tramp-completion-mode filename)
3562 (tramp-run-real-handler
3563 'file-exists-p (list filename))
3564 (tramp-completion-run-real-handler
3565 'file-exists-p (list filename))))
3566
3567;; Path manipulation in case of partial TRAMP file names.
3568(defun tramp-completion-handle-file-name-directory (file)
3569 "Like `file-name-directory' but aware of TRAMP files."
3570 (if (tramp-completion-mode file)
3571 "/"
3572 (tramp-completion-run-real-handler
3573 'file-name-directory (list file))))
3303 3574
3575;; Path manipulation in case of partial TRAMP file names.
3576(defun tramp-completion-handle-file-name-nondirectory (file)
3577 "Like `file-name-nondirectory' but aware of TRAMP files."
3578 (substring
3579 file (length (tramp-completion-handle-file-name-directory file))))
3580
3581;; Method, host name and user name completion.
3582;; `tramp-completion-dissect-file-name' returns a list of
3583;; tramp-file-name structures. For all of them we return possible completions.
3584(defun tramp-completion-handle-file-name-all-completions (filename directory)
3585 "Like `file-name-all-completions' for partial tramp files."
3586
3587 (let*
3588 ((fullname (concat directory filename))
3589 ;; prepare ange-ftp fix
3590 (fix-ange-ftp-string
3591 (concat tramp-ftp-method tramp-postfix-single-method-format))
3592 (fix-ange-ftp (string-match (concat "^" fix-ange-ftp-string) filename))
3593 ;; local files
3594 (result
3595 (if (tramp-completion-mode fullname)
3596 (tramp-run-real-handler
3597 'file-name-all-completions (list filename directory))
3598 (tramp-completion-run-real-handler
3599 'file-name-all-completions (list filename directory))))
3600 ;; possible completion structures
3601 (v (tramp-completion-dissect-file-name fullname)))
3602
3603 (while v
3604 (let* ((car (car v))
3605 (multi-method (tramp-file-name-multi-method car))
3606 (method (tramp-file-name-method car))
3607 (user (tramp-file-name-user car))
3608 (host (tramp-file-name-host car))
3609 (path (tramp-file-name-path car))
3610 (m (tramp-find-method multi-method method user host))
3611 all-user-hosts)
3612
3613 (unless (or multi-method ;; Not handled (yet).
3614 path) ;; Nothing to complete
3615
3616 (if (or user host)
3617
3618 ;; Method dependent user / host combinations
3619 (progn
3620 (mapcar
3621 '(lambda (x)
3622 (setq all-user-hosts
3623 (append all-user-hosts
3624 (funcall (nth 0 x) (nth 1 x)))))
3625 (tramp-get-completion-function m))
3626
3627 (setq result (append result
3628 (mapcar
3629 '(lambda (x)
3630 (tramp-get-completion-user-host
3631 method user host (nth 0 x) (nth 1 x)))
3632 (delq nil all-user-hosts)))))
3633
3634 ;; Possible methods
3635 (setq result
3636 (append result (tramp-get-completion-methods m))))
3637
3638 ;; Ange-ftp completions.
3639 ;; Filename might have the form "ftp:xxx". Ange-ftp isn't able to
3640 ;; handle the prefix "ftp:" correctly in
3641 ;; `ange-ftp-file-name-all-completions'; it simply calls
3642 ;;`(all-completions file (ange-ftp-generate-root-prefixes))'.
3643 ;; So we must wrap around.
3644 (when (tramp-ange-ftp-file-name-p nil m)
3645 (setq result (append result
3646 (mapcar
3647 '(lambda (x) (if fix-ange-ftp (concat fix-ange-ftp-string x) x))
3648 (catch 'tramp-forward-to-ange-ftp
3649 (tramp-invoke-ange-ftp
3650 'file-name-all-completions
3651 (if fix-ange-ftp
3652 (substring filename (length fix-ange-ftp-string))
3653 filename)
3654 directory)))))))
3655
3656 (setq v (delq car v))))
3657
3658 ;;; unify list, remove nil elements
3659 (let (result1)
3660 (while result
3661 (let ((car (car result)))
3662 (when car (add-to-list 'result1 car))
3663 (setq result (delq car result))))
3664
3665 result1)))
3666
3667;; Method, host name and user name completion for a file.
3668(defun tramp-completion-handle-file-name-completion (filename directory)
3669 "Like `file-name-completion' for tramp files."
3670 (try-completion filename
3671 (mapcar 'list (file-name-all-completions filename directory))))
3672
3673;; I misuse a little bit the tramp-file-name structure in order to handle
3674;; completion possibilities for partial methods / user names / host names.
3675;; Return value is a list of tramp-file-name structures according to possible
3676;; completions. If "multi-method" or "path" is non-nil it means there
3677;; shouldn't be a completion anymore.
3678
3679;; Expected results:
3680
3681;; "/x" "/[x" "/x@" "/[x@" "/x@y" "/[x@y"
3682;; [nil nil nil "x" nil] [nil nil "x" nil nil] [nil nil "x" "y" nil]
3683;; [nil nil "x" nil nil]
3684;; [nil "x" nil nil nil]
3685
3686;; "/x:" "/x:y" "/x:y:"
3687;; [nil nil nil "x" ""] [nil nil nil "x" "y"] [nil "x" nil "y" ""]
3688;; "/[x/" "/[x/y"
3689;; [nil "x" nil "" nil] [nil "x" nil "y" nil]
3690;; [nil "x" "" nil nil] [nil "x" "y" nil nil]
3691
3692;; "/x:y@" "/x:y@z" "/x:y@z:"
3693;; [nil nil nil "x" "y@"] [nil nil nil "x" "y@z"] [nil "x" "y" "z" ""]
3694;; "/[x/y@" "/[x/y@z"
3695;; [nil "x" nil "y" nil] [nil "x" "y" "z" nil]
3696(defun tramp-completion-dissect-file-name (name)
3697 "Returns a list of `tramp-file-name' structures.
3698They are collected by `tramp-completion-dissect-file-name1'."
3699
3700 (let* ((result)
3701 (x-nil "\\|\\(\\)"))
3702
3703 ;; "/method" "/[method"
3704 (defconst tramp-completion-file-name-structure1
3705 (list (concat tramp-prefix-regexp "\\(" tramp-method-regexp x-nil "\\)$")
3706 1 9 9 9))
3707 ;; "/user" "/[user"
3708 (defconst tramp-completion-file-name-structure2
3709 (list (concat tramp-prefix-regexp "\\(" tramp-user-regexp x-nil "\\)$")
3710 9 1 9 9))
3711 ;; "/host" "/[host"
3712 (defconst tramp-completion-file-name-structure3
3713 (list (concat tramp-prefix-regexp "\\(" tramp-host-regexp x-nil "\\)$")
3714 9 9 1 9))
3715 ;; "/user@host" "/[user@host"
3716 (defconst tramp-completion-file-name-structure4
3717 (list (concat tramp-prefix-regexp
3718 "\\(" tramp-user-regexp "\\)" tramp-postfix-user-regexp
3719 "\\(" tramp-host-regexp x-nil "\\)$")
3720 9 1 2 9))
3721 ;; "/method:user" "/[method/user"
3722 (defconst tramp-completion-file-name-structure5
3723 (list (concat tramp-prefix-regexp
3724 "\\(" tramp-method-regexp "\\)" tramp-postfix-single-method-regexp
3725 "\\(" tramp-user-regexp x-nil "\\)$")
3726 1 2 9 9))
3727 ;; "/method:host" "/[method/host"
3728 (defconst tramp-completion-file-name-structure6
3729 (list (concat tramp-prefix-regexp
3730 "\\(" tramp-method-regexp "\\)" tramp-postfix-single-method-regexp
3731 "\\(" tramp-host-regexp x-nil "\\)$")
3732 1 9 2 9))
3733 ;; "/method:user@host" "/[method/user@host"
3734 (defconst tramp-completion-file-name-structure7
3735 (list (concat tramp-prefix-regexp
3736 "\\(" tramp-method-regexp "\\)" tramp-postfix-single-method-regexp
3737 "\\(" tramp-user-regexp "\\)" tramp-postfix-user-regexp
3738 "\\(" tramp-host-regexp x-nil "\\)$")
3739 1 2 3 9))
3740
3741 (mapcar '(lambda (regexp)
3742 (add-to-list 'result
3743 (tramp-completion-dissect-file-name1 regexp name)))
3744 (list
3745 tramp-completion-file-name-structure1
3746 tramp-completion-file-name-structure2
3747 tramp-completion-file-name-structure3
3748 tramp-completion-file-name-structure4
3749 tramp-completion-file-name-structure5
3750 tramp-completion-file-name-structure6
3751 tramp-completion-file-name-structure7
3752 tramp-file-name-structure))
3753
3754 (delq nil result)))
3755
3756(defun tramp-completion-dissect-file-name1 (structure name)
3757 "Returns a `tramp-file-name' structure matching STRUCTURE.
3758The structure consists of multi-method, remote method, remote user,
3759remote host and remote path name."
3304 3760
3761 (let (method)
3762 (save-match-data
3763 (when (string-match (nth 0 structure) name)
3764 (setq method (match-string (nth 1 structure) name))
3765 (if (and method (member method tramp-multi-methods))
3766 ;; Not handled (yet).
3767 (make-tramp-file-name
3768 :multi-method method
3769 :method nil
3770 :user nil
3771 :host nil
3772 :path nil)
3773 (let ((user (match-string (nth 2 structure) name))
3774 (host (match-string (nth 3 structure) name))
3775 (path (match-string (nth 4 structure) name)))
3776 (make-tramp-file-name
3777 :multi-method nil
3778 :method method
3779 :user user
3780 :host host
3781 :path path)))))))
3782
3783;; This function returns all possible method completions, adding the
3784;; trailing method delimeter.
3785;; In case of Emacs, `tramp-ftp-method' is handled as well because it doesn't
3786;; belong to `tramp-methods'.
3787(defun tramp-get-completion-methods (partial-method)
3788 "Returns all method completions for PARTIAL-METHOD."
3789 (let ((all-methods (delete "multi" (mapcar 'car tramp-methods))))
3790
3791 (mapcar
3792 '(lambda (method)
3793 (and method
3794 (string-match (concat "^" (regexp-quote partial-method)) method)
3795 ;; we must remove leading "/".
3796 (substring (tramp-make-tramp-file-name nil method nil nil nil) 1)))
3797
3798 (add-to-list 'all-methods
3799 (when tramp-unified-filenames tramp-ftp-method)))))
3800
3801;; Compares partial user and host names with possible completions.
3802(defun tramp-get-completion-user-host (method partial-user partial-host user host)
3803 "Returns the most expanded string for user and host name completion.
3804PARTIAL-USER must match USER, PARTIAL-HOST must match HOST."
3805 (cond
3806
3807 ((and partial-user partial-host)
3808 (if (and host
3809 (string-match (concat "^" (regexp-quote partial-host)) host)
3810 (string-equal partial-user (or user partial-user)))
3811 (setq user partial-user)
3812 (setq user nil
3813 host nil)))
3814
3815 (partial-user
3816 (setq host nil)
3817 (unless
3818 (and user (string-match (concat "^" (regexp-quote partial-user)) user))
3819 (setq user nil)))
3820
3821 (partial-host
3822 (setq user nil)
3823 (unless
3824 (and host (string-match (concat "^" (regexp-quote partial-host)) host))
3825 (setq host nil)))
3826
3827 (t (setq user nil
3828 host nil)))
3829
3830 (when (or user host)
3831 ;; we must remove leading "/".
3832 (substring (tramp-make-tramp-file-name nil method user host nil) 1)))
3833
3834(defun tramp-parse-rhosts (filename)
3835 "Return a list of (user host) tuples allowed to access.
3836Either user or host may be nil"
3837
3838 (let (res)
3839 (when (file-exists-p filename)
3840 (with-temp-buffer
3841 (insert-file-contents filename)
3842 (goto-char (point-min))
3843 (while (not (eobp))
3844 (add-to-list 'res (tramp-parse-rhosts-group)))))
3845 res))
3846
3847;; Taken from gnus/netrc.el
3848(eval-and-compile
3849 (defalias 'tramp-point-at-eol
3850 (if (fboundp 'point-at-eol)
3851 'point-at-eol
3852 'line-end-position)))
3853
3854(defun tramp-parse-rhosts-group ()
3855 "Return a (user host) tuple allowed to access.
3856Either user or host may be nil"
3857
3858 (let ((result)
3859 (regexp
3860 (concat
3861 "^\\(" tramp-host-regexp "\\)"
3862 "\\([ \t]+" "\\(" tramp-user-regexp "\\)" "\\)?")))
3863
3864 (narrow-to-region (point) (tramp-point-at-eol))
3865 (when (re-search-forward regexp nil t)
3866 (setq result (append (list (match-string 3) (match-string 1)))))
3867 (widen)
3868 (forward-line 1)
3869 result))
3870
3871(defun tramp-parse-shosts (filename)
3872 "Return a list of (user host) tuples allowed to access.
3873User is always nil."
3874
3875 (let (res)
3876 (when (file-exists-p filename)
3877 (with-temp-buffer
3878 (insert-file-contents filename)
3879 (goto-char (point-min))
3880 (while (not (eobp))
3881 (add-to-list 'res (tramp-parse-shosts-group)))))
3882 res))
3883
3884(defun tramp-parse-shosts-group ()
3885 "Return a (user host) tuple allowed to access.
3886User is always nil."
3887
3888 (let ((result)
3889 (regexp (concat "^\\(" tramp-host-regexp "\\)")))
3890
3891 (narrow-to-region (point) (tramp-point-at-eol))
3892 (when (re-search-forward regexp nil t)
3893 (setq result (list nil (match-string 1))))
3894 (widen)
3895 (or
3896 (> (skip-chars-forward ",") 0)
3897 (forward-line 1))
3898 result))
3899
3900(defun tramp-parse-hosts (filename)
3901 "Return a list of (user host) tuples allowed to access.
3902User is always nil."
3903
3904 (let (res)
3905 (when (file-exists-p filename)
3906 (with-temp-buffer
3907 (insert-file-contents filename)
3908 (goto-char (point-min))
3909 (while (not (eobp))
3910 (add-to-list 'res (tramp-parse-hosts-group)))))
3911 res))
3912
3913(defun tramp-parse-hosts-group ()
3914 "Return a (user host) tuple allowed to access.
3915User is always nil."
3916
3917 (let ((result)
3918 (regexp (concat "^\\(" tramp-host-regexp "\\)")))
3919
3920 (narrow-to-region (point) (tramp-point-at-eol))
3921 (when (re-search-forward regexp nil t)
3922 (unless (char-equal (or (char-after) ?\n) ?:) ; no IPv6
3923 (setq result (list nil (match-string 1)))))
3924 (widen)
3925 (or
3926 (> (skip-chars-forward " \t") 0)
3927 (forward-line 1))
3928 result))
3929
3930(defun tramp-parse-passwd (filename)
3931 "Return a list of (user host) tuples allowed to access.
3932Host is always \"localhost\"."
3933
3934 (let (res)
3935 (if (and (symbolp 'user) (zerop (length user)))
3936 '(("root" nil))
3937 (when (file-exists-p filename)
3938 (with-temp-buffer
3939 (insert-file-contents filename)
3940 (goto-char (point-min))
3941 (while (not (eobp))
3942 (add-to-list 'res (tramp-parse-passwd-group)))))
3943 res)))
3944
3945(defun tramp-parse-passwd-group ()
3946 "Return a (user host) tuple allowed to access.
3947User is always nil."
3948
3949 (let ((result)
3950 (regexp (concat "^\\(" tramp-user-regexp "\\):")))
3951
3952 (narrow-to-region (point) (tramp-point-at-eol))
3953 (when (re-search-forward regexp nil t)
3954 (setq result (list (match-string 1) "localhost")))
3955 (widen)
3956 (forward-line 1)
3957 result))
3958
3959(defun tramp-completion-handle-expand-file-name (name &optional dir)
3960 "Like `expand-file-name' for tramp files."
3961 (let ((fullname (concat (or dir default-directory) name)))
3962 (if (tramp-completion-mode fullname)
3963 (tramp-run-real-handler
3964 'expand-file-name (list name dir))
3965 (tramp-completion-run-real-handler
3966 'expand-file-name (list name dir)))))
3305 3967
3306;;; Internal Functions: 3968;;; Internal Functions:
3307 3969
@@ -3551,22 +4213,18 @@ file exists and nonzero exit status otherwise."
3551 (error "Couldn't find remote `%s' prompt." shell)) 4213 (error "Couldn't find remote `%s' prompt." shell))
3552 (tramp-message 4214 (tramp-message
3553 9 "Setting remote shell prompt...") 4215 9 "Setting remote shell prompt...")
4216 ;; Douglas Gray Stephens <DGrayStephens@slb.com> says that we
4217 ;; must use "\n" here, not tramp-rsh-end-of-line. Kai left the
4218 ;; last tramp-rsh-end-of-line, Douglas wanted to replace that,
4219 ;; as well.
3554 (process-send-string nil (format "PS1='%s%s%s'; PS2=''; PS3=''%s" 4220 (process-send-string nil (format "PS1='%s%s%s'; PS2=''; PS3=''%s"
3555 tramp-rsh-end-of-line 4221 tramp-rsh-end-of-line
3556 tramp-end-of-output 4222 tramp-end-of-output
3557 tramp-rsh-end-of-line 4223 tramp-rsh-end-of-line
3558 tramp-rsh-end-of-line)) 4224 tramp-rsh-end-of-line))
3559 (tramp-wait-for-output) 4225 (tramp-wait-for-output)
3560 (tramp-message 4226 (tramp-message
3561 9 "Setting remote shell prompt...done") 4227 9 "Setting remote shell prompt...done")
3562;; (tramp-send-command multi-method method user host "echo hello")
3563;; (tramp-message 5 "Waiting for remote `%s' to start up..." shell)
3564;; (unless (tramp-wait-for-output 5)
3565;; (unless (tramp-wait-for-output 5)
3566;; (pop-to-buffer (buffer-name))
3567;; (error "Couldn't start remote `%s', see buffer `%s' for details"
3568;; shell (buffer-name))))
3569;; (tramp-message 5 "Waiting for remote `%s' to start up...done" shell)
3570 ) 4228 )
3571 (t (tramp-message 5 "Remote `%s' groks tilde expansion, good" 4229 (t (tramp-message 5 "Remote `%s' groks tilde expansion, good"
3572 (tramp-get-remote-sh multi-method method)))))) 4230 (tramp-get-remote-sh multi-method method))))))
@@ -3634,11 +4292,12 @@ Returns nil if none was found, else the command is returned."
3634 4292
3635(defun tramp-action-password (p multi-method method user host) 4293(defun tramp-action-password (p multi-method method user host)
3636 "Query the user for a password." 4294 "Query the user for a password."
3637 (when (tramp-method-out-of-band-p multi-method method) 4295 (when (tramp-method-out-of-band-p multi-method method user host)
3638 (kill-process (get-buffer-process (current-buffer))) 4296 (kill-process (get-buffer-process (current-buffer)))
3639 (error (concat "Out of band method `%s' not applicable " 4297 (error (concat "Out of band method `%s' not applicable "
3640 "for remote shell asking for a password") 4298 "for remote shell asking for a password")
3641 method)) 4299 method))
4300 (tramp-message 9 "Sending password")
3642 (tramp-enter-password p (match-string 0))) 4301 (tramp-enter-password p (match-string 0)))
3643 4302
3644(defun tramp-action-succeed (p multi-method method user host) 4303(defun tramp-action-succeed (p multi-method method user host)
@@ -3689,6 +4348,7 @@ See also `tramp-action-yesno'."
3689 4348
3690(defun tramp-multi-action-password (p method user host) 4349(defun tramp-multi-action-password (p method user host)
3691 "Query the user for a password." 4350 "Query the user for a password."
4351 (tramp-message 9 "Sending password")
3692 (tramp-enter-password p (match-string 0))) 4352 (tramp-enter-password p (match-string 0)))
3693 4353
3694(defun tramp-multi-action-succeed (p method user host) 4354(defun tramp-multi-action-succeed (p method user host)
@@ -3799,7 +4459,7 @@ Maybe the different regular expressions need to be tuned.
3799* Actually, the telnet program as well as the args to be used can be 4459* Actually, the telnet program as well as the args to be used can be
3800 specified in the method parameters, see the variable `tramp-methods'." 4460 specified in the method parameters, see the variable `tramp-methods'."
3801 (save-match-data 4461 (save-match-data
3802 (when (tramp-method-out-of-band-p multi-method method) 4462 (when (tramp-method-out-of-band-p multi-method method user host)
3803 (error "Cannot use out-of-band method `%s' with telnet connection method" 4463 (error "Cannot use out-of-band method `%s' with telnet connection method"
3804 method)) 4464 method))
3805 (when multi-method 4465 (when multi-method
@@ -3810,15 +4470,22 @@ Maybe the different regular expressions need to be tuned.
3810 (let ((process-environment (copy-sequence process-environment))) 4470 (let ((process-environment (copy-sequence process-environment)))
3811 (setenv "TERM" tramp-terminal-type) 4471 (setenv "TERM" tramp-terminal-type)
3812 (let* ((default-directory (tramp-temporary-file-directory)) 4472 (let* ((default-directory (tramp-temporary-file-directory))
4473 ;; If we omit the conditional here, then we would use
4474 ;; `undecided-dos' in some cases. With the conditional,
4475 ;; we use nil in these cases. Which one is right?
3813 (coding-system-for-read (unless (and (not (featurep 'xemacs)) 4476 (coding-system-for-read (unless (and (not (featurep 'xemacs))
3814 (> emacs-major-version 20)) 4477 (> emacs-major-version 20))
3815 tramp-dos-coding-system)) 4478 tramp-dos-coding-system))
3816 (p (apply 'start-process 4479 (p (apply 'start-process
3817 (tramp-buffer-name multi-method method user host) 4480 (tramp-buffer-name multi-method method user host)
3818 (tramp-get-buffer multi-method method user host) 4481 (tramp-get-buffer multi-method method user host)
3819 (tramp-get-telnet-program multi-method method) 4482 (tramp-get-telnet-program
4483 multi-method
4484 (tramp-find-method multi-method method user host))
3820 host 4485 host
3821 (tramp-get-telnet-args multi-method method))) 4486 (tramp-get-telnet-args
4487 multi-method
4488 (tramp-find-method multi-method method user host))))
3822 (found nil) 4489 (found nil)
3823 (pw nil)) 4490 (pw nil))
3824 (process-kill-without-query p) 4491 (process-kill-without-query p)
@@ -3860,15 +4527,19 @@ arguments, and xx will be used as the host name to connect to.
3860 (when multi-method 4527 (when multi-method
3861 (error "Cannot multi-connect using rsh connection method")) 4528 (error "Cannot multi-connect using rsh connection method"))
3862 (tramp-pre-connection multi-method method user host) 4529 (tramp-pre-connection multi-method method user host)
3863 (if user 4530 (if (and user (not (string= user "")))
3864 (tramp-message 7 "Opening connection for %s@%s using %s..." 4531 (tramp-message 7 "Opening connection for %s@%s using %s..."
3865 user host method) 4532 user host method)
3866 (tramp-message 7 "Opening connection at %s using %s..." host method)) 4533 (tramp-message 7 "Opening connection at %s using %s..." host method))
3867 (let ((process-environment (copy-sequence process-environment)) 4534 (let ((process-environment (copy-sequence process-environment))
3868 (bufnam (tramp-buffer-name multi-method method user host)) 4535 (bufnam (tramp-buffer-name multi-method method user host))
3869 (buf (tramp-get-buffer multi-method method user host)) 4536 (buf (tramp-get-buffer multi-method method user host))
3870 (rsh-program (tramp-get-rsh-program multi-method method)) 4537 (rsh-program (tramp-get-rsh-program
3871 (rsh-args (tramp-get-rsh-args multi-method method))) 4538 multi-method
4539 (tramp-find-method multi-method method user host)))
4540 (rsh-args (tramp-get-rsh-args
4541 multi-method
4542 (tramp-find-method multi-method method user host))))
3872 ;; The following should be changed. We need a more general 4543 ;; The following should be changed. We need a more general
3873 ;; mechanism to parse extra host args. 4544 ;; mechanism to parse extra host args.
3874 (when (string-match "\\([^#]*\\)#\\(.*\\)" host) 4545 (when (string-match "\\([^#]*\\)#\\(.*\\)" host)
@@ -3876,10 +4547,13 @@ arguments, and xx will be used as the host name to connect to.
3876 (setq host (match-string 1 host))) 4547 (setq host (match-string 1 host)))
3877 (setenv "TERM" tramp-terminal-type) 4548 (setenv "TERM" tramp-terminal-type)
3878 (let* ((default-directory (tramp-temporary-file-directory)) 4549 (let* ((default-directory (tramp-temporary-file-directory))
4550 ;; If we omit the conditional, we would use
4551 ;; `undecided-dos' in some cases. With the conditional,
4552 ;; we use nil in these cases. Which one is right?
3879 (coding-system-for-read (unless (and (not (featurep 'xemacs)) 4553 (coding-system-for-read (unless (and (not (featurep 'xemacs))
3880 (> emacs-major-version 20)) 4554 (> emacs-major-version 20))
3881 tramp-dos-coding-system)) 4555 tramp-dos-coding-system))
3882 (p (if user 4556 (p (if (and user (not (string= user "")))
3883 (apply #'start-process bufnam buf rsh-program 4557 (apply #'start-process bufnam buf rsh-program
3884 host "-l" user rsh-args) 4558 host "-l" user rsh-args)
3885 (apply #'start-process bufnam buf rsh-program 4559 (apply #'start-process bufnam buf rsh-program
@@ -3908,33 +4582,40 @@ set up correctly. Note that the other user may have a different shell
3908prompt than you do, so it is not at all unlikely that the variable 4582prompt than you do, so it is not at all unlikely that the variable
3909`shell-prompt-pattern' is set up wrongly!" 4583`shell-prompt-pattern' is set up wrongly!"
3910 (save-match-data 4584 (save-match-data
3911 (when (tramp-method-out-of-band-p multi-method method) 4585 (when (tramp-method-out-of-band-p multi-method method user host)
3912 (error "Cannot use out-of-band method `%s' with `su' connection method" 4586 (error "Cannot use out-of-band method `%s' with `su' connection method"
3913 method)) 4587 method))
3914 (unless (or (string-match (concat "^" (regexp-quote host)) 4588 (unless (or (string-match (concat "^" (regexp-quote host))
3915 (system-name)) 4589 (system-name))
3916 (string= "localhost" host)) 4590 (string= "localhost" host)
4591 (string= "" host))
3917 (error 4592 (error
3918 "Cannot connect to different host `%s' with `su' connection method" 4593 "Cannot connect to different host `%s' with `su' connection method"
3919 host)) 4594 host))
3920 (when (not user)
3921 (setq user "root"))
3922 (tramp-pre-connection multi-method method user host) 4595 (tramp-pre-connection multi-method method user host)
3923 (tramp-message 7 "Opening connection for `%s' using `%s'..." user method) 4596 (tramp-message 7 "Opening connection for `%s' using `%s'..."
4597 (or user "<root>") method)
3924 (let ((process-environment (copy-sequence process-environment))) 4598 (let ((process-environment (copy-sequence process-environment)))
3925 (setenv "TERM" tramp-terminal-type) 4599 (setenv "TERM" tramp-terminal-type)
3926 (let* ((default-directory (tramp-temporary-file-directory)) 4600 (let* ((default-directory (tramp-temporary-file-directory))
4601 ;; If we omit the conditional, we use `undecided-dos' in
4602 ;; some cases. With the conditional, we use nil in these
4603 ;; cases. What's the difference? Which one is right?
3927 (coding-system-for-read (unless (and (not (featurep 'xemacs)) 4604 (coding-system-for-read (unless (and (not (featurep 'xemacs))
3928 (> emacs-major-version 20)) 4605 (> emacs-major-version 20))
3929 tramp-dos-coding-system)) 4606 tramp-dos-coding-system))
3930 (p (apply 'start-process 4607 (p (apply 'start-process
3931 (tramp-buffer-name multi-method method user host) 4608 (tramp-buffer-name multi-method method user host)
3932 (tramp-get-buffer multi-method method user host) 4609 (tramp-get-buffer multi-method method user host)
3933 (tramp-get-su-program multi-method method) 4610 (tramp-get-su-program
4611 multi-method
4612 (tramp-find-method multi-method method user host))
3934 (mapcar 4613 (mapcar
3935 '(lambda (x) 4614 '(lambda (x)
3936 (format-spec x `((?u . ,user)))) 4615 (format-spec x `((?u . ,(or user "root")))))
3937 (tramp-get-su-args multi-method method)))) 4616 (tramp-get-su-args
4617 multi-method
4618 (tramp-find-method multi-method method user host)))))
3938 (found nil) 4619 (found nil)
3939 (pw nil)) 4620 (pw nil))
3940 (process-kill-without-query p) 4621 (process-kill-without-query p)
@@ -3963,7 +4644,7 @@ log in as u2 to h2."
3963 (save-match-data 4644 (save-match-data
3964 (unless multi-method 4645 (unless multi-method
3965 (error "Multi-hop open connection function called on non-multi method")) 4646 (error "Multi-hop open connection function called on non-multi method"))
3966 (when (tramp-method-out-of-band-p multi-method method) 4647 (when (tramp-method-out-of-band-p multi-method method user host)
3967 (error "No out of band multi-hop connections")) 4648 (error "No out of band multi-hop connections"))
3968 (unless (and (arrayp method) (not (stringp method))) 4649 (unless (and (arrayp method) (not (stringp method)))
3969 (error "METHOD must be an array of strings for multi methods")) 4650 (error "METHOD must be an array of strings for multi methods"))
@@ -3979,6 +4660,9 @@ log in as u2 to h2."
3979 (let ((process-environment (copy-sequence process-environment))) 4660 (let ((process-environment (copy-sequence process-environment)))
3980 (setenv "TERM" tramp-terminal-type) 4661 (setenv "TERM" tramp-terminal-type)
3981 (let* ((default-directory (tramp-temporary-file-directory)) 4662 (let* ((default-directory (tramp-temporary-file-directory))
4663 ;; If we omit the conditional, we use `undecided-dos' in
4664 ;; some cases. With the conditional, we use nil in these
4665 ;; cases. What's the difference? Which one is right?
3982 (coding-system-for-read (unless (and (not (featurep 'xemacs)) 4666 (coding-system-for-read (unless (and (not (featurep 'xemacs))
3983 (> emacs-major-version 20)) 4667 (> emacs-major-version 20))
3984 tramp-dos-coding-system)) 4668 tramp-dos-coding-system))
@@ -4137,7 +4821,7 @@ nil."
4137Uses PROMPT as a prompt and sends the password to process P." 4821Uses PROMPT as a prompt and sends the password to process P."
4138 (let ((pw (tramp-read-passwd prompt))) 4822 (let ((pw (tramp-read-passwd prompt)))
4139 (erase-buffer) 4823 (erase-buffer)
4140 (process-send-string p (concat pw tramp-rsh-end-of-line)))) 4824 (process-send-string p (concat pw tramp-password-end-of-line))))
4141 4825
4142;; HHH: Not Changed. This might handle the case where USER is not 4826;; HHH: Not Changed. This might handle the case where USER is not
4143;; given in the "File name" very poorly. Then, the local 4827;; given in the "File name" very poorly. Then, the local
@@ -4163,7 +4847,16 @@ to set up. METHOD, USER and HOST specify the connection."
4163 ;; a Kerberos login. 4847 ;; a Kerberos login.
4164 (sit-for 1) 4848 (sit-for 1)
4165 (tramp-discard-garbage-erase-buffer p multi-method method user host) 4849 (tramp-discard-garbage-erase-buffer p multi-method method user host)
4166 (process-send-string nil (format "exec %s%s" 4850 ;; It is useful to set the prompt in the following command because
4851 ;; some people have a setting for $PS1 which /bin/sh doesn't know
4852 ;; about and thus /bin/sh will display a strange prompt. For
4853 ;; example, if $PS1 has "${CWD}" in the value, then ksh will display
4854 ;; the current working directory but /bin/sh will display a dollar
4855 ;; sign. The following command line sets $PS1 to a sane value, and
4856 ;; works under Bourne-ish shells as well as csh-like shells. Daniel
4857 ;; Pittman reports that the unusual positioning of the single quotes
4858 ;; makes it work under `rc', too.
4859 (process-send-string nil (format "exec env 'PS1=$ ' %s%s"
4167 (tramp-get-remote-sh multi-method method) 4860 (tramp-get-remote-sh multi-method method)
4168 tramp-rsh-end-of-line)) 4861 tramp-rsh-end-of-line))
4169 (when tramp-debug-buffer 4862 (when tramp-debug-buffer
@@ -4171,7 +4864,8 @@ to set up. METHOD, USER and HOST specify the connection."
4171 (set-buffer (tramp-get-debug-buffer multi-method method user host)) 4864 (set-buffer (tramp-get-debug-buffer multi-method method user host))
4172 (goto-char (point-max)) 4865 (goto-char (point-max))
4173 (tramp-insert-with-face 4866 (tramp-insert-with-face
4174 'bold (format "$ exec %s\n" (tramp-get-remote-sh multi-method method))))) 4867 'bold (format "$ exec env PS1='$ ' %s\n"
4868 (tramp-get-remote-sh multi-method method)))))
4175 (tramp-message 9 "Waiting 30s for remote `%s' to come up..." 4869 (tramp-message 9 "Waiting 30s for remote `%s' to come up..."
4176 (tramp-get-remote-sh multi-method method)) 4870 (tramp-get-remote-sh multi-method method))
4177 (unless (tramp-wait-for-regexp 4871 (unless (tramp-wait-for-regexp
@@ -4285,24 +4979,15 @@ to set up. METHOD, USER and HOST specify the connection."
4285 (buffer-name))) 4979 (buffer-name)))
4286 (erase-buffer) 4980 (erase-buffer)
4287 (tramp-message 9 "Setting shell prompt") 4981 (tramp-message 9 "Setting shell prompt")
4982 ;; Douglas Gray Stephens <DGrayStephens@slb.com> says that we must
4983 ;; use "\n" here, not tramp-rsh-end-of-line.
4288 (tramp-send-command 4984 (tramp-send-command
4289 multi-method method user host 4985 multi-method method user host
4290 (format "PS1='%s%s%s'; PS2=''; PS3=''" 4986 (format "PS1='%s%s%s'; PS2=''; PS3=''"
4291 tramp-rsh-end-of-line 4987 tramp-rsh-end-of-line
4292 tramp-end-of-output 4988 tramp-end-of-output
4293 tramp-rsh-end-of-line)) 4989 tramp-rsh-end-of-line))
4294 (tramp-wait-for-output) 4990 (tramp-wait-for-output))
4295;; (tramp-send-command multi-method method user host "echo hello")
4296;; (tramp-message 9 "Waiting for remote `%s' to come up..."
4297;; (tramp-get-remote-sh multi-method method))
4298;; (unless (tramp-wait-for-output 5)
4299;; (unless (tramp-wait-for-output 5)
4300;; (pop-to-buffer (buffer-name))
4301;; (error "Couldn't set remote shell prompt. See buffer `%s' for details"
4302;; (buffer-name))))
4303;; (tramp-message 7 "Waiting for remote `%s' to come up...done"
4304;; (tramp-get-remote-sh multi-method method))
4305 )
4306 4991
4307(defun tramp-post-connection (multi-method method user host) 4992(defun tramp-post-connection (multi-method method user host)
4308 "Prepare a remote shell before being able to work on it. 4993 "Prepare a remote shell before being able to work on it.
@@ -4380,7 +5065,7 @@ locale to C and sets up the remote shell search path."
4380 (tramp-wait-for-output) 5065 (tramp-wait-for-output)
4381 (goto-char (point-min)) 5066 (goto-char (point-min))
4382 (setq tramp-test-groks-nt 5067 (setq tramp-test-groks-nt
4383 (looking-at (format "\n%s\n" (regexp-quote tramp-end-of-output)))) 5068 (looking-at (format "\n%s\r?\n" (regexp-quote tramp-end-of-output))))
4384 (unless tramp-test-groks-nt 5069 (unless tramp-test-groks-nt
4385 (tramp-send-command 5070 (tramp-send-command
4386 multi-method method user host 5071 multi-method method user host
@@ -4412,36 +5097,39 @@ locale to C and sets up the remote shell search path."
4412 " -e '" tramp-perl-file-attributes "' $1 2>/dev/null\n" 5097 " -e '" tramp-perl-file-attributes "' $1 2>/dev/null\n"
4413 "}")) 5098 "}"))
4414 (tramp-wait-for-output) 5099 (tramp-wait-for-output)
4415 (tramp-message 5 "Sending the Perl `mime-encode' implementations.") 5100 (unless (tramp-get-rcp-program
4416 (tramp-send-linewise 5101 multi-method
4417 multi-method method user host 5102 (tramp-find-method multi-method method user host))
4418 (concat "tramp_encode () {\n" 5103 (tramp-message 5 "Sending the Perl `mime-encode' implementations.")
4419 (format tramp-perl-encode tramp-remote-perl) 5104 (tramp-send-linewise
4420 " 2>/dev/null" 5105 multi-method method user host
4421 "\n}")) 5106 (concat "tramp_encode () {\n"
4422 (tramp-wait-for-output) 5107 (format tramp-perl-encode tramp-remote-perl)
4423 (tramp-send-linewise 5108 " 2>/dev/null"
4424 multi-method method user host 5109 "\n}"))
4425 (concat "tramp_encode_with_module () {\n" 5110 (tramp-wait-for-output)
4426 (format tramp-perl-encode-with-module tramp-remote-perl) 5111 (tramp-send-linewise
4427 " 2>/dev/null" 5112 multi-method method user host
4428 "\n}")) 5113 (concat "tramp_encode_with_module () {\n"
4429 (tramp-wait-for-output) 5114 (format tramp-perl-encode-with-module tramp-remote-perl)
4430 (tramp-message 5 "Sending the Perl `mime-decode' implementations.") 5115 " 2>/dev/null"
4431 (tramp-send-linewise 5116 "\n}"))
4432 multi-method method user host 5117 (tramp-wait-for-output)
4433 (concat "tramp_decode () {\n" 5118 (tramp-message 5 "Sending the Perl `mime-decode' implementations.")
4434 (format tramp-perl-decode tramp-remote-perl) 5119 (tramp-send-linewise
4435 " 2>/dev/null" 5120 multi-method method user host
4436 "\n}")) 5121 (concat "tramp_decode () {\n"
4437 (tramp-wait-for-output) 5122 (format tramp-perl-decode tramp-remote-perl)
4438 (tramp-send-linewise 5123 " 2>/dev/null"
4439 multi-method method user host 5124 "\n}"))
4440 (concat "tramp_decode_with_module () {\n" 5125 (tramp-wait-for-output)
4441 (format tramp-perl-decode-with-module tramp-remote-perl) 5126 (tramp-send-linewise
4442 " 2>/dev/null" 5127 multi-method method user host
4443 "\n}")) 5128 (concat "tramp_decode_with_module () {\n"
4444 (tramp-wait-for-output)))) 5129 (format tramp-perl-decode-with-module tramp-remote-perl)
5130 " 2>/dev/null"
5131 "\n}"))
5132 (tramp-wait-for-output)))))
4445 ;; Find ln(1) 5133 ;; Find ln(1)
4446 (erase-buffer) 5134 (erase-buffer)
4447 (let ((ln (tramp-find-executable multi-method method user host 5135 (let ((ln (tramp-find-executable multi-method method user host
@@ -4450,26 +5138,29 @@ locale to C and sets up the remote shell search path."
4450 (tramp-set-connection-property "ln" ln multi-method method user host))) 5138 (tramp-set-connection-property "ln" ln multi-method method user host)))
4451 (erase-buffer) 5139 (erase-buffer)
4452 ;; Find the right encoding/decoding commands to use. 5140 ;; Find the right encoding/decoding commands to use.
4453 (unless (tramp-get-rcp-program multi-method method) 5141 (unless (tramp-get-rcp-program
5142 multi-method
5143 (tramp-find-method multi-method method user host))
4454 (tramp-find-inline-encoding multi-method method user host)) 5144 (tramp-find-inline-encoding multi-method method user host))
4455 ;; If encoding/decoding command are given, test to see if they work. 5145 ;; If encoding/decoding command are given, test to see if they work.
4456 ;; CCC: Maybe it would be useful to run the encoder both locally and 5146 ;; CCC: Maybe it would be useful to run the encoder both locally and
4457 ;; remotely to see if they produce the same result. 5147 ;; remotely to see if they produce the same result.
4458 (let ((decoding (tramp-get-decoding-command multi-method method user host)) 5148 (let ((rem-enc (tramp-get-remote-encoding multi-method method user host))
4459 (encoding (tramp-get-encoding-command multi-method method user host)) 5149 (rem-dec (tramp-get-remote-decoding multi-method method user host))
4460 (magic-string "xyzzy")) 5150 (magic-string "xyzzy"))
4461 (when (and (or decoding encoding) (not (and decoding encoding))) 5151 (when (and (or rem-dec rem-enc) (not (and rem-dec rem-enc)))
4462 (tramp-kill-process multi-method method user host) 5152 (tramp-kill-process multi-method method user host)
5153 ;; Improve error message and/or error check.
4463 (error 5154 (error
4464 "Must give both decoding and encoding command in method definition")) 5155 "Must give both decoding and encoding command in method definition"))
4465 (when (and decoding encoding) 5156 (when (and rem-enc rem-dec)
4466 (tramp-message 5157 (tramp-message
4467 5 5158 5
4468 "Checking to see if encoding/decoding commands work on remote host...") 5159 "Checking to see if encoding/decoding commands work on remote host...")
4469 (tramp-send-command 5160 (tramp-send-command
4470 multi-method method user host 5161 multi-method method user host
4471 (format "echo %s | %s | %s" 5162 (format "echo %s | %s | %s"
4472 (tramp-shell-quote-argument magic-string) encoding decoding)) 5163 (tramp-shell-quote-argument magic-string) rem-enc rem-dec))
4473 (tramp-wait-for-output) 5164 (tramp-wait-for-output)
4474 (unless (looking-at (regexp-quote magic-string)) 5165 (unless (looking-at (regexp-quote magic-string))
4475 (tramp-kill-process multi-method method user host) 5166 (tramp-kill-process multi-method method user host)
@@ -4483,6 +5174,20 @@ locale to C and sets up the remote shell search path."
4483;; and decoding. Then we just use that in the last item. The other 5174;; and decoding. Then we just use that in the last item. The other
4484;; alternative is to use the Perl version of UU encoding. But then 5175;; alternative is to use the Perl version of UU encoding. But then
4485;; we need a Lisp version of uuencode. 5176;; we need a Lisp version of uuencode.
5177;;
5178;; Old text from documentation of tramp-methods:
5179;; Using a uuencode/uudecode inline method is discouraged, please use one
5180;; of the base64 methods instead since base64 encoding is much more
5181;; reliable and the commands are more standardized between the different
5182;; Unix versions. But if you can't use base64 for some reason, please
5183;; note that the default uudecode command does not work well for some
5184;; Unices, in particular AIX and Irix. For AIX, you might want to use
5185;; the following command for uudecode:
5186;;
5187;; sed '/^begin/d;/^[` ]$/d;/^end/d' | iconv -f uucode -t ISO8859-1
5188;;
5189;; For Irix, no solution is known yet.
5190
4486(defvar tramp-coding-commands 5191(defvar tramp-coding-commands
4487 '(("mimencode -b" "mimencode -u -b" 5192 '(("mimencode -b" "mimencode -u -b"
4488 base64-encode-region base64-decode-region) 5193 base64-encode-region base64-decode-region)
@@ -4491,31 +5196,36 @@ locale to C and sets up the remote shell search path."
4491 ("recode data..base64" "recode base64..data" 5196 ("recode data..base64" "recode base64..data"
4492 base64-encode-region base64-decode-region) 5197 base64-encode-region base64-decode-region)
4493 ("uuencode xxx" "uudecode -o -" 5198 ("uuencode xxx" "uudecode -o -"
4494 nil uudecode-decode-region) 5199 tramp-uuencode-region uudecode-decode-region)
4495 ("uuencode xxx" "uudecode -p" 5200 ("uuencode xxx" "uudecode -p"
4496 nil uudecode-decode-region) 5201 tramp-uuencode-region uudecode-decode-region)
4497 ("uuencode xxx" "tramp_uudecode" 5202 ("uuencode xxx" "tramp_uudecode"
4498 nil uudecode-decode-region) 5203 tramp-uuencode-region uudecode-decode-region)
4499 ("tramp_encode_with_module" "tramp_decode_with_module" 5204 ("tramp_encode_with_module" "tramp_decode_with_module"
4500 base64-encode-region base64-decode-region) 5205 base64-encode-region base64-decode-region)
4501 ("tramp_encode" "tramp_decode" 5206 ("tramp_encode" "tramp_decode"
4502 base64-encode-region base64-decode-region)) 5207 base64-encode-region base64-decode-region))
4503 "List of coding commands for inline transfer. 5208 "List of coding commands for inline transfer.
4504Each item is a list (ENCODING-COMMAND DECODING-COMMAND 5209Each item is a list that looks like this:
4505ENCODING-FUNCTION DECODING-FUNCTION). 5210
5211\(REMOTE-ENCODING REMOTE-DECODING LOCAL-ENCODING LOCAL-DECODING)
4506 5212
4507Each item can be a string, giving a command, or a symbol, giving 5213The REMOTE-ENCODING should be a string, giving a command accepting a
4508a function. 5214plain file on standard input and writing the encoded file to standard
5215output. The REMOTE-DECODING should also be a string, giving a command
5216accepting an encoded file on standard input and writing the decoded
5217file to standard output.
4509 5218
4510The ENCODING-COMMAND should be a command accepting a plain file on 5219LOCAL-ENCODING and LOCAL-DECODING can be strings, giving commands, or
4511standard input and writing the encoded file to standard output. The 5220symbols, giving functions. If they are strings, then they can contain
4512DECODING-COMMAND should be a command accepting an encoded file on 5221the \"%s\" format specifier. If that specifier is present, the input
4513standard input and writing the decoded file to standard output. 5222filename will be put into the command line at that spot. If the
5223specifier is not present, the input should be read from standard
5224input.
4514 5225
4515The ENCODING-FUNCTION and DECODING-FUNCTION functions will be called 5226If they are functions, they will be called with two arguments, start
4516with two arguments, start and end of region, and are expected to 5227and end of region, and are expected to replace the region contents
4517replace the region contents with the encoded or decoded results, 5228with the encoded or decoded results, respectively.")
4518respectively.")
4519 5229
4520(defun tramp-find-inline-encoding (multi-method method user host) 5230(defun tramp-find-inline-encoding (multi-method method user host)
4521 "Find an inline transfer encoding that works. 5231 "Find an inline transfer encoding that works.
@@ -4525,53 +5235,44 @@ Goes through the list `tramp-coding-commands'."
4525 (while (and commands (null found)) 5235 (while (and commands (null found))
4526 (setq item (pop commands)) 5236 (setq item (pop commands))
4527 (catch 'wont-work 5237 (catch 'wont-work
4528 (let ((ec (nth 0 item)) 5238 (let ((rem-enc (nth 0 item))
4529 (dc (nth 1 item)) 5239 (rem-dec (nth 1 item))
4530 (ef (nth 2 item)) 5240 (loc-enc (nth 2 item))
4531 (df (nth 3 item))) 5241 (loc-dec (nth 3 item)))
4532 ;; Check if encoding and decoding commands can be called 5242 ;; Check if remote encoding and decoding commands can be
4533 ;; remotely with null input and output. This makes sure there 5243 ;; called remotely with null input and output. This makes
4534 ;; are no syntax errors and the command is really found. 5244 ;; sure there are no syntax errors and the command is really
5245 ;; found.
4535 (tramp-message-for-buffer 5246 (tramp-message-for-buffer
4536 multi-method method user host 9 5247 multi-method method user host 9
4537 "Checking remote encoding command `%s' for sanity" ec) 5248 "Checking remote encoding command `%s' for sanity" rem-enc)
4538 (unless (zerop (tramp-send-command-and-check 5249 (unless (zerop (tramp-send-command-and-check
4539 multi-method method user host 5250 multi-method method user host
4540 (format "%s </dev/null >/dev/null" ec) t)) 5251 (format "%s </dev/null >/dev/null" rem-enc) t))
4541 (throw 'wont-work nil)) 5252 (throw 'wont-work nil))
4542 (tramp-message-for-buffer 5253 (tramp-message-for-buffer
4543 multi-method method user host 9 5254 multi-method method user host 9
4544 "Checking remote decoding command `%s' for sanity" dc) 5255 "Checking remote decoding command `%s' for sanity" rem-dec)
4545 (unless (zerop (tramp-send-command-and-check 5256 (unless (zerop (tramp-send-command-and-check
4546 multi-method method user host 5257 multi-method method user host
4547 (format "echo xyzzy | %s | %s >/dev/null" ec dc) t)) 5258 (format "echo xyzzy | %s | %s >/dev/null"
5259 rem-enc rem-dec) t))
4548 (throw 'wont-work nil)) 5260 (throw 'wont-work nil))
4549 ;; If no encoding/decoding function is given, the 5261 ;; If the local encoder or decoder is a string, the
4550 ;; corresponding encoding/decoding command also has to work 5262 ;; corresponding command has to work locally.
4551 ;; locally. 5263 (when (stringp loc-enc)
4552 (when (not (fboundp ef))
4553 (tramp-message-for-buffer 5264 (tramp-message-for-buffer
4554 multi-method method user host 9 5265 multi-method method user host 9
4555 "Checking local encoding command `%s' for sanity" ec) 5266 "Checking local encoding command `%s' for sanity" loc-enc)
4556 (unless (zerop (call-process 5267 (unless (zerop (tramp-call-local-coding-command
4557 tramp-sh-program ;program 5268 loc-enc nil nil))
4558 nil ;input
4559 nil ;output buffer
4560 nil ;redisplay
4561 "-c"
4562 (format "%s </dev/null >/dev/null" ec)))
4563 (throw 'wont-work nil))) 5269 (throw 'wont-work nil)))
4564 (when (not (fboundp df)) 5270 (when (stringp loc-dec)
4565 (tramp-message-for-buffer 5271 (tramp-message-for-buffer
4566 multi-method method user host 9 5272 multi-method method user host 9
4567 "Checking local decoding command `%s' for sanity" dc) 5273 "Checking local decoding command `%s' for sanity" loc-dec)
4568 (unless (zerop (call-process 5274 (unless (zerop (tramp-call-local-coding-command
4569 tramp-sh-program ;program 5275 loc-dec nil nil))
4570 nil ;input file
4571 nil ;output buffer
4572 nil ;redisplay
4573 "-c"
4574 (format "%s </dev/null >/dev/null" dc)))
4575 (throw 'wont-work nil))) 5276 (throw 'wont-work nil)))
4576 ;; CCC: At this point, maybe we should check that the output 5277 ;; CCC: At this point, maybe we should check that the output
4577 ;; of the commands is correct. But for the moment we will 5278 ;; of the commands is correct. But for the moment we will
@@ -4582,21 +5283,45 @@ Goes through the list `tramp-coding-commands'."
4582 ;; set connection properties. 5283 ;; set connection properties.
4583 (unless found 5284 (unless found
4584 (error "Couldn't find an inline transfer encoding")) 5285 (error "Couldn't find an inline transfer encoding"))
4585 (let ((ec (nth 0 found)) 5286 (let ((rem-enc (nth 0 found))
4586 (dc (nth 1 found)) 5287 (rem-dec (nth 1 found))
4587 (ef (nth 2 found)) 5288 (loc-enc (nth 2 found))
4588 (df (nth 3 found))) 5289 (loc-dec (nth 3 found)))
4589 (tramp-set-encoding-command multi-method method user host ec) 5290 (tramp-message 10 "Using remote encoding %s" rem-enc)
4590 (tramp-set-decoding-command multi-method method user host dc) 5291 (tramp-set-remote-encoding multi-method method user host rem-enc)
4591 (tramp-set-encoding-function multi-method method user host ef) 5292 (tramp-message 10 "Using remote decoding %s" rem-dec)
4592 (tramp-set-decoding-function multi-method method user host df)))) 5293 (tramp-set-remote-decoding multi-method method user host rem-dec)
4593 5294 (tramp-message 10 "Using local encoding %s" loc-enc)
5295 (tramp-set-local-encoding multi-method method user host loc-enc)
5296 (tramp-message 10 "Using local decoding %s" loc-dec)
5297 (tramp-set-local-decoding multi-method method user host loc-dec))))
5298
5299(defun tramp-call-local-coding-command (cmd input output)
5300 "Call the local encoding or decoding command.
5301If CMD contains \"%s\", provide input file INPUT there in command.
5302Otherwise, INPUT is passed via standard input.
5303INPUT can also be nil which means `/dev/null'.
5304OUTPUT can be a string (which specifies a filename), or t (which
5305means standard output and thus the current buffer), or nil (which
5306means discard it)."
5307 (call-process
5308 tramp-encoding-shell ;program
5309 (when (and input (not (string-match "%s" cmd)))
5310 input) ;input
5311 (if (eq output t) t nil) ;output
5312 nil ;redisplay
5313 tramp-encoding-command-switch
5314 ;; actual shell command
5315 (concat
5316 (if (string-match "%s" cmd) (format cmd input) cmd)
5317 (if (stringp output) (concat "> " output) ""))))
4594 5318
4595(defun tramp-maybe-open-connection (multi-method method user host) 5319(defun tramp-maybe-open-connection (multi-method method user host)
4596 "Maybe open a connection to HOST, logging in as USER, using METHOD. 5320 "Maybe open a connection to HOST, logging in as USER, using METHOD.
4597Does not do anything if a connection is already open, but re-opens the 5321Does not do anything if a connection is already open, but re-opens the
4598connection if a previous connection has died for some reason." 5322connection if a previous connection has died for some reason."
4599 (let ((p (get-buffer-process (tramp-get-buffer multi-method method user host))) 5323 (let ((p (get-buffer-process
5324 (tramp-get-buffer multi-method method user host)))
4600 last-cmd-time) 5325 last-cmd-time)
4601 ;; If too much time has passed since last command was sent, look 5326 ;; If too much time has passed since last command was sent, look
4602 ;; whether process is still alive. If it isn't, kill it. When 5327 ;; whether process is still alive. If it isn't, kill it. When
@@ -4618,7 +5343,9 @@ connection if a previous connection has died for some reason."
4618 (unless (and p (processp p) (memq (process-status p) '(run open))) 5343 (unless (and p (processp p) (memq (process-status p) '(run open)))
4619 (when (and p (processp p)) 5344 (when (and p (processp p))
4620 (delete-process p)) 5345 (delete-process p))
4621 (funcall (tramp-get-connection-function multi-method method) 5346 (funcall (tramp-get-connection-function
5347 multi-method
5348 (tramp-find-method multi-method method user host))
4622 multi-method method user host)))) 5349 multi-method method user host))))
4623 5350
4624(defun tramp-send-command 5351(defun tramp-send-command
@@ -4681,7 +5408,7 @@ the remote host use line-endings as defined in the variable
4681 (start-time (current-time)) 5408 (start-time (current-time))
4682 (end-of-output (concat "^" 5409 (end-of-output (concat "^"
4683 (regexp-quote tramp-end-of-output) 5410 (regexp-quote tramp-end-of-output)
4684 "$"))) 5411 "\r?$")))
4685 ;; Algorithm: get waiting output. See if last line contains 5412 ;; Algorithm: get waiting output. See if last line contains
4686 ;; end-of-output sentinel. If not, wait a bit and again get 5413 ;; end-of-output sentinel. If not, wait a bit and again get
4687 ;; waiting output. Repeat until timeout expires or end-of-output 5414 ;; waiting output. Repeat until timeout expires or end-of-output
@@ -4778,6 +5505,10 @@ FMT and ARGS which are passed to `error'."
4778 (pop-to-buffer (current-buffer)) 5505 (pop-to-buffer (current-buffer))
4779 (funcall 'signal signal (apply 'format fmt args)))) 5506 (funcall 'signal signal (apply 'format fmt args))))
4780 5507
5508;; Chunked sending kluge.
5509(defvar tramp-chunksize nil
5510 "If non-nil, chunksize for sending things to remote host.")
5511
4781(defun tramp-send-region (multi-method method user host start end) 5512(defun tramp-send-region (multi-method method user host start end)
4782 "Send the region from START to END to remote command 5513 "Send the region from START to END to remote command
4783running as USER on HOST using METHOD." 5514running as USER on HOST using METHOD."
@@ -4785,7 +5516,19 @@ running as USER on HOST using METHOD."
4785 (tramp-get-buffer multi-method method user host)))) 5516 (tramp-get-buffer multi-method method user host))))
4786 (unless proc 5517 (unless proc
4787 (error "Can't send region to remote host -- not logged in")) 5518 (error "Can't send region to remote host -- not logged in"))
4788 (process-send-region proc start end) 5519 (if tramp-chunksize
5520 (let ((pos start))
5521 (while (< pos end)
5522 (tramp-message-for-buffer
5523 multi-method method user host 10
5524 "Sending chunk from %s to %s" pos end)
5525 (process-send-region proc
5526 pos
5527 (min (+ pos tramp-chunksize)
5528 end))
5529 (setq pos (+ pos tramp-chunksize))
5530 (sleep-for 0.1)))
5531 (process-send-region proc start end))
4789 (when tramp-debug-buffer 5532 (when tramp-debug-buffer
4790 (append-to-buffer 5533 (append-to-buffer
4791 (tramp-get-debug-buffer multi-method method user host) 5534 (tramp-get-debug-buffer multi-method method user host)
@@ -4978,8 +5721,6 @@ remote path name."
4978 (let ((user (match-string (nth 2 tramp-file-name-structure) name)) 5721 (let ((user (match-string (nth 2 tramp-file-name-structure) name))
4979 (host (match-string (nth 3 tramp-file-name-structure) name)) 5722 (host (match-string (nth 3 tramp-file-name-structure) name))
4980 (path (match-string (nth 4 tramp-file-name-structure) name))) 5723 (path (match-string (nth 4 tramp-file-name-structure) name)))
4981 (when (not method)
4982 (setq method (tramp-find-default-method user host)))
4983 (make-tramp-file-name 5724 (make-tramp-file-name
4984 :multi-method nil 5725 :multi-method nil
4985 :method method 5726 :method method
@@ -4994,11 +5735,18 @@ remote path name."
4994 item) 5735 item)
4995 (while choices 5736 (while choices
4996 (setq item (pop choices)) 5737 (setq item (pop choices))
4997 (when (and (string-match (nth 0 item) host) 5738 (when (and (string-match (nth 0 item) (or host ""))
4998 (string-match (nth 1 item) (or user ""))) 5739 (string-match (nth 1 item) (or user "")))
4999 (setq method (nth 2 item)) 5740 (setq method (nth 2 item))
5000 (setq choices nil))) 5741 (setq choices nil)))
5001 method)) 5742 method))
5743
5744(defun tramp-find-method (multi-method method user host)
5745 "Return the right method string to use.
5746This is MULTI-METHOD, if non-nil. Otherwise, it is METHOD, if non-nil.
5747If both MULTI-METHOD and METHOD are nil, do a lookup in
5748`tramp-default-method-alist'."
5749 (or multi-method method (tramp-find-default-method user host)))
5002 5750
5003;; HHH: Not Changed. Multi method. Will probably not handle the case where 5751;; HHH: Not Changed. Multi method. Will probably not handle the case where
5004;; a user name is not provided in the "file name" very well. 5752;; a user name is not provided in the "file name" very well.
@@ -5038,15 +5786,15 @@ remote path name."
5038 5786
5039(defun tramp-make-tramp-file-name (multi-method method user host path) 5787(defun tramp-make-tramp-file-name (multi-method method user host path)
5040 "Constructs a tramp file name from METHOD, USER, HOST and PATH." 5788 "Constructs a tramp file name from METHOD, USER, HOST and PATH."
5041 (unless tramp-make-tramp-file-format
5042 (error "`tramp-make-tramp-file-format' is nil"))
5043 (if multi-method 5789 (if multi-method
5044 (tramp-make-tramp-multi-file-name multi-method method user host path) 5790 (tramp-make-tramp-multi-file-name multi-method method user host path)
5045 (if user 5791 (format-spec
5046 (format-spec tramp-make-tramp-file-format 5792 (concat tramp-prefix-format
5047 `((?m . ,method) (?u . ,user) (?h . ,host) (?p . ,path))) 5793 (when method (concat "%m" tramp-postfix-single-method-format))
5048 (format-spec tramp-make-tramp-file-user-nil-format 5794 (when user (concat "%u" tramp-postfix-user-format))
5049 `((?m . ,method) (?h . ,host) (?p . ,path)))))) 5795 (when host (concat "%h" tramp-postfix-host-format))
5796 (when path (concat "%p")))
5797 `((?m . ,method) (?u . ,user) (?h . ,host) (?p . ,path)))))
5050 5798
5051;; CCC: Henrik Holm: Not Changed. Multi Method. What should be done 5799;; CCC: Henrik Holm: Not Changed. Multi Method. What should be done
5052;; with this when USER is nil? 5800;; with this when USER is nil?
@@ -5081,11 +5829,13 @@ remote path name."
5081 (format "/%s@%s:%s" user host path) 5829 (format "/%s@%s:%s" user host path)
5082 (format "/%s:%s" host path))) 5830 (format "/%s:%s" host path)))
5083 5831
5084(defun tramp-method-out-of-band-p (multi-method method) 5832(defun tramp-method-out-of-band-p (multi-method method user host)
5085 "Return t if this is an out-of-band method, nil otherwise. 5833 "Return t if this is an out-of-band method, nil otherwise.
5086It is important to check for this condition, since it is not possible 5834It is important to check for this condition, since it is not possible
5087to enter a password for the `tramp-rcp-program'." 5835to enter a password for the `tramp-rcp-program'."
5088 (tramp-get-rcp-program multi-method method)) 5836 (tramp-get-rcp-program
5837 multi-method
5838 (tramp-find-method multi-method method user host)))
5089 5839
5090;; Variables local to connection. 5840;; Variables local to connection.
5091 5841
@@ -5136,136 +5886,113 @@ If the value is not set for the connection, return `default'"
5136 value))) 5886 value)))
5137 5887
5138;; Some predefined connection properties. 5888;; Some predefined connection properties.
5139(defun tramp-get-encoding-command (multi-method method user host) 5889(defun tramp-set-remote-encoding (multi-method method user host rem-enc)
5140 (tramp-get-connection-property "encoding-command" nil 5890 (tramp-set-connection-property "remote-encoding" rem-enc
5141 multi-method method user host)) 5891 multi-method method user host))
5142(defun tramp-set-encoding-command (multi-method method user host command) 5892(defun tramp-get-remote-encoding (multi-method method user host)
5143 (tramp-set-connection-property "encoding-command" command 5893 (tramp-get-connection-property "remote-encoding" nil
5144 multi-method method user host)) 5894 multi-method method user host))
5145(defun tramp-get-decoding-command (multi-method method user host) 5895
5146 (tramp-get-connection-property "decoding-command" nil 5896(defun tramp-set-remote-decoding (multi-method method user host rem-dec)
5897 (tramp-set-connection-property "remote-decoding" rem-dec
5147 multi-method method user host)) 5898 multi-method method user host))
5148(defun tramp-set-decoding-command (multi-method method user host command) 5899(defun tramp-get-remote-decoding (multi-method method user host)
5149 (tramp-set-connection-property "decoding-command" command 5900 (tramp-get-connection-property "remote-decoding" nil
5150 multi-method method user host)) 5901 multi-method method user host))
5151(defun tramp-get-encoding-function (multi-method method user host) 5902
5152 (tramp-get-connection-property "encoding-function" nil 5903(defun tramp-set-local-encoding (multi-method method user host loc-enc)
5904 (tramp-set-connection-property "local-encoding" loc-enc
5153 multi-method method user host)) 5905 multi-method method user host))
5154(defun tramp-set-encoding-function (multi-method method user host func) 5906(defun tramp-get-local-encoding (multi-method method user host)
5155 (tramp-set-connection-property "encoding-function" func 5907 (tramp-get-connection-property "local-encoding" nil
5156 multi-method method user host)) 5908 multi-method method user host))
5157(defun tramp-get-decoding-function (multi-method method user host) 5909
5158 (tramp-get-connection-property "decoding-function" nil 5910(defun tramp-set-local-decoding (multi-method method user host loc-dec)
5911 (tramp-set-connection-property "local-decoding" loc-dec
5159 multi-method method user host)) 5912 multi-method method user host))
5160(defun tramp-set-decoding-function (multi-method method user host func) 5913(defun tramp-get-local-decoding (multi-method method user host)
5161 (tramp-set-connection-property "decoding-function" func 5914 (tramp-get-connection-property "local-decoding" nil
5162 multi-method method user host)) 5915 multi-method method user host))
5163 5916
5164 5917
5165(defun tramp-get-connection-function (multi-method method) 5918
5919(defun tramp-get-connection-function (multi-method method user host)
5166 (second (or (assoc 'tramp-connection-function 5920 (second (or (assoc 'tramp-connection-function
5167 (assoc (or multi-method method tramp-default-method) 5921 (assoc (tramp-find-method multi-method method user host)
5168 tramp-methods)) 5922 tramp-methods))
5169 (error "Method `%s' didn't specify a connection function" 5923 (error "Method `%s' didn't specify a connection function"
5170 (or multi-method method))))) 5924 (or multi-method method)))))
5171 5925
5172(defun tramp-get-remote-sh (multi-method method) 5926(defun tramp-get-remote-sh (multi-method method user host)
5173 (second (or (assoc 'tramp-remote-sh 5927 (second (or (assoc 'tramp-remote-sh
5174 (assoc (or multi-method method tramp-default-method) 5928 (assoc (tramp-find-method multi-method method user host)
5175 tramp-methods)) 5929 tramp-methods))
5176 (error "Method `%s' didn't specify a remote shell" 5930 (error "Method `%s' didn't specify a remote shell"
5177 (or multi-method method))))) 5931 (or multi-method method)))))
5178 5932
5179(defun tramp-get-rsh-program (multi-method method) 5933(defun tramp-get-rsh-program (multi-method method user host)
5180 (second (or (assoc 'tramp-rsh-program 5934 (second (or (assoc 'tramp-rsh-program
5181 (assoc (or multi-method method tramp-default-method) 5935 (assoc (tramp-find-method multi-method method user host)
5182 tramp-methods)) 5936 tramp-methods))
5183 (error "Method `%s' didn't specify an rsh program" 5937 (error "Method `%s' didn't specify an rsh program"
5184 (or multi-method method))))) 5938 (or multi-method method)))))
5185 5939
5186(defun tramp-get-rsh-args (multi-method method) 5940(defun tramp-get-rsh-args (multi-method method user host)
5187 (second (or (assoc 'tramp-rsh-args 5941 (second (or (assoc 'tramp-rsh-args
5188 (assoc (or multi-method method tramp-default-method) 5942 (assoc (tramp-find-method multi-method method user host)
5189 tramp-methods)) 5943 tramp-methods))
5190 (error "Method `%s' didn't specify rsh args" 5944 (error "Method `%s' didn't specify rsh args"
5191 (or multi-method method))))) 5945 (or multi-method method)))))
5192 5946
5193(defun tramp-get-rcp-program (multi-method method) 5947(defun tramp-get-rcp-program (multi-method method user host)
5194 (second (or (assoc 'tramp-rcp-program 5948 (second (or (assoc 'tramp-rcp-program
5195 (assoc (or multi-method method tramp-default-method) 5949 (assoc (tramp-find-method multi-method method user host)
5196 tramp-methods)) 5950 tramp-methods))
5197 (error "Method `%s' didn't specify an rcp program" 5951 (error "Method `%s' didn't specify an rcp program"
5198 (or multi-method method))))) 5952 (or multi-method method)))))
5199 5953
5200(defun tramp-get-rcp-args (multi-method method) 5954(defun tramp-get-rcp-args (multi-method method user host)
5201 (second (or (assoc 'tramp-rcp-args 5955 (second (or (assoc 'tramp-rcp-args
5202 (assoc (or multi-method method tramp-default-method) 5956 (assoc (tramp-find-method multi-method method user host)
5203 tramp-methods)) 5957 tramp-methods))
5204 (error "Method `%s' didn't specify rcp args" 5958 (error "Method `%s' didn't specify rcp args"
5205 (or multi-method method))))) 5959 (or multi-method method)))))
5206 5960
5207(defun tramp-get-rcp-keep-date-arg (multi-method method) 5961(defun tramp-get-rcp-keep-date-arg (multi-method method user host)
5208 (second (or (assoc 'tramp-rcp-keep-date-arg 5962 (second (or (assoc 'tramp-rcp-keep-date-arg
5209 (assoc (or multi-method method tramp-default-method) 5963 (assoc (tramp-find-method multi-method method user host)
5210 tramp-methods)) 5964 tramp-methods))
5211 (error "Method `%s' didn't specify `keep-date' arg for tramp" 5965 (error "Method `%s' didn't specify `keep-date' arg for tramp"
5212 (or multi-method method))))) 5966 (or multi-method method)))))
5213 5967
5214(defun tramp-get-su-program (multi-method method) 5968(defun tramp-get-su-program (multi-method method user host)
5215 (second (or (assoc 'tramp-su-program 5969 (second (or (assoc 'tramp-su-program
5216 (assoc (or multi-method method tramp-default-method) 5970 (assoc (tramp-find-method multi-method method user host)
5217 tramp-methods)) 5971 tramp-methods))
5218 (error "Method `%s' didn't specify a su program" 5972 (error "Method `%s' didn't specify a su program"
5219 (or multi-method method))))) 5973 (or multi-method method)))))
5220 5974
5221(defun tramp-get-su-args (multi-method method) 5975(defun tramp-get-su-args (multi-method method user host)
5222 (second (or (assoc 'tramp-su-args 5976 (second (or (assoc 'tramp-su-args
5223 (assoc (or multi-method method tramp-default-method) 5977 (assoc (tramp-find-method multi-method method user host)
5224 tramp-methods)) 5978 tramp-methods))
5225 (error "Method `%s' didn't specify su args" 5979 (error "Method `%s' didn't specify su args"
5226 (or multi-method method))))) 5980 (or multi-method method)))))
5227 5981
5228(defun tramp-get-telnet-program (multi-method method) 5982(defun tramp-get-telnet-program (multi-method method user host)
5229 (second (or (assoc 'tramp-telnet-program 5983 (second (or (assoc 'tramp-telnet-program
5230 (assoc (or multi-method method tramp-default-method) 5984 (assoc (tramp-find-method multi-method method user host)
5231 tramp-methods)) 5985 tramp-methods))
5232 (error "Method `%s' didn't specify a telnet program" 5986 (error "Method `%s' didn't specify a telnet program"
5233 (or multi-method method))))) 5987 (or multi-method method)))))
5234 5988
5235(defun tramp-get-telnet-args (multi-method method) 5989(defun tramp-get-telnet-args (multi-method method user host)
5236 (second (or (assoc 'tramp-telnet-args 5990 (second (or (assoc 'tramp-telnet-args
5237 (assoc (or multi-method method tramp-default-method) 5991 (assoc (tramp-find-method multi-method method user host)
5238 tramp-methods)) 5992 tramp-methods))
5239 (error "Method `%s' didn't specify telnet args" 5993 (error "Method `%s' didn't specify telnet args"
5240 (or multi-method method))))) 5994 (or multi-method method)))))
5241 5995
5242;; (defun tramp-get-encoding-command (multi-method method)
5243;; (second (or (assoc 'tramp-encoding-command
5244;; (assoc (or multi-method method tramp-default-method)
5245;; tramp-methods))
5246;; (error "Method `%s' didn't specify an encoding command"
5247;; (or multi-method method)))))
5248
5249;; (defun tramp-get-decoding-command (multi-method method)
5250;; (second (or (assoc 'tramp-decoding-command
5251;; (assoc (or multi-method method tramp-default-method)
5252;; tramp-methods))
5253;; (error "Method `%s' didn't specify a decoding command"
5254;; (or multi-method method)))))
5255
5256;; (defun tramp-get-encoding-function (multi-method method)
5257;; (second (or (assoc 'tramp-encoding-function
5258;; (assoc (or multi-method method tramp-default-method)
5259;; tramp-methods))
5260;; (error "Method `%s' didn't specify an encoding function"
5261;; (or multi-method method)))))
5262
5263;; (defun tramp-get-decoding-function (multi-method method)
5264;; (second (or (assoc 'tramp-decoding-function
5265;; (assoc (or multi-method method tramp-default-method)
5266;; tramp-methods))
5267;; (error "Method `%s' didn't specify a decoding function"
5268;; (or multi-method method)))))
5269 5996
5270;; Auto saving to a special directory. 5997;; Auto saving to a special directory.
5271 5998
@@ -5463,20 +6190,16 @@ Only works for Bourne-like shells."
5463;; nil 6190;; nil
5464;; ad-do-it)) 6191;; ad-do-it))
5465 6192
5466;; We currently use "[" and "]" in the filename format. In Emacs 6193;; We currently (sometimes) use "[" and "]" in the filename format.
5467;; 20.x, this means that Emacs wants to expand wildcards if 6194;; This means that Emacs wants to expand wildcards if
5468;; `find-file-wildcards' is non-nil, and then barfs because no 6195;; `find-file-wildcards' is non-nil, and then barfs because no
5469;; expansion could be found. We detect this situation and do 6196;; expansion could be found. We detect this situation and do
5470;; something really awful: we have `file-expand-wildcards' return the 6197;; something really awful: we have `file-expand-wildcards' return the
5471;; original filename if it can't expand anything. Let's just hope 6198;; original filename if it can't expand anything. Let's just hope
5472;; that this doesn't break anything else. 6199;; that this doesn't break anything else.
5473;; 6200;; CCC: This check is now also really awful; we should search all
5474;; Another problem is that the check is done by Emacs version, which 6201;; of the filename format, not just the prefix.
5475;; is really not what we want to do. Oh, well. 6202(when (string-match "\\[" tramp-prefix-format)
5476
5477;;(when (and (not (featurep 'xemacs))
5478;; (= emacs-major-version 20))
5479;; It seems that this advice is needed in Emacs 21, too.
5480(defadvice file-expand-wildcards (around tramp-fix activate) 6203(defadvice file-expand-wildcards (around tramp-fix activate)
5481 (let ((name (ad-get-arg 0))) 6204 (let ((name (ad-get-arg 0)))
5482 (if (tramp-tramp-file-p name) 6205 (if (tramp-tramp-file-p name)
@@ -5490,7 +6213,7 @@ Only works for Bourne-like shells."
5490 ;; If it is not a Tramp file, just run the original function. 6213 ;; If it is not a Tramp file, just run the original function.
5491 (let ((res ad-do-it)) 6214 (let ((res ad-do-it))
5492 (setq ad-return-value (or res (list name))))))) 6215 (setq ad-return-value (or res (list name)))))))
5493;; ) 6216)
5494 6217
5495;; Tramp version is useful in a number of situations. 6218;; Tramp version is useful in a number of situations.
5496 6219
@@ -5526,6 +6249,7 @@ Only works for Bourne-like shells."
5526 tramp-auto-save-directory ; vars to dump 6249 tramp-auto-save-directory ; vars to dump
5527 tramp-default-method 6250 tramp-default-method
5528 tramp-rsh-end-of-line 6251 tramp-rsh-end-of-line
6252 tramp-password-end-of-line
5529 tramp-remote-path 6253 tramp-remote-path
5530 tramp-login-prompt-regexp 6254 tramp-login-prompt-regexp
5531 tramp-password-prompt-regexp 6255 tramp-password-prompt-regexp
@@ -5539,7 +6263,7 @@ Only works for Bourne-like shells."
5539 tramp-multi-file-name-hop-structure 6263 tramp-multi-file-name-hop-structure
5540 tramp-multi-methods 6264 tramp-multi-methods
5541 tramp-multi-connection-function-alist 6265 tramp-multi-connection-function-alist
5542 tramp-make-tramp-file-format 6266 tramp-methods
5543 tramp-end-of-output 6267 tramp-end-of-output
5544 tramp-coding-commands 6268 tramp-coding-commands
5545 tramp-actions-before-shell 6269 tramp-actions-before-shell
@@ -5587,6 +6311,7 @@ report.
5587 6311
5588;;; TODO: 6312;;; TODO:
5589 6313
6314;; * Autodetect if remote `ls' groks the "--dired" switch.
5590;; * Add fallback for inline encodings. This should be used 6315;; * Add fallback for inline encodings. This should be used
5591;; if the remote end doesn't support mimencode or a similar program. 6316;; if the remote end doesn't support mimencode or a similar program.
5592;; For reading files from the remote host, we can just parse the output 6317;; For reading files from the remote host, we can just parse the output
@@ -5599,6 +6324,9 @@ report.
5599;; two commands to write a null byte: 6324;; two commands to write a null byte:
5600;; dd if=/dev/zero bs=1 count=1 6325;; dd if=/dev/zero bs=1 count=1
5601;; echo | tr '\n' '\000' 6326;; echo | tr '\n' '\000'
6327;; * Separate local `tramp-coding-commands' from remote ones. Connect
6328;; the two via a format which can be `uu' or `b64'. Then we can search
6329;; for the right local commands and the right remote commands separately.
5602;; * Cooperate with PCL-CVS. It uses start-process, which doesn't 6330;; * Cooperate with PCL-CVS. It uses start-process, which doesn't
5603;; work for remote files. 6331;; work for remote files.
5604;; * Rewrite `tramp-shell-quote-argument' to abstain from using 6332;; * Rewrite `tramp-shell-quote-argument' to abstain from using
@@ -5684,6 +6412,25 @@ report.
5684;; about Tramp, it does not do the right thing if the target file 6412;; about Tramp, it does not do the right thing if the target file
5685;; name is a Tramp name. 6413;; name is a Tramp name.
5686;; * Username and hostname completion. 6414;; * Username and hostname completion.
6415;; ** If `partial-completion-mode' isn't loaded, "/foo:bla" tries to
6416;; connect to host "blabla" already if that host is unique. No idea
6417;; how to suppress. Maybe not an essential problem.
6418;; ** For "/ssh1-old:", `(file-name-all-completions "ssh1" "/")' is called
6419;; only. Likely due to word delimeter property of "-". Maybe we can remove
6420;; all the "*-old" methods? Or rename them to "*_old"?
6421;; ** Try to avoid usage of `last-input-event' in `tramp-completion-mode'.
6422;; ** Handle quoted file names, starting with "/:". Problem is that
6423;; `file-name-non-special' calls later on `file-name-all-completions'
6424;; without ":". Hmm. Worth a bug report?
6425;; ** Acknowledge port numbers.
6426;; ** Extend `tramp-get-completion-su' for NIS and shadow passwords.
6427;; ** Unify `tramp-parse-{rhosts,shosts,hosts,passwd}'.
6428;; Code is nearly identical.
6429;; ** Decide whiche files to take for searching user/host names depending on
6430;; operating system (windows-nt) in `tramp-completion-function-alist'.
6431;; ** Enhance variables for debug.
6432;; ** Implement "/multi:" completion.
6433;; ** Add a learning mode for completion. Make results persistent.
5687 6434
5688;; Functions for file-name-handler-alist: 6435;; Functions for file-name-handler-alist:
5689;; diff-latest-backup-file -- in diff.el 6436;; diff-latest-backup-file -- in diff.el