aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog449
-rw-r--r--lisp/net/tramp-uu.el89
-rw-r--r--lisp/net/tramp.el1777
-rw-r--r--man/tramp.texi733
4 files changed, 2290 insertions, 758 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
diff --git a/man/tramp.texi b/man/tramp.texi
index daf32c7c184..66b16b23fd7 100644
--- a/man/tramp.texi
+++ b/man/tramp.texi
@@ -8,6 +8,12 @@
8@c This is *so* much nicer :) 8@c This is *so* much nicer :)
9@footnotestyle end 9@footnotestyle end
10 10
11@c In the Tramp CVS, the version number is auto-frobbed from the
12@c Makefile, so you should edit the top-level Makefile to change
13@c the version number.
14@macro trampver{}
152.0.20
16@end macro
11 17
12@c Entries for @command{install-info} to use 18@c Entries for @command{install-info} to use
13@dircategory Emacs 19@dircategory Emacs
@@ -21,39 +27,46 @@
21@sc{tramp} 27@sc{tramp}
22@end macro 28@end macro
23 29
24@c Copying permissions, et al 30@c Distinguish between GNU Emacs and XEmacs. Derived from the
25@copying 31@c Makefile variable $(EMACS-ID). Valid values are `emacs' and `xemacs'.
26This file documents @tramp{}, a remote file editing package for Emacs and 32@set emacs
27XEmacs. 33
28 34@c Some flags which make the text independent on the (X)Emacs flavor.
29Copyright @copyright{} 1999, 2000, 2001, 2002 Free Software 35@c GNU Emacs values.
30Foundation, Inc. 36@ifset emacs
31 37@set emacs-name Emacs
32@quotation 38@set emacs-dir emacs
33Permission is granted to copy, distribute and/or modify this document 39@set ftp-package-name Ange-FTP
34under the terms of the GNU Free Documentation License, Version 1.1 or 40@set tramp-prefix /
35any later version published by the Free Software Foundation; with no 41@set tramp-prefix-single-hop
36Invariant Sections, with the Front-Cover texts being ``A GNU 42@set tramp-postfix :
37Manual'', and with the Back-Cover Texts as in (a) below. A copy of the 43@set tramp-postfix-single-hop :
38license is included in the section entitled ``GNU Free Documentation 44@set tramp-postfix-multi-hop :
39License'' in the Emacs manual. 45@end ifset
40 46
41(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify 47@c XEmacs counterparts.
42this GNU Manual, like GNU software. Copies published by the Free 48@ifset xemacs
43Software Foundation raise funds for GNU development.'' 49@set emacs-name XEmacs
44 50@set emacs-dir xemacs
45This document is part of a collection distributed under the GNU Free 51@set ftp-package-name EFS
46Documentation License. If you want to distribute this document 52@set tramp-prefix /[
47separately from the collection, you can do so by adding a copy of the 53@set tramp-prefix-single-hop [
48license to the document, as described in section 6 of the license. 54@set tramp-postfix ]
49@end quotation 55@set tramp-postfix-single-hop /
50@end copying 56@set tramp-postfix-multi-hop :
51 57@end ifset
58
59@c Macros for formatting a filename.
60@c trampfn is for a full filename, trampfnmhp means method, host, path
61@c were given, and so on.
62@macro trampfn(method, user, host, path)
63@value{tramp-prefix}@value{method}@value{user}@@@value{host}@value{tramp-postfix}@value{path}
64@end macro
52 65
53@tex 66@tex
54 67
55@titlepage 68@titlepage
56@title @tramp{} User Manual 69@title @tramp{} version @trampver{} User Manual
57 70
58@author by Daniel Pittman 71@author by Daniel Pittman
59@author based on documentation by Kai Gro@ss{}johann 72@author based on documentation by Kai Gro@ss{}johann
@@ -66,16 +79,19 @@ license to the document, as described in section 6 of the license.
66 79
67@ifnottex 80@ifnottex
68@node Top, Overview, (dir), (dir) 81@node Top, Overview, (dir), (dir)
69@top @tramp{} User Manual 82@top @tramp{} version @trampver{} User Manual
83
84This file documents @tramp{} version @trampver{}, a remote file
85editing package for @value{emacs-name}.
70 86
71@tramp{} stands for `Transparent Remote (file) Access, Multiple 87@tramp{} stands for `Transparent Remote (file) Access, Multiple
72Protocol'. This package provides remote file editing, similar to 88Protocol'. This package provides remote file editing, similar to
73@cite{Ange-FTP} and @cite{EFS}. 89@value{ftp-package-name}.
74 90
75The difference is that Ange-FTP uses FTP to transfer files between the 91The difference is that @value{ftp-package-name} uses FTP to transfer
76local and the remote host, whereas @tramp{} uses a combination of 92files between the local and the remote host, whereas @tramp{} uses a
77@command{rsh} and @command{rcp} or other work-alike programs, such as 93combination of @command{rsh} and @command{rcp} or other work-alike
78@command{ssh}/@command{scp}. 94programs, such as @command{ssh}/@command{scp}.
79 95
80You can find the latest version of this document on the web at 96You can find the latest version of this document on the web at
81@uref{http://www.freesoftware.fsf.org/tramp/}. 97@uref{http://www.freesoftware.fsf.org/tramp/}.
@@ -102,20 +118,21 @@ well as the usual Savannah archives.
102 118
103@menu 119@menu
104* Overview:: What @tramp{} can and cannot do. 120* Overview:: What @tramp{} can and cannot do.
121* Copying:: The license for this documentation.
105 122
106For the end user: 123For the end user:
107* Obtaining @tramp{}:: How to obtain @tramp{}. 124* Obtaining @tramp{}:: How to obtain @tramp{}.
108* History:: History of @tramp{} 125* History:: History of @tramp{}.
109* Installation:: Installing @tramp{} with your (X)Emacs. 126* Installation:: Installing @tramp{} with your @value{emacs-name}.
110* Configuration:: Configuring @tramp{} for use. 127* Configuration:: Configuring @tramp{} for use.
111* Usage:: An overview of the operation of @tramp{}. 128* Usage:: An overview of the operation of @tramp{}.
112* Bug Reports:: Reporting Bugs and Problems 129* Bug Reports:: Reporting Bugs and Problems.
113* Frequently Asked Questions:: Questions and answers from the mailing list. 130* Frequently Asked Questions:: Questions and answers from the mailing list.
114 131
115For the developer: 132For the developer:
116* Version Control:: The inner workings of remote version control. 133* Version Control:: The inner workings of remote version control.
117* Files directories and paths:: How file names, directories and paths are mangled and managed. 134* Files directories and paths:: How file names, directories and paths are mangled and managed.
118* Issues:: 135* Issues:: Debatable Issues and What Was Decided.
119 136
120@detailmenu 137@detailmenu
121 --- The Detailed Node Listing --- 138 --- The Detailed Node Listing ---
@@ -128,14 +145,17 @@ Configuring @tramp{} for use
128* Multi-hop Methods:: Connecting to a remote host using multiple hops. 145* Multi-hop Methods:: Connecting to a remote host using multiple hops.
129* Default Method:: Selecting a default method. 146* Default Method:: Selecting a default method.
130* Customizing Methods:: Using Non-Standard Methods. 147* Customizing Methods:: Using Non-Standard Methods.
148* Customizing Completion:: Selecting config files for user/host name completion.
131* Remote Programs:: How @tramp{} finds and uses programs on the remote machine. 149* Remote Programs:: How @tramp{} finds and uses programs on the remote machine.
132* Remote shell setup:: 150* Remote shell setup:: Remote shell setup hints.
151* Windows setup hints:: Issues with Cygwin ssh.
133 152
134Using @tramp 153Using @tramp
135 154
136* Filename Syntax:: @tramp{} filename conventions. 155* Filename Syntax:: @tramp{} filename conventions.
137* Multi-hop filename syntax:: Multi-hop filename conventions 156* Multi-hop filename syntax:: Multi-hop filename conventions.
138* Dired:: Dired and filename completion. 157* Filename completion:: Filename completion.
158* Dired:: Dired.
139 159
140The inner workings of remote version control 160The inner workings of remote version control
141 161
@@ -143,7 +163,7 @@ The inner workings of remote version control
143* Remote Commands:: Executing the version control commands on the remote machine. 163* Remote Commands:: Executing the version control commands on the remote machine.
144* Changed workfiles:: Detecting if the working file has changed. 164* Changed workfiles:: Detecting if the working file has changed.
145* Checking out files:: Bringing the workfile out of the repository. 165* Checking out files:: Bringing the workfile out of the repository.
146* Miscellaneous Version Control:: Things related to Version Control that don't fit elsewhere 166* Miscellaneous Version Control:: Things related to Version Control that don't fit elsewhere.
147 167
148Things related to Version Control that don't fit elsewhere 168Things related to Version Control that don't fit elsewhere
149 169
@@ -157,15 +177,14 @@ How file names, directories and paths are mangled and managed.
157@end detailmenu 177@end detailmenu
158@end menu 178@end menu
159 179
160
161@node Overview 180@node Overview
162@chapter An overview of @tramp 181@chapter An overview of @tramp
163@cindex overview 182@cindex overview
164 183
165After the installation of @tramp{} into your Emacs, you will be able 184After the installation of @tramp{} into your @value{emacs-name}, you
166to access files on remote machines as though they were local. Access 185will be able to access files on remote machines as though they were
167to the remote file system for editing files, version control, and 186local. Access to the remote file system for editing files, version
168@command{dired} are transparently enabled. 187control, and @command{dired} are transparently enabled.
169 188
170Your access to the remote machine can be with the @command{rsh}, 189Your access to the remote machine can be with the @command{rsh},
171@command{rlogin}, @command{telnet} programs or with any similar 190@command{rlogin}, @command{telnet} programs or with any similar
@@ -229,8 +248,9 @@ what happens:
229@tramp{} discovers that it needs a connection to the host. So it 248@tramp{} discovers that it needs a connection to the host. So it
230invokes @samp{telnet @var{host}} or @samp{rsh @var{host} -l 249invokes @samp{telnet @var{host}} or @samp{rsh @var{host} -l
231@var{user}} or a similar tool to connect to the remote host. 250@var{user}} or a similar tool to connect to the remote host.
232Communication with this process happens through an Emacs buffer, that 251Communication with this process happens through an
233is, the output from the remote end goes into a buffer. 252@value{emacs-name} buffer, that is, the output from the remote end
253goes into a buffer.
234 254
235@item 255@item
236The remote host may prompt for a login name (for @command{telnet}). The 256The remote host may prompt for a login name (for @command{telnet}). The
@@ -254,8 +274,8 @@ If @tramp{} sees neither of them after a certain period of time (a minute,
254say), then it issues an error message saying that it couldn't find the 274say), then it issues an error message saying that it couldn't find the
255remote shell prompt and shows you what the remote host has sent. 275remote shell prompt and shows you what the remote host has sent.
256 276
257If @tramp{} sees a `login failed' message, it tells you so, aborts the 277If @tramp{} sees a @samp{login failed} message, it tells you so,
258login attempt and allows you to try again. 278aborts the login attempt and allows you to try again.
259 279
260@item 280@item
261Suppose that the login was successful and @tramp{} sees the shell prompt 281Suppose that the login was successful and @tramp{} sees the shell prompt
@@ -293,10 +313,12 @@ For inline transfers, @tramp{} issues a command like @samp{mimencode -b
293buffer that's used for communication, then decodes that output to 313buffer that's used for communication, then decodes that output to
294produce the file contents. 314produce the file contents.
295 315
296For out-of-band transfers, @tramp{} issues a command like @samp{rcp 316For out-of-band transfers, @tramp{} issues a command like the following:
297user@@host:/path/to/remote/file /tmp/tramp.4711} and then reads the local 317@example
298temporary file @file{/tmp/tramp.4711} into a buffer and deletes the 318rcp user@@host:/path/to/remote/file /tmp/tramp.4711
299temporary file. 319@end example
320It then reads the local temporary file @file{/tmp/tramp.4711} into a
321buffer and deletes the temporary file.
300 322
301@item 323@item
302You now edit the buffer contents, blithely unaware of what has happened 324You now edit the buffer contents, blithely unaware of what has happened
@@ -314,6 +336,36 @@ I hope this has provided you with a basic overview of what happens
314behind the scenes when you open a file with @tramp{}. 336behind the scenes when you open a file with @tramp{}.
315 337
316 338
339@c Copying permissions, et al
340@node Copying
341@chapter Copying.
342@cindex copying
343
344@copying
345Copyright @copyright{} 1999, 2000, 2001, 2002 Free Software
346Foundation, Inc.
347
348@quotation
349Permission is granted to copy, distribute and/or modify this document
350under the terms of the GNU Free Documentation License, Version 1.1 or
351any later version published by the Free Software Foundation; with no
352Invariant Sections, with the Front-Cover texts being ``A GNU
353Manual'', and with the Back-Cover Texts as in (a) below. A copy of the
354license is included in the section entitled ``GNU Free Documentation
355License'' in the Emacs manual.
356
357(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
358this GNU Manual, like GNU software. Copies published by the Free
359Software Foundation raise funds for GNU development.''
360
361This document is part of a collection distributed under the GNU Free
362Documentation License. If you want to distribute this document
363separately from the collection, you can do so by adding a copy of the
364license to the document, as described in section 6 of the license.
365@end quotation
366@end copying
367
368
317@c For the end user 369@c For the end user
318@node Obtaining @tramp{} 370@node Obtaining @tramp{}
319@chapter Obtaining @tramp{}. 371@chapter Obtaining @tramp{}.
@@ -333,13 +385,18 @@ is the latest version of the code and may contain incomplete features or
333new issues. Use these versions at your own risk. 385new issues. Use these versions at your own risk.
334 386
335Instructions for obtaining the latest development version of @tramp{} 387Instructions for obtaining the latest development version of @tramp{}
336from CVS can be found by going to the Savannah project page at 388from CVS can be found by going to the Savannah project page at the
337@uref{http://savannah.gnu.org/projects/tramp/} and then clicking on the 389following URL and then clicking on the CVS link in the navigation bar at
338CVS link in the navigation bar at the top. Or follow the example 390the top.
339session below: 391
392@noindent
393@uref{http://savannah.gnu.org/projects/tramp/}
394
395@noindent
396Or follow the example session below:
340 397
341@example 398@example
342] @strong{cd ~/lisp} 399] @strong{cd ~/@value{emacs-dir}}
343] @strong{cvs -d:pserver:anoncvs@@subversions.gnu.org:/cvsroot/tramp login} 400] @strong{cvs -d:pserver:anoncvs@@subversions.gnu.org:/cvsroot/tramp login}
344 401
345(Logging in to anoncvs@@subversions.gnu.org) 402(Logging in to anoncvs@@subversions.gnu.org)
@@ -349,12 +406,13 @@ CVS password: @strong{(just hit RET here)}
349] @strong{cvs -z3 -d:pserver:anoncvs@@subversions.gnu.org:/cvsroot/tramp co tramp} 406] @strong{cvs -z3 -d:pserver:anoncvs@@subversions.gnu.org:/cvsroot/tramp co tramp}
350@end example 407@end example
351 408
352You should now have a directory @file{~/lisp/tramp} containing the latest 409@noindent
410You should now have a directory @file{~/@value{emacs-dir}/tramp} containing the latest
353version of @tramp{}. You can fetch the latest updates from the repository 411version of @tramp{}. You can fetch the latest updates from the repository
354by issuing the command: 412by issuing the command:
355 413
356@example 414@example
357] @strong{cd ~/lisp/tramp} 415] @strong{cd ~/@value{emacs-dir}/tramp}
358] @strong{cvs update -d} 416] @strong{cvs update -d}
359@end example 417@end example
360 418
@@ -378,111 +436,122 @@ filenames in July 2002.
378 436
379 437
380@node Installation 438@node Installation
381@chapter Installing @tramp{} into Emacs or XEmacs 439@chapter Installing @tramp{} into @value{emacs-name}.
382@cindex installation 440@cindex installation
383 441
384If you use the version that comes with your Emacs or the XEmacs 442If you use the version that comes with your @value{emacs-name}, the
385package, the following information is not necessary. Installing 443following information is not necessary. Installing @tramp{} into your
386@tramp{} into your Emacs or XEmacs is a relatively easy process, at 444@value{emacs-name} is a relatively easy process, at least compared
387least compared to rebuilding your machine from scratch. ;) 445to rebuilding your machine from scratch. ;)
388 446
389Seriously though, the installation should be a fairly simple matter. 447Seriously though, the installation should be a fairly simple matter.
390 448
391The easiest way to proceed is as follows: 449The easiest way to proceed is as follows:
392 450
393@itemize 451@itemize @bullet
394@item 452@item
395Choose a directory, say @file{~/emacs/}. Change into that directory and 453Choose a directory, say @file{~/@value{emacs-dir}/}. Change into that directory and
396unpack the tarball. This will give you a directory 454unpack the tarball. This will give you a directory
397@file{~/emacs/tramp/} which contains subdirectories @file{lisp} for the 455@file{~/@value{emacs-dir}/tramp/} which contains subdirectories @file{lisp} for the
398Lisp code and @file{texi} for the documentation. 456Lisp code and @file{texi} for the documentation.
399 457
400@item 458@item
401Optionally byte-compile all files in the Lisp directory, 459Optionally byte-compile all files in the Lisp directory,
402@file{~/emacs/tramp/lisp/}, by issuing a command like the following from 460@file{~/@value{emacs-dir}/tramp/lisp/}, by issuing a command like the following from
403the top level directory @file{~/emacs/tramp/}: 461the top level directory @file{~/@value{emacs-dir}/tramp/}:
462
404@example 463@example
405make EMACS=emacs all # for Emacs users 464make EMACS=@value{emacs-dir} all
406make EMACS=xemacs all # for XEmacs users
407@end example 465@end example
408 466
409@item 467@item
410NOTE: 468NOTE: If you run into problems running the example @command{make}
411@example 469command, don't dispare. You can still byte compile the @file{*.el}
412If you run into problems running the example @command{make} 470files by opening @value{emacs-name} in @command{dired} (@command{C-x
413commands, don't dispare. You can still byte compile the 471d}) mode, at @file{~/@value{emacs-dir}/tramp/lisp}. Mark the lisp files with
414@file{*.el} files by opening emacs in @command{dired} 472@kbd{m}, then press @kbd{B} to byte compile your selections.
415(@command{C-x d}) mode, at @file{~/tramp/lisp}. Mark the lisp 473
416files with @kbd{m}, then press @kbd{B} to byte compile 474Something similar can be done to create the info manual. Just change
417your selections. 475to directory @file{~/@value{emacs-dir}/tramp/texi} and load the
418 476@file{tramp.texi} file in @value{emacs-name}. Then press @kbd{M-x
419Something similar can be done to create the info manual. 477makeinfo-buffer @key{RET}} to generate @file{tramp.info}.
420Just cd to @file{~/emacs/tramp/texi} and load the @file{tramp.texi}
421file in emacs. Then press @kbd{M-x makeinfo-buffer <RET>}
422to generate @file{tramp.info}.
423@end example
424 478
425@item 479@item
426Tell Emacs about the new Lisp directory and the @tramp{} package 480Tell @value{emacs-name} about the new Lisp directory and the
427with the following lines in @file{~/.emacs}: 481@tramp{} package with the following lines in @file{~/.emacs}:
482
428@lisp 483@lisp
429(add-to-list 'load-path "~/emacs/tramp/lisp/") 484(add-to-list 'load-path "~/@value{emacs-dir}/tramp/lisp/")
430(require 'tramp) 485(require 'tramp)
431@end lisp 486@end lisp
432 487
433@item 488@item
434To be able to read the Info documentation, create a file 489To be able to read the Info documentation, create a file
435@file{~/emacs/tramp/texi/dir} using for example the 490@file{~/@value{emacs-dir}/tramp/texi/dir} using the
436@command{install-info} command, and add the directory to the search 491@command{install-info} command, and add the directory to the search
437path for Info. 492path for Info.
438 493
439@item
440NOTE: 494NOTE:
495On systems using the @cite{gnu} version of @command{install-info}, the
496@command{install-info} syntax is very direct and simple. One can
497change to directory @file{~/@value{emacs-dir}/tramp/texi} and type:
498
441@example 499@example
442On systems using `gnu' @command{install-info}, the 500install-info tramp.info dir
443@command{install-info} syntax is very direct and simple. One can 501@end example
444cd to @file{~/emacs/tramp/texi} and type: 502
445 @kbd{install-info tramp.info dir}
446and a @file{dir} file will be created with the @tramp{} 503and a @file{dir} file will be created with the @tramp{}
447entry. The info reader will know how to interpret it, but must 504entry. The info reader will know how to interpret it, but must
448be told where to find it (see below). If you want anything fancier 505be told where to find it (see below). If you want anything fancier
449you'll need to look through @kbd{man install-info}. 506you'll need to look through @kbd{man install-info}.
450 507
451Debian gnu/linux doesn't default to `gnu' @command{install-info} and 508Debian gnu/linux doesn't default to @cite{gnu} @command{install-info}
452uses its own version. This version does not create a @file{dir} file 509and uses its own version. This version does not create a @file{dir}
453for you from scratch. You must provide a skeleton dir file it 510file for you from scratch. You must provide a skeleton @file{dir}
454recognizes. One can be found in a default install at 511file it recognizes. One can be found in a default installation of
455@file{/usr/info/dir}. Copy the top of this file down to the first 512@value{emacs-name} at @file{/usr/info/dir}. Copy the top of this file
456occurrence of `* Menu' including that line plus one more blank line, 513down to the first occurrence of @code{* Menu} including that line plus
457to your working directory @file{texi/dir}, or use the sample provided 514one more blank line, to your working directory
458in the @file{texi} directory of this distribution. See 515@file{~/@value{emacs-dir}/tramp/texi}, or use the sample
459@file{texi/dir_sample} 516@file{~/@value{emacs-dir}/tramp/texi/dir_sample}.
460 517
461Once a @file{dir} file is in place, this command will make the entry. 518Once a @file{dir} file is in place, this command will make the entry:
462 install-info --infodir=. tramp.info 519
463If you want it in a specific category 520@example
464 (see @kbd{man install-info} for further details) 521install-info --infodir=. tramp.info
465@end example 522@end example
466 523
524If you want it in a specific category see @kbd{man install-info} for
525further details.
526
467If the environment variable @env{INFOPATH} is set, add the directory 527If the environment variable @env{INFOPATH} is set, add the directory
468@file{~/emacs/tramp/texi/} to it. Else, add the directory to 528@file{~/@value{emacs-dir}/tramp/texi/} to it. Else, add the directory to
529@ifset emacs
469@code{Info-default-directory-list}, as follows: 530@code{Info-default-directory-list}, as follows:
531
470@lisp 532@lisp
471(add-to-list 'Info-default-directory-list "~/emacs/tramp/texi/") 533(add-to-list 'Info-default-directory-list "~/@value{emacs-dir}/tramp/texi/")
472@end lisp 534@end lisp
473XEmacs 21 users should use @code{Info-directory-list} rather than 535@end ifset
474@code{Info-default-directory-list}. 536@ifset xemacs
537@code{Info-directory-list}, as follows:
538@lisp
539(add-to-list 'Info-directory-list "~/@value{emacs-dir}/tramp/texi/")
540@end lisp
541@end ifset
475 542
476@end itemize 543@end itemize
477 544
478 545@ifset xemacs
479For XEmacs users, the package @file{fsf-compat} must be installed. 546For @value{emacs-name}, the package @file{fsf-compat} must be installed.
480For details on package installation, see @ref{Packages, , ,xemacs}. 547For details on package installation, see @ref{Packages, , ,xemacs}.
481@ifhtml 548@ifhtml
482(If the previous link doesn't work, try the XEmacs documentation at 549(If the previous link doesn't work, try the @value{emacs-name}
483@uref{http://www.xemacs.org/Documentation/packageGuide.html,the XEmacs 550documentation at
484site}.) 551@uref{http://www.xemacs.org/Documentation/packageGuide.html,the
552@value{emacs-name} site}.)
485@end ifhtml 553@end ifhtml
554@end ifset
486 555
487@node Configuration 556@node Configuration
488@chapter Configuring @tramp{} for use 557@chapter Configuring @tramp{} for use
@@ -490,7 +559,7 @@ site}.)
490 559
491@cindex default configuration 560@cindex default configuration
492@tramp{} is (normally) fully functional when it is initially 561@tramp{} is (normally) fully functional when it is initially
493installed. It is initially configured to use the @command{sh} program 562installed. It is initially configured to use the @command{ssh} program
494to connect to the remote host and to use base-64 encoding (on the 563to connect to the remote host and to use base-64 encoding (on the
495remote host, via @command{mimencode}, and on the local host via the 564remote host, via @command{mimencode}, and on the local host via the
496built-in support for base-64 encoding in Emacs). 565built-in support for base-64 encoding in Emacs).
@@ -513,6 +582,7 @@ can use to connect to remote machines and transfer files
513* Multi-hop Methods:: Connecting to a remote host using multiple hops. 582* Multi-hop Methods:: Connecting to a remote host using multiple hops.
514* Default Method:: Selecting a default method. 583* Default Method:: Selecting a default method.
515* Customizing Methods:: Using Non-Standard Methods. 584* Customizing Methods:: Using Non-Standard Methods.
585* Customizing Completion:: Selecting config files for user/host name completion.
516* Remote Programs:: How @tramp{} finds and uses programs on the remote machine. 586* Remote Programs:: How @tramp{} finds and uses programs on the remote machine.
517* Remote shell setup:: Remote shell setup hints. 587* Remote shell setup:: Remote shell setup hints.
518* Windows setup hints:: Issues with Cygwin ssh. 588* Windows setup hints:: Issues with Cygwin ssh.
@@ -541,9 +611,9 @@ differ.
541@cindex methods, external transfer 611@cindex methods, external transfer
542@cindex methods, out-of-band 612@cindex methods, out-of-band
543Loading or saving a remote file requires that the content of the file 613Loading or saving a remote file requires that the content of the file
544be transferred between the two machines. The content of the file can be 614be transfered between the two machines. The content of the file can be
545transferred over the same connection used to log in to the remote 615transfered over the same connection used to log in to the remote
546machine or the file can be transferred through another connection using 616machine or the file can be transfered through another connection using
547a remote copy program such as @command{rcp}, @command{scp} or 617a remote copy program such as @command{rcp}, @command{scp} or
548@command{rsync}. The former are called @dfn{inline methods}, the 618@command{rsync}. The former are called @dfn{inline methods}, the
549latter are called @dfn{out-of-band methods} or @dfn{external transfer 619latter are called @dfn{out-of-band methods} or @dfn{external transfer
@@ -643,7 +713,7 @@ There are also two variants, @option{sm-ssh1} and @option{sm-ssh2}
643that use the @command{ssh1} and @command{ssh2} commands explicitly. If 713that use the @command{ssh1} and @command{ssh2} commands explicitly. If
644you don't know what these are, you do not need these options. 714you don't know what these are, you do not need these options.
645 715
646All the methods based on @command{ssh} have an additional kludgey 716All the methods based on @command{ssh} have an additional kludgy
647feature: you can specify a host name which looks like @file{host#42} 717feature: you can specify a host name which looks like @file{host#42}
648(the real host name, then a hash sign, then a port number). This 718(the real host name, then a hash sign, then a port number). This
649means to connect to the given host but to also pass @code{-p 42} as 719means to connect to the given host but to also pass @code{-p 42} as
@@ -776,7 +846,7 @@ rather than @command{su} to become a different user.
776As you expect, this is similar to @option{sm}, only a little 846As you expect, this is similar to @option{sm}, only a little
777different. Whereas @option{sm} opens a normal interactive shell on 847different. Whereas @option{sm} opens a normal interactive shell on
778the remote host, this option uses @samp{ssh -t -t @var{host} -l 848the remote host, this option uses @samp{ssh -t -t @var{host} -l
779@var{user} /bin/sh} tp open a connection. This is useful for users 849@var{user} /bin/sh} to open a connection. This is useful for users
780where the normal login shell is set up to ask them a number of 850where the normal login shell is set up to ask them a number of
781questions when logging in. This procedure avoids these questions, and 851questions when logging in. This procedure avoids these questions, and
782just gives @tramp{} a more-or-less `standard' login shell to work 852just gives @tramp{} a more-or-less `standard' login shell to work
@@ -901,7 +971,7 @@ The cost of the cryptographic handshake at the start of an @command{scp}
901session can begin to absorb the advantage that the lack of encoding and 971session can begin to absorb the advantage that the lack of encoding and
902decoding presents. 972decoding presents.
903 973
904All the @command{ssh} based methods support the kludgey @samp{-p} 974All the @command{ssh} based methods support the kludgy @samp{-p}
905feature where you can specify a port number to connect to in the host 975feature where you can specify a port number to connect to in the host
906name. For example, the host name @file{host#42} tells Tramp to 976name. For example, the host name @file{host#42} tells Tramp to
907specify @samp{-p 42} in the argument list for @command{ssh}. 977specify @samp{-p 42} in the argument list for @command{ssh}.
@@ -1097,11 +1167,12 @@ also be accomplished within Tramp, by adding a multi-hop method. For
1097example: 1167example:
1098 1168
1099@lisp 1169@lisp
1100(add-to-list 'tramp-multi-connection-function-alist 1170(add-to-list
1101 '("sshf" tramp-multi-connect-rlogin "ssh %h -l %u -p 4400%n")) 1171 'tramp-multi-connection-function-alist
1172 '("sshf" tramp-multi-connect-rlogin "ssh %h -l %u -p 4400%n"))
1102@end lisp 1173@end lisp
1103 1174
1104Now you can use a @code{sshf} hop which connects to port 4400 instead of 1175Now you can use an @code{sshf} hop which connects to port 4400 instead of
1105the standard port. 1176the standard port.
1106 1177
1107 1178
@@ -1175,6 +1246,105 @@ For the time being, I'll refer you to the Lisp documentation of that
1175variable, accessible with @kbd{C-h v tramp-methods @key{RET}}. 1246variable, accessible with @kbd{C-h v tramp-methods @key{RET}}.
1176 1247
1177 1248
1249@node Customizing Completion
1250@section Selecting config files for user/host name completion
1251@cindex customizing completion
1252@cindex selecting config files
1253@vindex tramp-completion-function-alist
1254
1255The variable @code{tramp-completion-function-alist} is intended to
1256customize, which files are taken into account for user and host name
1257completion (@pxref{Filename completion}). For every method, it keeps
1258a set of configuration files, accompanied by a Lisp function able to
1259parse that file. Entries in @code{tramp-completion-function-alist}
1260have the form (@var{method} @var{pair1} @var{pair2} ...).
1261
1262Each @var{pair} is composed of (@var{function} @var{file}).
1263@var{function} is responsible to extract user names and host names
1264from @var{file} for completion. There are two functions which access
1265this variable:
1266
1267@defun tramp-get-completion-function method
1268This function returns the list of completion functions for @var{method}.
1269
1270Example:
1271@example
1272(tramp-get-completion-function "rsh")
1273
1274 @result{} ((tramp-parse-rhosts "/etc/hosts.equiv")
1275 (tramp-parse-rhosts "~/.rhosts"))
1276@end example
1277@end defun
1278
1279@defun tramp-set-completion-function method function-list
1280This function sets @var{function-list} as list of completion functions
1281for @var{method}.
1282
1283Example:
1284@example
1285(tramp-set-completion-function "ssh"
1286 '((tramp-parse-shosts "/etc/ssh_known_hosts")
1287 (tramp-parse-shosts "~/.ssh/known_hosts")))
1288
1289 @result{} ((tramp-parse-shosts "/etc/ssh_known_hosts")
1290 (tramp-parse-shosts "~/.ssh/known_hosts"))
1291@end example
1292@end defun
1293
1294The following predefined functions parsing configuration files exists:
1295
1296@table @asis
1297@item @code{tramp-parse-rhosts}
1298@findex tramp-parse-rhosts
1299
1300This function parses files which are syntactical equivalent to
1301@file{~/.rhosts}. It returns both host names and user names, if
1302specified.
1303
1304@item @code{tramp-parse-shosts}
1305@findex tramp-parse-shosts
1306
1307This function parses files which are syntactical equivalent to
1308@file{/etc/ssh_known_hosts}. Since there are no user names specified
1309in such files, it can return host names only.
1310
1311@item @code{tramp-parse-hosts}
1312@findex tramp-parse-hosts
1313
1314A function dedicated to @file{/etc/hosts} style files. It returns
1315host names only.
1316
1317@item @code{tramp-parse-passwd}
1318@findex tramp-parse-passwd
1319
1320Finally a method which parses @file{/etc/passwd} like files.
1321Obviously, it can return user names only.
1322@end table
1323
1324@ifset emacs
1325A function which parses @file{~/.netrc"} file syntax doesn't exist in
1326@tramp{}, because this task is delegated to
1327@value{ftp-package-name}. Its customization should be used instead.
1328@end ifset
1329
1330If you want to keep your own data in a file, with your own structure,
1331you might provide such a function as well. This function must meet
1332the following conventions:
1333
1334@defun my-tramp-parse file
1335@var{file} must be either a file name on your host, or @code{nil}. The
1336function must return a list of (@var{user} @var{host}), which are
1337taken as candidates for user and host name completion.
1338
1339Example:
1340@example
1341(my-tramp-parse "~/.my-tramp-hosts")
1342
1343 @result{} ((nil "toto") ("daniel" "melancholia"))
1344@end example
1345@end defun
1346
1347
1178@node Remote Programs 1348@node Remote Programs
1179@section How @tramp{} finds and uses programs on the remote machine. 1349@section How @tramp{} finds and uses programs on the remote machine.
1180 1350
@@ -1209,13 +1379,13 @@ found.
1209To add a directory to the remote search path, you could use code such 1379To add a directory to the remote search path, you could use code such
1210as: 1380as:
1211 1381
1212@example 1382@lisp
1213(require 'tramp) @i{; @tramp{} must be loaded before this} 1383@i{;; We load @tramp{} to define the variable.}
1214 @i{; happens.} 1384(require 'tramp)
1215 1385@i{;; We have @command{perl} in "/usr/local/perl/bin"}
1216@i{; We have @command{perl} in "/usr/local/perl/bin"}
1217(add-to-list 'tramp-remote-path "/usr/local/perl/bin") 1386(add-to-list 'tramp-remote-path "/usr/local/perl/bin")
1218@end example 1387@end lisp
1388
1219 1389
1220@node Remote shell setup 1390@node Remote shell setup
1221@comment node-name, next, previous, up 1391@comment node-name, next, previous, up
@@ -1228,7 +1398,7 @@ as:
1228As explained in the @ref{Overview} section, @tramp{} connects to the 1398As explained in the @ref{Overview} section, @tramp{} connects to the
1229remote host and talks to the shell it finds there. Of course, when you 1399remote host and talks to the shell it finds there. Of course, when you
1230log in, the shell executes its init files. Suppose your init file 1400log in, the shell executes its init files. Suppose your init file
1231requires you to enter the birthdate of your mother; clearly @tramp{} 1401requires you to enter the birth date of your mother; clearly @tramp{}
1232does not know this and hence fails to log you in to that host. 1402does not know this and hence fails to log you in to that host.
1233 1403
1234There are different possible strategies for pursuing this problem. One 1404There are different possible strategies for pursuing this problem. One
@@ -1270,25 +1440,39 @@ suppose your shell prompt is @code{a <b> c $ }. In this case, Tramp
1270recognizes the @code{>} character as the end of the prompt, but it is 1440recognizes the @code{>} character as the end of the prompt, but it is
1271not at the end of the buffer. 1441not at the end of the buffer.
1272 1442
1443@item @var{tramp-shell-prompt-pattern}
1444@vindex tramp-shell-prompt-pattern
1445
1446This regular expression is used by @tramp{} in the same way as
1447@code{shell-prompt-pattern}, to match prompts from the remote shell.
1448This second variable exists because the prompt from the remote shell
1449might be different from the prompt from a local shell --- after all,
1450the whole point of @tramp{} is to log in to remote hosts as a
1451different user. The default value of
1452@code{tramp-shell-prompt-pattern} is the same as the default value of
1453@code{shell-prompt-pattern}, which is reported to work well in many
1454circumstances.
1455
1273@item @code{tset} and other questions 1456@item @code{tset} and other questions
1274@cindex Unix command tset 1457@cindex Unix command tset
1275@cindex tset Unix command 1458@cindex tset Unix command
1276 1459
1277Some people invoke the @code{tset} program from their shell startup 1460Some people invoke the @code{tset} program from their shell startup
1278scripts which asks the user about the terminal type of the shell. Maybe 1461scripts which asks the user about the terminal type of the shell.
1279some shells ask other questions when they are started. @tramp{} does 1462Maybe some shells ask other questions when they are started. @tramp{}
1280not know how to answer these questions. (A facility for enabling 1463does not know how to answer these questions. There are two approaches
1281@tramp{} to answer these questions is planned for some future version, 1464for dealing with this problem. One approach is to take care that the
1282but don't hold your breath.) 1465shell does not ask any questions when invoked from @tramp{}. You can
1283 1466do this by checking the @code{TERM} environment variable, it will be
1284Therefore, you should take care that the shell does not ask any 1467set to @code{dumb} when connecting.
1285questions when invoked from @tramp{}. You can do this by checking the
1286@code{TERM} environment variable, it will be set to @code{dumb} when
1287connecting.
1288 1468
1289@vindex tramp-terminal-type 1469@vindex tramp-terminal-type
1290The variable @code{tramp-terminal-type} can be used to change this value 1470The variable @code{tramp-terminal-type} can be used to change this value
1291@code{dumb}. 1471to @code{dumb}.
1472
1473The other approach is to teach @tramp{} about these questions. See
1474the variables @code{tramp-actions-before-shell} and
1475@code{tramp-multi-actions} (for multi-hop connections).
1292 1476
1293@end table 1477@end table
1294 1478
@@ -1317,13 +1501,24 @@ to as though they were local.
1317 1501
1318Files are specified to @tramp{} using a formalized syntax specifying the 1502Files are specified to @tramp{} using a formalized syntax specifying the
1319details of the system to connect to. This is similar to the syntax used 1503details of the system to connect to. This is similar to the syntax used
1320by the @command{EFS} and @command{Ange-FTP} packages. 1504by the @value{ftp-package-name} package.
1321 1505
1506@cindex type-ahead
1507Something that might happen which surprises you is that Emacs
1508remembers all your keystrokes, so if you see a password prompt from
1509Emacs, say, and hit @kbd{@key{RET}} twice instead of once, then the
1510second keystroke will be processed by Emacs after @tramp{} has done
1511its thing. Why, this type-ahead is normal behavior, you say. Right
1512you are, but be aware that opening a remote file might take quite a
1513while, maybe half a minute when a connection needs to be opened.
1514Maybe after half a minute you have already forgotten that you hit that
1515key!
1322 1516
1323@menu 1517@menu
1324* Filename Syntax:: @tramp{} filename conventions. 1518* Filename Syntax:: @tramp{} filename conventions.
1325* Multi-hop filename syntax:: Multi-hop filename conventions 1519* Multi-hop filename syntax:: Multi-hop filename conventions.
1326* Dired:: Dired and filename completion. 1520* Filename completion:: Filename completion.
1521* Dired:: Dired.
1327@end menu 1522@end menu
1328 1523
1329 1524
@@ -1332,79 +1527,70 @@ by the @command{EFS} and @command{Ange-FTP} packages.
1332@cindex filename syntax 1527@cindex filename syntax
1333@cindex filename examples 1528@cindex filename examples
1334 1529
1335On Emacs, the Ange-FTP and Tramp filenames use a unified syntax. On 1530To access the file @var{path} on the remote machine @var{machine} you
1336XEmacs, EFS and Tramp use different formats for the filenames. 1531would specify the filename
1337Therefore, the following will describe the Emacs and XEmacs cases 1532@file{@value{tramp-prefix}@var{machine}@value{tramp-postfix}@var{path}}.
1338separately. 1533This will connect to @var{machine} and transfer the file using the
1534default method. @xref{Default Method}.
1339 1535
1340On Emacs, to access the file @var{path} on the remote machine 1536Some examples of @tramp{} filenames are shown below.
1341@var{machine} you would specify the filename
1342@file{/@var{machine}:@var{path}}. This will connect to @var{machine}
1343and transfer the file using the default method. @xref{Default
1344Method}. On XEmacs, use @file{/[@var{machine}]@var{path}}. (The
1345square brackets are part of the file name.)
1346
1347Some examples of @tramp{} filenames are shown below. In each case,
1348the Emacs-style filename is shown first, then the XEmacs-style
1349filename.
1350 1537
1351@table @file 1538@table @file
1352@item /melancholia:.emacs 1539@item @value{tramp-prefix}melancholia@value{tramp-postfix}.emacs
1353@itemx /[melancholia].emacs
1354Edit the file @file{.emacs} in your home directory on the machine 1540Edit the file @file{.emacs} in your home directory on the machine
1355@code{melancholia}. 1541@code{melancholia}.
1356 1542
1357@item /melancholia.danann.net:.emacs 1543@item @value{tramp-prefix}melancholia.danann.net@value{tramp-postfix}.emacs
1358@itemx /[melancholia.danann.net].emacs
1359This edits the same file, using the fully qualified domain name of 1544This edits the same file, using the fully qualified domain name of
1360the machine. 1545the machine.
1361 1546
1362@item /melancholia:~/.emacs 1547@item @value{tramp-prefix}melancholia@value{tramp-postfix}~/.emacs
1363@itemx /[melancholia]~/.emacs
1364This also edits the same file --- the @file{~} is expanded to your 1548This also edits the same file --- the @file{~} is expanded to your
1365home directory on the remote machine, just like it is locally. 1549home directory on the remote machine, just like it is locally.
1366 1550
1367@item /melancholia:~daniel/.emacs 1551@item @value{tramp-prefix}melancholia@value{tramp-postfix}~daniel/.emacs
1368@itemx /[melancholia]~daniel/.emacs
1369This edits the file @file{.emacs} in the home directory of the user 1552This edits the file @file{.emacs} in the home directory of the user
1370@code{daniel} on the machine @code{melancholia}. The @file{~<user>} 1553@code{daniel} on the machine @code{melancholia}. The @file{~<user>}
1371construct is expanded to the home directory of that user on the remote 1554construct is expanded to the home directory of that user on the remote
1372machine. 1555machine.
1373 1556
1374@item /melancholia:/etc/squid.conf 1557@item @value{tramp-prefix}melancholia@value{tramp-postfix}/etc/squid.conf
1375@itemx /[melancholia]/etc/squid.conf
1376This edits the file @file{/etc/squid.conf} on the machine 1558This edits the file @file{/etc/squid.conf} on the machine
1377@code{melancholia}. 1559@code{melancholia}.
1378 1560
1379@end table 1561@end table
1380 1562
1381Unless you specify a different name to use, @tramp{} will use the current 1563Unless you specify a different name to use, @tramp{} will use the
1382local user name as the remote user name to log in with. If you need to 1564current local user name as the remote user name to log in with. If you
1383log in as a different user, you can specify the user name as part of the 1565need to log in as a different user, you can specify the user name as
1384filename. 1566part of the filename.
1385 1567
1386On Emacs, to log in to the remote machine as a specific user, you use 1568To log in to the remote machine as a specific user, you use the syntax
1387the syntax @file{/@var{user}@@@var{machine}:/path/to.file}. On 1569@file{@value{tramp-prefix}@var{user}@@@var{machine}@value{tramp-postfix}/@var{path/to.file}}.
1388XEmacs, use @file{/[@var{user}@@@var{machine}]/path/to.file}. That 1570That means that connecting to @code{melancholia} as @code{daniel} and
1389means that connecting to @code{melancholia} as @code{daniel} and
1390editing @file{.emacs} in your home directory you would specify 1571editing @file{.emacs} in your home directory you would specify
1391@file{/daniel@@melancholia:.emacs} on Emacs and 1572@file{@value{tramp-prefix}daniel@@melancholia@value{tramp-postfix}.emacs}.
1392@file{/[daniel@@melancholia].emacs} on XEmacs.
1393
1394 1573
1395It is also possible to specify other file transfer methods 1574It is also possible to specify other file transfer methods
1396(@pxref{Default Method}) as part of the filename. On Emacs, this is 1575(@pxref{Default Method}) as part of the filename.
1397done by puttig the method before the user and host name, as in 1576@ifset emacs
1398@file{/@var{method}:} (note the trailing colon). On XEmacs, it is 1577This is done by putting the method before the user and host name, as
1399done by replacing the initial @file{/[} with @file{/[<method>/}. 1578in
1400(Note the trailing slash!) The user, machine and file specification 1579@file{@value{tramp-prefix}@var{method}@value{tramp-postfix-single-hop}}
1401remain the same. 1580(note the trailing colon).
1581@end ifset
1582@ifset xemacs
1583This is done by replacing the initial
1584@file{@value{tramp-prefix}} with
1585@file{@value{tramp-prefix}<method>@value{tramp-postfix-single-hop}}.
1586(Note the trailing slash!).
1587@end ifset
1588The user, machine and file specification remain the same.
1402 1589
1403So, to connect to the machine @code{melancholia} as @code{daniel}, 1590So, to connect to the machine @code{melancholia} as @code{daniel},
1404using the @option{su} method to transfer files, and edit @file{.emacs} 1591using the @option{su} method to transfer files, and edit @file{.emacs}
1405in my home directory I would specify the filename 1592in my home directory I would specify the filename
1406@file{/su:daniel@@melancholia:.emacs} on Emacs and 1593@file{@value{tramp-prefix}su@value{tramp-postfix-single-hop}daniel@@melancholia@value{tramp-postfix}.emacs}.
1407@file{/[su/daniel@@melancholia].emacs} on XEmacs.
1408 1594
1409 1595
1410@node Multi-hop filename syntax 1596@node Multi-hop filename syntax
@@ -1413,64 +1599,116 @@ in my home directory I would specify the filename
1413@cindex multi-hop filename syntax 1599@cindex multi-hop filename syntax
1414 1600
1415The syntax of multi-hop file names is necessarily slightly different 1601The syntax of multi-hop file names is necessarily slightly different
1416than the syntax of other @tramp{} file names. Here's an example multi-hop 1602than the syntax of other @tramp{} file names. Here's an example
1417file name, first in Emacs syntax and then in XEmacs syntax: 1603multi-hop file name, first in Emacs syntax and then in XEmacs syntax:
1418 1604
1419@file{/multi:rsh:out@@gate:telnet:kai@@real.host:/path/to.file} 1605@example
1420@file{/[multi/rsh:out@@gate/telnet:kai@@real.host]/path/to.file} 1606@value{tramp-prefix}multi@value{tramp-postfix-single-hop}rsh@value{tramp-postfix-multi-hop}out@@gate@value{tramp-postfix-single-hop}telnet@value{tramp-postfix-multi-hop}kai@@real.host@value{tramp-postfix}/path/to.file
1607@end example
1421 1608
1422This is quite a mouthful. So let's go through it step by step. The 1609This is quite a mouthful. So let's go through it step by step. The
1423file name consists of three parts. On Emacs, the parts are separated 1610file name consists of three parts.
1424by colons, on XEmacs they are separated by slashes and square 1611@ifset emacs
1425brackets. The first part is @file{/multi:} (or @file{/[multi}), the 1612The parts are separated by colons
1426method specification. The second part is 1613@end ifset
1427@file{rsh:out@@gate:telnet:kai@@real.host} (or 1614@ifset xemacs
1428@file{rsh:out@@gate/telnet:kai@@real.host}) and specifies the hops. 1615The parts are separated by slashes and square brackets.
1429(Yes, on Emacs the second part may contain even more colons, so that's why 1616@end ifset
1430this file name has more than two colons in it.) The final part is 1617The first part is @file{@value{tramp-prefix}multi}, the method
1431@file{/path/to.file} and specifies the file name on the remote host. 1618specification. The second part is
1619@file{rsh@value{tramp-postfix-multi-hop}out@@gate@value{tramp-postfix-single-hop}telnet@value{tramp-postfix-multi-hop}kai@@real.host}
1620and specifies the hops. The final part is @file{/path/to.file} and
1621specifies the file name on the remote host.
1432 1622
1433The first part and the final part should be clear. @ref{Multi-hop 1623The first part and the final part should be clear. @ref{Multi-hop
1434Methods}, for a list of alternatives for the method specification. 1624Methods}, for a list of alternatives for the method specification.
1435 1625
1436The second part can be subdivided again into components, so-called hops. 1626The second part can be subdivided again into components, so-called
1437In the above file name, there are two hops, @file{rsh:out@@gate} and 1627hops. In the above file name, there are two hops,
1438@file{telnet:kai@@real.host}. 1628@file{rsh@value{tramp-postfix-multi-hop}out@@gate} and
1629@file{telnet@value{tramp-postfix-multi-hop}kai@@real.host}.
1439 1630
1440Each hop can @emph{again} be subdivided into (three) components, the 1631Each hop can @emph{again} be subdivided into (three) components, the
1441@dfn{hop method}, the @dfn{user name} and the @dfn{host name}. The 1632@dfn{hop method}, the @dfn{user name} and the @dfn{host name}. The
1442meaning of the second and third component should be clear, and the hop 1633meaning of the second and third component should be clear, and the hop
1443method says what program to use to perform that hop. 1634method says what program to use to perform that hop.
1444 1635
1445The first hop, @file{rsh:out@@gate}, says to use @command{rsh} to log in 1636The first hop, @file{rsh@value{tramp-postfix-multi-hop}out@@gate},
1446as user @code{out} to the host @code{gate}. Starting at that host, the 1637says to use @command{rsh} to log in as user @code{out} to the host
1447second hop, @file{telnet:kai@@real.host}, says to use @command{telnet} 1638@code{gate}. Starting at that host, the second hop,
1448to log in as user @code{kai} to host @code{real.host}. 1639@file{telnet@value{tramp-postfix-multi-hop}kai@@real.host}, says to
1640use @command{telnet} to log in as user @code{kai} to host
1641@code{real.host}.
1642
1643@xref{Multi-hop Methods}, for a list of possible hop method values.
1644The variable @code{tramp-multi-connection-function-alist} contains the
1645list of possible hop methods and information on how to execute them,
1646should you want to add your own.
1449 1647
1450@xref{Multi-hop Methods}, for a list of possible hop method values. The 1648
1451variable @var{tramp-multi-connection-function-alist} contains the list of 1649@node Filename completion
1452possible hop methods and information on how to execute them, should you 1650@section Filename completion
1453want to add your own. 1651@cindex filename completion
1652
1653Filename completion works with @tramp{} for both completing methods,
1654user names and machine names (except multi hop methods) as well as for
1655files on remote machines.
1656
1657If you, for example, type @kbd{C-x C-f @value{tramp-prefix}t
1658@key{TAB}}, @tramp{} might give you as result the choice for
1659
1660@example
1661@ifset emacs
1662@value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop} tmp/
1663@value{tramp-prefix-single-hop}toto@value{tramp-postfix}
1664@end ifset
1665@ifset xemacs
1666@value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop} @value{tramp-prefix-single-hop}toto@value{tramp-postfix}
1667@end ifset
1668@end example
1669
1670@samp{@value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}}
1671is a possible completion for the respective method,
1672@ifset emacs
1673@samp{tmp/} stands for the directory @file{/tmp} on your local
1674machine,
1675@end ifset
1676and @samp{@value{tramp-prefix-single-hop}toto@value{tramp-postfix}}
1677might be a host @tramp has detected in your @file{~/.ssh/known_hosts}
1678file (given you're using default method @option{ssh}).
1679
1680If you go on to type @kbd{e @key{TAB}}, the minibuffer is completed to
1681@samp{@value{tramp-prefix}telnet@value{tramp-postfix-single-hop}}.
1682Next @kbd{@key{TAB}} brings you all machine names @tramp{} detects in
1683your @file{/etc/hosts} file, let's say
1684
1685@example
1686@value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}127.0.0.1@value{tramp-postfix} @value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}192.168.0.1@value{tramp-postfix}
1687@value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}localhost@value{tramp-postfix} @value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}melancholia.danann.net@value{tramp-postfix}
1688@value{tramp-prefix-single-hop}telnet@value{tramp-postfix-single-hop}melancholia@value{tramp-postfix}
1689@end example
1690
1691Now you can choose the desired machine, and you can continue to
1692complete file names on that machine.
1693
1694As filename completion needs to fetch the listing of files from the
1695remote machine, this feature is sometimes fairly slow. As @tramp{}
1696does not yet cache the results of directory listing, there is no gain
1697in performance the second time you complete filenames.
1698
1699If the configuration files (@pxref{Customizing Completion}), which
1700@tramp{} uses for analysis of completion, offer user names, those user
1701names will be taken into account as well.
1454 1702
1455 1703
1456@node Dired 1704@node Dired
1457@section Dired and filename completion 1705@section Dired
1458@cindex dired 1706@cindex dired
1459@cindex filename completion
1460 1707
1461@tramp{} works transparently with dired, enabling you to use this powerful 1708@tramp{} works transparently with dired, enabling you to use this powerful
1462file management tool to manage files on any machine you have access to 1709file management tool to manage files on any machine you have access to
1463over the Internet. 1710over the Internet.
1464 1711
1465Filename completion also works with @tramp{} for files on remote machines
1466although there is no completion for user names or machine names at this
1467stage.
1468
1469As filename completion needs to fetch the listing of files from the
1470remote machine, this feature is sometimes fairly slow. As @tramp{} does not
1471yet cache the results of directory listing, there is no gain in
1472performance the second time you complete filenames.
1473
1474If you need to browse a directory tree, Dired is a better choice, at 1712If you need to browse a directory tree, Dired is a better choice, at
1475present, than filename completion. Dired has its own cache mechanism 1713present, than filename completion. Dired has its own cache mechanism
1476and will only fetch the directory listing once. 1714and will only fetch the directory listing once.
@@ -1516,11 +1754,16 @@ development team to analyze and correct the problem.
1516@item 1754@item
1517Where can I get the latest @tramp{}? 1755Where can I get the latest @tramp{}?
1518 1756
1519@tramp{} is available at 1757@tramp{} is available under the URL below.
1520@uref{ftp://ls6-ftp.cs.uni-dortmund.de/pub/src/emacs/tramp.tar.gz}.
1521There is also a Savannah project page, at
1522@uref{https://savannah.gnu.org/projects/tramp/}.
1523 1758
1759@noindent
1760@uref{ftp://ls6-ftp.cs.uni-dortmund.de/pub/src/emacs/tramp.tar.gz}
1761
1762@noindent
1763There is also a Savannah project page.
1764
1765@noindent
1766@uref{https://savannah.gnu.org/projects/tramp/}
1524 1767
1525@item 1768@item
1526Which systems does it work on? 1769Which systems does it work on?
@@ -1555,10 +1798,10 @@ first thing to do is to make sure that you have the latest version of
1555@tramp{} installed. 1798@tramp{} installed.
1556 1799
1557If you do, please try and find out exactly the conditions required for 1800If you do, please try and find out exactly the conditions required for
1558the @code{EFS} handlers to fire. If you can, putting a breakpoint on 1801the EFS handlers to fire. If you can, putting a breakpoint on
1559@code{efs-ftp-path} and sending in the stack trace along with your bug 1802@code{efs-ftp-path} and sending in the stack trace along with your bug
1560report would make it easier for the developers to work out what is going 1803report would make it easier for the developers to work out what is
1561wrong. 1804going wrong.
1562 1805
1563 1806
1564@item 1807@item
@@ -1657,9 +1900,9 @@ fi
1657@node Version Control 1900@node Version Control
1658@chapter The inner workings of remote version control 1901@chapter The inner workings of remote version control
1659 1902
1660Unlike EFS and Ange-FTP, @tramp{} has full shell access to the remote 1903Unlike @value{ftp-package-name}, @tramp{} has full shell access to the
1661machine. This makes it possible to provide version control for files 1904remote machine. This makes it possible to provide version control for
1662accessed under @tramp{}. 1905files accessed under @tramp{}.
1663 1906
1664The actual version control binaries must be installed on the remote 1907The actual version control binaries must be installed on the remote
1665machine, accessible in the directories specified in 1908machine, accessible in the directories specified in
@@ -1674,7 +1917,7 @@ Work is ongoing to improve the transparency of the system.
1674* Remote Commands:: Executing the version control commands on the remote machine. 1917* Remote Commands:: Executing the version control commands on the remote machine.
1675* Changed workfiles:: Detecting if the working file has changed. 1918* Changed workfiles:: Detecting if the working file has changed.
1676* Checking out files:: Bringing the workfile out of the repository. 1919* Checking out files:: Bringing the workfile out of the repository.
1677* Miscellaneous Version Control:: Things related to Version Control that don't fit elsewhere 1920* Miscellaneous Version Control:: Things related to Version Control that don't fit elsewhere.
1678@end menu 1921@end menu
1679 1922
1680 1923
@@ -1880,3 +2123,7 @@ would have to be installed from the start, too.
1880@c * Make terminology "inline" vs "out-of-band" consistent. 2123@c * Make terminology "inline" vs "out-of-band" consistent.
1881@c It seems that "external" is also used instead of "out-of-band". 2124@c It seems that "external" is also used instead of "out-of-band".
1882 2125
2126@c * M. Albinus
2127@c ** Use `filename' resp. `file name' consistently.
2128@c ** Use `host' resp. `machine' consistently.
2129@c ** Consistent small or capitalized words especially in menues.