Mercurial > emacs
annotate lisp/net/tramp.el @ 46460:876356a4a4ca
(find_charset_in_text, c_string_width):
(chars_in_text, multibyte_chars_in_text, parse_str_as_multibyte):
String pointer args now point to const.
(find_charset_in_text, lisp_string_width): Use const
for pointer to lisp string data.
author | Ken Raeburn <raeburn@raeburn.org> |
---|---|
date | Tue, 16 Jul 2002 19:47:56 +0000 |
parents | 3996ea20e5e3 |
children | f548d7d0c651 |
rev | line source |
---|---|
45861 | 1 ;;; tramp.el --- Transparent Remote Access, Multiple Protocol -*- coding: iso-8859-1; -*- |
2 | |
3 ;; Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Kai.Grossjohann@CS.Uni-Dortmund.DE | |
6 ;; Keywords: comm, processes | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;; This package provides remote file editing, similar to ange-ftp. | |
28 ;; The difference is that ange-ftp uses FTP to transfer files between | |
29 ;; the local and the remote host, whereas tramp.el uses a combination | |
30 ;; of rsh and rcp or other work-alike programs, such as ssh/scp. | |
31 ;; | |
32 ;; For more detailed instructions, please see the info file, which is | |
33 ;; included in the file `tramp.tar.gz' mentioned below. | |
34 ;; | |
35 ;; Notes: | |
36 ;; ----- | |
37 ;; | |
38 ;; This package only works for Emacs 20 and higher, and for XEmacs 21 | |
39 ;; and higher. (XEmacs 20 is missing the `with-timeout' macro. Emacs | |
40 ;; 19 is reported to have other problems. For XEmacs 21, you need the | |
41 ;; package `fsf-compat' for the `with-timeout' macro.) | |
42 ;; | |
43 ;; This version might not work with pre-Emacs 21 VC unless VC is | |
44 ;; loaded before tramp.el. Could you please test this and tell me about | |
45 ;; the result? Thanks. | |
46 ;; | |
47 ;; Also see the todo list at the bottom of this file. | |
48 ;; | |
49 ;; The current version of tramp.el can be retrieved from the following | |
50 ;; URL: ftp://ls6-ftp.cs.uni-dortmund.de/pub/src/emacs/tramp.tar.gz | |
51 ;; For your convenience, the *.el file is available separately from | |
52 ;; the same directory. | |
53 ;; | |
54 ;; There's a mailing list for this, as well. Its name is: | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
55 ;; tramp-devel@mail.freesoftware.fsf.org |
45861 | 56 ;; Send a mail with `help' in the subject (!) to the administration |
57 ;; address for instructions on joining the list. The administration | |
58 ;; address is: | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
59 ;; tramp-devel-request@mail.freesoftware.fsf.org |
45861 | 60 ;; You can also use the Web to subscribe, under the following URL: |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
61 ;; http://mail.freesoftware.fsf.org/mailman/listinfo/tramp-devel |
45861 | 62 ;; |
63 ;; For the adventurous, the current development sources are available | |
64 ;; via CVS. You can find instructions about this at the following URL: | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
65 ;; http://savannah.gnu.org/projects/tramp/ |
45861 | 66 ;; Click on "CVS" in the navigation bar near the top. |
67 ;; | |
68 ;; Don't forget to put on your asbestos longjohns, first! | |
69 | |
70 ;;; Code: | |
71 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
72 (defconst tramp-version "2.0.1" |
45861 | 73 "This version of tramp.") |
74 (defconst tramp-bug-report-address "tramp-devel@mail.freesoftware.fsf.org" | |
75 "Email address to send bug reports to.") | |
76 | |
77 (require 'timer) | |
78 (require 'format-spec) ;from Gnus 5.8, also in tar ball | |
79 (require 'base64) ;for the mimencode methods | |
80 (require 'shell) | |
81 (require 'advice) | |
82 | |
83 ;; ;; It does not work to load EFS after loading TRAMP. | |
84 ;; (when (fboundp 'efs-file-handler-function) | |
85 ;; (require 'efs)) | |
86 | |
87 (eval-when-compile | |
88 (require 'cl) | |
89 (require 'custom) | |
90 ;; Emacs 19.34 compatibility hack -- is this needed? | |
91 (or (>= emacs-major-version 20) | |
92 (load "cl-seq"))) | |
93 | |
94 (unless (boundp 'custom-print-functions) | |
95 (defvar custom-print-functions nil)) ; not autoloaded before Emacs 20.4 | |
96 | |
97 ;;; User Customizable Internal Variables: | |
98 | |
99 (defgroup tramp nil | |
100 "Edit remote files with a combination of rsh and rcp or similar programs." | |
101 :group 'files) | |
102 | |
103 (defcustom tramp-verbose 10 | |
104 "*Verbosity level for tramp.el. 0 means be silent, 10 is most verbose." | |
105 :group 'tramp | |
106 :type 'integer) | |
107 | |
108 (defcustom tramp-debug-buffer nil | |
109 "*Whether to send all commands and responses to a debug buffer." | |
110 :group 'tramp | |
111 :type 'boolean) | |
112 | |
113 (defcustom tramp-auto-save-directory nil | |
114 "*Put auto-save files in this directory, if set. | |
115 The idea is to use a local directory so that auto-saving is faster." | |
116 :group 'tramp | |
117 :type '(choice (const nil) | |
118 string)) | |
119 | |
120 (defcustom tramp-sh-program "/bin/sh" | |
121 "*Use this program for shell commands on the local host. | |
122 This MUST be a Bourne-like shell. This shell is used to execute | |
123 the encoding and decoding command on the local host, so if you | |
124 want to use `~' in those commands, you should choose a shell here | |
125 which groks tilde expansion. `/bin/sh' normally does not | |
126 understand tilde expansion. | |
127 | |
128 Note that this variable is not used for remote commands. There are | |
129 mechanisms in tramp.el which automatically determine the right shell to | |
130 use for the remote host." | |
131 :group 'tramp | |
132 :type '(file :must-match t)) | |
133 | |
134 ;; CCC I have changed all occurrences of comint-quote-filename with | |
135 ;; tramp-shell-quote-argument, except in tramp-handle-expand-many-files. | |
136 ;; There, comint-quote-filename was removed altogether. If it turns | |
137 ;; out to be necessary there, something will need to be done. | |
138 ;;-(defcustom tramp-file-name-quote-list | |
139 ;;- '(?] ?[ ?\| ?& ?< ?> ?\( ?\) ?\; ?\ ?\* ?\? ?\! ?\" ?\' ?\` ?# ?\@ ?\+ ) | |
140 ;;- "*Protect these characters from the remote shell. | |
141 ;;-Any character in this list is quoted (preceded with a backslash) | |
142 ;;-because it means something special to the shell. This takes effect | |
143 ;;-when sending file and directory names to the remote shell. | |
144 ;;- | |
145 ;;-See `comint-file-name-quote-list' for details." | |
146 ;;- :group 'tramp | |
147 ;;- :type '(repeat character)) | |
148 | |
149 (defcustom tramp-methods | |
150 '( ("rcp" (tramp-connection-function tramp-open-connection-rsh) | |
151 (tramp-rsh-program "rsh") | |
152 (tramp-rcp-program "rcp") | |
153 (tramp-remote-sh "/bin/sh") | |
154 (tramp-rsh-args nil) | |
155 (tramp-rcp-args nil) | |
156 (tramp-rcp-keep-date-arg "-p") | |
157 (tramp-su-program nil) | |
158 (tramp-su-args nil) | |
159 (tramp-encoding-command nil) | |
160 (tramp-decoding-command nil) | |
161 (tramp-encoding-function nil) | |
162 (tramp-decoding-function nil) | |
163 (tramp-telnet-program nil) | |
164 (tramp-telnet-args nil)) | |
165 ("scp" (tramp-connection-function tramp-open-connection-rsh) | |
166 (tramp-rsh-program "ssh") | |
167 (tramp-rcp-program "scp") | |
168 (tramp-remote-sh "/bin/sh") | |
169 (tramp-rsh-args ("-e" "none")) | |
170 (tramp-rcp-args nil) | |
171 (tramp-rcp-keep-date-arg "-p") | |
172 (tramp-su-program nil) | |
173 (tramp-su-args nil) | |
174 (tramp-encoding-command nil) | |
175 (tramp-decoding-command nil) | |
176 (tramp-encoding-function nil) | |
177 (tramp-decoding-function nil) | |
178 (tramp-telnet-program nil) | |
179 (tramp-telnet-args nil)) | |
180 ("scp1" (tramp-connection-function tramp-open-connection-rsh) | |
181 (tramp-rsh-program "ssh1") | |
182 (tramp-rcp-program "scp1") | |
183 (tramp-remote-sh "/bin/sh") | |
184 (tramp-rsh-args ("-e" "none")) | |
185 (tramp-rcp-args nil) | |
186 (tramp-rcp-keep-date-arg "-p") | |
187 (tramp-su-program nil) | |
188 (tramp-su-args nil) | |
189 (tramp-encoding-command nil) | |
190 (tramp-decoding-command nil) | |
191 (tramp-encoding-function nil) | |
192 (tramp-decoding-function nil) | |
193 (tramp-telnet-program nil) | |
194 (tramp-telnet-args nil)) | |
195 ("scp2" (tramp-connection-function tramp-open-connection-rsh) | |
196 (tramp-rsh-program "ssh2") | |
197 (tramp-rcp-program "scp2") | |
198 (tramp-remote-sh "/bin/sh") | |
199 (tramp-rsh-args ("-e" "none")) | |
200 (tramp-rcp-args nil) | |
201 (tramp-rcp-keep-date-arg "-p") | |
202 (tramp-su-program nil) | |
203 (tramp-su-args nil) | |
204 (tramp-encoding-command nil) | |
205 (tramp-decoding-command nil) | |
206 (tramp-encoding-function nil) | |
207 (tramp-decoding-function nil) | |
208 (tramp-telnet-program nil) | |
209 (tramp-telnet-args nil)) | |
210 ("rsync" (tramp-connection-function tramp-open-connection-rsh) | |
211 (tramp-rsh-program "ssh") | |
212 (tramp-rcp-program "rsync") | |
213 (tramp-remote-sh "/bin/sh") | |
214 (tramp-rsh-args ("-e" "none")) | |
215 (tramp-rcp-args ("-e" "ssh")) | |
216 (tramp-rcp-keep-date-arg "-t") | |
217 (tramp-su-program nil) | |
218 (tramp-su-args nil) | |
219 (tramp-encoding-command nil) | |
220 (tramp-decoding-command nil) | |
221 (tramp-encoding-function nil) | |
222 (tramp-decoding-function nil) | |
223 (tramp-telnet-program nil) | |
224 (tramp-telnet-args nil)) | |
225 ("ru" (tramp-connection-function tramp-open-connection-rsh) | |
226 (tramp-rsh-program "rsh") | |
227 (tramp-rcp-program nil) | |
228 (tramp-remote-sh "/bin/sh") | |
229 (tramp-rsh-args nil) | |
230 (tramp-rcp-args nil) | |
231 (tramp-rcp-keep-date-arg nil) | |
232 (tramp-su-program nil) | |
233 (tramp-su-args nil) | |
234 (tramp-encoding-command "uuencode xxx") | |
235 (tramp-decoding-command | |
236 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") | |
237 (tramp-encoding-function nil) | |
238 (tramp-decoding-function uudecode-decode-region) | |
239 (tramp-telnet-program nil) | |
240 (tramp-telnet-args nil)) | |
241 ("su" (tramp-connection-function tramp-open-connection-rsh) | |
242 (tramp-rsh-program "ssh") | |
243 (tramp-rcp-program nil) | |
244 (tramp-remote-sh "/bin/sh") | |
245 (tramp-rsh-args ("-e" "none")) | |
246 (tramp-rcp-args nil) | |
247 (tramp-rcp-keep-date-arg nil) | |
248 (tramp-su-program nil) | |
249 (tramp-su-args nil) | |
250 (tramp-encoding-command "uuencode xxx") | |
251 (tramp-decoding-command | |
252 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") | |
253 (tramp-encoding-function nil) | |
254 (tramp-decoding-function uudecode-decode-region) | |
255 (tramp-telnet-program nil) | |
256 (tramp-telnet-args nil)) | |
257 ("su1" (tramp-connection-function tramp-open-connection-rsh) | |
258 (tramp-rsh-program "ssh1") | |
259 (tramp-rcp-program nil) | |
260 (tramp-remote-sh "/bin/sh") | |
261 (tramp-rsh-args ("-e" "none")) | |
262 (tramp-rcp-args nil) | |
263 (tramp-rcp-keep-date-arg nil) | |
264 (tramp-su-program nil) | |
265 (tramp-su-args nil) | |
266 (tramp-encoding-command "uuencode xxx") | |
267 (tramp-decoding-command | |
268 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") | |
269 (tramp-encoding-function nil) | |
270 (tramp-decoding-function uudecode-decode-region) | |
271 (tramp-telnet-program nil) | |
272 (tramp-telnet-args nil)) | |
273 ("su2" (tramp-connection-function tramp-open-connection-rsh) | |
274 (tramp-rsh-program "ssh2") | |
275 (tramp-rcp-program nil) | |
276 (tramp-remote-sh "/bin/sh") | |
277 (tramp-rsh-args ("-e" "none")) | |
278 (tramp-rcp-args nil) | |
279 (tramp-rcp-keep-date-arg nil) | |
280 (tramp-su-program nil) | |
281 (tramp-su-args nil) | |
282 (tramp-encoding-command "uuencode xxx") | |
283 (tramp-decoding-command | |
284 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") | |
285 (tramp-encoding-function nil) | |
286 (tramp-decoding-function uudecode-decode-region) | |
287 (tramp-telnet-program nil) | |
288 (tramp-telnet-args nil)) | |
289 ("rm" (tramp-connection-function tramp-open-connection-rsh) | |
290 (tramp-rsh-program "rsh") | |
291 (tramp-rcp-program nil) | |
292 (tramp-remote-sh "/bin/sh") | |
293 (tramp-rsh-args nil) | |
294 (tramp-rcp-args nil) | |
295 (tramp-rcp-keep-date-arg nil) | |
296 (tramp-su-program nil) | |
297 (tramp-su-args nil) | |
298 (tramp-encoding-command "mimencode -b") | |
299 (tramp-decoding-command "mimencode -u -b") | |
300 (tramp-encoding-function base64-encode-region) | |
301 (tramp-decoding-function base64-decode-region) | |
302 (tramp-telnet-program nil) | |
303 (tramp-telnet-args nil)) | |
304 ("sm" (tramp-connection-function tramp-open-connection-rsh) | |
305 (tramp-rsh-program "ssh") | |
306 (tramp-rcp-program nil) | |
307 (tramp-remote-sh "/bin/sh") | |
308 (tramp-rsh-args ("-e" "none")) | |
309 (tramp-rcp-args nil) | |
310 (tramp-rcp-keep-date-arg nil) | |
311 (tramp-su-program nil) | |
312 (tramp-su-args nil) | |
313 (tramp-encoding-command "mimencode -b") | |
314 (tramp-decoding-command "mimencode -u -b") | |
315 (tramp-encoding-function base64-encode-region) | |
316 (tramp-decoding-function base64-decode-region) | |
317 (tramp-telnet-program nil) | |
318 (tramp-telnet-args nil)) | |
319 ("smp" (tramp-connection-function tramp-open-connection-rsh) | |
320 (tramp-rsh-program "ssh") | |
321 (tramp-rcp-program nil) | |
322 (tramp-remote-sh "/bin/sh") | |
323 (tramp-rsh-args ("-e" "none")) | |
324 (tramp-rcp-args nil) | |
325 (tramp-rcp-keep-date-arg nil) | |
326 (tramp-su-program nil) | |
327 (tramp-su-args nil) | |
328 (tramp-encoding-command "tramp_mimencode") | |
329 (tramp-decoding-command "tramp_mimedecode") | |
330 (tramp-encoding-function base64-encode-region) | |
331 (tramp-decoding-function base64-decode-region) | |
332 (tramp-telnet-program nil)) | |
333 ("sm1" (tramp-connection-function tramp-open-connection-rsh) | |
334 (tramp-rsh-program "ssh1") | |
335 (tramp-rcp-program nil) | |
336 (tramp-remote-sh "/bin/sh") | |
337 (tramp-rsh-args ("-e" "none")) | |
338 (tramp-rcp-args nil) | |
339 (tramp-rcp-keep-date-arg nil) | |
340 (tramp-su-program nil) | |
341 (tramp-su-args nil) | |
342 (tramp-encoding-command "mimencode -b") | |
343 (tramp-decoding-command "mimencode -u -b") | |
344 (tramp-encoding-function base64-encode-region) | |
345 (tramp-decoding-function base64-decode-region) | |
346 (tramp-telnet-program nil) | |
347 (tramp-telnet-args nil)) | |
348 ("sm2" (tramp-connection-function tramp-open-connection-rsh) | |
349 (tramp-rsh-program "ssh2") | |
350 (tramp-rcp-program nil) | |
351 (tramp-remote-sh "/bin/sh") | |
352 (tramp-rsh-args ("-e" "none")) | |
353 (tramp-rcp-args nil) | |
354 (tramp-rcp-keep-date-arg nil) | |
355 (tramp-su-program nil) | |
356 (tramp-su-args nil) | |
357 (tramp-encoding-command "mimencode -b") | |
358 (tramp-decoding-command "mimencode -u -b") | |
359 (tramp-encoding-function base64-encode-region) | |
360 (tramp-decoding-function base64-decode-region) | |
361 (tramp-telnet-program nil) | |
362 (tramp-telnet-args nil)) | |
363 ("tm" (tramp-connection-function tramp-open-connection-telnet) | |
364 (tramp-rsh-program nil) | |
365 (tramp-rcp-program nil) | |
366 (tramp-remote-sh "/bin/sh") | |
367 (tramp-rsh-args nil) | |
368 (tramp-rcp-args nil) | |
369 (tramp-rcp-keep-date-arg nil) | |
370 (tramp-su-program nil) | |
371 (tramp-su-args nil) | |
372 (tramp-encoding-command "mimencode -b") | |
373 (tramp-decoding-command "mimencode -u -b") | |
374 (tramp-encoding-function base64-encode-region) | |
375 (tramp-decoding-function base64-decode-region) | |
376 (tramp-telnet-program "telnet") | |
377 (tramp-telnet-args nil)) | |
378 ("tu" (tramp-connection-function tramp-open-connection-telnet) | |
379 (tramp-rsh-program nil) | |
380 (tramp-rcp-program nil) | |
381 (tramp-remote-sh "/bin/sh") | |
382 (tramp-rsh-args nil) | |
383 (tramp-rcp-args nil) | |
384 (tramp-rcp-keep-date-arg nil) | |
385 (tramp-su-program nil) | |
386 (tramp-su-args nil) | |
387 (tramp-encoding-command "uuencode xxx") | |
388 (tramp-decoding-command | |
389 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") | |
390 (tramp-encoding-function nil) | |
391 (tramp-decoding-function uudecode-decode-region) | |
392 (tramp-telnet-program "telnet") | |
393 (tramp-telnet-args nil)) | |
394 ("sum" (tramp-connection-function tramp-open-connection-su) | |
395 (tramp-rsh-program nil) | |
396 (tramp-rcp-program nil) | |
397 (tramp-remote-sh "/bin/sh") | |
398 (tramp-rsh-args nil) | |
399 (tramp-rcp-args nil) | |
400 (tramp-rcp-keep-date-arg nil) | |
401 (tramp-su-program "su") | |
402 (tramp-su-args ("-" "%u")) | |
403 (tramp-encoding-command "mimencode -b") | |
404 (tramp-decoding-command "mimencode -u -b") | |
405 (tramp-encoding-function base64-encode-region) | |
406 (tramp-decoding-function base64-decode-region) | |
407 (tramp-telnet-program nil) | |
408 (tramp-telnet-args nil)) | |
409 ("suu" (tramp-connection-function tramp-open-connection-su) | |
410 (tramp-rsh-program nil) | |
411 (tramp-rcp-program nil) | |
412 (tramp-remote-sh "/bin/sh") | |
413 (tramp-rsh-args nil) | |
414 (tramp-rcp-args nil) | |
415 (tramp-rcp-keep-date-arg nil) | |
416 (tramp-su-program "su") | |
417 (tramp-su-args ("-" "%u")) | |
418 (tramp-encoding-command "uuencode xxx") | |
419 (tramp-decoding-command | |
420 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") | |
421 (tramp-encoding-function nil) | |
422 (tramp-decoding-function uudecode-decode-region) | |
423 (tramp-telnet-program nil) | |
424 (tramp-telnet-args nil)) | |
425 ("sudm" (tramp-connection-function tramp-open-connection-su) | |
426 (tramp-rsh-program nil) | |
427 (tramp-rcp-program nil) | |
428 (tramp-remote-sh "/bin/sh") | |
429 (tramp-rsh-args nil) | |
430 (tramp-rcp-args nil) | |
431 (tramp-rcp-keep-date-arg nil) | |
432 (tramp-su-program "sudo") | |
433 (tramp-su-args ("-u" "%u" "-s")) | |
434 (tramp-encoding-command "mimencode -b") | |
435 (tramp-decoding-command "mimencode -u -b") | |
436 (tramp-encoding-function base64-encode-region) | |
437 (tramp-decoding-function base64-decode-region) | |
438 (tramp-telnet-program nil) | |
439 (tramp-telnet-args nil)) | |
440 ("sudu" (tramp-connection-function tramp-open-connection-su) | |
441 (tramp-rsh-program nil) | |
442 (tramp-rcp-program nil) | |
443 (tramp-remote-sh "/bin/sh") | |
444 (tramp-rsh-args nil) | |
445 (tramp-rcp-args nil) | |
446 (tramp-rcp-keep-date-arg nil) | |
447 (tramp-su-program "sudo") | |
448 (tramp-su-args ("-u" "%u" "-s")) | |
449 (tramp-encoding-command "uuencode xxx") | |
450 (tramp-decoding-command | |
451 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") | |
452 (tramp-encoding-function nil) | |
453 (tramp-decoding-function uudecode-decode-region) | |
454 (tramp-telnet-program nil) | |
455 (tramp-telnet-args nil)) | |
456 ("multi" (tramp-connection-function tramp-open-connection-multi) | |
457 (tramp-rsh-program nil) | |
458 (tramp-rcp-program nil) | |
459 (tramp-remote-sh "/bin/sh") | |
460 (tramp-rsh-args nil) | |
461 (tramp-rcp-args nil) | |
462 (tramp-rcp-keep-date-arg nil) | |
463 (tramp-su-program nil) | |
464 (tramp-su-args nil) | |
465 (tramp-encoding-command "mimencode -b") | |
466 (tramp-decoding-command "mimencode -u -b") | |
467 (tramp-encoding-function base64-encode-region) | |
468 (tramp-decoding-function base64-decode-region) | |
469 (tramp-telnet-program nil) | |
470 (tramp-telnet-args nil)) | |
471 ("multiu" (tramp-connection-function tramp-open-connection-multi) | |
472 (tramp-rsh-program nil) | |
473 (tramp-rcp-program nil) | |
474 (tramp-remote-sh "/bin/sh") | |
475 (tramp-rsh-args nil) | |
476 (tramp-rcp-args nil) | |
477 (tramp-rcp-keep-date-arg nil) | |
478 (tramp-su-program nil) | |
479 (tramp-su-args nil) | |
480 (tramp-encoding-command "uuencode xxx") | |
481 (tramp-decoding-command | |
482 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") | |
483 (tramp-encoding-function nil) | |
484 (tramp-decoding-function uudecode-decode-region) | |
485 (tramp-telnet-program nil) | |
486 (tramp-telnet-args nil)) | |
487 ("scpx" (tramp-connection-function tramp-open-connection-rsh) | |
488 (tramp-rsh-program "ssh") | |
489 (tramp-rcp-program "scp") | |
490 (tramp-remote-sh "/bin/sh") | |
491 (tramp-rsh-args ("-e" "none" "-t" "-t" "/bin/sh")) | |
492 (tramp-rcp-args nil) | |
493 (tramp-rcp-keep-date-arg "-p") | |
494 (tramp-encoding-command nil) | |
495 (tramp-decoding-command nil) | |
496 (tramp-encoding-function nil) | |
497 (tramp-decoding-function nil) | |
498 (tramp-telnet-program nil) | |
499 (tramp-telnet-args nil)) | |
500 ("smx" (tramp-connection-function tramp-open-connection-rsh) | |
501 (tramp-rsh-program "ssh") | |
502 (tramp-rcp-program nil) | |
503 (tramp-remote-sh "/bin/sh") | |
504 (tramp-rsh-args ("-e" "none" "-t" "-t" "/bin/sh")) | |
505 (tramp-rcp-args nil) | |
506 (tramp-rcp-keep-date-arg nil) | |
507 (tramp-su-program nil) | |
508 (tramp-su-args nil) | |
509 (tramp-encoding-command "mimencode -b") | |
510 (tramp-decoding-command "mimencode -u -b") | |
511 (tramp-encoding-function base64-encode-region) | |
512 (tramp-decoding-function base64-decode-region) | |
513 (tramp-telnet-program nil) | |
514 (tramp-telnet-args nil)) | |
515 ("km" | |
516 (tramp-connection-function tramp-open-connection-rsh) | |
517 (tramp-rsh-program "krlogin") | |
518 (tramp-rcp-program nil) | |
519 (tramp-remote-sh "/bin/sh") | |
520 (tramp-rsh-args ("-x")) | |
521 (tramp-rcp-args nil) | |
522 (tramp-rcp-keep-date-arg nil) | |
523 (tramp-su-program nil) | |
524 (tramp-su-args nil) | |
525 (tramp-encoding-command "mimencode -b") | |
526 (tramp-decoding-command "mimencode -u -b") | |
527 (tramp-encoding-function base64-encode-region) | |
528 (tramp-decoding-function base64-decode-region) | |
529 (tramp-telnet-program nil) | |
530 (tramp-telnet-args nil)) | |
531 ("plinku" | |
532 (tramp-connection-function tramp-open-connection-rsh) | |
533 (tramp-rsh-program "plink") | |
534 (tramp-rcp-program nil) | |
535 (tramp-remote-sh "/bin/sh") | |
536 (tramp-rsh-args ("-ssh")) ;optionally add "-v" | |
537 (tramp-rcp-args nil) | |
538 (tramp-rcp-keep-date-arg nil) | |
539 (tramp-su-program nil) | |
540 (tramp-su-args nil) | |
541 (tramp-encoding-command "uuencode xxx") | |
542 (tramp-decoding-command | |
543 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") | |
544 (tramp-encoding-function nil) | |
545 (tramp-decoding-function uudecode-decode-region) | |
546 (tramp-telnet-program nil) | |
547 (tramp-telnet-args nil)) | |
548 ("plinkm" | |
549 (tramp-connection-function tramp-open-connection-rsh) | |
550 (tramp-rsh-program "plink") | |
551 (tramp-rcp-program nil) | |
552 (tramp-remote-sh "/bin/sh") | |
553 (tramp-rsh-args ("-ssh")) ;optionally add "-v" | |
554 (tramp-rcp-args nil) | |
555 (tramp-rcp-keep-date-arg nil) | |
556 (tramp-su-program nil) | |
557 (tramp-su-args nil) | |
558 (tramp-encoding-command "mimencode -b") | |
559 (tramp-decoding-command "mimencode -u -b") | |
560 (tramp-encoding-function base64-encode-region) | |
561 (tramp-decoding-function base64-decode-region) | |
562 (tramp-telnet-program nil) | |
563 (tramp-telnet-args nil)) | |
564 ("pscp" | |
565 (tramp-connection-function tramp-open-connection-rsh) | |
566 (tramp-rsh-program "plink") | |
567 (tramp-rcp-program "pscp") | |
568 (tramp-remote-sh "/bin/sh") | |
569 (tramp-rsh-args ("-ssh")) | |
570 (tramp-rcp-args nil) | |
571 (tramp-rcp-keep-date-arg "-p") | |
572 (tramp-su-program nil) | |
573 (tramp-su-args nil) | |
574 (tramp-encoding-command nil) | |
575 (tramp-decoding-command nil) | |
576 (tramp-encoding-function nil) | |
577 (tramp-decoding-function nil) | |
578 (tramp-telnet-program nil) | |
579 (tramp-telnet-args nil)) | |
580 ("fcp" | |
581 (tramp-connection-function tramp-open-connection-rsh) | |
582 (tramp-rsh-program "fsh") | |
583 (tramp-rcp-program "fcp") | |
584 (tramp-remote-sh "/bin/sh -i") | |
585 (tramp-rsh-args ("sh" "-i")) | |
586 (tramp-rcp-args nil) | |
587 (tramp-rcp-keep-date-arg "-p") | |
588 (tramp-su-program nil) | |
589 (tramp-su-args nil) | |
590 (tramp-encoding-command nil) | |
591 (tramp-decoding-command nil) | |
592 (tramp-encoding-function nil) | |
593 (tramp-decoding-function nil) | |
594 (tramp-telnet-program nil) | |
595 (tramp-telnet-args nil)) | |
596 ) | |
597 "*Alist of methods for remote files. | |
598 This is a list of entries of the form (NAME PARAM1 PARAM2 ...). | |
599 Each NAME stands for a remote access method. Each PARAM is a | |
600 pair of the form (KEY VALUE). The following KEYs are defined: | |
601 * `tramp-connection-function' | |
602 This specifies the function to use to connect to the remote host. | |
603 Currently, `tramp-open-connection-rsh', `tramp-open-connection-telnet' | |
604 and `tramp-open-connection-su' are defined. See the documentation | |
605 of these functions for more details. | |
606 * `tramp-remote-sh' | |
607 This specifies the Bourne shell to use on the remote host. This | |
608 MUST be a Bourne-like shell. It is normally not necessary to set | |
609 this to any value other than \"/bin/sh\": tramp wants to use a shell | |
610 which groks tilde expansion, but it can search for it. Also note | |
611 that \"/bin/sh\" exists on all Unixen, this might not be true for | |
612 the value that you decide to use. You Have Been Warned. | |
613 * `tramp-rsh-program' | |
614 This specifies the name of the program to use for rsh; this might be | |
615 the full path to rsh or the name of a workalike program. | |
616 * `tramp-rsh-args' | |
617 This specifies the list of arguments to pass to the above | |
618 mentioned program. Please note that this is a list of arguments, | |
619 that is, normally you don't want to put \"-a -b\" or \"-f foo\" | |
620 here. Instead, you want two list elements, one for \"-a\" and one | |
621 for \"-b\", or one for \"-f\" and one for \"foo\". | |
622 * `tramp-rcp-program' | |
623 This specifies the name of the program to use for rcp; this might be | |
624 the full path to rcp or the name of a workalike program. | |
625 * `tramp-rcp-args' | |
626 This specifies the list of parameters to pass to the above mentioned | |
627 program, the hints for `tramp-rsh-args' also apply here. | |
628 * `tramp-rcp-keep-date-arg' | |
629 This specifies the parameter to use for `rcp' when the timestamp | |
630 of the original file should be kept. For `rcp', use `-p', for | |
631 `rsync', use `-t'. | |
632 * `tramp-su-program' | |
633 This specifies the name of the program to use for `su'. | |
634 * `tramp-su-args' | |
635 This specifies the list of arguments to pass to `su'. | |
636 \"%u\" is replaced by the user name, use \"%%\" for a literal | |
637 percent character. | |
638 * `tramp-encoding-command' | |
639 This specifies a command to use to encode the file contents for | |
640 transfer. The command should read the raw file contents from | |
641 standard input and write the encoded file contents to standard | |
642 output. In this string, the percent escape \"%f\" should be used | |
643 to indicate the file to convert. Use \"%%\" if you need a literal | |
644 percent character in your command. | |
645 * `tramp-decoding-command' | |
646 This specifies a command to use to decode file contents encoded | |
647 with `tramp-encoding-command'. The command should read from standard | |
648 input and write to standard output. | |
649 * `tramp-encoding-function' | |
650 This specifies a function to be called to encode the file contents | |
651 on the local side. This function should accept two arguments | |
652 START and END, the beginning and end of the region to encode. The | |
653 region should be replaced with the encoded contents. | |
654 * `tramp-decoding-function' | |
655 Same for decoding on the local side. | |
656 * `tramp-telnet-program' | |
657 Specifies the telnet program to use when using | |
658 `tramp-open-connection-telnet' to log in. | |
659 * `tramp-telnet-args' | |
660 Specifies list of arguments to pass to `telnet'. The hints for | |
661 `tramp-rsh-args' also apply here. | |
662 | |
663 What does all this mean? Well, you should specify `tramp-rsh-program', | |
664 `tramp-telnet-program' or `tramp-su-program' for all methods; this program | |
665 is used to log in to the remote site. Then, there are two ways to | |
666 actually transfer the files between the local and the remote side. | |
667 One way is using an additional rcp-like program. If you want to do | |
668 this, set `tramp-rcp-program' in the method. | |
669 | |
670 Another possibility for file transfer is inline transfer, i.e. the | |
671 file is passed through the same buffer used by `tramp-rsh-program'. In | |
672 this case, the file contents need to be protected since the | |
673 `tramp-rsh-program' might use escape codes or the connection might not | |
674 be eight-bit clean. Therefore, file contents are encoded for transit. | |
675 | |
676 Two possibilities for encoding are uuencode/uudecode and mimencode. | |
677 For uuencode/uudecode you want to set `tramp-encoding-command' to | |
678 something like \"uuencode\" and `tramp-decoding-command' to \"uudecode | |
679 -p\". For mimencode you want to set `tramp-encoding-command' to | |
680 something like \"mimencode -b\" and `tramp-decoding-command' to | |
681 \"mimencode -b -u\". | |
682 | |
683 When using inline transfer, you can use a program or a Lisp function | |
684 on the local side to encode or decode the file contents. Set the | |
685 `tramp-encoding-function' and `tramp-decoding-function' parameters to nil | |
686 in order to use the commands or to the function to use. It is | |
687 possible to specify one function and the other parameter as nil. | |
688 | |
689 So, to summarize: if the method is an inline method, you must specify | |
690 `tramp-encoding-command' and `tramp-decoding-command', and | |
691 `tramp-rcp-program' must be nil. If the method is out of band, then | |
692 you must specify `tramp-rcp-program' and `tramp-rcp-args' and | |
693 `tramp-encoding-command' and `tramp-decoding-command' must be nil. | |
694 Every method, inline or out of band, must specify | |
695 `tramp-connection-function' plus the associated arguments (for | |
696 example, the telnet program if you chose | |
697 `tramp-open-connection-telnet'). | |
698 | |
699 Notes: | |
700 | |
701 When using `tramp-open-connection-su' the phrase `open connection to a | |
702 remote host' sounds strange, but it is used nevertheless, for | |
703 consistency. No connection is opened to a remote host, but `su' is | |
704 started on the local host. You are not allowed to specify a remote | |
705 host other than `localhost' or the name of the local host. | |
706 | |
707 Using a uuencode/uudecode inline method is discouraged, please use one | |
708 of the base64 methods instead since base64 encoding is much more | |
709 reliable and the commands are more standardized between the different | |
710 Unix versions. But if you can't use base64 for some reason, please | |
711 note that the default uudecode command does not work well for some | |
712 Unices, in particular AIX and Irix. For AIX, you might want to use | |
713 the following command for uudecode: | |
714 | |
715 sed '/^begin/d;/^[` ]$/d;/^end/d' | iconv -f uucode -t ISO8859-1 | |
716 | |
717 For Irix, no solution is known yet." | |
718 :group 'tramp | |
719 :type '(repeat | |
720 (cons string | |
721 (set (list (const tramp-connection-function) function) | |
722 (list (const tramp-rsh-program) | |
723 (choice (const nil) string)) | |
724 (list (const tramp-rcp-program) | |
725 (choice (const nil) string)) | |
726 (list (const tramp-remote-sh) | |
727 (choice (const nil) string)) | |
728 (list (const tramp-rsh-args) (repeat string)) | |
729 (list (const tramp-rcp-args) (repeat string)) | |
730 (list (const tramp-rcp-keep-date-arg) | |
731 (choice (const nil) string)) | |
732 (list (const tramp-su-program) | |
733 (choice (const nil) string)) | |
734 (list (const tramp-su-args) (repeat string)) | |
735 (list (const tramp-encoding-command) | |
736 (choice (const nil) string)) | |
737 (list (const tramp-decoding-command) | |
738 (choice (const nil) string)) | |
739 (list (const tramp-encoding-function) | |
740 (choice (const nil) function)) | |
741 (list (const tramp-decoding-function) | |
742 (choice (const nil) function)) | |
743 (list (const tramp-telnet-program) | |
744 (choice (const nil) string)) | |
745 (list (const tramp-telnet-args) (repeat string)))))) | |
746 | |
747 (defcustom tramp-multi-methods '("multi" "multiu") | |
748 "*List of multi-hop methods. | |
749 Each entry in this list should be a method name as mentioned in the | |
750 variable `tramp-methods'." | |
751 :group 'tramp | |
752 :type '(repeat string)) | |
753 | |
754 (defcustom tramp-multi-connection-function-alist | |
755 '(("telnet" tramp-multi-connect-telnet "telnet %h%n") | |
756 ("rsh" tramp-multi-connect-rlogin "rsh %h -l %u%n") | |
757 ("ssh" tramp-multi-connect-rlogin "ssh %h -l %u%n") | |
758 ("su" tramp-multi-connect-su "su - %u%n") | |
759 ("sudo" tramp-multi-connect-su "sudo -u %u -s%n")) | |
760 "*List of connection functions for multi-hop methods. | |
761 Each list item is a list of three items (METHOD FUNCTION COMMAND), | |
762 where METHOD is the name as used in the file name, FUNCTION is the | |
763 function to be executed, and COMMAND is the shell command used for | |
764 connecting. | |
765 | |
766 COMMAND may contain percent escapes. `%u' will be replaced with the | |
767 user name, `%h' will be replaced with the host name, and `%n' will be | |
768 replaced with an end-of-line character, as specified in the variable | |
769 `tramp-rsh-end-of-line'. Use `%%' for a literal percent character. | |
770 Note that the interpretation of the percent escapes also depends on | |
771 the FUNCTION. For example, the `%u' escape is forbidden with the | |
772 function `tramp-multi-connect-telnet'. See the documentation of the | |
773 various functions for details." | |
774 :group 'tramp | |
775 :type '(repeat (list string function string))) | |
776 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
777 (defcustom tramp-default-method "sm" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
778 ;;(if (featurep 'xemacs) "sm" "ftp") |
45861 | 779 "*Default method to use for transferring files. |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
780 See `tramp-methods' for possibilities. |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
781 Also see `tramp-default-method-alist'. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
782 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
783 Emacs uses a unified filename syntax for Tramp and Ange-FTP. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
784 For backward compatibility, the default value of this variable |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
785 is \"ftp\" on Emacs. But XEmacs uses a separate filename syntax |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
786 for Tramp and EFS, so there the default method is \"sm\"." |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
787 :group 'tramp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
788 :type 'string) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
789 |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
790 (defcustom tramp-default-method-alist |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
791 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
792 nil |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
793 '(("\\`ftp\\." "" "ftp") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
794 ("" "\\`\\(anonymous\\|ftp\\)\\'" "ftp"))) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
795 "*Default method to use for specific user/host pairs. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
796 This is an alist of items (HOST USER METHOD). The first matching item |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
797 specifies the method to use for a file name which does not specify a |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
798 method. HOST and USER are regular expressions or nil, which is |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
799 interpreted as a regular expression which always matches. If no entry |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
800 matches, the variable `tramp-default-method' takes effect. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
801 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
802 If the file name does not specify the user, lookup is done using the |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
803 empty string for the user name. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
804 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
805 See `tramp-methods' for a list of possibilities for METHOD." |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
806 :group 'tramp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
807 :type '(repeat (list (regexp :tag "Host regexp") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
808 (regexp :tag "User regexp") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
809 (string :tag "Method")))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
810 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
811 (defcustom tramp-ftp-method "ftp" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
812 "*When this method name is used, forward all calls to Ange-FTP." |
45861 | 813 :group 'tramp |
814 :type 'string) | |
815 | |
816 (defcustom tramp-rsh-end-of-line "\n" | |
817 "*String used for end of line in rsh connections. | |
818 I don't think this ever needs to be changed, so please tell me about it | |
819 if you need to change this." | |
820 :group 'tramp | |
821 :type 'string) | |
822 | |
823 (defcustom tramp-remote-path | |
824 '("/bin" "/usr/bin" "/usr/sbin" "/usr/local/bin" "/usr/ccs/bin" | |
825 "/local/bin" "/local/freeware/bin" "/local/gnu/bin" | |
826 "/usr/freeware/bin" "/usr/pkg/bin" "/usr/contrib/bin") | |
827 "*List of directories to search for executables on remote host. | |
828 Please notify me about other semi-standard directories to include here. | |
829 | |
830 You can use `~' in this list, but when searching for a shell which groks | |
831 tilde expansion, all directory names starting with `~' will be ignored." | |
832 :group 'tramp | |
833 :type '(repeat string)) | |
834 | |
835 (defcustom tramp-login-prompt-regexp | |
836 ".*ogin: *$" | |
837 "*Regexp matching login-like prompts. | |
838 The regexp should match the whole line." | |
839 :group 'tramp | |
840 :type 'regexp) | |
841 | |
842 (defcustom tramp-password-prompt-regexp | |
843 "^.*\\([pP]assword\\|passphrase.*\\):\^@? *$" | |
844 "*Regexp matching password-like prompts. | |
845 The regexp should match the whole line. | |
846 | |
847 The `sudo' program appears to insert a `^@' character into the prompt." | |
848 :group 'tramp | |
849 :type 'regexp) | |
850 | |
851 (defcustom tramp-wrong-passwd-regexp | |
852 (concat "^.*\\(Permission denied.\\|Login [Ii]ncorrect\\|" | |
853 "Received signal [0-9]+\\|Connection \\(refused\\|closed\\)\\|" | |
854 "Sorry, try again.\\|Name or service not known\\).*$") | |
855 "*Regexp matching a `login failed' message. | |
856 The regexp should match the whole line." | |
857 :group 'tramp | |
858 :type 'regexp) | |
859 | |
860 (defcustom tramp-temp-name-prefix "tramp." | |
861 "*Prefix to use for temporary files. | |
862 If this is a relative file name (such as \"tramp.\"), it is considered | |
863 relative to the directory name returned by the function | |
864 `tramp-temporary-file-directory' (which see). It may also be an | |
865 absolute file name; don't forget to include a prefix for the filename | |
866 part, though." | |
867 :group 'tramp | |
868 :type 'string) | |
869 | |
870 (defcustom tramp-discard-garbage nil | |
871 "*If non-nil, try to discard garbage sent by remote shell. | |
872 Some shells send such garbage upon connection setup." | |
873 :group 'tramp | |
874 :type 'boolean) | |
875 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
876 (defcustom tramp-sh-extra-args '(("/bash\\'" . "--norc")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
877 "*Alist specifying extra arguments to pass to the remote shell. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
878 Entries are (REGEXP . ARGS) where REGEXP is a regular expression |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
879 matching the shell file name and ARGS is a string specifying the |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
880 arguments. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
881 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
882 This variable is only used when Tramp needs to start up another shell |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
883 for tilde expansion. The extra arguments should typically prevent the |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
884 shell from reading its init file." |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
885 :group 'tramp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
886 :type '(alist :key-type string :value-type string)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
887 |
45861 | 888 ;; File name format. |
889 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
890 (defconst tramp-file-name-structure-unified |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
891 (list (concat "\\`/\\(\\([a-zA-Z0-9]+\\):\\)?" ;method |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
892 "\\(\\([^:@/]+\\)@\\)?" ;user |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
893 "\\([^:/]+\\):" ;host |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
894 "\\(.*\\)\\'") ;path |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
895 2 4 5 6) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
896 "Default value for `tramp-file-name-structure' for unified remoting. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
897 On Emacs (not XEmacs), the Tramp and Ange-FTP packages use a unified |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
898 filename space. This value is used for this unified namespace.") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
899 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
900 (defconst tramp-file-name-structure-separate |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
901 (list (concat "\\`/\\[\\(\\([a-zA-Z0-9]+\\)/\\)?" ;method |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
902 "\\(\\([-a-zA-Z0-9_#/:]+\\)@\\)?" ;user |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
903 "\\([-a-zA-Z0-9_#/:@.]+\\)\\]" ;host |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
904 "\\(.*\\)\\'") ;path |
45861 | 905 2 4 5 6) |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
906 "Default value for `tramp-file-name-structure' for separate remoting. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
907 On XEmacs, the Tramp and EFS packages use a separate namespace for |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
908 remote filenames. This value is used in that case. It is designed |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
909 not to clash with the EFS filename syntax.") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
910 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
911 (defcustom tramp-file-name-structure |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
912 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
913 tramp-file-name-structure-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
914 tramp-file-name-structure-unified) |
45861 | 915 "*List of five elements (REGEXP METHOD USER HOST FILE), detailing \ |
916 the tramp file name structure. | |
917 | |
918 The first element REGEXP is a regular expression matching a tramp file | |
919 name. The regex should contain parentheses around the method name, | |
920 the user name, the host name, and the file name parts. | |
921 | |
922 The second element METHOD is a number, saying which pair of | |
923 parentheses matches the method name. The third element USER is | |
924 similar, but for the user name. The fourth element HOST is similar, | |
925 but for the host name. The fifth element FILE is for the file name. | |
926 These numbers are passed directly to `match-string', which see. That | |
927 means the opening parentheses are counted to identify the pair. | |
928 | |
929 See also `tramp-file-name-regexp' and `tramp-make-tramp-file-format'." | |
930 :group 'tramp | |
931 :type '(list (regexp :tag "File name regexp") | |
932 (integer :tag "Paren pair for method name") | |
933 (integer :tag "Paren pair for user name ") | |
934 (integer :tag "Paren pair for host name ") | |
935 (integer :tag "Paren pair for file name "))) | |
936 | |
937 ;;;###autoload | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
938 (defconst tramp-file-name-regexp-unified |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
939 "\\`/[^/:]+:" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
940 "Value for `tramp-file-name-regexp' for unified remoting. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
941 Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
942 Tramp. See `tramp-file-name-structure-unified' for more explanations.") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
943 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
944 ;;;###autoload |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
945 (defconst tramp-file-name-regexp-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
946 "\\`/\\[.*\\]" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
947 "Value for `tramp-file-name-regexp' for separate remoting. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
948 XEmacs uses a separate filename syntax for Tramp and EFS. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
949 See `tramp-file-name-structure-separate' for more explanations.") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
950 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
951 ;;;###autoload |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
952 (defcustom tramp-file-name-regexp |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
953 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
954 tramp-file-name-regexp-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
955 tramp-file-name-regexp-unified) |
45861 | 956 "*Regular expression matching file names handled by tramp. |
957 This regexp should match tramp file names but no other file names. | |
958 \(When tramp.el is loaded, this regular expression is prepended to | |
959 `file-name-handler-alist', and that is searched sequentially. Thus, | |
960 if the tramp entry appears rather early in the `file-name-handler-alist' | |
961 and is a bit too general, then some files might be considered tramp | |
962 files which are not really tramp files. | |
963 | |
964 Please note that the entry in `file-name-handler-alist' is made when | |
965 this file (tramp.el) is loaded. This means that this variable must be set | |
966 before loading tramp.el. Alternatively, `file-name-handler-alist' can be | |
967 updated after changing this variable. | |
968 | |
969 Also see `tramp-file-name-structure' and `tramp-make-tramp-file-format'." | |
970 :group 'tramp | |
971 :type 'regexp) | |
972 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
973 (defconst tramp-make-tramp-file-format-unified |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
974 "/%m:%u@%h:%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
975 "Value for `tramp-make-tramp-file-format' for unified remoting. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
976 Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and Tramp. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
977 See `tramp-file-name-structure-unified' for more details.") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
978 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
979 (defconst tramp-make-tramp-file-format-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
980 "/[%m/%u@%h]%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
981 "Value for `tramp-make-tramp-file-format' for separate remoting. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
982 XEmacs uses a separate filename syntax for EFS and Tramp. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
983 See `tramp-file-name-structure-separate' for more details.") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
984 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
985 (defcustom tramp-make-tramp-file-format |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
986 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
987 tramp-make-tramp-file-format-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
988 tramp-make-tramp-file-format-unified) |
45861 | 989 "*Format string saying how to construct tramp file name. |
990 `%m' is replaced by the method name. | |
991 `%u' is replaced by the user name. | |
992 `%h' is replaced by the host name. | |
993 `%p' is replaced by the file name. | |
994 `%%' is replaced by %. | |
995 | |
996 Also see `tramp-file-name-structure' and `tramp-file-name-regexp'." | |
997 :group 'tramp | |
998 :type 'string) | |
999 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1000 (defconst tramp-make-tramp-file-user-nil-format-unified |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1001 "/%m:%h:%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1002 "Value of `tramp-make-tramp-file-user-nil-format' for unified remoting. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1003 Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and Tramp. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1004 See `tramp-file-name-structure-unified' for details.") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1005 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1006 (defconst tramp-make-tramp-file-user-nil-format-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1007 "/[%m/%h]%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1008 "Value of `tramp-make-tramp-file-user-nil-format' for separate remoting. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1009 XEmacs uses a separate filename syntax for EFS and Tramp. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1010 See `tramp-file-name-structure-separate' for details.") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1011 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1012 (defcustom tramp-make-tramp-file-user-nil-format |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1013 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1014 tramp-make-tramp-file-user-nil-format-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1015 tramp-make-tramp-file-user-nil-format-unified) |
45861 | 1016 "*Format string saying how to construct tramp file name when the user name is not known. |
1017 `%m' is replaced by the method name. | |
1018 `%h' is replaced by the host name. | |
1019 `%p' is replaced by the file name. | |
1020 `%%' is replaced by %. | |
1021 | |
1022 Also see `tramp-make-tramp-file-format', `tramp-file-name-structure', and `tramp-file-name-regexp'." | |
1023 :group 'tramp | |
1024 :type 'string) | |
1025 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1026 (defconst tramp-multi-file-name-structure-unified |
46347
3996ea20e5e3
(tramp-multi-file-name-structure-unified): Add
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46307
diff
changeset
|
1027 (list (concat "\\`/\\(\\([a-zA-Z0-9]+\\)?:\\)" ;method |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1028 "\\(\\(%s\\)+\\)" ;hops |
46347
3996ea20e5e3
(tramp-multi-file-name-structure-unified): Add
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46307
diff
changeset
|
1029 "\\(.*\\)\\'") ;path |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1030 2 3 -1) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1031 "Value for `tramp-multi-file-name-structure' for unified remoting. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1032 Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and Tramp. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1033 See `tramp-file-name-structure-unified' for details.") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1034 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1035 (defconst tramp-file-name-structure-separate |
45861 | 1036 (list (concat |
1037 ;; prefix | |
46347
3996ea20e5e3
(tramp-multi-file-name-structure-unified): Add
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46307
diff
changeset
|
1038 "\\`/\\[\\(\\([a-z0-9]+\\)?\\)" |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1039 ;; regexp specifying the hops |
45861 | 1040 "\\(\\(%s\\)+\\)" |
1041 ;; path name | |
1042 "\\]\\(.*\\)\\'") | |
1043 2 ;number of pair to match method | |
1044 3 ;number of pair to match hops | |
1045 -1) ;number of pair to match path | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1046 "Value of `tramp-multi-file-name-structure' for separate remoting. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1047 XEmacs uses a separate filename syntax for EFS and Tramp. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1048 See `tramp-file-name-structure-separate' for details.") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1049 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1050 (defcustom tramp-multi-file-name-structure |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1051 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1052 tramp-multi-file-name-structure-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1053 tramp-multi-file-name-structure-unified) |
45861 | 1054 "*Describes the file name structure of `multi' files. |
1055 Multi files allow you to contact a remote host in several hops. | |
1056 This is a list of four elements (REGEXP METHOD HOP PATH). | |
1057 | |
1058 The first element, REGEXP, gives a regular expression to match against | |
1059 the file name. In this regular expression, `%s' is replaced with the | |
1060 value of `tramp-multi-file-name-hop-structure'. (Note: in order to | |
1061 allow multiple hops, you normally want to use something like | |
1062 \"\\\\(\\\\(%s\\\\)+\\\\)\" in the regular expression. The outer pair | |
1063 of parentheses is used for the HOP element, see below.) | |
1064 | |
1065 All remaining elements are numbers. METHOD gives the number of the | |
1066 paren pair which matches the method name. HOP gives the number of the | |
1067 paren pair which matches the hop sequence. PATH gives the number of | |
1068 the paren pair which matches the path name on the remote host. | |
1069 | |
1070 PATH can also be negative, which means to count from the end. Ie, a | |
1071 value of -1 means the last paren pair. | |
1072 | |
1073 I think it would be good if the regexp matches the whole of the | |
1074 string, but I haven't actually tried what happens if it doesn't..." | |
1075 :group 'tramp | |
1076 :type '(list (regexp :tag "File name regexp") | |
1077 (integer :tag "Paren pair for method name") | |
1078 (integer :tag "Paren pair for hops") | |
1079 (integer :tag "Paren pair to match path"))) | |
1080 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1081 (defconst tramp-multi-file-name-hop-structure-unified |
46347
3996ea20e5e3
(tramp-multi-file-name-structure-unified): Add
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46307
diff
changeset
|
1082 (list (concat "\\([a-zA-z0-9_]+\\):" ;hop method |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1083 "\\([^@:/]+\\)@" ;user |
46347
3996ea20e5e3
(tramp-multi-file-name-structure-unified): Add
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46307
diff
changeset
|
1084 "\\([^:/]+\\):") ;host |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1085 1 2 3) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1086 "Value of `tramp-multi-file-name-hop-structure' for unified remoting. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1087 Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and Tramp. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1088 See `tramp-file-name-structure-unified' for details.") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1089 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1090 (defconst tramp-multi-file-name-hop-structure-separate |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1091 (list (concat "/\\([a-z0-9_]+\\):" ;hop method |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1092 "\\([a-z0-9_]+\\)@" ;user |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1093 "\\([a-z0-9.-]+\\)") ;host |
45861 | 1094 1 2 3) |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1095 "Value of `tramp-multi-file-name-hop-structure' for separate remoting. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1096 XEmacs uses a separate filename syntax for EFS and Tramp. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1097 See `tramp-file-name-structure-separate' for details.") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1098 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1099 (defcustom tramp-multi-file-name-hop-structure |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1100 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1101 tramp-multi-file-name-hop-structure-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1102 tramp-multi-file-name-hop-structure-unified) |
45861 | 1103 "*Describes the structure of a hop in multi files. |
1104 This is a list of four elements (REGEXP METHOD USER HOST). First | |
1105 element REGEXP is used to match against the hop. Pair number METHOD | |
1106 matches the method of one hop, pair number USER matches the user of | |
1107 one hop, pair number HOST matches the host of one hop. | |
1108 | |
1109 This regular expression should match exactly all of one hop." | |
1110 :group 'tramp | |
1111 :type '(list (regexp :tag "Hop regexp") | |
1112 (integer :tag "Paren pair for method name") | |
1113 (integer :tag "Paren pair for user name") | |
1114 (integer :tag "Paren pair for host name"))) | |
1115 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1116 (defconst tramp-make-multi-tramp-file-format-unified |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1117 (list "/%m" ":%m:%u@%h" ":%p") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1118 "Value of `tramp-make-multi-tramp-file-format' for unified remoting. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1119 Emacs (not XEmacs) uses a unified filename syntax for Ange-FTP and Tramp. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1120 See `tramp-file-name-structure-unified' for details.") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1121 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1122 (defconst tramp-make-multi-tramp-file-format-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1123 (list "/[%m" "/%m:%u@%h" "]%p") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1124 "Value of `tramp-make-multi-tramp-file-format' for separate remoting. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1125 XEmacs uses a separate filename syntax for EFS and Tramp. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1126 See `tramp-file-name-structure-separate' for details.") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1127 |
45861 | 1128 (defcustom tramp-make-multi-tramp-file-format |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1129 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1130 tramp-make-multi-tramp-file-format-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1131 tramp-make-multi-tramp-file-format-unified) |
45861 | 1132 "*Describes how to construct a `multi' file name. |
1133 This is a list of three elements PREFIX, HOP and PATH. | |
1134 | |
1135 The first element PREFIX says how to construct the prefix, the second | |
1136 element HOP specifies what each hop looks like, and the final element | |
1137 PATH says how to construct the path name. | |
1138 | |
1139 In PREFIX, `%%' means `%' and `%m' means the method name. | |
1140 | |
1141 In HOP, `%%' means `%' and `%m', `%u', `%h' mean the hop method, hop | |
1142 user and hop host, respectively. | |
1143 | |
1144 In PATH, `%%' means `%' and `%p' means the path name. | |
1145 | |
1146 The resulting file name always contains one copy of PREFIX and one | |
1147 copy of PATH, but there is one copy of HOP for each hop in the file | |
1148 name. | |
1149 | |
1150 Note: the current implementation requires the prefix to contain the | |
1151 method name, followed by all the hops, and the path name must come | |
1152 last." | |
1153 :group 'tramp | |
1154 :type '(list string string string)) | |
1155 | |
1156 (defcustom tramp-terminal-type "dumb" | |
1157 "*Value of TERM environment variable for logging in to remote host. | |
1158 Because Tramp wants to parse the output of the remote shell, it is easily | |
1159 confused by ANSI color escape sequences and suchlike. Often, shell init | |
1160 files conditionalize this setup based on the TERM environment variable." | |
1161 :group 'tramp | |
1162 :type 'string) | |
1163 | |
1164 (defcustom tramp-completion-without-shell-p nil | |
1165 "*If nil, use shell wildcards for completion, else rely on Lisp only. | |
1166 Using shell wildcards for completions has the advantage that it can be | |
1167 fast even in large directories, but completion is always | |
1168 case-sensitive. Relying on Lisp only means that case-insensitive | |
1169 completion is possible (subject to the variable `completion-ignore-case'), | |
1170 but it might be slow on large directories." | |
1171 :group 'tramp | |
1172 :type 'boolean) | |
1173 | |
1174 ;;; Internal Variables: | |
1175 | |
1176 (defvar tramp-buffer-file-attributes nil | |
1177 "Holds the `ls -ild' output for the current buffer. | |
1178 This variable is local to each buffer. It is not used if the remote | |
1179 machine groks Perl. If it is used, it's used as an emulation for | |
1180 the visited file modtime.") | |
1181 (make-variable-buffer-local 'tramp-buffer-file-attributes) | |
1182 | |
1183 (defvar tramp-end-of-output "/////" | |
1184 "String used to recognize end of output.") | |
1185 | |
1186 (defvar tramp-connection-function nil | |
1187 "This internal variable holds a parameter for `tramp-methods'. | |
1188 In the connection buffer, this variable has the value of the like-named | |
1189 method parameter, as specified in `tramp-methods' (which see).") | |
1190 | |
1191 (defvar tramp-remote-sh nil | |
1192 "This internal variable holds a parameter for `tramp-methods'. | |
1193 In the connection buffer, this variable has the value of the like-named | |
1194 method parameter, as specified in `tramp-methods' (which see).") | |
1195 | |
1196 (defvar tramp-rsh-program nil | |
1197 "This internal variable holds a parameter for `tramp-methods'. | |
1198 In the connection buffer, this variable has the value of the like-named | |
1199 method parameter, as specified in `tramp-methods' (which see).") | |
1200 | |
1201 (defvar tramp-rsh-args nil | |
1202 "This internal variable holds a parameter for `tramp-methods'. | |
1203 In the connection buffer, this variable has the value of the like-named | |
1204 method parameter, as specified in `tramp-methods' (which see).") | |
1205 | |
1206 (defvar tramp-rcp-program nil | |
1207 "This internal variable holds a parameter for `tramp-methods'. | |
1208 In the connection buffer, this variable has the value of the like-named | |
1209 method parameter, as specified in `tramp-methods' (which see).") | |
1210 | |
1211 (defvar tramp-rcp-args nil | |
1212 "This internal variable holds a parameter for `tramp-methods'. | |
1213 In the connection buffer, this variable has the value of the like-named | |
1214 method parameter, as specified in `tramp-methods' (which see).") | |
1215 | |
1216 (defvar tramp-rcp-keep-date-arg nil | |
1217 "This internal variable holds a parameter for `tramp-methods'. | |
1218 In the connection buffer, this variable has the value of the like-named | |
1219 method parameter, as specified in `tramp-methods' (which see).") | |
1220 | |
1221 (defvar tramp-encoding-command nil | |
1222 "This internal variable holds a parameter for `tramp-methods'. | |
1223 In the connection buffer, this variable has the value of the like-named | |
1224 method parameter, as specified in `tramp-methods' (which see).") | |
1225 | |
1226 (defvar tramp-decoding-command nil | |
1227 "This internal variable holds a parameter for `tramp-methods'. | |
1228 In the connection buffer, this variable has the value of the like-named | |
1229 method parameter, as specified in `tramp-methods' (which see).") | |
1230 | |
1231 (defvar tramp-encoding-function nil | |
1232 "This internal variable holds a parameter for `tramp-methods'. | |
1233 In the connection buffer, this variable has the value of the like-named | |
1234 method parameter, as specified in `tramp-methods' (which see).") | |
1235 | |
1236 (defvar tramp-decoding-function nil | |
1237 "This internal variable holds a parameter for `tramp-methods'. | |
1238 In the connection buffer, this variable has the value of the like-named | |
1239 method parameter, as specified in `tramp-methods' (which see).") | |
1240 | |
1241 (defvar tramp-telnet-program nil | |
1242 "This internal variable holds a parameter for `tramp-methods'. | |
1243 In the connection buffer, this variable has the value of the like-named | |
1244 method parameter, as specified in `tramp-methods' (which see).") | |
1245 | |
1246 (defvar tramp-telnet-args nil | |
1247 "This internal variable holds a parameter for `tramp-methods'. | |
1248 In the connection buffer, this variable has the value of the like-named | |
1249 method parameter, as specified in `tramp-methods' (which see).") | |
1250 | |
1251 ;; CCC `local in each buffer'? | |
1252 (defvar tramp-ls-command nil | |
1253 "This command is used to get a long listing with numeric user and group ids. | |
1254 This variable is automatically made buffer-local to each rsh process buffer | |
1255 upon opening the connection.") | |
1256 | |
1257 (defvar tramp-current-multi-method nil | |
1258 "Name of `multi' connection method for this *tramp* buffer, or nil if not multi. | |
1259 This variable is automatically made buffer-local to each rsh process buffer | |
1260 upon opening the connection.") | |
1261 | |
1262 (defvar tramp-current-method nil | |
1263 "Connection method for this *tramp* buffer. | |
1264 This variable is automatically made buffer-local to each rsh process buffer | |
1265 upon opening the connection.") | |
1266 | |
1267 (defvar tramp-current-user nil | |
1268 "Remote login name for this *tramp* buffer. | |
1269 This variable is automatically made buffer-local to each rsh process buffer | |
1270 upon opening the connection.") | |
1271 | |
1272 (defvar tramp-current-host nil | |
1273 "Remote host for this *tramp* buffer. | |
1274 This variable is automatically made buffer-local to each rsh process buffer | |
1275 upon opening the connection.") | |
1276 | |
1277 (defvar tramp-test-groks-nt nil | |
1278 "Whether the `test' command groks the `-nt' switch. | |
1279 \(`test A -nt B' tests if file A is newer than file B.) | |
1280 This variable is automatically made buffer-local to each rsh process buffer | |
1281 upon opening the connection.") | |
1282 | |
1283 (defvar tramp-file-exists-command nil | |
1284 "Command to use for checking if a file exists. | |
1285 This variable is automatically made buffer-local to each rsh process buffer | |
1286 upon opening the connection.") | |
1287 | |
1288 ;; Perl script to implement `file-attributes' in a Lisp `read'able output. | |
1289 ;; If you are hacking on this, note that you get *no* output unless this | |
1290 ;; spits out a complete line, including the '\n' at the end. | |
1291 (defconst tramp-perl-file-attributes (concat | |
1292 "$f = $ARGV[0]; | |
1293 @s = lstat($f); | |
1294 if (($s[2] & 0170000) == 0120000) { $l = readlink($f); $l = \"\\\"$l\\\"\"; } | |
1295 elsif (($s[2] & 0170000) == 040000) { $l = \"t\"; } | |
1296 else { $l = \"nil\" }; | |
1297 printf(\"(%s %u %u %u (%u %u) (%u %u) (%u %u) %u %u t (%u . %u) (%u %u))\\n\", | |
1298 $l, $s[3], $s[4], $s[5], $s[8] >> 16 & 0xffff, $s[8] & 0xffff, | |
1299 $s[9] >> 16 & 0xffff, $s[9] & 0xffff, $s[10] >> 16 & 0xffff, $s[10] & 0xffff, | |
1300 $s[7], $s[2], $s[1] >> 16 & 0xffff, $s[1] & 0xffff, $s[0] >> 16 & 0xffff, $s[0] & 0xffff);" | |
1301 ) | |
1302 "Perl script to produce output suitable for use with `file-attributes' | |
1303 on the remote file system.") | |
1304 | |
1305 ;; Perl script to implement `mime-encode' | |
1306 (defvar tramp-perl-mime-encode (concat | |
1307 "sub encode_base64 ($); | |
1308 my $buf; | |
1309 while(read(STDIN, $buf, 60*57)) { print encode_base64($buf) } | |
1310 sub encode_base64 ($) { | |
1311 my $res = \"\"; | |
1312 my $eol = \"\n\"; | |
1313 pos($_[0]) = 0; # ensure start at the beginning | |
1314 while ($_[0] =~ /(.{1,45})/gs) { | |
1315 $res .= substr(pack(\"u\", $1), 1); | |
1316 chop($res); | |
1317 } | |
1318 $res =~ tr|` -_|AA-Za-z0-9+/|; # `# help emacs | |
1319 # fix padding at the end | |
1320 my $padding = (3 - length($_[0]) % 3) % 3; | |
1321 $res =~ s/.{$padding}$/\"=\" x $padding/e if $padding; | |
1322 # break encoded string into lines of no more than 76 characters each | |
1323 if (length $eol) { | |
1324 $res =~ s/(.{1,76})/$1$eol/g; | |
1325 } | |
1326 $res;}")) | |
1327 | |
1328 ;; Perl script to implement `mime-decode' | |
1329 (defvar tramp-perl-mime-decode (concat | |
1330 "sub decode_base64 ($); | |
1331 my $buf; | |
1332 while(read(STDIN, $buf, 60*57)) { print decode_base64($buf) } | |
1333 sub decode_base64 ($) { | |
1334 local($^W) = 0; # unpack(\"u\",...) gives bogus warning in 5.00[123] | |
1335 | |
1336 my $str = shift; | |
1337 my $res = \"\"; | |
1338 | |
1339 $str =~ tr|A-Za-z0-9+=/||cd; # remove non-base64 chars | |
1340 if (length($str) % 4) { | |
1341 warn(\"Length of base64 data not a multiple of 4\") | |
1342 } | |
1343 $str =~ s/=+$//; # remove padding | |
1344 $str =~ tr|A-Za-z0-9+/| -_|; # convert to uuencoded format | |
1345 while ($str =~ /(.{1,60})/gs) { | |
1346 my $len = chr(32 + length($1)*3/4); # compute length byte | |
1347 $res .= unpack(\"u\", $len . $1 ); # uudecode | |
1348 } | |
1349 $res;}")) | |
1350 | |
1351 ; These values conform to `file-attributes' from XEmacs 21.2. | |
1352 ; GNU Emacs and other tools not checked. | |
1353 (defconst tramp-file-mode-type-map '((0 . "-") ; Normal file (SVID-v2 and XPG2) | |
1354 (1 . "p") ; fifo | |
1355 (2 . "c") ; character device | |
1356 (3 . "m") ; multiplexed character device (v7) | |
1357 (4 . "d") ; directory | |
1358 (5 . "?") ; Named special file (XENIX) | |
1359 (6 . "b") ; block device | |
1360 (7 . "?") ; multiplexed block device (v7) | |
1361 (8 . "-") ; regular file | |
1362 (9 . "n") ; network special file (HP-UX) | |
1363 (10 . "l") ; symlink | |
1364 (11 . "?") ; ACL shadow inode (Solaris, not userspace) | |
1365 (12 . "s") ; socket | |
1366 (13 . "D") ; door special (Solaris) | |
1367 (14 . "w")) ; whiteout (BSD) | |
1368 "A list of file types returned from the `stat' system call. | |
1369 This is used to map a mode number to a permission string.") | |
1370 | |
1371 (defvar tramp-dos-coding-system | |
1372 (if (and (fboundp 'coding-system-p) | |
1373 (funcall 'coding-system-p '(dos))) | |
1374 'dos | |
1375 'undecided-dos) | |
1376 "Some Emacsen know the `dos' coding system, others need `undecided-dos'.") | |
1377 | |
1378 | |
1379 ;; New handlers should be added here. The following operations can be | |
1380 ;; handled using the normal primitives: file-name-as-directory, | |
1381 ;; file-name-directory, file-name-nondirectory, | |
1382 ;; file-name-sans-versions, get-file-buffer. | |
1383 (defconst tramp-file-name-handler-alist | |
1384 '( | |
1385 (load . tramp-handle-load) | |
1386 (make-symbolic-link . tramp-handle-make-symbolic-link) | |
1387 (file-name-directory . tramp-handle-file-name-directory) | |
1388 (file-name-nondirectory . tramp-handle-file-name-nondirectory) | |
1389 (file-truename . tramp-handle-file-truename) | |
1390 (file-exists-p . tramp-handle-file-exists-p) | |
1391 (file-directory-p . tramp-handle-file-directory-p) | |
1392 (file-executable-p . tramp-handle-file-executable-p) | |
1393 (file-accessible-directory-p . tramp-handle-file-accessible-directory-p) | |
1394 (file-readable-p . tramp-handle-file-readable-p) | |
1395 (file-regular-p . tramp-handle-file-regular-p) | |
1396 (file-symlink-p . tramp-handle-file-symlink-p) | |
1397 (file-writable-p . tramp-handle-file-writable-p) | |
1398 (file-ownership-preserved-p . tramp-handle-file-ownership-preserved-p) | |
1399 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) | |
1400 (file-attributes . tramp-handle-file-attributes) | |
1401 (file-modes . tramp-handle-file-modes) | |
1402 (file-directory-files . tramp-handle-file-directory-files) | |
1403 (directory-files . tramp-handle-directory-files) | |
1404 (file-name-all-completions . tramp-handle-file-name-all-completions) | |
1405 (file-name-completion . tramp-handle-file-name-completion) | |
1406 (add-name-to-file . tramp-handle-add-name-to-file) | |
1407 (copy-file . tramp-handle-copy-file) | |
1408 (rename-file . tramp-handle-rename-file) | |
1409 (set-file-modes . tramp-handle-set-file-modes) | |
1410 (make-directory . tramp-handle-make-directory) | |
1411 (delete-directory . tramp-handle-delete-directory) | |
1412 (delete-file . tramp-handle-delete-file) | |
1413 (directory-file-name . tramp-handle-directory-file-name) | |
1414 (shell-command . tramp-handle-shell-command) | |
1415 (insert-directory . tramp-handle-insert-directory) | |
1416 (expand-file-name . tramp-handle-expand-file-name) | |
1417 (file-local-copy . tramp-handle-file-local-copy) | |
1418 (insert-file-contents . tramp-handle-insert-file-contents) | |
1419 (write-region . tramp-handle-write-region) | |
1420 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory) | |
1421 (dired-call-process . tramp-handle-dired-call-process) | |
1422 (dired-recursive-delete-directory | |
1423 . tramp-handle-dired-recursive-delete-directory) | |
1424 (set-visited-file-modtime . tramp-handle-set-visited-file-modtime) | |
1425 (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)) | |
1426 "Alist of handler functions. | |
1427 Operations not mentioned here will be handled by the normal Emacs functions.") | |
1428 | |
1429 ;;; For better error reporting. | |
1430 | |
1431 (defun tramp-version (arg) | |
1432 "Print version number of tramp.el in minibuffer or current buffer." | |
1433 (interactive "P") | |
1434 (if arg (insert tramp-version) (message tramp-version))) | |
1435 | |
1436 ;;; Internal functions which must come first. | |
1437 | |
1438 (defsubst tramp-message (level fmt-string &rest args) | |
1439 "Emit a message depending on verbosity level. | |
1440 First arg LEVEL says to be quiet if `tramp-verbose' is less than LEVEL. The | |
1441 message is emitted only if `tramp-verbose' is greater than or equal to LEVEL. | |
1442 Calls function `message' with FMT-STRING as control string and the remaining | |
1443 ARGS to actually emit the message (if applicable). | |
1444 | |
1445 This function expects to be called from the tramp buffer only!" | |
1446 (when (<= level tramp-verbose) | |
1447 (apply #'message (concat "tramp: " fmt-string) args) | |
1448 (when tramp-debug-buffer | |
1449 (save-excursion | |
1450 (set-buffer | |
1451 (tramp-get-debug-buffer | |
1452 tramp-current-multi-method tramp-current-method | |
1453 tramp-current-user tramp-current-host)) | |
1454 (goto-char (point-max)) | |
1455 (tramp-insert-with-face | |
1456 'italic | |
1457 (concat "# " (apply #'format fmt-string args) "\n")))))) | |
1458 | |
1459 (defun tramp-message-for-buffer | |
1460 (multi-method method user host level fmt-string &rest args) | |
1461 "Like `tramp-message' but temporarily switches to the tramp buffer. | |
1462 First three args METHOD, USER, and HOST identify the tramp buffer to use, | |
1463 remaining args passed to `tramp-message'." | |
1464 (save-excursion | |
1465 (set-buffer (tramp-get-buffer multi-method method user host)) | |
1466 (apply 'tramp-message level fmt-string args))) | |
1467 | |
1468 (defsubst tramp-line-end-position nil | |
1469 "Return point at end of line. | |
1470 Calls `line-end-position' or `point-at-eol' if defined, else | |
1471 own implementation." | |
1472 (cond | |
1473 ((fboundp 'line-end-position) (funcall 'line-end-position)) | |
1474 ((fboundp 'point-at-eol) (funcall 'point-at-eol)) | |
1475 (t (save-excursion (end-of-line) (point))))) | |
1476 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1477 (defmacro with-parsed-tramp-file-name (filename var &rest body) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1478 "Parse a Tramp filename and make components available in the body. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1479 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1480 First arg FILENAME is evaluated and dissected into its components. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1481 Second arg VAR is a symbol. It is used as a variable name to hold |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1482 the filename structure. It is also used as a prefix for the variables |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1483 holding the components. For example, if VAR is the symbol `foo', then |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1484 `foo' will be bound to the whole structure, `foo-multi-method' will |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1485 be bound to the multi-method component, and so on for `foo-method', |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1486 `foo-user', `foo-host', `foo-path'. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1487 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1488 Remaining args are Lisp expressions to be evaluated (inside an implicit |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1489 `progn'). |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1490 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1491 If VAR is nil, then we bind `v' to the structure and `multi-method', |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1492 `method', `user', `host', `path' to the components." |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1493 `(let* ((,(or var 'v) (tramp-dissect-file-name ,filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1494 (,(if var (intern (concat (symbol-name var) "-multi-method")) 'multi-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1495 (tramp-file-name-multi-method ,(or var 'v))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1496 (,(if var (intern (concat (symbol-name var) "-method")) 'method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1497 (tramp-file-name-method ,(or var 'v))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1498 (,(if var (intern (concat (symbol-name var) "-user")) 'user) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1499 (tramp-file-name-user ,(or var 'v))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1500 (,(if var (intern (concat (symbol-name var) "-host")) 'host) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1501 (tramp-file-name-host ,(or var 'v))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1502 (,(if var (intern (concat (symbol-name var) "-path")) 'path) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1503 (tramp-file-name-path ,(or var 'v)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1504 ,@body)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1505 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1506 (put 'with-parsed-tramp-file-name 'lisp-indent-function 2) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1507 |
45861 | 1508 ;;; File Name Handler Functions: |
1509 | |
1510 (defun tramp-handle-make-symbolic-link | |
1511 (filename linkname &optional ok-if-already-exists) | |
1512 "Like `make-symbolic-link' for tramp files. | |
46307
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1513 If LINKNAME is a non-Tramp file, it is used verbatim as the target of |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1514 the symlink. If LINKNAME is a Tramp file, only the path component is |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1515 used as the target of the symlink. |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1516 |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1517 If LINKNAME is a Tramp file and the path component is relative, then |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1518 it is expanded first, before the path component is taken. Note that |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1519 this can give surprising results if the user/host for the source and |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1520 target of the symlink differ." |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1521 (with-parsed-tramp-file-name linkname l |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1522 (when (tramp-ange-ftp-file-name-p l-multi-method l-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1523 (tramp-invoke-ange-ftp 'make-symbolic-link |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1524 filename linkname ok-if-already-exists)) |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1525 (let ((ln (tramp-get-remote-ln l-multi-method l-method l-user l-host)) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1526 (cwd (file-name-directory l-path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1527 (unless ln |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1528 (signal 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1529 (list "Making a symbolic link." |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1530 "ln(1) does not exist on the remote host."))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1531 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1532 ;; Do the 'confirm if exists' thing. |
46307
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1533 (when (file-exists-p linkname) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1534 ;; What to do? |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1535 (if (or (null ok-if-already-exists) ; not allowed to exist |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1536 (and (numberp ok-if-already-exists) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1537 (not (yes-or-no-p |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1538 (format |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1539 "File %s already exists; make it a link anyway? " |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1540 l-path))))) |
46307
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1541 (signal 'file-already-exists (list "File already exists" l-path)) |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1542 (delete-file linkname))) |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1543 |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1544 ;; If FILENAME is a Tramp name, use just the path component. |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1545 (when (tramp-tramp-file-p filename) |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1546 (setq filename (tramp-file-name-path |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1547 (tramp-dissect-file-name |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1548 (expand-file-name filename))))) |
45861 | 1549 |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1550 ;; Right, they are on the same host, regardless of user, method, etc. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1551 ;; We now make the link on the remote machine. This will occur as the user |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1552 ;; that FILENAME belongs to. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1553 (zerop |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1554 (tramp-send-command-and-check |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1555 l-multi-method l-method l-user l-host |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1556 (format "cd %s && %s -sf %s %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1557 cwd ln |
46307
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1558 filename |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1559 l-path) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1560 t))))) |
45861 | 1561 |
1562 | |
1563 (defun tramp-handle-load (file &optional noerror nomessage nosuffix must-suffix) | |
1564 "Like `load' for tramp files. Not implemented!" | |
1565 (unless (file-name-absolute-p file) | |
1566 (error "Tramp cannot `load' files without absolute path name")) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1567 (with-parsed-tramp-file-name file nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1568 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1569 (tramp-invoke-ange-ftp 'load |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1570 file noerror nomessage nosuffix must-suffix)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1571 (unless nosuffix |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1572 (cond ((file-exists-p (concat file ".elc")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1573 (setq file (concat file ".elc"))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1574 ((file-exists-p (concat file ".el")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1575 (setq file (concat file ".el"))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1576 (when must-suffix |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1577 ;; The first condition is always true for absolute file names. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1578 ;; Included for safety's sake. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1579 (unless (or (file-name-directory file) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1580 (string-match "\\.elc?\\'" file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1581 (error "File `%s' does not include a `.el' or `.elc' suffix" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1582 file))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1583 (unless noerror |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1584 (when (not (file-exists-p file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1585 (error "Cannot load nonexistant file `%s'" file))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1586 (if (not (file-exists-p file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1587 nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1588 (unless nomessage |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1589 (message "Loading %s..." file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1590 (let ((local-copy (file-local-copy file))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1591 ;; MUST-SUFFIX doesn't exist on XEmacs, so let it default to nil. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1592 (load local-copy noerror t t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1593 (delete-file local-copy)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1594 (unless nomessage |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1595 (message "Loading %s...done" file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1596 t))) |
45861 | 1597 |
1598 ;; Path manipulation functions that grok TRAMP paths... | |
1599 (defun tramp-handle-file-name-directory (file) | |
1600 "Like `file-name-directory' but aware of TRAMP files." | |
1601 ;; everything except the last filename thing is the directory | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1602 (with-parsed-tramp-file-name file nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1603 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1604 (tramp-invoke-ange-ftp 'file-name-directory file)) |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1605 ;; For the following condition, two possibilities should be tried: |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1606 ;; (1) (string= path "") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1607 ;; (2) (or (string= path "") (string= path "/")) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1608 ;; The second variant fails when completing a "/" directory on |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1609 ;; the remote host, that is a filename which looks like |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1610 ;; "/user@host:/". But maybe wildcards fail with the first variant. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1611 ;; We should do some investigation. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1612 (if (string= path "") |
45861 | 1613 ;; For a filename like "/[foo]", we return "/". The `else' |
1614 ;; case would return "/[foo]" unchanged. But if we do that, | |
1615 ;; then `file-expand-wildcards' ceases to work. It's not | |
1616 ;; quite clear to me what's the intuition that tells that this | |
1617 ;; behavior is the right behavior, but oh, well. | |
1618 "/" | |
1619 ;; run the command on the path portion only | |
1620 ;; CCC: This should take into account the remote machine type, no? | |
1621 ;; --daniel <daniel@danann.net> | |
1622 (tramp-make-tramp-file-name multi-method method user host | |
1623 ;; This will not recurse... | |
1624 (or (file-name-directory path) ""))))) | |
1625 | |
1626 (defun tramp-handle-file-name-nondirectory (file) | |
1627 "Like `file-name-nondirectory' but aware of TRAMP files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1628 (with-parsed-tramp-file-name file nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1629 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1630 (tramp-invoke-ange-ftp 'file-name-nondirectory file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1631 (file-name-nondirectory path))) |
45861 | 1632 |
1633 (defun tramp-handle-file-truename (filename &optional counter prev-dirs) | |
1634 "Like `file-truename' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1635 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1636 ;; Ange-FTP does not support truename processing. It returns the |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1637 ;; file name as-is. So that's what we do, too. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1638 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1639 filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1640 (let* ((steps (tramp-split-string path "/")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1641 (pathdir (let ((directory-sep-char ?/)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1642 (file-name-as-directory path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1643 (is-dir (string= path pathdir)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1644 (thisstep nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1645 (numchase 0) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1646 ;; Don't make the following value larger than necessary. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1647 ;; People expect an error message in a timely fashion when |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1648 ;; something is wrong; otherwise they might think that Emacs |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1649 ;; is hung. Of course, correctness has to come first. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1650 (numchase-limit 20) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1651 (result nil) ;result steps in reverse order |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1652 (curstri "") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1653 symlink-target) |
45861 | 1654 (tramp-message-for-buffer |
1655 multi-method method user host | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1656 10 "Finding true name for `%s'" filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1657 (while (and steps (< numchase numchase-limit)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1658 (setq thisstep (pop steps)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1659 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1660 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1661 10 "Check %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1662 (mapconcat 'identity |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1663 (append '("") (reverse result) (list thisstep)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1664 "/")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1665 (setq symlink-target |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1666 (nth 0 (tramp-handle-file-attributes |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1667 (tramp-make-tramp-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1668 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1669 (mapconcat 'identity |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1670 (append '("") (reverse result) (list thisstep)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1671 "/"))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1672 (cond ((string= "." thisstep) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1673 (tramp-message-for-buffer multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1674 10 "Ignoring step `.'")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1675 ((string= ".." thisstep) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1676 (tramp-message-for-buffer multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1677 10 "Processing step `..'") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1678 (pop result)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1679 ((stringp symlink-target) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1680 ;; It's a symlink, follow it. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1681 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1682 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1683 10 "Follow symlink to %s" symlink-target) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1684 (setq numchase (1+ numchase)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1685 (when (file-name-absolute-p symlink-target) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1686 (setq result nil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1687 (setq steps |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1688 (append (tramp-split-string symlink-target "/") steps))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1689 (t |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1690 ;; It's a file. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1691 (setq result (cons thisstep result))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1692 (when (>= numchase numchase-limit) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1693 (error "Maximum number (%d) of symlinks exceeded" numchase-limit)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1694 (setq result (reverse result)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1695 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1696 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1697 10 "True name of `%s' is `%s'" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1698 filename (mapconcat 'identity (cons "" result) "/")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1699 (tramp-make-tramp-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1700 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1701 (concat (mapconcat 'identity (cons "" result) "/") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1702 (if is-dir "/" "")))))) |
45861 | 1703 |
1704 ;; Basic functions. | |
1705 | |
1706 (defun tramp-handle-file-exists-p (filename) | |
1707 "Like `file-exists-p' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1708 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1709 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1710 (tramp-invoke-ange-ftp 'file-exists-p filename)) |
45861 | 1711 (save-excursion |
1712 (zerop (tramp-send-command-and-check | |
1713 multi-method method user host | |
1714 (format | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1715 (tramp-get-file-exists-command multi-method method user host) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1716 (tramp-shell-quote-argument path))))))) |
45861 | 1717 |
1718 ;; CCC: This should check for an error condition and signal failure | |
1719 ;; when something goes wrong. | |
1720 ;; Daniel Pittman <daniel@danann.net> | |
1721 (defun tramp-handle-file-attributes (filename &optional nonnumeric) | |
1722 "Like `file-attributes' for tramp files. | |
1723 Optional argument NONNUMERIC means return user and group name | |
1724 rather than as numbers." | |
1725 (if (tramp-handle-file-exists-p filename) | |
1726 ;; file exists, find out stuff | |
1727 (save-excursion | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1728 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1729 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1730 (tramp-invoke-ange-ftp 'file-attributes file)) |
45861 | 1731 (if (tramp-get-remote-perl multi-method method user host) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1732 (tramp-handle-file-attributes-with-perl |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1733 multi-method method user host path nonnumeric) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1734 (tramp-handle-file-attributes-with-ls |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1735 multi-method method user host path nonnumeric)))) |
45861 | 1736 nil)) ; no file |
1737 | |
1738 | |
1739 (defun tramp-handle-file-attributes-with-ls | |
1740 (multi-method method user host path &optional nonnumeric) | |
1741 "Implement `file-attributes' for tramp files using the ls(1) command." | |
1742 (let (symlinkp dirp | |
1743 res-inode res-filemodes res-numlinks | |
1744 res-uid res-gid res-size res-symlink-target) | |
1745 (tramp-send-command | |
1746 multi-method method user host | |
1747 (format "%s %s %s" | |
1748 (tramp-get-ls-command multi-method method user host) | |
1749 (if nonnumeric "-ild" "-ildn") | |
1750 (tramp-shell-quote-argument path))) | |
1751 (tramp-wait-for-output) | |
1752 ;; parse `ls -l' output ... | |
1753 ;; ... inode | |
1754 (setq res-inode | |
1755 (condition-case err | |
1756 (read (current-buffer)) | |
1757 (invalid-read-syntax | |
1758 (when (and (equal (cadr err) | |
1759 "Integer constant overflow in reader") | |
1760 (string-match | |
1761 "^[0-9]+\\([0-9][0-9][0-9][0-9][0-9]\\)\\'" | |
1762 (caddr err))) | |
1763 (let* ((big (read (substring (caddr err) 0 | |
1764 (match-beginning 1)))) | |
1765 (small (read (match-string 1 (caddr err)))) | |
1766 (twiddle (/ small 65536))) | |
1767 (cons (+ big twiddle) | |
1768 (- small (* twiddle 65536)))))))) | |
1769 ;; ... file mode flags | |
1770 (setq res-filemodes (symbol-name (read (current-buffer)))) | |
1771 ;; ... number links | |
1772 (setq res-numlinks (read (current-buffer))) | |
1773 ;; ... uid and gid | |
1774 (setq res-uid (read (current-buffer))) | |
1775 (setq res-gid (read (current-buffer))) | |
1776 (unless nonnumeric | |
1777 (unless (numberp res-uid) (setq res-uid -1)) | |
1778 (unless (numberp res-gid) (setq res-gid -1))) | |
1779 ;; ... size | |
1780 (setq res-size (read (current-buffer))) | |
1781 ;; From the file modes, figure out other stuff. | |
1782 (setq symlinkp (eq ?l (aref res-filemodes 0))) | |
1783 (setq dirp (eq ?d (aref res-filemodes 0))) | |
1784 ;; if symlink, find out file name pointed to | |
1785 (when symlinkp | |
1786 (search-forward "-> ") | |
1787 (setq res-symlink-target | |
1788 (buffer-substring (point) | |
1789 (tramp-line-end-position)))) | |
1790 ;; return data gathered | |
1791 (list | |
1792 ;; 0. t for directory, string (name linked to) for symbolic | |
1793 ;; link, or nil. | |
1794 (or dirp res-symlink-target nil) | |
1795 ;; 1. Number of links to file. | |
1796 res-numlinks | |
1797 ;; 2. File uid. | |
1798 res-uid | |
1799 ;; 3. File gid. | |
1800 res-gid | |
1801 ;; 4. Last access time, as a list of two integers. First | |
1802 ;; integer has high-order 16 bits of time, second has low 16 | |
1803 ;; bits. | |
1804 ;; 5. Last modification time, likewise. | |
1805 ;; 6. Last status change time, likewise. | |
1806 '(0 0) '(0 0) '(0 0) ;CCC how to find out? | |
1807 ;; 7. Size in bytes (-1, if number is out of range). | |
1808 res-size | |
1809 ;; 8. File modes, as a string of ten letters or dashes as in ls -l. | |
1810 res-filemodes | |
1811 ;; 9. t iff file's gid would change if file were deleted and | |
1812 ;; recreated. | |
1813 nil ;hm? | |
1814 ;; 10. inode number. | |
1815 res-inode | |
1816 ;; 11. Device number. | |
1817 -1 ;hm? | |
1818 ))) | |
1819 | |
1820 (defun tramp-handle-file-attributes-with-perl | |
1821 (multi-method method user host path &optional nonnumeric) | |
1822 "Implement `file-attributes' for tramp files using a Perl script. | |
1823 | |
1824 The Perl command is sent to the remote machine when the connection | |
1825 is initially created and is kept cached by the remote shell." | |
1826 (tramp-send-command | |
1827 multi-method method user host | |
1828 (format "tramp_file_attributes %s" | |
1829 (tramp-shell-quote-argument path))) | |
1830 (tramp-wait-for-output) | |
1831 (let ((result (read (current-buffer)))) | |
1832 (setcar (nthcdr 8 result) | |
1833 (tramp-file-mode-from-int (nth 8 result))) | |
1834 result)) | |
1835 | |
1836 (defun tramp-handle-set-visited-file-modtime (&optional time-list) | |
1837 "Like `set-visited-file-modtime' for tramp files." | |
1838 (unless (buffer-file-name) | |
1839 (error "Can't set-visited-file-modtime: buffer `%s' not visiting a file" | |
1840 (buffer-name))) | |
1841 (when time-list | |
1842 (tramp-run-real-handler 'set-visited-file-modtime (list time-list))) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1843 (let ((f (buffer-file-name)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1844 (coding-system-used nil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1845 (with-parsed-tramp-file-name f nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1846 ;; This operation is not handled by Ange-FTP! |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1847 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1848 (throw 'tramp-forward-to-ange-ftp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1849 (tramp-run-real-handler 'set-visited-file-modtime |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1850 (list time-list)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1851 (let* ((attr (file-attributes f)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1852 (modtime (nth 5 attr))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1853 ;; We use '(0 0) as a don't-know value. See also |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1854 ;; `tramp-handle-file-attributes-with-ls'. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1855 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1856 (setq coding-system-used last-coding-system-used)) |
45861 | 1857 (if (not (equal modtime '(0 0))) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1858 (tramp-run-real-handler 'set-visited-file-modtime (list modtime)) |
45861 | 1859 (save-excursion |
1860 (tramp-send-command | |
1861 multi-method method user host | |
1862 (format "%s -ild %s" | |
1863 (tramp-get-ls-command multi-method method user host) | |
1864 (tramp-shell-quote-argument path))) | |
1865 (tramp-wait-for-output) | |
1866 (setq attr (buffer-substring (point) | |
1867 (progn (end-of-line) (point))))) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1868 (setq tramp-buffer-file-attributes attr)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1869 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1870 (setq last-coding-system-used coding-system-used)) |
45861 | 1871 nil)))) |
1872 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1873 ;; CCC continue here |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1874 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1875 ;; This function makes the same assumption as |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1876 ;; `tramp-handle-set-visited-file-modtime'. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1877 (defun tramp-handle-verify-visited-file-modtime (buf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1878 "Like `verify-visited-file-modtime' for tramp files." |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1879 (with-current-buffer buf |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1880 (let ((f (buffer-file-name))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1881 (with-parsed-tramp-file-name f nil |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1882 (when (tramp-ange-ftp-file-name-p multi-method method) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1883 ;; This one requires a hack since the file name is not passed |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1884 ;; on the arg list. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1885 (let ((buffer-file-name (tramp-make-ange-ftp-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1886 user host path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1887 (tramp-invoke-ange-ftp 'verify-visited-file-modtime buf))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1888 (let* ((attr (file-attributes f)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1889 (modtime (nth 5 attr))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1890 (cond ((and attr (not (equal modtime '(0 0)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1891 ;; Why does `file-attributes' return a list (HIGH |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1892 ;; LOW), but `visited-file-modtime' returns a cons |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1893 ;; (HIGH . LOW)? |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1894 (let ((mt (visited-file-modtime))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1895 (< (abs (tramp-time-diff |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1896 modtime (list (car mt) (cdr mt)))) 2))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1897 (attr |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1898 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1899 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1900 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1901 (format "%s -ild %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1902 (tramp-get-ls-command multi-method method |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1903 user host) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1904 (tramp-shell-quote-argument path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1905 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1906 (setq attr (buffer-substring |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1907 (point) (progn (end-of-line) (point))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1908 (equal tramp-buffer-file-attributes attr)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1909 ;; If file does not exist, say it is not modified. |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1910 (t nil))))))) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1911 |
45861 | 1912 (defadvice clear-visited-file-modtime (after tramp activate) |
1913 "Set `tramp-buffer-file-attributes' back to nil. | |
1914 Tramp uses this variable as an emulation for the actual modtime of the file, | |
1915 if the remote host can't provide the modtime." | |
1916 (setq tramp-buffer-file-attributes nil)) | |
1917 | |
1918 (defun tramp-handle-set-file-modes (filename mode) | |
1919 "Like `set-file-modes' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1920 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1921 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1922 (tramp-invoke-ange-ftp 'set-file-modes filename mode)) |
45861 | 1923 (save-excursion |
1924 (unless (zerop (tramp-send-command-and-check | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1925 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1926 (format "chmod %s %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1927 (tramp-decimal-to-octal mode) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1928 (tramp-shell-quote-argument path)))) |
45861 | 1929 (signal 'file-error |
1930 (list "Doing chmod" | |
1931 ;; FIXME: extract the proper text from chmod's stderr. | |
1932 "error while changing file's mode" | |
1933 filename)))))) | |
1934 | |
1935 ;; Simple functions using the `test' command. | |
1936 | |
1937 (defun tramp-handle-file-executable-p (filename) | |
1938 "Like `file-executable-p' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1939 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1940 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1941 (tramp-invoke-ange-ftp 'file-executable-p filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1942 (zerop (tramp-run-test "-x" filename)))) |
45861 | 1943 |
1944 (defun tramp-handle-file-readable-p (filename) | |
1945 "Like `file-readable-p' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1946 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1947 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1948 (tramp-invoke-ange-ftp 'file-readable-p filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1949 (zerop (tramp-run-test "-r" filename)))) |
45861 | 1950 |
1951 (defun tramp-handle-file-accessible-directory-p (filename) | |
1952 "Like `file-accessible-directory-p' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1953 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1954 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1955 (tramp-invoke-ange-ftp 'file-accessible-directory-p filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1956 (and (zerop (tramp-run-test "-d" filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1957 (zerop (tramp-run-test "-r" filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1958 (zerop (tramp-run-test "-x" filename))))) |
45861 | 1959 |
1960 ;; When the remote shell is started, it looks for a shell which groks | |
1961 ;; tilde expansion. Here, we assume that all shells which grok tilde | |
1962 ;; expansion will also provide a `test' command which groks `-nt' (for | |
1963 ;; newer than). If this breaks, tell me about it and I'll try to do | |
1964 ;; something smarter about it. | |
1965 (defun tramp-handle-file-newer-than-file-p (file1 file2) | |
1966 "Like `file-newer-than-file-p' for tramp files." | |
1967 (cond ((not (file-exists-p file1)) | |
1968 nil) | |
1969 ((not (file-exists-p file2)) | |
1970 t) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1971 ;; We are sure both files exist at this point. We assume that |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1972 ;; both files are Tramp files, otherwise we issue an error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1973 ;; message. Todo: make a better error message. |
45861 | 1974 (t |
1975 (save-excursion | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1976 (with-parsed-tramp-file-name file1 v1 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1977 (with-parsed-tramp-file-name file2 v2 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1978 (when (and (tramp-ange-ftp-file-name-p v1-multi-method v1-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1979 (tramp-ange-ftp-file-name-p v2-multi-method v2-method)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1980 (tramp-invoke-ange-ftp 'file-newer-than-file-p |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1981 file1 file2)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1982 (unless (and (equal v1-multi-method v2-multi-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1983 (equal v1-method v2-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1984 (equal v1-user v2-user) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1985 (equal v1-host v2-host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1986 (signal 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1987 (list "Files must have same method, user, host" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1988 file1 file2))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1989 (unless (and (tramp-tramp-file-p file1) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1990 (tramp-tramp-file-p file2)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1991 (signal 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1992 (list "Files must be tramp files on same host" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1993 file1 file2))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1994 (if (tramp-get-test-groks-nt |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1995 v1-multi-method v1-method v1-user v1-host) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1996 (zerop (tramp-run-test2 "test" file1 file2 "-nt")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1997 (zerop (tramp-run-test2 "tramp_test_nt" file1 file2))))))))) |
45861 | 1998 |
1999 ;; Functions implemented using the basic functions above. | |
2000 | |
2001 (defun tramp-handle-file-modes (filename) | |
2002 "Like `file-modes' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2003 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2004 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2005 (tramp-invoke-ange-ftp 'file-modes filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2006 (when (file-exists-p filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2007 (tramp-mode-string-to-int |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2008 (nth 8 (tramp-handle-file-attributes filename)))))) |
45861 | 2009 |
2010 (defun tramp-handle-file-directory-p (filename) | |
2011 "Like `file-directory-p' for tramp files." | |
2012 ;; Care must be taken that this function returns `t' for symlinks | |
2013 ;; pointing to directories. Surely the most obvious implementation | |
2014 ;; would be `test -d', but that returns false for such symlinks. | |
2015 ;; CCC: Stefan Monnier says that `test -d' follows symlinks. And | |
2016 ;; I now think he's right. So we could be using `test -d', couldn't | |
2017 ;; we? | |
2018 ;; | |
2019 ;; Alternatives: `cd %s', `test -d %s' | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2020 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2021 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2022 (tramp-invoke-ange-ftp 'file-directory-p filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2023 (save-excursion |
45861 | 2024 (zerop |
2025 (tramp-send-command-and-check | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2026 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2027 (format "test -d %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2028 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2029 t))))) ;run command in subshell |
45861 | 2030 |
2031 (defun tramp-handle-file-regular-p (filename) | |
2032 "Like `file-regular-p' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2033 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2034 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2035 (tramp-invoke-ange-ftp 'file-regular-p filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2036 (and (tramp-handle-file-exists-p filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2037 (eq ?- (aref (nth 8 (tramp-handle-file-attributes filename)) 0))))) |
45861 | 2038 |
2039 (defun tramp-handle-file-symlink-p (filename) | |
2040 "Like `file-symlink-p' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2041 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2042 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2043 (tramp-invoke-ange-ftp 'file-symlink-p filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2044 (let ((x (car (tramp-handle-file-attributes filename)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2045 (when (stringp x) x)))) |
45861 | 2046 |
2047 (defun tramp-handle-file-writable-p (filename) | |
2048 "Like `file-writable-p' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2049 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2050 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2051 (tramp-invoke-ange-ftp 'file-writable-p filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2052 (if (tramp-handle-file-exists-p filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2053 ;; Existing files must be writable. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2054 (zerop (tramp-run-test "-w" filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2055 ;; If file doesn't exist, check if directory is writable. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2056 (and (zerop (tramp-run-test |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2057 "-d" (tramp-handle-file-name-directory filename))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2058 (zerop (tramp-run-test |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2059 "-w" (tramp-handle-file-name-directory filename))))))) |
45861 | 2060 |
2061 (defun tramp-handle-file-ownership-preserved-p (filename) | |
2062 "Like `file-ownership-preserved-p' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2063 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2064 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2065 (tramp-invoke-ange-ftp 'file-ownership-preserved-p filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2066 (or (not (tramp-handle-file-exists-p filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2067 ;; Existing files must be writable. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2068 (zerop (tramp-run-test "-O" filename))))) |
45861 | 2069 |
2070 ;; Other file name ops. | |
2071 | |
2072 ;; ;; Matthias Köppe <mkoeppe@mail.math.uni-magdeburg.de> | |
2073 ;; (defun tramp-handle-directory-file-name (directory) | |
2074 ;; "Like `directory-file-name' for tramp files." | |
2075 ;; (if (and (eq (aref directory (- (length directory) 1)) ?/) | |
2076 ;; (not (eq (aref directory (- (length directory) 2)) ?:))) | |
2077 ;; (substring directory 0 (- (length directory) 1)) | |
2078 ;; directory)) | |
2079 | |
2080 ;; Philippe Troin <phil@fifi.org> | |
2081 (defun tramp-handle-directory-file-name (directory) | |
2082 "Like `directory-file-name' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2083 (with-parsed-tramp-file-name directory nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2084 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2085 (tramp-invoke-ange-ftp 'directory-file-name directory)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2086 (let ((directory-length-1 (1- (length directory)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2087 (save-match-data |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2088 (if (and (eq (aref directory directory-length-1) ?/) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2089 (eq (string-match tramp-file-name-regexp directory) 0) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2090 (/= (match-end 0) directory-length-1)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2091 (substring directory 0 directory-length-1) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2092 directory))))) |
45861 | 2093 |
2094 ;; Directory listings. | |
2095 | |
2096 (defun tramp-handle-directory-files (directory &optional full match nosort) | |
2097 "Like `directory-files' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2098 (with-parsed-tramp-file-name directory nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2099 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2100 (tramp-invoke-ange-ftp 'directory-files |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2101 directory full match nosort)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2102 (let (result x) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2103 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2104 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2105 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2106 (concat "cd " (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2107 nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2108 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2109 "tramp-handle-directory-files: couldn't `cd %s'" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2110 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2111 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2112 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2113 (concat (tramp-get-ls-command multi-method method user host) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2114 " -a | cat")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2115 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2116 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2117 (while (zerop (forward-line -1)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2118 (setq x (buffer-substring (point) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2119 (tramp-line-end-position))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2120 (when (or (not match) (string-match match x)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2121 (if full |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2122 (push (concat (file-name-as-directory directory) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2123 x) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2124 result) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2125 (push x result)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2126 (tramp-send-command multi-method method user host "cd") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2127 (tramp-wait-for-output)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2128 result))) |
45861 | 2129 |
2130 ;; This function should return "foo/" for directories and "bar" for | |
2131 ;; files. We use `ls -ad' to get a list of files (including | |
2132 ;; directories), and `find . -type d \! -name . -prune' to get a list | |
2133 ;; of directories. | |
2134 (defun tramp-handle-file-name-all-completions (filename directory) | |
2135 "Like `file-name-all-completions' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2136 (with-parsed-tramp-file-name directory nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2137 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2138 (tramp-invoke-ange-ftp 'file-name-all-completions |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2139 filename directory)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2140 (unless (save-match-data (string-match "/" filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2141 (let* ((nowild tramp-completion-without-shell-p) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2142 result) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2143 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2144 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2145 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2146 (format "cd %s" (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2147 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2148 "tramp-handle-file-name-all-completions: Couldn't `cd %s'" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2149 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2150 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2151 ;; Get a list of directories and files, including reliably |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2152 ;; tagging the directories with a trailing '/'. Because I |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2153 ;; rock. --daniel@danann.net |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2154 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2155 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2156 (format (concat "%s -a %s 2>/dev/null | while read f; do " |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2157 "if test -d \"$f\" 2>/dev/null; " |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2158 "then echo \"$f/\"; else echo \"$f\"; fi; done") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2159 (tramp-get-ls-command multi-method method user host) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2160 (if (or nowild (zerop (length filename))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2161 "" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2162 (format "-d %s*" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2163 (tramp-shell-quote-argument filename))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2164 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2165 ;; Now grab the output. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2166 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2167 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2168 (while (zerop (forward-line -1)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2169 (push (buffer-substring (point) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2170 (tramp-line-end-position)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2171 result)) |
45861 | 2172 |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2173 (tramp-send-command multi-method method user host "cd") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2174 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2175 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2176 ;; Return the list. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2177 (if nowild |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2178 (all-completions filename (mapcar 'list result)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2179 result)))))) |
45861 | 2180 |
2181 | |
2182 ;; The following isn't needed for Emacs 20 but for 19.34? | |
2183 (defun tramp-handle-file-name-completion (filename directory) | |
2184 "Like `file-name-completion' for tramp files." | |
2185 (unless (tramp-tramp-file-p directory) | |
2186 (error | |
2187 "tramp-handle-file-name-completion invoked on non-tramp directory `%s'" | |
2188 directory)) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2189 (with-parsed-tramp-file-name directory nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2190 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2191 (tramp-invoke-ange-ftp 'file-name-completion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2192 filename directory)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2193 (try-completion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2194 filename |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2195 (mapcar (lambda (x) (cons x nil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2196 (tramp-handle-file-name-all-completions filename directory))))) |
45861 | 2197 |
2198 ;; cp, mv and ln | |
2199 | |
2200 (defun tramp-handle-add-name-to-file | |
2201 (filename newname &optional ok-if-already-exists) | |
2202 "Like `add-name-to-file' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2203 (with-parsed-tramp-file-name filename v1 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2204 (with-parsed-tramp-file-name newname v2 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2205 (let ((ln (when v1 (tramp-get-remote-ln |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2206 v1-multi-method v1-method v1-user v1-host)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2207 (unless (and v1-method v2-method v1-user v2-user v1-host v2-host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2208 (equal v1-multi-method v2-multi-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2209 (equal v1-method v2-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2210 (equal v1-user v2-user) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2211 (equal v1-host v2-host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2212 (error "add-name-to-file: %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2213 "only implemented for same method, same user, same host")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2214 (when (and (tramp-ange-ftp-file-name-p v1-multi-method v1-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2215 (tramp-ange-ftp-file-name-p v2-multi-method v2-method)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2216 (tramp-invoke-ange-ftp 'add-name-to-file |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2217 filename newname ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2218 (when (tramp-ange-ftp-file-name-p v1-multi-method v1-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2219 (tramp-invoke-ange-ftp 'add-name-to-file |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2220 filename newname ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2221 (when (tramp-ange-ftp-file-name-p v2-multi-method v2-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2222 (tramp-invoke-ange-ftp 'add-name-to-file |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2223 filename newname ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2224 (when (and (not ok-if-already-exists) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2225 (file-exists-p newname) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2226 (not (numberp ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2227 (y-or-n-p |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2228 (format |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2229 "File %s already exists; make it a new name anyway? " |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2230 newname))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2231 (error "add-name-to-file: file %s already exists" newname)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2232 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2233 v1-multi-method v1-method v1-user v1-host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2234 (format "%s %s %s" ln (tramp-shell-quote-argument v1-path) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2235 (tramp-shell-quote-argument v2-path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2236 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2237 "error with add-name-to-file, see buffer `%s' for details" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2238 (buffer-name)))))) |
45861 | 2239 |
2240 (defun tramp-handle-copy-file | |
2241 (filename newname &optional ok-if-already-exists keep-date) | |
2242 "Like `copy-file' for tramp files." | |
2243 ;; Check if both files are local -- invoke normal copy-file. | |
2244 ;; Otherwise, use tramp from local system. | |
2245 (setq filename (expand-file-name filename)) | |
2246 (setq newname (expand-file-name newname)) | |
2247 ;; At least one file a tramp file? | |
2248 (if (or (tramp-tramp-file-p filename) | |
2249 (tramp-tramp-file-p newname)) | |
2250 (tramp-do-copy-or-rename-file | |
2251 'copy filename newname ok-if-already-exists keep-date) | |
2252 (tramp-run-real-handler | |
2253 'copy-file | |
2254 (list filename newname ok-if-already-exists keep-date)))) | |
2255 | |
2256 (defun tramp-handle-rename-file | |
2257 (filename newname &optional ok-if-already-exists) | |
2258 "Like `rename-file' for tramp files." | |
2259 ;; Check if both files are local -- invoke normal rename-file. | |
2260 ;; Otherwise, use tramp from local system. | |
2261 (setq filename (expand-file-name filename)) | |
2262 (setq newname (expand-file-name newname)) | |
2263 ;; At least one file a tramp file? | |
2264 (if (or (tramp-tramp-file-p filename) | |
2265 (tramp-tramp-file-p newname)) | |
2266 (tramp-do-copy-or-rename-file | |
2267 'rename filename newname ok-if-already-exists) | |
2268 (tramp-run-real-handler 'rename-file | |
2269 (list filename newname ok-if-already-exists)))) | |
2270 | |
2271 (defun tramp-do-copy-or-rename-file | |
2272 (op filename newname &optional ok-if-already-exists keep-date) | |
2273 "Copy or rename a remote file. | |
2274 OP must be `copy' or `rename' and indicates the operation to perform. | |
2275 FILENAME specifies the file to copy or rename, NEWNAME is the name of | |
2276 the new file (for copy) or the new name of the file (for rename). | |
2277 OK-IF-ALREADY-EXISTS means don't barf if NEWNAME exists already. | |
2278 KEEP-DATE means to make sure that NEWNAME has the same timestamp | |
2279 as FILENAME. | |
2280 | |
2281 This function is invoked by `tramp-handle-copy-file' and | |
2282 `tramp-handle-rename-file'. It is an error if OP is neither of `copy' | |
2283 and `rename'. FILENAME and NEWNAME must be absolute file names." | |
2284 (unless (memq op '(copy rename)) | |
2285 (error "Unknown operation `%s', must be `copy' or `rename'" op)) | |
2286 (unless ok-if-already-exists | |
2287 (when (file-exists-p newname) | |
2288 (signal 'file-already-exists | |
2289 (list newname)))) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2290 (with-parsed-tramp-file-name filename v1 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2291 (with-parsed-tramp-file-name newname v2 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2292 (when (and (tramp-ange-ftp-file-name-p v1-multi-method v1-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2293 (tramp-ange-ftp-file-name-p v2-multi-method v2-method)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2294 (tramp-invoke-ange-ftp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2295 (if (eq op 'copy) 'copy-file 'rename-file) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2296 filename newname ok-if-already-exists keep-date)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2297 (let* ((mmeth (tramp-file-name-multi-method (or v1 v2))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2298 (meth (tramp-file-name-method (or v1 v2))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2299 (rcp-program (tramp-get-rcp-program mmeth meth)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2300 (rcp-args (tramp-get-rcp-args mmeth meth)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2301 (trampbuf (get-buffer-create "*tramp output*"))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2302 ;; Check if we can use a shortcut. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2303 (if (and v1-method v2-method |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2304 (equal v1-multi-method v2-multi-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2305 (equal v1-method v2-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2306 (equal v1-host v2-host) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2307 (equal v1-user v2-user)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2308 ;; Shortcut: if method, host, user are the same for both |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2309 ;; files, we invoke `cp' or `mv' on the remote host directly. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2310 (tramp-do-copy-or-rename-file-directly |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2311 op |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2312 v1-multi-method v1-method v1-user v1-host v1-path v2-path |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2313 keep-date) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2314 ;; New algorithm: copy file first. Then, if operation is |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2315 ;; `rename', go back and delete the original file if the copy |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2316 ;; was successful. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2317 (if rcp-program |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2318 ;; The following code uses a tramp program to copy the file. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2319 (let ((f1 (if (not v1) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2320 filename |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2321 (tramp-make-rcp-program-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2322 v1-user v1-host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2323 (tramp-shell-quote-argument v1-path)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2324 (f2 (if (not v2) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2325 newname |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2326 (tramp-make-rcp-program-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2327 v2-user v2-host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2328 (tramp-shell-quote-argument v2-path)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2329 (default-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2330 (if (tramp-tramp-file-p default-directory) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2331 (tramp-temporary-file-directory) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2332 default-directory))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2333 (when keep-date |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2334 (add-to-list 'rcp-args |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2335 (tramp-get-rcp-keep-date-arg mmeth meth))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2336 (save-excursion (set-buffer trampbuf) (erase-buffer)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2337 (unless (equal 0 (apply #'call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2338 (tramp-get-rcp-program mmeth meth) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2339 nil trampbuf nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2340 (append rcp-args (list f1 f2)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2341 (pop-to-buffer trampbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2342 (error (concat "tramp-do-copy-or-rename-file: %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2343 " didn't work, see buffer `%s' for details") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2344 (tramp-get-rcp-program mmeth meth) trampbuf))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2345 ;; The following code uses an inline method for copying. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2346 ;; Let's start with a simple-minded approach: we create a new |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2347 ;; buffer, insert the contents of the source file into it, |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2348 ;; then write out the buffer. This should work fine, whether |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2349 ;; the source or the target files are tramp files. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2350 ;; CCC TODO: error checking |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2351 (when keep-date |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2352 (tramp-message |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2353 1 (concat "Warning: cannot preserve file time stamp" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2354 " with inline copying across machines"))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2355 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2356 (set-buffer trampbuf) (erase-buffer) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2357 (insert-file-contents-literally filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2358 (let ((coding-system-for-write 'no-conversion)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2359 (write-region (point-min) (point-max) newname)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2360 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2361 ;; If the operation was `rename', delete the original file. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2362 (unless (eq op 'copy) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2363 (delete-file filename))))))) |
45861 | 2364 |
2365 (defun tramp-do-copy-or-rename-file-directly | |
2366 (op multi-method method user host path1 path2 keep-date) | |
2367 "Invokes `cp' or `mv' on the remote system. | |
2368 OP must be one of `copy' or `rename', indicating `cp' or `mv', | |
2369 respectively. METHOD, USER, and HOST specify the connection. | |
2370 PATH1 and PATH2 specify the two arguments of `cp' or `mv'. | |
2371 If KEEP-DATE is non-nil, preserve the time stamp when copying." | |
2372 ;; CCC: What happens to the timestamp when renaming? | |
2373 (let ((cmd (cond ((and (eq op 'copy) keep-date) "cp -f -p") | |
2374 ((eq op 'copy) "cp -f") | |
2375 ((eq op 'rename) "mv -f") | |
2376 (t (error | |
2377 "Unknown operation `%s', must be `copy' or `rename'" | |
2378 op))))) | |
2379 (save-excursion | |
2380 (tramp-barf-unless-okay | |
2381 multi-method method user host | |
2382 (format "%s %s %s" | |
2383 cmd | |
2384 (tramp-shell-quote-argument path1) | |
2385 (tramp-shell-quote-argument path2)) | |
2386 nil 'file-error | |
2387 "Copying directly failed, see buffer `%s' for details." | |
2388 (buffer-name))))) | |
2389 | |
2390 ;; mkdir | |
2391 (defun tramp-handle-make-directory (dir &optional parents) | |
2392 "Like `make-directory' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2393 (with-parsed-tramp-file-name dir nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2394 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2395 (tramp-invoke-ange-ftp 'make-directory dir parents)) |
45861 | 2396 (tramp-barf-unless-okay |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2397 multi-method method user host |
45861 | 2398 (format " %s %s" |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2399 (if parents "mkdir -p" "mkdir") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2400 (tramp-shell-quote-argument path)) |
45861 | 2401 nil 'file-error |
2402 "Couldn't make directory %s" dir))) | |
2403 | |
2404 ;; CCC error checking? | |
2405 (defun tramp-handle-delete-directory (directory) | |
2406 "Like `delete-directory' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2407 (with-parsed-tramp-file-name directory nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2408 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2409 (tramp-invoke-ange-ftp 'delete-directory directory)) |
45861 | 2410 (save-excursion |
2411 (tramp-send-command | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2412 multi-method method user host |
45861 | 2413 (format "rmdir %s ; echo ok" |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2414 (tramp-shell-quote-argument path))) |
45861 | 2415 (tramp-wait-for-output)))) |
2416 | |
2417 (defun tramp-handle-delete-file (filename) | |
2418 "Like `delete-file' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2419 (with-parsed-tramp-file-name filename nil |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2420 (when (tramp-ange-ftp-file-name-p multi-method method) |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2421 (tramp-invoke-ange-ftp 'delete-file filename)) |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2422 (save-excursion |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2423 (unless (zerop (tramp-send-command-and-check |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2424 multi-method method user host |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2425 (format "rm -f %s" |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2426 (tramp-shell-quote-argument path)))) |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2427 (signal 'file-error "Couldn't delete Tramp file"))))) |
45861 | 2428 |
2429 ;; Dired. | |
2430 | |
2431 ;; CCC: This does not seem to be enough. Something dies when | |
2432 ;; we try and delete two directories under TRAMP :/ | |
2433 (defun tramp-handle-dired-recursive-delete-directory (filename) | |
2434 "Recursively delete the directory given. | |
2435 This is like `dired-recursive-delete-directory' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2436 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2437 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2438 (tramp-invoke-ange-ftp 'dired-recursive-delete-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2439 filename)) |
45861 | 2440 ;; run a shell command 'rm -r <path>' |
2441 ;; Code shamelessly stolen for the dired implementation and, um, hacked :) | |
2442 (or (tramp-handle-file-exists-p filename) | |
2443 (signal | |
2444 'file-error | |
2445 (list "Removing old file name" "no such directory" filename))) | |
2446 ;; Which is better, -r or -R? (-r works for me <daniel@danann.net>) | |
2447 (tramp-send-command multi-method method user host | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2448 (format "rm -r %s" (tramp-shell-quote-argument path))) |
45861 | 2449 ;; Wait for the remote system to return to us... |
2450 ;; This might take a while, allow it plenty of time. | |
2451 (tramp-wait-for-output 120) | |
2452 ;; Make sure that it worked... | |
2453 (and (tramp-handle-file-exists-p filename) | |
2454 (error "Failed to recusively delete %s" filename)))) | |
2455 | |
2456 | |
2457 (defun tramp-handle-dired-call-process (program discard &rest arguments) | |
2458 "Like `dired-call-process' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2459 (with-parsed-tramp-file-name default-directory nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2460 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2461 (let ((default-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2462 (tramp-make-ange-ftp-file-name user host path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2463 (tramp-invoke-ange-ftp 'dired-call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2464 program discard arguments))) |
45861 | 2465 (save-excursion |
2466 (tramp-barf-unless-okay | |
2467 multi-method method user host | |
2468 (format "cd %s" (tramp-shell-quote-argument path)) | |
2469 nil 'file-error | |
2470 "tramp-handle-dired-call-process: Couldn't `cd %s'" | |
2471 (tramp-shell-quote-argument path)) | |
2472 (tramp-send-command | |
2473 multi-method method user host | |
2474 (mapconcat #'tramp-shell-quote-argument (cons program arguments) " ")) | |
2475 (tramp-wait-for-output)) | |
2476 (unless discard | |
2477 (insert-buffer (tramp-get-buffer multi-method method user host))) | |
2478 (save-excursion | |
2479 (prog1 | |
2480 (tramp-send-command-and-check multi-method method user host nil) | |
2481 (tramp-send-command multi-method method user host "cd") | |
2482 (tramp-wait-for-output))))) | |
2483 | |
2484 ;; Pacify byte-compiler. The function is needed on XEmacs only. I'm | |
2485 ;; not sure at all that this is the right way to do it, but let's hope | |
2486 ;; it works for now, and wait for a guru to point out the Right Way to | |
2487 ;; achieve this. | |
2488 ;;(eval-when-compile | |
2489 ;; (unless (fboundp 'dired-insert-set-properties) | |
2490 ;; (fset 'dired-insert-set-properties 'ignore))) | |
2491 ;; Gerd suggests this: | |
2492 (eval-when-compile (require 'dired)) | |
2493 ;; Note that dired is required at run-time, too, when it is needed. | |
2494 ;; It is only needed on XEmacs for the function | |
2495 ;; `dired-insert-set-properties'. | |
2496 | |
2497 (defun tramp-handle-insert-directory | |
2498 (filename switches &optional wildcard full-directory-p) | |
2499 "Like `insert-directory' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2500 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2501 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2502 (tramp-invoke-ange-ftp 'insert-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2503 filename switches wildcard full-directory-p)) |
45861 | 2504 (tramp-message-for-buffer |
2505 multi-method method user host 10 | |
2506 "Inserting directory `ls %s %s', wildcard %s, fulldir %s" | |
2507 switches filename (if wildcard "yes" "no") | |
2508 (if full-directory-p "yes" "no")) | |
2509 (when wildcard | |
2510 (setq wildcard (file-name-nondirectory path)) | |
2511 (setq path (file-name-directory path))) | |
2512 (when (listp switches) | |
2513 (setq switches (mapconcat 'identity switches " "))) | |
2514 (unless full-directory-p | |
2515 (setq switches (concat "-d " switches))) | |
2516 (when wildcard | |
2517 (setq switches (concat switches " " wildcard))) | |
2518 (save-excursion | |
2519 ;; If `full-directory-p', we just say `ls -l FILENAME'. | |
2520 ;; Else we chdir to the parent directory, then say `ls -ld BASENAME'. | |
2521 (if full-directory-p | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2522 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2523 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2524 (format "%s %s %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2525 (tramp-get-ls-command multi-method method user host) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2526 switches |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2527 (if wildcard |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2528 path |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2529 (tramp-shell-quote-argument (concat path "."))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2530 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2531 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2532 (format "cd %s" (tramp-shell-quote-argument |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2533 (file-name-directory path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2534 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2535 "Couldn't `cd %s'" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2536 (tramp-shell-quote-argument (file-name-directory path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2537 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2538 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2539 (format "%s %s %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2540 (tramp-get-ls-command multi-method method user host) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2541 switches |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2542 (if full-directory-p |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2543 ;; Add "/." to make sure we got complete dir |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2544 ;; listing for symlinks, too. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2545 (concat (file-name-as-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2546 (file-name-nondirectory path)) ".") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2547 (file-name-nondirectory path))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2548 (sit-for 1) ;needed for rsh but not ssh? |
45861 | 2549 (tramp-wait-for-output)) |
2550 (insert-buffer (tramp-get-buffer multi-method method user host)) | |
2551 ;; On XEmacs, we want to call (exchange-point-and-mark t), but | |
2552 ;; that doesn't exist on Emacs, so we use this workaround instead. | |
2553 ;; Since zmacs-region-stays doesn't exist in Emacs, this ought to | |
2554 ;; be safe. Thanks to Daniel Pittman <daniel@danann.net>. | |
2555 (let ((zmacs-region-stays t)) | |
2556 (exchange-point-and-mark)) | |
2557 (save-excursion | |
2558 (tramp-send-command multi-method method user host "cd") | |
2559 (tramp-wait-for-output)) | |
2560 ;; Another XEmacs specialty follows. What's the right way to do | |
2561 ;; it? | |
2562 (when (and (featurep 'xemacs) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2563 (eq major-mode 'dired-mode)) |
45861 | 2564 (save-excursion |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2565 (require 'dired) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2566 (dired-insert-set-properties (point) (mark t)))))) |
45861 | 2567 |
2568 ;; Continuation of kluge to pacify byte-compiler. | |
2569 ;;(eval-when-compile | |
2570 ;; (when (eq (symbol-function 'dired-insert-set-properties) 'ignore) | |
2571 ;; (fmakunbound 'dired-insert-set-properties))) | |
2572 | |
2573 ;; CCC is this the right thing to do? | |
2574 (defun tramp-handle-unhandled-file-name-directory (filename) | |
2575 "Like `unhandled-file-name-directory' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2576 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2577 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2578 (tramp-invoke-ange-ftp 'unhandled-file-name-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2579 filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2580 (expand-file-name "~/"))) |
45861 | 2581 |
2582 ;; Canonicalization of file names. | |
2583 | |
2584 (defun tramp-drop-volume-letter (name) | |
2585 "Cut off unnecessary drive letter from file NAME. | |
2586 The function `tramp-handle-expand-file-name' calls `expand-file-name' | |
2587 locally on a remote file name. When the local system is a W32 system | |
2588 but the remote system is Unix, this introduces a superfluous drive | |
2589 letter into the file name. This function removes it. | |
2590 | |
2591 Doesn't do anything if the NAME does not start with a drive letter." | |
2592 (if (and (> (length name) 1) | |
2593 (char-equal (aref name 1) ?:) | |
2594 (let ((c1 (aref name 0))) | |
2595 (or (and (>= c1 ?A) (<= c1 ?Z)) | |
2596 (and (>= c1 ?a) (<= c1 ?z))))) | |
2597 (substring name 2) | |
2598 name)) | |
2599 | |
2600 (defun tramp-handle-expand-file-name (name &optional dir) | |
2601 "Like `expand-file-name' for tramp files." | |
2602 ;; If DIR is not given, use DEFAULT-DIRECTORY or "/". | |
2603 (setq dir (or dir default-directory "/")) | |
2604 ;; Unless NAME is absolute, concat DIR and NAME. | |
2605 (unless (file-name-absolute-p name) | |
2606 (setq name (concat (file-name-as-directory dir) name))) | |
2607 ;; If NAME is not a tramp file, run the real handler | |
2608 (if (not (tramp-tramp-file-p name)) | |
2609 (tramp-run-real-handler 'expand-file-name | |
2610 (list name nil)) | |
2611 ;; Dissect NAME. | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2612 (with-parsed-tramp-file-name name nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2613 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2614 (tramp-invoke-ange-ftp 'expand-file-name name nil)) |
45861 | 2615 (unless (file-name-absolute-p path) |
2616 (setq path (concat "~/" path))) | |
2617 (save-excursion | |
2618 ;; Tilde expansion if necessary. This needs a shell which | |
2619 ;; groks tilde expansion! The function `tramp-find-shell' is | |
2620 ;; supposed to find such a shell on the remote host. Please | |
2621 ;; tell me about it when this doesn't work on your system. | |
2622 (when (string-match "\\`\\(~[^/]*\\)\\(.*\\)\\'" path) | |
2623 (let ((uname (match-string 1 path)) | |
2624 (fname (match-string 2 path))) | |
2625 ;; CCC fanatic error checking? | |
2626 (set-buffer (tramp-get-buffer multi-method method user host)) | |
2627 (erase-buffer) | |
2628 (tramp-send-command | |
2629 multi-method method user host | |
2630 (format "cd %s; pwd" uname) | |
2631 t) | |
2632 (tramp-wait-for-output) | |
2633 (goto-char (point-min)) | |
2634 (setq uname (buffer-substring (point) (tramp-line-end-position))) | |
2635 (setq path (concat uname fname)) | |
2636 (erase-buffer))) | |
2637 ;; No tilde characters in file name, do normal | |
2638 ;; expand-file-name (this does "/./" and "/../"). We bind | |
2639 ;; directory-sep-char here for XEmacs on Windows, which would | |
2640 ;; otherwise use backslash. | |
2641 (let ((directory-sep-char ?/)) | |
2642 (tramp-make-tramp-file-name | |
2643 multi-method method user host | |
2644 (tramp-drop-volume-letter | |
2645 (tramp-run-real-handler 'expand-file-name (list path))))))))) | |
2646 | |
2647 ;; Remote commands. | |
2648 | |
2649 (defun tramp-handle-shell-command (command &optional output-buffer error-buffer) | |
2650 "Like `shell-command' for tramp files. | |
2651 This will break if COMMAND prints a newline, followed by the value of | |
2652 `tramp-end-of-output', followed by another newline." | |
2653 (if (tramp-tramp-file-p default-directory) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2654 (with-parsed-tramp-file-name default-directory nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2655 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2656 (let ((default-directory (tramp-make-ange-ftp-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2657 user host path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2658 (tramp-invoke-ange-ftp 'shell-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2659 command output-buffer error-buffer))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2660 (let (status) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2661 (when (string-match "&[ \t]*\\'" command) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2662 (error "Tramp doesn't grok asynchronous shell commands, yet")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2663 (when error-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2664 (error "Tramp doesn't grok optional third arg ERROR-BUFFER, yet")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2665 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2666 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2667 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2668 (format "cd %s" (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2669 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2670 "tramp-handle-shell-command: Couldn't `cd %s'" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2671 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2672 (tramp-send-command multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2673 (concat command "; tramp_old_status=$?")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2674 ;; This will break if the shell command prints "/////" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2675 ;; somewhere. Let's just hope for the best... |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2676 (tramp-wait-for-output)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2677 (unless output-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2678 (setq output-buffer (get-buffer-create "*Shell Command Output*")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2679 (set-buffer output-buffer) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2680 (erase-buffer)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2681 (unless (bufferp output-buffer) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2682 (setq output-buffer (current-buffer))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2683 (set-buffer output-buffer) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2684 (insert-buffer (tramp-get-buffer multi-method method user host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2685 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2686 (tramp-send-command multi-method method user host "cd") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2687 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2688 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2689 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2690 (concat "tramp_set_exit_status $tramp_old_status;" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2691 " echo tramp_exit_status $?")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2692 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2693 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2694 (unless (search-backward "tramp_exit_status " nil t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2695 (error "Couldn't find exit status of `%s'" command)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2696 (skip-chars-forward "^ ") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2697 (setq status (read (current-buffer)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2698 (unless (zerop (buffer-size)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2699 (pop-to-buffer output-buffer)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2700 status))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2701 ;; The following is only executed if something strange was |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2702 ;; happening. Emit a helpful message and do it anyway. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2703 (message "tramp-handle-shell-command called with non-tramp directory: `%s'" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2704 default-directory) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2705 (tramp-run-real-handler 'shell-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2706 (list command output-buffer error-buffer))) |
45861 | 2707 |
2708 ;; File Editing. | |
2709 | |
2710 (defsubst tramp-make-temp-file () | |
2711 (funcall (if (fboundp 'make-temp-file) 'make-temp-file 'make-temp-name) | |
2712 (expand-file-name tramp-temp-name-prefix | |
2713 (tramp-temporary-file-directory)))) | |
2714 | |
2715 (defun tramp-handle-file-local-copy (filename) | |
2716 "Like `file-local-copy' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2717 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2718 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2719 (tramp-invoke-ange-ftp 'file-local-copy filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2720 (let ((trampbuf (get-buffer-create "*tramp output*")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2721 tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2722 (unless (file-exists-p filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2723 (error "Cannot make local copy of non-existing file `%s'" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2724 filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2725 (setq tmpfil (tramp-make-temp-file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2726 (cond ((tramp-get-rcp-program multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2727 ;; Use tramp-like program for file transfer. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2728 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2729 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2730 5 "Fetching %s to tmp file %s..." filename tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2731 (save-excursion (set-buffer trampbuf) (erase-buffer)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2732 (unless (equal |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2733 0 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2734 (apply #'call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2735 (tramp-get-rcp-program multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2736 nil trampbuf nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2737 (append (tramp-get-rcp-args multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2738 (list |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2739 (tramp-make-rcp-program-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2740 user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2741 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2742 tmpfil)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2743 (pop-to-buffer trampbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2744 (error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2745 (concat "tramp-handle-file-local-copy: `%s' didn't work, " |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2746 "see buffer `%s' for details") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2747 (tramp-get-rcp-program multi-method method) trampbuf)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2748 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2749 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2750 5 "Fetching %s to tmp file %s...done" filename tmpfil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2751 ((and (tramp-get-encoding-command multi-method method) |
45861 | 2752 (tramp-get-decoding-command multi-method method)) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2753 ;; Use inline encoding for file transfer. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2754 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2755 ;; Following line for setting tramp-current-method, |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2756 ;; tramp-current-user, tramp-current-host. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2757 (set-buffer (tramp-get-buffer multi-method method user host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2758 (tramp-message 5 "Encoding remote file %s..." filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2759 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2760 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2761 (concat (tramp-get-encoding-command multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2762 " < " (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2763 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2764 "Encoding remote file failed, see buffer `%s' for details" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2765 (tramp-get-buffer multi-method method user host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2766 ;; Remove trailing status code |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2767 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2768 (delete-region (point) (progn (forward-line -1) (point))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2769 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2770 (tramp-message 5 "Decoding remote file %s..." filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2771 (if (and (tramp-get-decoding-function multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2772 (fboundp (tramp-get-decoding-function |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2773 multi-method method))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2774 ;; If tramp-decoding-function is defined for this |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2775 ;; method, we call it. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2776 (let ((tmpbuf (get-buffer-create " *tramp tmp*"))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2777 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2778 (erase-buffer) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2779 (insert-buffer (tramp-get-buffer multi-method method |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2780 user host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2781 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2782 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2783 6 "Decoding remote file %s with function %s..." |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2784 filename |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2785 (tramp-get-decoding-function multi-method method)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2786 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2787 (let ((coding-system-for-write 'no-conversion)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2788 (funcall (tramp-get-decoding-function |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2789 multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2790 (point-min) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2791 (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2792 (write-region (point-min) (point-max) tmpfil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2793 (kill-buffer tmpbuf)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2794 ;; If tramp-decoding-function is not defined for this |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2795 ;; method, we invoke tramp-decoding-command instead. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2796 (let ((tmpfil2 (tramp-make-temp-file))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2797 (write-region (point-min) (point-max) tmpfil2) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2798 (tramp-message |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2799 6 "Decoding remote file %s with command %s..." |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2800 filename |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2801 (tramp-get-decoding-command multi-method method)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2802 (call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2803 tramp-sh-program |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2804 tmpfil2 ;input |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2805 nil ;output |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2806 nil ;display |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2807 "-c" (concat (tramp-get-decoding-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2808 multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2809 " > " tmpfil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2810 (delete-file tmpfil2))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2811 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2812 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2813 5 "Decoding remote file %s...done" filename))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2814 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2815 (t (error "Wrong method specification for `%s'" method))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2816 tmpfil))) |
45861 | 2817 |
2818 | |
2819 (defun tramp-handle-insert-file-contents | |
2820 (filename &optional visit beg end replace) | |
2821 "Like `insert-file-contents' for tramp files." | |
2822 (barf-if-buffer-read-only) | |
2823 (setq filename (expand-file-name filename)) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2824 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2825 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2826 (tramp-invoke-ange-ftp 'insert-file-contents |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2827 filename visit beg end replace)) |
45861 | 2828 (if (not (tramp-handle-file-exists-p filename)) |
2829 (progn | |
2830 (when visit | |
2831 (setq buffer-file-name filename) | |
2832 (set-visited-file-modtime) | |
2833 (set-buffer-modified-p nil)) | |
2834 (signal 'file-error | |
2835 (format "File `%s' not found on remote host" filename)) | |
2836 (list (tramp-handle-expand-file-name filename) 0)) | |
2837 (let ((local-copy (tramp-handle-file-local-copy filename)) | |
2838 (coding-system-used nil) | |
2839 (result nil)) | |
2840 (when visit | |
2841 (setq buffer-file-name filename) | |
2842 (set-visited-file-modtime) | |
2843 (set-buffer-modified-p nil)) | |
2844 (tramp-message-for-buffer | |
2845 multi-method method user host | |
2846 9 "Inserting local temp file `%s'..." local-copy) | |
2847 (setq result | |
2848 (tramp-run-real-handler 'insert-file-contents | |
2849 (list local-copy nil beg end replace))) | |
2850 ;; Now `last-coding-system-used' has right value. Remember it. | |
2851 (when (boundp 'last-coding-system-used) | |
2852 (setq coding-system-used last-coding-system-used)) | |
2853 (tramp-message 9 "Inserting local temp file `%s'...done" local-copy) | |
2854 (delete-file local-copy) | |
2855 (when (boundp 'last-coding-system-used) | |
2856 (setq last-coding-system-used coding-system-used)) | |
2857 (list (expand-file-name filename) | |
2858 (second result)))))) | |
2859 | |
2860 ;; CCC grok APPEND, LOCKNAME, CONFIRM | |
2861 (defun tramp-handle-write-region | |
2862 (start end filename &optional append visit lockname confirm) | |
2863 "Like `write-region' for tramp files." | |
2864 (unless (eq append nil) | |
2865 (error "Cannot append to file using tramp (`%s')" filename)) | |
2866 (setq filename (expand-file-name filename)) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2867 ;; Following part commented out because we don't know what to do about |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2868 ;; file locking, and it does not appear to be a problem to ignore it. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2869 ;; Ange-ftp ignores it, too. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2870 ;; (when (and lockname (stringp lockname)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2871 ;; (setq lockname (expand-file-name lockname))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2872 ;; (unless (or (eq lockname nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2873 ;; (string= lockname filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2874 ;; (error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2875 ;; "tramp-handle-write-region: LOCKNAME must be nil or equal FILENAME")) |
45861 | 2876 ;; XEmacs takes a coding system as the sevent argument, not `confirm' |
2877 (when (and (not (featurep 'xemacs)) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2878 confirm (file-exists-p filename)) |
45861 | 2879 (unless (y-or-n-p (format "File %s exists; overwrite anyway? " |
2880 filename)) | |
2881 (error "File not overwritten"))) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2882 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2883 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2884 (tramp-invoke-ange-ftp 'write-region |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2885 start end filename append visit lockname confirm)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2886 (let ((curbuf (current-buffer)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2887 (rcp-program (tramp-get-rcp-program multi-method method)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2888 (rcp-args (tramp-get-rcp-args multi-method method)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2889 (encoding-command (tramp-get-encoding-command multi-method method)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2890 (encoding-function |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2891 (tramp-get-encoding-function multi-method method)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2892 (decoding-command (tramp-get-decoding-command multi-method method)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2893 (trampbuf (get-buffer-create "*tramp output*")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2894 ;; We use this to save the value of `last-coding-system-used' |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2895 ;; after writing the tmp file. At the end of the function, |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2896 ;; we set `last-coding-system-used' to this saved value. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2897 ;; This way, any intermediary coding systems used while |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2898 ;; talking to the remote shell or suchlike won't hose this |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2899 ;; variable. This approach was snarfed from ange-ftp.el. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2900 coding-system-used |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2901 tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2902 ;; Write region into a tmp file. This isn't really needed if we |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2903 ;; use an encoding function, but currently we use it always |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2904 ;; because this makes the logic simpler. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2905 (setq tmpfil (tramp-make-temp-file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2906 ;; We say `no-message' here because we don't want the visited file |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2907 ;; modtime data to be clobbered from the temp file. We call |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2908 ;; `set-visited-file-modtime' ourselves later on. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2909 (tramp-run-real-handler |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2910 'write-region |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2911 (if confirm ; don't pass this arg unless defined for backward compat. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2912 (list start end tmpfil append 'no-message lockname confirm) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2913 (list start end tmpfil append 'no-message lockname))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2914 ;; Now, `last-coding-system-used' has the right value. Remember it. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2915 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2916 (setq coding-system-used last-coding-system-used)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2917 ;; This is a bit lengthy due to the different methods possible for |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2918 ;; file transfer. First, we check whether the method uses an rcp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2919 ;; program. If so, we call it. Otherwise, both encoding and |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2920 ;; decoding command must be specified. However, if the method |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2921 ;; _also_ specifies an encoding function, then that is used for |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2922 ;; encoding the contents of the tmp file. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2923 (cond (rcp-program |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2924 ;; use rcp-like program for file transfer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2925 (let ((argl (append rcp-args |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2926 (list |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2927 tmpfil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2928 (tramp-make-rcp-program-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2929 user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2930 (tramp-shell-quote-argument path)))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2931 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2932 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2933 6 "Writing tmp file using `%s'..." rcp-program) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2934 (save-excursion (set-buffer trampbuf) (erase-buffer)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2935 (when tramp-debug-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2936 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2937 (set-buffer (tramp-get-debug-buffer multi-method |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2938 method user host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2939 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2940 (tramp-insert-with-face |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2941 'bold (format "$ %s %s\n" rcp-program |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2942 (mapconcat 'identity argl " "))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2943 (unless (equal 0 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2944 (apply #'call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2945 rcp-program nil trampbuf nil argl)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2946 (pop-to-buffer trampbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2947 (error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2948 "Cannot write region to file `%s', command `%s' failed" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2949 filename rcp-program)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2950 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2951 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2952 6 "Transferring file using `%s'...done" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2953 rcp-program))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2954 ((and encoding-command decoding-command) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2955 ;; Use inline file transfer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2956 (let ((tmpbuf (get-buffer-create " *tramp file transfer*"))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2957 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2958 ;; Encode tmpfil into tmpbuf |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2959 (tramp-message-for-buffer multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2960 5 "Encoding region...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2961 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2962 (erase-buffer) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2963 ;; Use encoding function or command. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2964 (if (and encoding-function |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2965 (fboundp encoding-function)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2966 (progn |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2967 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2968 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2969 6 "Encoding region using function...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2970 (insert-file-contents-literally tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2971 ;; CCC. The following `let' is a workaround for |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2972 ;; the base64.el that comes with pgnus-0.84. If |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2973 ;; both of the following conditions are |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2974 ;; satisfied, it tries to write to a local file |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2975 ;; in default-directory, but at this point, |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2976 ;; default-directory is remote. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2977 ;; (CALL-PROCESS-REGION can't write to remote |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2978 ;; files, it seems.) The file in question is a |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2979 ;; tmp file anyway. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2980 (let ((default-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2981 (tramp-temporary-file-directory))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2982 (funcall encoding-function (point-min) (point-max))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2983 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2984 (unless (bolp) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2985 (newline))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2986 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2987 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2988 6 "Encoding region using command...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2989 (unless (equal 0 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2990 (call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2991 tramp-sh-program |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2992 tmpfil ;input = local tmp file |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2993 t ;output is current buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2994 nil ;don't redisplay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2995 "-c" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2996 encoding-command)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2997 (pop-to-buffer trampbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2998 (error (concat "Cannot write to `%s', local encoding" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2999 " command `%s' failed") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3000 filename encoding-command))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3001 ;; Send tmpbuf into remote decoding command which |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3002 ;; writes to remote file. Because this happens on the |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3003 ;; remote host, we cannot use the function. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3004 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3005 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3006 5 "Decoding region into remote file %s..." filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3007 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3008 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3009 (format "%s >%s <<'EOF'" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3010 decoding-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3011 (tramp-shell-quote-argument path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3012 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3013 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3014 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3015 6 "Sending data to remote host...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3016 (tramp-send-region multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3017 (point-min) (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3018 ;; wait for remote decoding to complete |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3019 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3020 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3021 6 "Sending end of data token...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3022 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3023 multi-method method user host "EOF") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3024 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3025 multi-method method user host 6 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3026 "Waiting for remote host to process data...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3027 (set-buffer (tramp-get-buffer multi-method method user host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3028 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3029 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3030 multi-method method user host nil nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3031 (concat "Couldn't write region to `%s'," |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3032 " decode using `%s' failed") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3033 filename decoding-command) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3034 (tramp-message 5 "Decoding region into remote file %s...done" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3035 filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3036 (kill-buffer tmpbuf)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3037 (t |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3038 (error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3039 (concat "Method `%s' should specify both encoding and " |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3040 "decoding command or an rcp program") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3041 method))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3042 (delete-file tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3043 (unless (equal curbuf (current-buffer)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3044 (error "Buffer has changed from `%s' to `%s'" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3045 curbuf (current-buffer))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3046 (when (eq visit t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3047 (set-visited-file-modtime)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3048 ;; Make `last-coding-system-used' have the right value. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3049 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3050 (setq last-coding-system-used coding-system-used)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3051 (when (or (eq visit t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3052 (eq visit nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3053 (stringp visit)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3054 (message "Wrote %s" filename))))) |
45861 | 3055 |
3056 ;; Call down to the real handler. | |
3057 ;; Because EFS does not play nicely with TRAMP (both systems match an | |
3058 ;; TRAMP path) it is needed to disable efs as well as tramp for the | |
3059 ;; operation. | |
3060 ;; | |
3061 ;; Other than that, this is the canon file-handler code that the doco | |
3062 ;; says should be used here. Which is nice. | |
3063 ;; | |
3064 ;; Under XEmacs current, EFS also hooks in as | |
3065 ;; efs-sifn-handler-function to handle any path with environment | |
3066 ;; variables. This has two implications: | |
3067 ;; 1) That EFS may not be completely dead (yet) for TRAMP paths | |
3068 ;; 2) That TRAMP might want to do the same thing. | |
3069 ;; Details as they come in. | |
3070 ;; | |
3071 ;; Daniel Pittman <daniel@danann.net> | |
3072 | |
3073 ;; (defun tramp-run-real-handler (operation args) | |
3074 ;; "Invoke normal file name handler for OPERATION. | |
3075 ;; This inhibits EFS and Ange-FTP, too, because they conflict with tramp. | |
3076 ;; First arg specifies the OPERATION, remaining ARGS are passed to the | |
3077 ;; OPERATION." | |
3078 ;; (let ((inhibit-file-name-handlers | |
3079 ;; (list 'tramp-file-name-handler | |
3080 ;; 'efs-file-handler-function | |
3081 ;; 'ange-ftp-hook-function | |
3082 ;; (and (eq inhibit-file-name-operation operation) | |
3083 ;; inhibit-file-name-handlers))) | |
3084 ;; (inhibit-file-name-operation operation)) | |
3085 ;; (apply operation args))) | |
3086 | |
3087 (defun tramp-run-real-handler (operation args) | |
3088 "Invoke normal file name handler for OPERATION. | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3089 First arg specifies the OPERATION, second arg is a list of arguments to |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3090 pass to the OPERATION." |
45861 | 3091 (let ((inhibit-file-name-handlers |
3092 (list 'tramp-file-name-handler | |
3093 (and (eq inhibit-file-name-operation operation) | |
3094 inhibit-file-name-handlers))) | |
3095 (inhibit-file-name-operation operation)) | |
3096 (apply operation args))) | |
3097 | |
3098 ;; Main function. | |
3099 ;;;###autoload | |
3100 (defun tramp-file-name-handler (operation &rest args) | |
3101 "Invoke tramp file name handler. | |
3102 Falls back to normal file name handler if no tramp file name handler exists." | |
3103 (let ((fn (assoc operation tramp-file-name-handler-alist))) | |
3104 (if fn | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3105 (catch 'tramp-forward-to-ange-ftp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3106 (save-match-data (apply (cdr fn) args))) |
45861 | 3107 (tramp-run-real-handler operation args)))) |
3108 | |
3109 ;; Register in file name handler alist | |
3110 ;;;###autoload | |
3111 (add-to-list 'file-name-handler-alist | |
3112 (cons tramp-file-name-regexp 'tramp-file-name-handler)) | |
3113 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3114 ;; To handle EFS, the following functions need to be dealt with: |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3115 ;; |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3116 ;; * dired-before-readin-hook contains efs-dired-before-readin |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3117 ;; * file-name-handler-alist contains efs-file-handler-function |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3118 ;; and efs-root-handler-function and efs-sifn-handler-function |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3119 ;; * find-file-hooks contains efs-set-buffer-mode |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3120 ;; |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3121 ;; But it won't happen for EFS since the XEmacs maintainers |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3122 ;; don't want to use a unified filename syntax. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3123 (defun tramp-disable-ange-ftp () |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3124 "Turn Ange-FTP off. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3125 This is useful for unified remoting. See |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3126 `tramp-file-name-structure-unified' and |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3127 `tramp-file-name-structure-separate' for details. Requests suitable |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3128 for Ange-FTP will be forwarded to Ange-FTP. Also see the variables |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3129 `tramp-ftp-method', `tramp-default-method', and |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3130 `tramp-default-method-alist'. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3131 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3132 This function is not needed in Emacsen which include Tramp, but is |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3133 present for backward compatibility." |
46060
40298ba8e901
(tramp-handle-ange-ftp): Fix typo.
Andreas Schwab <schwab@suse.de>
parents:
46048
diff
changeset
|
3134 (let ((a1 (rassq 'ange-ftp-hook-function file-name-handler-alist)) |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3135 (a2 (rassq 'ange-ftp-completion-hook-function file-name-handler-alist))) |
45861 | 3136 (setq file-name-handler-alist |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3137 (delete a1 (delete a2 file-name-handler-alist))))) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3138 (tramp-disable-ange-ftp) |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3139 |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3140 (defun tramp-repair-jka-compr () |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3141 "If jka-compr is already loaded, move it to the front of |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3142 `file-name-handler-alist'. On Emacs 21.4 or so this will not be |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3143 necessary anymore." |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3144 (let ((jka (rassoc 'jka-compr-handler file-name-handler-alist))) |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3145 (when jka |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3146 (setq file-name-handler-alist |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3147 (cons jka (delete jka file-name-handler-alist)))))) |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3148 (tramp-repair-jka-compr) |
45861 | 3149 |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3150 (defun tramp-invoke-ange-ftp (operation &rest args) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3151 "Invoke the Ange-FTP handler function and throw." |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3152 (let ((ange-ftp-name-format |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3153 (list (nth 0 tramp-file-name-structure) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3154 (nth 3 tramp-file-name-structure) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3155 (nth 2 tramp-file-name-structure) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3156 (nth 4 tramp-file-name-structure)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3157 (throw 'tramp-forward-to-ange-ftp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3158 (apply 'ange-ftp-hook-function operation args)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3159 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3160 (defun tramp-ange-ftp-file-name-p (multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3161 "Check if it's a filename that should be forwarded to Ange-FTP." |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3162 (and (null multi-method) (string= method tramp-ftp-method))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3163 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3164 |
45861 | 3165 ;;; Interactions with other packages: |
3166 | |
3167 ;; -- complete.el -- | |
3168 | |
3169 ;; This function contributed by Ed Sabol | |
3170 (defun tramp-handle-expand-many-files (name) | |
3171 "Like `PC-expand-many-files' for tramp files." | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3172 (with-parsed-tramp-file-name name nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3173 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3174 (tramp-invoke-ange-ftp 'expand-many-files name)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3175 (save-match-data |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3176 (if (or (string-match "\\*" name) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3177 (string-match "\\?" name) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3178 (string-match "\\[.*\\]" name)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3179 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3180 ;; Dissect NAME. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3181 (let (bufstr) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3182 ;; Perhaps invoke Ange-FTP. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3183 (when (string= method tramp-ftp-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3184 (signal 'tramp-run-ange-ftp (list 0))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3185 ;; CCC: To do it right, we should quote certain characters |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3186 ;; in the file name, but since the echo command is going to |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3187 ;; break anyway when there are spaces in the file names, we |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3188 ;; don't bother. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3189 ;;-(let ((comint-file-name-quote-list |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3190 ;;- (set-difference tramp-file-name-quote-list |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3191 ;;- '(?\* ?\? ?[ ?])))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3192 ;;- (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3193 ;;- multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3194 ;;- (format "echo %s" (comint-quote-filename path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3195 ;;- (tramp-wait-for-output)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3196 (tramp-send-command multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3197 (format "echo %s" path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3198 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3199 (setq bufstr (buffer-substring (point-min) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3200 (tramp-line-end-position))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3201 (goto-char (point-min)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3202 (if (string-equal path bufstr) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3203 nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3204 (insert "(\"") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3205 (while (search-forward " " nil t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3206 (delete-backward-char 1) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3207 (insert "\" \"")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3208 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3209 (delete-backward-char 1) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3210 (insert "\")") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3211 (goto-char (point-min)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3212 (mapcar |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3213 (function (lambda (x) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3214 (tramp-make-tramp-file-name multi-method method |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3215 user host x))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3216 (read (current-buffer)))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3217 (list (tramp-handle-expand-file-name name)))))) |
45861 | 3218 |
3219 ;; Check for complete.el and override PC-expand-many-files if appropriate. | |
3220 (eval-when-compile | |
3221 (defun tramp-save-PC-expand-many-files (name))); avoid compiler warning | |
3222 | |
3223 (defun tramp-setup-complete () | |
3224 (fset 'tramp-save-PC-expand-many-files | |
3225 (symbol-function 'PC-expand-many-files)) | |
3226 (defun PC-expand-many-files (name) | |
3227 (if (tramp-tramp-file-p name) | |
3228 (tramp-handle-expand-many-files name) | |
3229 (tramp-save-PC-expand-many-files name)))) | |
3230 | |
3231 ;; Why isn't eval-after-load sufficient? | |
3232 (if (fboundp 'PC-expand-many-files) | |
3233 (tramp-setup-complete) | |
3234 (eval-after-load "complete" '(tramp-setup-complete))) | |
3235 | |
3236 | |
3237 | |
3238 | |
3239 ;;; Internal Functions: | |
3240 | |
3241 (defun tramp-set-auto-save () | |
3242 (when (and (buffer-file-name) | |
3243 (tramp-tramp-file-p (buffer-file-name)) | |
3244 auto-save-default) | |
3245 (auto-save-mode 1))) | |
3246 (add-hook 'find-file-hooks 'tramp-set-auto-save t) | |
3247 | |
3248 (defun tramp-run-test (switch filename) | |
3249 "Run `test' on the remote system, given a SWITCH and a FILENAME. | |
3250 Returns the exit code of the `test' program." | |
3251 (let ((v (tramp-dissect-file-name filename))) | |
3252 (save-excursion | |
3253 (tramp-send-command-and-check | |
3254 (tramp-file-name-multi-method v) (tramp-file-name-method v) | |
3255 (tramp-file-name-user v) (tramp-file-name-host v) | |
3256 (format "test %s %s" switch | |
3257 (tramp-shell-quote-argument (tramp-file-name-path v))))))) | |
3258 | |
3259 (defun tramp-run-test2 (program file1 file2 &optional switch) | |
3260 "Run `test'-like PROGRAM on the remote system, given FILE1, FILE2. | |
3261 The optional SWITCH is inserted between the two files. | |
3262 Returns the exit code of the `test' PROGRAM. Barfs if the methods, | |
3263 hosts, or files, disagree." | |
3264 (let* ((v1 (tramp-dissect-file-name file1)) | |
3265 (v2 (tramp-dissect-file-name file2)) | |
3266 (mmethod1 (tramp-file-name-multi-method v1)) | |
3267 (mmethod2 (tramp-file-name-multi-method v2)) | |
3268 (method1 (tramp-file-name-method v1)) | |
3269 (method2 (tramp-file-name-method v2)) | |
3270 (user1 (tramp-file-name-user v1)) | |
3271 (user2 (tramp-file-name-user v2)) | |
3272 (host1 (tramp-file-name-host v1)) | |
3273 (host2 (tramp-file-name-host v2)) | |
3274 (path1 (tramp-file-name-path v1)) | |
3275 (path2 (tramp-file-name-path v2))) | |
3276 (unless (and method1 method2 host1 host2 | |
3277 (equal mmethod1 mmethod2) | |
3278 (equal method1 method2) | |
3279 (equal user1 user2) | |
3280 (equal host1 host2)) | |
3281 (error "tramp-run-test2: %s" | |
3282 "only implemented for same method, same user, same host")) | |
3283 (save-excursion | |
3284 (tramp-send-command-and-check | |
3285 mmethod1 method1 user1 host1 | |
3286 (format "%s %s %s %s" | |
3287 program | |
3288 (tramp-shell-quote-argument path1) | |
3289 (or switch "") | |
3290 (tramp-shell-quote-argument path2)))))) | |
3291 | |
3292 (defun tramp-buffer-name (multi-method method user host) | |
3293 "A name for the connection buffer for USER at HOST using METHOD." | |
3294 (cond (multi-method | |
3295 (tramp-buffer-name-multi-method "tramp" multi-method method user host)) | |
3296 (user | |
3297 (format "*tramp/%s %s@%s*" method user host)) | |
3298 (t | |
3299 (format "*tramp/%s %s*" method host)))) | |
3300 | |
3301 (defun tramp-buffer-name-multi-method (prefix multi-method method user host) | |
3302 "A name for the multi method connection buffer. | |
3303 MULTI-METHOD gives the multi method, METHOD the array of methods, | |
3304 USER the array of user names, HOST the array of host names." | |
3305 (unless (and (= (length method) (length user)) | |
3306 (= (length method) (length host))) | |
3307 (error "Syntax error in multi method (implementation error)")) | |
3308 (let ((len (length method)) | |
3309 (i 0) | |
3310 string-list) | |
3311 (while (< i len) | |
3312 (setq string-list | |
3313 (cons (if (aref user i) | |
3314 (format "%s#%s@%s:" (aref method i) | |
3315 (aref user i) (aref host i)) | |
3316 (format "%s@%s:" (aref method i) (aref host i))) | |
3317 string-list)) | |
3318 (incf i)) | |
3319 (format "*%s/%s %s*" | |
3320 prefix multi-method | |
3321 (apply 'concat (reverse string-list))))) | |
3322 | |
3323 (defun tramp-get-buffer (multi-method method user host) | |
3324 "Get the connection buffer to be used for USER at HOST using METHOD." | |
3325 (get-buffer-create (tramp-buffer-name multi-method method user host))) | |
3326 | |
3327 (defun tramp-debug-buffer-name (multi-method method user host) | |
3328 "A name for the debug buffer for USER at HOST using METHOD." | |
3329 (cond (multi-method | |
3330 (tramp-buffer-name-multi-method "debug tramp" | |
3331 multi-method method user host)) | |
3332 (user | |
3333 (format "*debug tramp/%s %s@%s*" method user host)) | |
3334 (t | |
3335 (format "*debug tramp/%s %s*" method host)))) | |
3336 | |
3337 (defun tramp-get-debug-buffer (multi-method method user host) | |
3338 "Get the debug buffer for USER at HOST using METHOD." | |
3339 (get-buffer-create (tramp-debug-buffer-name multi-method method user host))) | |
3340 | |
3341 (defun tramp-find-executable (multi-method method user host | |
3342 progname dirlist ignore-tilde) | |
3343 "Searches for PROGNAME in all directories mentioned in DIRLIST. | |
3344 First args METHOD, USER and HOST specify the connection, PROGNAME | |
3345 is the program to search for, and DIRLIST gives the list of directories | |
3346 to search. If IGNORE-TILDE is non-nil, directory names starting | |
3347 with `~' will be ignored. | |
3348 | |
3349 Returns the full path name of PROGNAME, if found, and nil otherwise. | |
3350 | |
3351 This function expects to be in the right *tramp* buffer." | |
3352 (let (result) | |
3353 (when ignore-tilde | |
3354 ;; Remove all ~/foo directories from dirlist. In Emacs 20, | |
3355 ;; `remove' is in CL, and we want to avoid CL dependencies. | |
3356 (let (newdl d) | |
3357 (while dirlist | |
3358 (setq d (car dirlist)) | |
3359 (setq dirlist (cdr dirlist)) | |
3360 (unless (char-equal ?~ (aref d 0)) | |
3361 (setq newdl (cons d newdl)))) | |
3362 (setq dirlist (nreverse newdl)))) | |
3363 (tramp-send-command | |
3364 multi-method method user host | |
3365 (format (concat "while read d; " | |
3366 "do if test -x $d/%s -a -f $d/%s; " | |
3367 "then echo tramp_executable $d/%s; " | |
3368 "break; fi; done <<'EOF'") | |
3369 progname progname progname)) | |
3370 (mapcar (lambda (d) | |
3371 (tramp-send-command multi-method method user host d)) | |
3372 dirlist) | |
3373 (tramp-send-command multi-method method user host "EOF") | |
3374 (tramp-wait-for-output) | |
3375 (goto-char (point-max)) | |
3376 (when (search-backward "tramp_executable " nil t) | |
3377 (skip-chars-forward "^ ") | |
3378 (skip-chars-forward " ") | |
3379 (buffer-substring (point) (tramp-line-end-position))))) | |
3380 | |
3381 (defun tramp-set-remote-path (multi-method method user host var dirlist) | |
3382 "Sets the remote environment VAR to existing directories from DIRLIST. | |
3383 I.e., for each directory in DIRLIST, it is tested whether it exists and if | |
3384 so, it is added to the environment variable VAR." | |
3385 (let ((existing-dirs | |
3386 (mapcar | |
3387 (lambda (x) | |
3388 (when (and | |
3389 (file-exists-p | |
3390 (tramp-make-tramp-file-name multi-method method user host x)) | |
3391 (file-directory-p | |
3392 (tramp-make-tramp-file-name multi-method method user host x))) | |
3393 x)) | |
3394 dirlist))) | |
3395 (tramp-send-command | |
3396 multi-method method user host | |
3397 (concat var "=" | |
3398 (mapconcat 'identity (delq nil existing-dirs) ":") | |
3399 "; export " var)) | |
3400 (tramp-wait-for-output))) | |
3401 | |
3402 ;; -- communication with external shell -- | |
3403 | |
3404 (defun tramp-find-file-exists-command (multi-method method user host) | |
3405 "Find a command on the remote host for checking if a file exists. | |
3406 Here, we are looking for a command which has zero exit status if the | |
3407 file exists and nonzero exit status otherwise." | |
3408 (make-local-variable 'tramp-file-exists-command) | |
3409 (tramp-message 10 "Finding command to check if file exists") | |
3410 (let ((existing | |
3411 (tramp-make-tramp-file-name | |
3412 multi-method method user host | |
3413 "/")) ;assume this file always exists | |
3414 (nonexisting | |
3415 (tramp-make-tramp-file-name | |
3416 multi-method method user host | |
3417 "/ this file does not exist "))) ;assume this never exists | |
3418 ;; The algorithm is as follows: we try a list of several commands. | |
3419 ;; For each command, we first run `$cmd /' -- this should return | |
3420 ;; true, as the root directory always exists. And then we run | |
3421 ;; `$cmd /this\ file\ does\ not\ exist', hoping that the file indeed | |
3422 ;; does not exist. This should return false. We use the first | |
3423 ;; command we find that seems to work. | |
3424 ;; The list of commands to try is as follows: | |
3425 ;; `ls -d' This works on most systems, but NetBSD 1.4 | |
3426 ;; has a bug: `ls' always returns zero exit | |
3427 ;; status, even for files which don't exist. | |
3428 ;; `test -e' Some Bourne shells have a `test' builtin | |
3429 ;; which does not know the `-e' option. | |
3430 ;; `/bin/test -e' For those, the `test' binary on disk normally | |
3431 ;; provides the option. Alas, the binary | |
3432 ;; is sometimes `/bin/test' and sometimes it's | |
3433 ;; `/usr/bin/test'. | |
3434 ;; `/usr/bin/test -e' In case `/bin/test' does not exist. | |
3435 (unless (or | |
3436 (and (setq tramp-file-exists-command "ls -d %s") | |
3437 (tramp-handle-file-exists-p existing) | |
3438 (not (tramp-handle-file-exists-p nonexisting))) | |
3439 (and (setq tramp-file-exists-command "test -e %s") | |
3440 (tramp-handle-file-exists-p existing) | |
3441 (not (tramp-handle-file-exists-p nonexisting))) | |
3442 (and (setq tramp-file-exists-command "/bin/test -e %s") | |
3443 (tramp-handle-file-exists-p existing) | |
3444 (not (tramp-handle-file-exists-p nonexisting))) | |
3445 (and (setq tramp-file-exists-command "/usr/bin/test -e %s") | |
3446 (tramp-handle-file-exists-p existing) | |
3447 (not (tramp-handle-file-exists-p nonexisting)))) | |
3448 (error "Couldn't find command to check if file exists.")))) | |
3449 | |
3450 | |
3451 ;; CCC test ksh or bash found for tilde expansion? | |
3452 (defun tramp-find-shell (multi-method method user host) | |
3453 "Find a shell on the remote host which groks tilde expansion." | |
3454 (let ((shell nil)) | |
3455 (tramp-send-command multi-method method user host "echo ~root") | |
3456 (tramp-wait-for-output) | |
3457 (cond | |
3458 ((string-match "^~root$" (buffer-string)) | |
3459 (setq shell | |
3460 (or (tramp-find-executable multi-method method user host | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3461 "bash" tramp-remote-path t) |
45861 | 3462 (tramp-find-executable multi-method method user host |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3463 "ksh" tramp-remote-path t))) |
45861 | 3464 (unless shell |
3465 (error "Couldn't find a shell which groks tilde expansion")) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3466 ;; Find arguments for this shell. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3467 (let ((alist tramp-sh-extra-args) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3468 item extra-args) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3469 (while (and alist (null extra-args)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3470 (setq item (pop alist)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3471 (when (string-match (car item) shell) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3472 (setq extra-args (cdr item)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3473 (when extra-args (setq shell (concat shell " " extra-args)))) |
45861 | 3474 (tramp-message |
3475 5 "Starting remote shell `%s' for tilde expansion..." shell) | |
3476 (tramp-send-command | |
3477 multi-method method user host | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3478 (concat "PS1='$ ' ; exec " shell)) ; |
45861 | 3479 (unless (tramp-wait-for-regexp |
3480 (get-buffer-process (current-buffer)) | |
3481 60 (format "\\(\\$ *\\|\\(%s\\)\\'\\)" shell-prompt-pattern)) | |
3482 (pop-to-buffer (buffer-name)) | |
3483 (error "Couldn't find remote `%s' prompt." shell)) | |
3484 (process-send-string nil (format "PS1='%s%s%s'; PS2=''; PS3=''%s" | |
3485 tramp-rsh-end-of-line | |
3486 tramp-end-of-output | |
3487 tramp-rsh-end-of-line | |
3488 tramp-rsh-end-of-line)) | |
3489 (tramp-wait-for-output) | |
3490 (tramp-send-command multi-method method user host "echo hello") | |
3491 (tramp-message 5 "Waiting for remote `%s' to start up..." shell) | |
3492 (unless (tramp-wait-for-output 5) | |
3493 (unless (tramp-wait-for-output 5) | |
3494 (pop-to-buffer (buffer-name)) | |
3495 (error "Couldn't start remote `%s', see buffer `%s' for details" | |
3496 shell (buffer-name)))) | |
3497 (tramp-message 5 "Waiting for remote `%s' to start up...done" shell)) | |
3498 (t (tramp-message 5 "Remote `%s' groks tilde expansion, good" | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3499 (tramp-get-remote-sh multi-method method)))))) |
45861 | 3500 |
3501 (defun tramp-check-ls-command (multi-method method user host cmd) | |
3502 "Checks whether the given `ls' executable groks `-n'. | |
3503 METHOD, USER and HOST specify the connection, CMD (the full path name of) | |
3504 the `ls' executable. Returns t if CMD supports the `-n' option, nil | |
3505 otherwise." | |
3506 (tramp-message 9 "Checking remote `%s' command for `-n' option" | |
3507 cmd) | |
3508 (when (tramp-handle-file-executable-p | |
3509 (tramp-make-tramp-file-name multi-method method user host cmd)) | |
3510 (let ((result nil)) | |
3511 (tramp-message 7 "Testing remote command `%s' for -n..." cmd) | |
3512 (setq result | |
3513 (tramp-send-command-and-check | |
3514 multi-method method user host | |
3515 (format "%s -lnd / >/dev/null" | |
3516 cmd))) | |
3517 (tramp-message 7 "Testing remote command `%s' for -n...%s" | |
3518 cmd | |
3519 (if (zerop result) "okay" "failed")) | |
3520 (zerop result)))) | |
3521 | |
3522 (defun tramp-check-ls-commands (multi-method method user host cmd dirlist) | |
3523 "Checks whether the given `ls' executable in one of the dirs groks `-n'. | |
3524 Returns nil if none was found, else the command is returned." | |
3525 (let ((dl dirlist) | |
3526 (result nil)) | |
3527 ;; It would be better to use the CL function `find', but | |
3528 ;; we don't want run-time dependencies on CL. | |
3529 (while (and dl (not result)) | |
3530 (let ((x (concat (file-name-as-directory (car dl)) cmd))) | |
3531 (when (tramp-check-ls-command multi-method method user host x) | |
3532 (setq result x))) | |
3533 (setq dl (cdr dl))) | |
3534 result)) | |
3535 | |
3536 (defun tramp-find-ls-command (multi-method method user host) | |
3537 "Finds an `ls' command which groks the `-n' option, returning nil if failed. | |
3538 \(This option prints numeric user and group ids in a long listing.)" | |
3539 (tramp-message 9 "Finding a suitable `ls' command") | |
3540 (or | |
3541 (tramp-check-ls-commands multi-method method user host "ls" tramp-remote-path) | |
3542 (tramp-check-ls-commands multi-method method user host "gnuls" tramp-remote-path) | |
3543 (tramp-check-ls-commands multi-method method user host "gls" tramp-remote-path))) | |
3544 | |
3545 ;; ------------------------------------------------------------ | |
3546 ;; -- Functions for establishing connection -- | |
3547 ;; ------------------------------------------------------------ | |
3548 | |
3549 (defun tramp-process-actions | |
3550 (multi-method method user host actions &optional timeout) | |
3551 "Process given ACTIONS for login specified via first four args. | |
3552 ACTIONS is a list of items (REGEXP FUN), where REGEXP specifies what | |
3553 output from the remote end to look for, and FUN specifies the action | |
3554 to take when the regexp matches." | |
3555 nil) | |
3556 | |
3557 (defun tramp-open-connection-telnet (multi-method method user host) | |
3558 "Open a connection using a telnet METHOD. | |
3559 This starts the command `telnet HOST ARGS'[*], then waits for a remote | |
3560 login prompt, then sends the user name USER, then waits for a remote | |
3561 password prompt. It queries the user for the password, then sends the | |
3562 password to the remote host. | |
3563 | |
3564 If USER is nil, uses value returned by `(user-login-name)' instead. | |
3565 | |
3566 Recognition of the remote shell prompt is based on the variable | |
3567 `shell-prompt-pattern' which must be set up correctly. | |
3568 | |
3569 Please note that it is NOT possible to use this connection method | |
3570 together with an out-of-band transfer method! You must use an inline | |
3571 transfer method. | |
3572 | |
3573 Maybe the different regular expressions need to be tuned. | |
3574 | |
3575 * Actually, the telnet program as well as the args to be used can be | |
3576 specified in the method parameters, see the variable `tramp-methods'." | |
3577 (save-match-data | |
3578 (when (tramp-method-out-of-band-p multi-method method) | |
3579 (error "Cannot use out-of-band method `%s' with telnet connection method" | |
3580 method)) | |
3581 (when multi-method | |
3582 (error "Cannot multi-connect using telnet connection method")) | |
3583 (tramp-pre-connection multi-method method user host) | |
3584 (tramp-message 7 "Opening connection for %s@%s using %s..." | |
3585 (or user (user-login-name)) host method) | |
3586 (let ((process-environment (copy-sequence process-environment))) | |
3587 (setenv "TERM" tramp-terminal-type) | |
3588 (let* ((default-directory (tramp-temporary-file-directory)) | |
3589 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
3590 (> emacs-major-version 20)) | |
3591 tramp-dos-coding-system)) | |
3592 (p (apply 'start-process | |
3593 (tramp-buffer-name multi-method method user host) | |
3594 (tramp-get-buffer multi-method method user host) | |
3595 (tramp-get-telnet-program multi-method method) | |
3596 host | |
3597 (tramp-get-telnet-args multi-method method))) | |
3598 (found nil) | |
3599 (pw nil)) | |
3600 (process-kill-without-query p) | |
3601 (tramp-message 9 "Waiting for login prompt...") | |
3602 (unless (tramp-wait-for-regexp p nil tramp-login-prompt-regexp) | |
3603 (pop-to-buffer (buffer-name)) | |
3604 (kill-process p) | |
3605 (error "Couldn't find remote login prompt")) | |
3606 (erase-buffer) | |
3607 ;; Remote login defaults to local one. | |
3608 (tramp-message 9 "Sending login name %s" (or user (user-login-name))) | |
3609 (process-send-string p (concat (or user (user-login-name)) | |
3610 tramp-rsh-end-of-line)) | |
3611 (tramp-message 9 "Waiting for password prompt...") | |
3612 (unless (setq found (tramp-wait-for-regexp | |
3613 p nil tramp-password-prompt-regexp)) | |
3614 (pop-to-buffer (buffer-name)) | |
3615 (kill-process p) | |
3616 (error "Couldn't find remote password prompt")) | |
3617 (erase-buffer) | |
3618 (setq pw (tramp-read-passwd (car found))) | |
3619 (tramp-message 9 "Sending password") | |
3620 (process-send-string p (concat pw tramp-rsh-end-of-line)) | |
3621 (tramp-message 9 "Waiting 30s for remote shell to come up...") | |
3622 (unless (setq found | |
3623 (tramp-wait-for-regexp | |
3624 p 30 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3625 tramp-wrong-passwd-regexp | |
3626 shell-prompt-pattern))) | |
3627 (pop-to-buffer (buffer-name)) | |
3628 (kill-process p) | |
3629 (error "Couldn't find remote shell prompt")) | |
3630 (when (nth 1 found) | |
3631 (pop-to-buffer (buffer-name)) | |
3632 (kill-process p) | |
3633 (error "Login failed: %s" (nth 1 found))) | |
3634 (tramp-open-connection-setup-interactive-shell | |
3635 p multi-method method user host) | |
3636 (tramp-post-connection multi-method method user host))))) | |
3637 | |
3638 ;; HHH: Changed to handle the case when USER is nil. | |
3639 (defun tramp-open-connection-rsh (multi-method method user host) | |
3640 "Open a connection using an rsh METHOD. | |
3641 This starts the command `rsh HOST -l USER'[*], then waits for a remote | |
3642 password or shell prompt. If a password prompt is seen, the user is | |
3643 queried for a password, this function sends the password to the remote | |
3644 host and waits for a shell prompt. | |
3645 | |
3646 If USER is nil, start the command `rsh HOST'[*] instead | |
3647 | |
3648 Recognition of the remote shell prompt is based on the variable | |
3649 `shell-prompt-pattern' which must be set up correctly. | |
3650 | |
3651 Please note that it is NOT possible to use this connection method with | |
3652 an out-of-band transfer method if this function asks the user for a | |
3653 password! You must use an inline transfer method in this case. | |
3654 Sadly, the transfer method cannot be switched on the fly, instead you | |
3655 must specify the right method in the file name. | |
3656 | |
46010
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3657 Kludgy feature: if HOST has the form \"xx#yy\", then yy is assumed to |
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3658 be a port number for ssh, and \"-p yy\" will be added to the list of |
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3659 arguments, and xx will be used as the host name to connect to. |
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3660 |
45861 | 3661 * Actually, the rsh program to be used can be specified in the |
3662 method parameters, see the variable `tramp-methods'." | |
3663 (save-match-data | |
3664 (when multi-method | |
3665 (error "Cannot multi-connect using rsh connection method")) | |
3666 (tramp-pre-connection multi-method method user host) | |
3667 (if user | |
3668 (tramp-message 7 "Opening connection for %s@%s using %s..." | |
3669 user host method) | |
3670 (tramp-message 7 "Opening connection at %s using %s..." host method)) | |
46010
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3671 (let ((process-environment (copy-sequence process-environment)) |
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3672 (bufnam (tramp-buffer-name multi-method method user host)) |
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3673 (buf (tramp-get-buffer multi-method method user host)) |
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3674 (rsh-program (tramp-get-rsh-program multi-method method)) |
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3675 (rsh-args (tramp-get-rsh-args multi-method method))) |
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3676 ;; The following should be changed. We need a more general |
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3677 ;; mechanism to parse extra host args. |
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3678 (when (string-match "\\([^#]*\\)#\\(.*\\)" host) |
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3679 (setq rsh-args (cons "-p" (cons (match-string 2 host) rsh-args))) |
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3680 (setq host (match-string 1 host))) |
45861 | 3681 (setenv "TERM" tramp-terminal-type) |
3682 (let* ((default-directory (tramp-temporary-file-directory)) | |
3683 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
3684 (> emacs-major-version 20)) | |
3685 tramp-dos-coding-system)) | |
3686 (p (if user | |
46010
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3687 (apply #'start-process bufnam buf rsh-program |
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3688 host "-l" user rsh-args) |
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3689 (apply #'start-process bufnam buf rsh-program |
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3690 host rsh-args))) |
45861 | 3691 (found nil)) |
3692 (process-kill-without-query p) | |
3693 (tramp-message 9 "Waiting 60s for shell or passwd prompt from %s" host) | |
3694 (setq found | |
3695 (tramp-wait-for-regexp | |
3696 p 60 | |
3697 (format | |
3698 "\\(%s\\)\\|\\(%s\\)\\'" | |
3699 tramp-password-prompt-regexp | |
3700 shell-prompt-pattern))) | |
3701 (unless found | |
3702 (pop-to-buffer (buffer-name)) | |
3703 (kill-process p) | |
3704 (error "Couldn't find remote shell or passwd prompt")) | |
3705 (when (nth 1 found) | |
3706 (when (tramp-method-out-of-band-p multi-method method) | |
3707 (pop-to-buffer (buffer-name)) | |
3708 (kill-process p) | |
3709 (error (concat "Out of band method `%s' not applicable" | |
3710 " for remote shell asking for a password") | |
3711 method)) | |
3712 (erase-buffer) | |
3713 (tramp-message 9 "Sending password...") | |
3714 (tramp-enter-password p (nth 1 found)) | |
3715 (tramp-message 9 "Sent password, waiting 60s for remote shell prompt") | |
3716 (setq found (tramp-wait-for-regexp p 60 | |
3717 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3718 tramp-wrong-passwd-regexp | |
3719 shell-prompt-pattern)))) | |
3720 (unless found | |
3721 (pop-to-buffer (buffer-name)) | |
3722 (kill-process p) | |
3723 (error "Couldn't find remote shell prompt")) | |
3724 (when (nth 1 found) | |
3725 (pop-to-buffer (buffer-name)) | |
3726 (kill-process p) | |
3727 (error "Login failed: %s" (nth 1 found))) | |
3728 (tramp-message 7 "Initializing remote shell") | |
3729 (tramp-open-connection-setup-interactive-shell | |
3730 p multi-method method user host) | |
3731 (tramp-post-connection multi-method method user host))))) | |
3732 | |
3733 ;; HHH: Changed. Now utilizes (or user (user-login-name)) instead of USER. | |
3734 (defun tramp-open-connection-su (multi-method method user host) | |
3735 "Open a connection using the `su' program with METHOD. | |
3736 This starts `su - USER', then waits for a password prompt. The HOST | |
3737 name must be equal to the local host name or to `localhost'. | |
3738 | |
3739 If USER is nil, uses value returned by user-login-name instead. | |
3740 | |
3741 Recognition of the remote shell prompt is based on the variable | |
3742 `shell-prompt-pattern' which must be set up correctly. Note that the | |
3743 other user may have a different shell prompt than you do, so it is not | |
3744 at all unlikely that this variable is set up wrongly!" | |
3745 (save-match-data | |
3746 (when (tramp-method-out-of-band-p multi-method method) | |
3747 (error "Cannot use out-of-band method `%s' with `su' connection method" | |
3748 method)) | |
3749 (unless (or (string-match (concat "^" (regexp-quote host)) | |
3750 (system-name)) | |
3751 (string= "localhost" host)) | |
3752 (error | |
3753 "Cannot connect to different host `%s' with `su' connection method" | |
3754 host)) | |
3755 (when (not user) | |
3756 (error "Must give user name for `su' connection method")) | |
3757 (tramp-pre-connection multi-method method user host) | |
3758 (tramp-message 7 "Opening connection for `%s' using `%s'..." | |
3759 (or user (user-login-name)) method) | |
3760 (let ((process-environment (copy-sequence process-environment))) | |
3761 (setenv "TERM" tramp-terminal-type) | |
3762 (let* ((default-directory (tramp-temporary-file-directory)) | |
3763 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
3764 (> emacs-major-version 20)) | |
3765 tramp-dos-coding-system)) | |
3766 (p (apply 'start-process | |
3767 (tramp-buffer-name multi-method method | |
3768 user host) | |
3769 (tramp-get-buffer multi-method method | |
3770 user host) | |
3771 (tramp-get-su-program multi-method method) | |
3772 (mapcar | |
3773 '(lambda (x) | |
3774 (format-spec | |
3775 x (list (cons ?u user)))) | |
3776 (tramp-get-su-args multi-method method)))) | |
3777 (found nil) | |
3778 (pw nil)) | |
3779 (process-kill-without-query p) | |
3780 (tramp-message 9 "Waiting 30s for shell or password prompt...") | |
3781 (unless (setq found (tramp-wait-for-regexp | |
3782 p 30 | |
3783 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3784 tramp-password-prompt-regexp | |
3785 shell-prompt-pattern))) | |
3786 (pop-to-buffer (buffer-name)) | |
3787 (kill-process p) | |
3788 (error "Couldn't find shell or password prompt")) | |
3789 (when (nth 1 found) | |
3790 (erase-buffer) | |
3791 (setq pw (tramp-read-passwd (car found))) | |
3792 (tramp-message 9 "Sending password") | |
3793 (process-send-string p (concat pw tramp-rsh-end-of-line)) | |
3794 (tramp-message 9 "Waiting 30s for remote shell to come up...") | |
3795 (unless (setq found | |
3796 (tramp-wait-for-regexp | |
3797 p 30 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3798 tramp-wrong-passwd-regexp | |
3799 shell-prompt-pattern))) | |
3800 (pop-to-buffer (buffer-name)) | |
3801 (kill-process p) | |
3802 (error "Couldn't find remote shell prompt")) | |
3803 (when (nth 1 found) | |
3804 (pop-to-buffer (buffer-name)) | |
3805 (kill-process p) | |
3806 (error "`su' failed: %s" (nth 1 found)))) | |
3807 (tramp-open-connection-setup-interactive-shell | |
3808 p multi-method method user host) | |
3809 (tramp-post-connection multi-method method | |
3810 user host))))) | |
3811 | |
3812 ;; HHH: Not Changed. Multi method. It is not clear to me how this can | |
3813 ;; handle not giving a user name in the "file name". | |
3814 ;; | |
3815 ;; This is more difficult than for the single-hop method. In the | |
3816 ;; multi-hop-method, the desired behaviour should be that the | |
3817 ;; user must specify names for the telnet hops of which the user | |
3818 ;; name is different than the "original" name (or different from | |
3819 ;; the previous hop. | |
3820 (defun tramp-open-connection-multi (multi-method method user host) | |
3821 "Open a multi-hop connection using METHOD. | |
3822 This uses a slightly changed file name syntax. The idea is to say | |
3823 [multi/telnet:u1@h1/rsh:u2@h2]/path/to/file | |
3824 This will use telnet to log in as u1 to h1, then use rsh from there to | |
3825 log in as u2 to h2." | |
3826 (save-match-data | |
3827 (unless multi-method | |
3828 (error "Multi-hop open connection function called on non-multi method")) | |
3829 (when (tramp-method-out-of-band-p multi-method method) | |
3830 (error "No out of band multi-hop connections")) | |
3831 (unless (and (arrayp method) (not (stringp method))) | |
3832 (error "METHOD must be an array of strings for multi methods")) | |
3833 (unless (and (arrayp user) (not (stringp user))) | |
3834 (error "USER must be an array of strings for multi methods")) | |
3835 (unless (and (arrayp host) (not (stringp host))) | |
3836 (error "HOST must be an array of strings for multi methods")) | |
3837 (unless (and (= (length method) (length user)) | |
3838 (= (length method) (length host))) | |
3839 (error "Arrays METHOD, USER, HOST must have equal length")) | |
3840 (tramp-pre-connection multi-method method user host) | |
3841 (tramp-message 7 "Opening `%s' connection..." multi-method) | |
3842 (let ((process-environment (copy-sequence process-environment))) | |
3843 (setenv "TERM" tramp-terminal-type) | |
3844 (let* ((default-directory (tramp-temporary-file-directory)) | |
3845 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
3846 (> emacs-major-version 20)) | |
3847 tramp-dos-coding-system)) | |
3848 (p (start-process (tramp-buffer-name multi-method method user host) | |
3849 (tramp-get-buffer multi-method method user host) | |
3850 tramp-sh-program)) | |
3851 (num-hops (length method)) | |
3852 (i 0)) | |
3853 (process-kill-without-query p) | |
3854 (tramp-message 9 "Waiting 60s for local shell to come up...") | |
3855 (unless (tramp-wait-for-regexp | |
3856 p 60 (format "%s\\'" shell-prompt-pattern)) | |
3857 (pop-to-buffer (buffer-name)) | |
3858 (kill-process p) | |
3859 (error "Couldn't find local shell prompt")) | |
3860 ;; Now do all the connections as specified. | |
3861 (while (< i num-hops) | |
3862 (let* ((m (aref method i)) | |
3863 (u (aref user i)) | |
3864 (h (aref host i)) | |
3865 (entry (assoc m tramp-multi-connection-function-alist)) | |
3866 (multi-func (nth 1 entry)) | |
3867 (command (nth 2 entry))) | |
3868 ;; The multi-funcs don't need to do save-match-data, as that | |
3869 ;; is done here. | |
3870 (funcall multi-func p m u h command) | |
3871 (erase-buffer) | |
3872 (incf i))) | |
3873 (tramp-open-connection-setup-interactive-shell | |
3874 p multi-method method user host) | |
3875 (tramp-post-connection multi-method method user host))))) | |
3876 | |
3877 ;; HHH: Changed. Multi method. Don't know how to handle this in the case | |
3878 ;; of no user name provided. Hack to make it work as it did before: | |
3879 ;; changed `user' to `(or user (user-login-name))' in the places where | |
3880 ;; the value is actually used. | |
3881 (defun tramp-multi-connect-telnet (p method user host command) | |
3882 "Issue `telnet' command. | |
3883 Uses shell COMMAND to issue a `telnet' command to log in as USER to | |
3884 HOST. You can use percent escapes in COMMAND: `%h' is replaced with | |
3885 the host name, and `%n' is replaced with an end of line character, as | |
3886 set in `tramp-rsh-end-of-line'. Use `%%' if you want a literal percent | |
3887 character. | |
3888 | |
3889 If USER is nil, uses the return value of (user-login-name) instead." | |
3890 (let ((cmd (format-spec command (list (cons ?h host) | |
3891 (cons ?n tramp-rsh-end-of-line)))) | |
3892 (cmd1 (format-spec command (list (cons ?h host) | |
3893 (cons ?n "")))) | |
3894 found pw) | |
3895 (erase-buffer) | |
3896 (tramp-message 9 "Sending telnet command `%s'" cmd1) | |
3897 (process-send-string p cmd) | |
3898 (tramp-message 9 "Waiting 30s for login prompt from %s" host) | |
3899 (unless (tramp-wait-for-regexp p 30 tramp-login-prompt-regexp) | |
3900 (pop-to-buffer (buffer-name)) | |
3901 (kill-process p) | |
3902 (error "Couldn't find login prompt from host %s" host)) | |
3903 (erase-buffer) | |
3904 (tramp-message 9 "Sending login name %s" (or user (user-login-name))) | |
3905 (process-send-string p (concat (or user (user-login-name)) tramp-rsh-end-of-line)) | |
3906 (tramp-message 9 "Waiting for password prompt") | |
3907 (unless (setq found (tramp-wait-for-regexp p nil tramp-password-prompt-regexp)) | |
3908 (pop-to-buffer (buffer-name)) | |
3909 (kill-process p) | |
3910 (error "Couldn't find password prompt from host %s" host)) | |
3911 (erase-buffer) | |
3912 (setq pw (tramp-read-passwd | |
3913 (format "Password for %s@%s, %s" (or user (user-login-name)) host found))) | |
3914 (tramp-message 9 "Sending password") | |
3915 (process-send-string p (concat pw tramp-rsh-end-of-line)) | |
3916 (tramp-message 9 "Waiting 60s for remote shell to come up...") | |
3917 (unless (setq found (tramp-wait-for-regexp | |
3918 p 60 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3919 tramp-wrong-passwd-regexp | |
3920 shell-prompt-pattern))) | |
3921 (pop-to-buffer (buffer-name)) | |
3922 (kill-process p) | |
3923 (error "Couldn't find shell prompt from host %s" host)) | |
3924 (when (nth 1 found) | |
3925 (pop-to-buffer (buffer-name)) | |
3926 (kill-process p) | |
3927 (error "Login to %s failed: %s" (nth 2 found))))) | |
3928 | |
3929 ;; HHH: Changed. Multi method. Don't know how to handle this in the case | |
3930 ;; of no user name provided. Hack to make it work as it did before: | |
3931 ;; changed `user' to `(or user (user-login-name))' in the places where | |
3932 ;; the value is actually used. | |
3933 (defun tramp-multi-connect-rlogin (p method user host command) | |
3934 "Issue `rlogin' command. | |
3935 Uses shell COMMAND to issue an `rlogin' command to log in as USER to | |
3936 HOST. You can use percent escapes in COMMAND. `%u' will be replaced | |
3937 with the user name, `%h' will be replaced with the host name, and `%n' | |
3938 will be replaced with the value of `tramp-rsh-end-of-line'. You can use | |
3939 `%%' if you want to use a literal percent character. | |
3940 | |
3941 If USER is nil, uses the return value of (user-login-name) instead." | |
3942 (let ((cmd (format-spec command (list (cons ?h host) | |
3943 (cons ?u (or user (user-login-name))) | |
3944 (cons ?n tramp-rsh-end-of-line)))) | |
3945 (cmd1 (format-spec command (list (cons ?h host) | |
3946 (cons ?u (or user (user-login-name))) | |
3947 (cons ?n "")))) | |
3948 found) | |
3949 (erase-buffer) | |
3950 (tramp-message 9 "Sending rlogin command `%s'" cmd1) | |
3951 (process-send-string p cmd) | |
3952 (tramp-message 9 "Waiting 60s for shell or passwd prompt from %s" host) | |
3953 (unless (setq found | |
3954 (tramp-wait-for-regexp p 60 | |
3955 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3956 tramp-password-prompt-regexp | |
3957 shell-prompt-pattern))) | |
3958 (pop-to-buffer (buffer-name)) | |
3959 (kill-process p) | |
3960 (error "Couldn't find remote shell or passwd prompt")) | |
3961 (when (nth 1 found) | |
3962 (erase-buffer) | |
3963 (tramp-message 9 "Sending password...") | |
3964 (tramp-enter-password p (nth 1 found)) | |
3965 (tramp-message 9 "Sent password, waiting 60s for remote shell prompt") | |
3966 (setq found (tramp-wait-for-regexp p 60 | |
3967 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3968 tramp-wrong-passwd-regexp | |
3969 shell-prompt-pattern)))) | |
3970 (unless found | |
3971 (pop-to-buffer (buffer-name)) | |
3972 (kill-process p) | |
3973 (error "Couldn't find remote shell prompt")) | |
3974 (when (nth 1 found) | |
3975 (pop-to-buffer (buffer-name)) | |
3976 (kill-process p) | |
3977 (error "Login failed: %s" (nth 1 found))))) | |
3978 | |
3979 ;; HHH: Changed. Multi method. Don't know how to handle this in the case | |
3980 ;; of no user name provided. Hack to make it work as it did before: | |
3981 ;; changed `user' to `(or user (user-login-name))' in the places where | |
3982 ;; the value is actually used. | |
3983 (defun tramp-multi-connect-su (p method user host command) | |
3984 "Issue `su' command. | |
3985 Uses shell COMMAND to issue a `su' command to log in as USER on | |
3986 HOST. The HOST name is ignored, this just changes the user id on the | |
3987 host currently logged in to. | |
3988 | |
3989 If USER is nil, uses the return value of (user-login-name) instead. | |
3990 | |
3991 You can use percent escapes in the COMMAND. `%u' is replaced with the | |
3992 user name, and `%n' is replaced with the value of | |
3993 `tramp-rsh-end-of-line'. Use `%%' if you want a literal percent | |
3994 character." | |
3995 (let ((cmd (format-spec command (list (cons ?u (or user (user-login-name))) | |
3996 (cons ?n tramp-rsh-end-of-line)))) | |
3997 (cmd1 (format-spec command (list (cons ?u (or user (user-login-name))) | |
3998 (cons ?n "")))) | |
3999 found) | |
4000 (erase-buffer) | |
4001 (tramp-message 9 "Sending su command `%s'" cmd1) | |
4002 (process-send-string p cmd) | |
4003 (tramp-message 9 "Waiting 60s for shell or passwd prompt for %s" (or user (user-login-name))) | |
4004 (unless (setq found (tramp-wait-for-regexp | |
4005 p 60 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
4006 tramp-password-prompt-regexp | |
4007 shell-prompt-pattern))) | |
4008 (pop-to-buffer (buffer-name)) | |
4009 (kill-process p) | |
4010 (error "Couldn't find shell or passwd prompt for %s" | |
4011 (or user (user-login-name)))) | |
4012 (when (nth 1 found) | |
4013 (tramp-message 9 "Sending password...") | |
4014 (tramp-enter-password p (nth 1 found)) | |
4015 (erase-buffer) | |
4016 (tramp-message 9 "Sent password, waiting 60s for remote shell prompt") | |
4017 (setq found (tramp-wait-for-regexp p 60 | |
4018 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
4019 tramp-wrong-passwd-regexp | |
4020 shell-prompt-pattern)))) | |
4021 (unless found | |
4022 (pop-to-buffer (buffer-name)) | |
4023 (kill-process p) | |
4024 (error "Couldn't find remote shell prompt")) | |
4025 (when (nth 1 found) | |
4026 (pop-to-buffer (buffer-name)) | |
4027 (kill-process p) | |
4028 (error "Login failed: %s" (nth 1 found))))) | |
4029 | |
4030 ;; Utility functions. | |
4031 | |
4032 (defun tramp-wait-for-regexp (proc timeout regexp) | |
4033 "Wait for a REGEXP to appear from process PROC within TIMEOUT seconds. | |
4034 Expects the output of PROC to be sent to the current buffer. Returns | |
4035 the string that matched, or nil. Waits indefinitely if TIMEOUT is | |
4036 nil." | |
4037 (let ((found nil) | |
4038 (start-time (current-time))) | |
4039 (cond (timeout | |
4040 ;; Work around a bug in XEmacs 21, where the timeout | |
4041 ;; expires faster than it should. This degenerates | |
4042 ;; to polling for buggy XEmacsen, but oh, well. | |
4043 (while (and (not found) | |
4044 (< (tramp-time-diff (current-time) start-time) | |
4045 timeout)) | |
4046 (with-timeout (timeout) | |
4047 (while (not found) | |
4048 (accept-process-output proc 1) | |
4049 (goto-char (point-min)) | |
4050 (setq found (when (re-search-forward regexp nil t) | |
4051 (tramp-match-string-list))))))) | |
4052 (t | |
4053 (while (not found) | |
4054 (accept-process-output proc 1) | |
4055 (goto-char (point-min)) | |
4056 (setq found (when (re-search-forward regexp nil t) | |
4057 (tramp-match-string-list)))))) | |
4058 (when tramp-debug-buffer | |
4059 (append-to-buffer | |
4060 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4061 tramp-current-user tramp-current-host) | |
4062 (point-min) (point-max)) | |
4063 (when (not found) | |
4064 (save-excursion | |
4065 (set-buffer | |
4066 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4067 tramp-current-user tramp-current-host)) | |
4068 (goto-char (point-max)) | |
4069 (insert "[[Regexp `" regexp "' not found" | |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
4070 (if timeout (format " in %d secs" timeout) "") |
45861 | 4071 "]]")))) |
4072 found)) | |
4073 | |
4074 (defun tramp-enter-password (p prompt) | |
4075 "Prompt for a password and send it to the remote end. | |
4076 Uses PROMPT as a prompt and sends the password to process P." | |
4077 (let ((pw (tramp-read-passwd prompt))) | |
4078 (process-send-string p (concat pw tramp-rsh-end-of-line)))) | |
4079 | |
4080 ;; HHH: Not Changed. This might handle the case where USER is not | |
4081 ;; given in the "File name" very poorly. Then, the local | |
4082 ;; variable tramp-current user will be set to nil. | |
4083 (defun tramp-pre-connection (multi-method method user host) | |
4084 "Do some setup before actually logging in. | |
4085 METHOD, USER and HOST specify the connection." | |
4086 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4087 (set (make-local-variable 'tramp-current-multi-method) multi-method) | |
4088 (set (make-local-variable 'tramp-current-method) method) | |
4089 (set (make-local-variable 'tramp-current-user) user) | |
4090 (set (make-local-variable 'tramp-current-host) host) | |
4091 (set (make-local-variable 'inhibit-eol-conversion) nil) | |
4092 (erase-buffer)) | |
4093 | |
4094 (defun tramp-open-connection-setup-interactive-shell | |
4095 (p multi-method method user host) | |
4096 "Set up an interactive shell. | |
4097 Mainly sets the prompt and the echo correctly. P is the shell process | |
4098 to set up. METHOD, USER and HOST specify the connection." | |
4099 ;; Wait a bit in case the remote end feels like sending a little | |
4100 ;; junk first. It seems that fencepost.gnu.org does this when doing | |
4101 ;; a Kerberos login. | |
4102 (sit-for 1) | |
4103 (tramp-discard-garbage-erase-buffer p multi-method method user host) | |
4104 (process-send-string nil (format "exec %s%s" | |
4105 (tramp-get-remote-sh multi-method method) | |
4106 tramp-rsh-end-of-line)) | |
4107 (when tramp-debug-buffer | |
4108 (save-excursion | |
4109 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
4110 (goto-char (point-max)) | |
4111 (tramp-insert-with-face | |
4112 'bold (format "$ exec %s\n" (tramp-get-remote-sh multi-method method))))) | |
4113 (tramp-message 9 "Waiting 30s for remote `%s' to come up..." | |
4114 (tramp-get-remote-sh multi-method method)) | |
4115 (unless (tramp-wait-for-regexp | |
4116 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4117 (pop-to-buffer (buffer-name)) | |
4118 (error "Remote `%s' didn't come up. See buffer `%s' for details" | |
4119 (tramp-get-remote-sh multi-method method) (buffer-name))) | |
4120 (tramp-message 9 "Setting up remote shell environment") | |
4121 (tramp-discard-garbage-erase-buffer p multi-method method user host) | |
4122 (process-send-string | |
4123 nil (format "stty -inlcr -echo kill '^U'%s" tramp-rsh-end-of-line)) | |
4124 (unless (tramp-wait-for-regexp | |
4125 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4126 (pop-to-buffer (buffer-name)) | |
4127 (error "Couldn't `stty -echo', see buffer `%s'" (buffer-name))) | |
4128 (erase-buffer) | |
4129 (process-send-string nil (format "TERM=dumb; export TERM%s" | |
4130 tramp-rsh-end-of-line)) | |
4131 (unless (tramp-wait-for-regexp | |
4132 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4133 (pop-to-buffer (buffer-name)) | |
4134 (error "Couldn't `TERM=dumb; export TERM', see buffer `%s'" (buffer-name))) | |
4135 ;; Try to set up the coding system correctly. | |
4136 ;; CCC this can't be the right way to do it. Hm. | |
4137 (save-excursion | |
4138 (erase-buffer) | |
4139 (tramp-message 9 "Determining coding system") | |
4140 (process-send-string nil (format "echo foo ; echo bar %s" | |
4141 tramp-rsh-end-of-line)) | |
4142 (unless (tramp-wait-for-regexp | |
4143 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4144 (pop-to-buffer (buffer-name)) | |
4145 (error "Couldn't `echo foo; echo bar' to determine line endings'")) | |
4146 (goto-char (point-min)) | |
4147 (if (featurep 'mule) | |
4148 ;; Use MULE to select the right EOL convention for communicating | |
4149 ;; with the process. | |
4150 (let* ((cs (or (process-coding-system p) (cons 'undecided 'undecided))) | |
4151 cs-decode cs-encode) | |
4152 (when (symbolp cs) (setq cs (cons cs cs))) | |
4153 (setq cs-decode (car cs)) | |
4154 (setq cs-encode (cdr cs)) | |
4155 (unless cs-decode (setq cs-decode 'undecided)) | |
4156 (unless cs-encode (setq cs-encode 'undecided)) | |
4157 (setq cs-encode (tramp-coding-system-change-eol-conversion | |
4158 cs-encode 'unix)) | |
4159 (when (search-forward "\r" nil t) | |
4160 (setq cs-decode (tramp-coding-system-change-eol-conversion | |
4161 cs-decode 'dos))) | |
4162 (set-buffer-process-coding-system cs-decode cs-encode)) | |
4163 ;; Look for ^M and do something useful if found. | |
4164 (when (search-forward "\r" nil t) | |
4165 ;; We have found a ^M but cannot frob the process coding system | |
4166 ;; because we're running on a non-MULE Emacs. Let's try | |
4167 ;; stty, instead. | |
4168 (tramp-message 9 "Trying `stty -onlcr'") | |
4169 (process-send-string nil (format "stty -onlcr%s" tramp-rsh-end-of-line)) | |
4170 (unless (tramp-wait-for-regexp | |
4171 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4172 (pop-to-buffer (buffer-name)) | |
4173 (error "Couldn't `stty -onlcr', see buffer `%s'" (buffer-name)))))) | |
4174 (erase-buffer) | |
4175 (tramp-message | |
4176 9 "Waiting 30s for `HISTFILE=$HOME/.tramp_history; HISTSIZE=1'") | |
4177 (process-send-string | |
4178 nil (format "HISTFILE=$HOME/.tramp_history; HISTSIZE=1%s" | |
4179 tramp-rsh-end-of-line)) | |
4180 (unless (tramp-wait-for-regexp | |
4181 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4182 (pop-to-buffer (buffer-name)) | |
4183 (error (concat "Couldn't `HISTFILE=$HOME/.tramp_history; " | |
4184 "HISTSIZE=1', see buffer `%s'") | |
4185 (buffer-name))) | |
4186 (erase-buffer) | |
4187 (tramp-message 9 "Waiting 30s for `set +o vi +o emacs'") | |
4188 (process-send-string | |
4189 nil (format "set +o vi +o emacs%s" ;mustn't `>/dev/null' with AIX? | |
4190 tramp-rsh-end-of-line)) | |
4191 (unless (tramp-wait-for-regexp | |
4192 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4193 (pop-to-buffer (buffer-name)) | |
4194 (error "Couldn't `set +o vi +o emacs', see buffer `%s'" | |
4195 (buffer-name))) | |
4196 (erase-buffer) | |
4197 (tramp-message 9 "Waiting 30s for `unset MAIL MAILCHECK MAILPATH'") | |
4198 (process-send-string | |
4199 nil (format "unset MAIL MAILCHECK MAILPATH 1>/dev/null 2>/dev/null%s" | |
4200 tramp-rsh-end-of-line)) | |
4201 (unless (tramp-wait-for-regexp | |
4202 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4203 (pop-to-buffer (buffer-name)) | |
4204 (error "Couldn't `unset MAIL MAILCHECK MAILPATH', see buffer `%s'" | |
4205 (buffer-name))) | |
4206 (erase-buffer) | |
4207 (tramp-message 9 "Waiting 30s for `unset CDPATH'") | |
4208 (process-send-string | |
4209 nil (format "unset CDPATH%s" tramp-rsh-end-of-line)) | |
4210 (unless (tramp-wait-for-regexp | |
4211 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4212 (pop-to-buffer (buffer-name)) | |
4213 (error "Couldn't `unset CDPATH', see buffer `%s'" | |
4214 (buffer-name))) | |
4215 (erase-buffer) | |
4216 (tramp-message 9 "Setting shell prompt") | |
4217 (tramp-send-command | |
4218 multi-method method user host | |
4219 (format "PS1='%s%s%s'; PS2=''; PS3=''" | |
4220 tramp-rsh-end-of-line | |
4221 tramp-end-of-output | |
4222 tramp-rsh-end-of-line)) | |
4223 (tramp-wait-for-output) | |
4224 (tramp-send-command multi-method method user host "echo hello") | |
4225 (tramp-message 9 "Waiting for remote `%s' to come up..." | |
4226 (tramp-get-remote-sh multi-method method)) | |
4227 (unless (tramp-wait-for-output 5) | |
4228 (unless (tramp-wait-for-output 5) | |
4229 (pop-to-buffer (buffer-name)) | |
4230 (error "Couldn't set remote shell prompt. See buffer `%s' for details" | |
4231 (buffer-name)))) | |
4232 (tramp-message 7 "Waiting for remote `%s' to come up...done" | |
4233 (tramp-get-remote-sh multi-method method))) | |
4234 | |
4235 (defun tramp-post-connection (multi-method method user host) | |
4236 "Prepare a remote shell before being able to work on it. | |
4237 METHOD, USER and HOST specify the connection. | |
4238 Among other things, this finds a shell which groks tilde expansion, | |
4239 tries to find an `ls' command which groks the `-n' option, sets the | |
4240 locale to C and sets up the remote shell search path." | |
4241 ;; Search for a good shell before searching for a command which | |
4242 ;; checks if a file exists. This is done because Tramp wants to use | |
4243 ;; "test foo; echo $?" to check if various conditions hold, and | |
4244 ;; there are buggy /bin/sh implementations which don't execute the | |
4245 ;; "echo $?" part if the "test" part has an error. In particular, | |
4246 ;; the Solaris /bin/sh is a problem. I'm betting that all systems | |
4247 ;; with buggy /bin/sh implementations will have a working bash or | |
4248 ;; ksh. Whee... | |
4249 (tramp-find-shell multi-method method user host) | |
4250 (tramp-find-file-exists-command multi-method method user host) | |
4251 (sit-for 1) | |
4252 ;; Without (sit-for 0.1) at least, my machine will almost always blow | |
4253 ;; up on 'not numberp /root' - a race that causes the 'echo ~root' | |
4254 ;; output of (tramp-find-shell) to show up along with the output of | |
4255 ;; (tramp-find-ls-command) testing. | |
4256 ;; | |
4257 ;; I can't work out why this is a problem though. The (tramp-wait-for-output) | |
4258 ;; call in (tramp-find-shell) *should* make this not happen, I thought. | |
4259 ;; | |
4260 ;; After much debugging I couldn't find any problem with the implementation | |
4261 ;; of that function though. The workaround stays for me at least. :/ | |
4262 ;; | |
4263 ;; Daniel Pittman <daniel@danann.net> | |
4264 (make-local-variable 'tramp-ls-command) | |
4265 (setq tramp-ls-command (tramp-find-ls-command multi-method method user host)) | |
4266 (unless tramp-ls-command | |
4267 (tramp-message | |
4268 1 | |
4269 "Danger! Couldn't find ls which groks -n. Muddling through anyway") | |
4270 (setq tramp-ls-command | |
4271 (tramp-find-executable multi-method method user host | |
4272 "ls" tramp-remote-path nil))) | |
4273 (unless tramp-ls-command | |
4274 (error "Fatal error: Couldn't find remote executable `ls'")) | |
4275 (tramp-message 5 "Using remote command `%s' for getting directory listings" | |
4276 tramp-ls-command) | |
4277 (tramp-send-command multi-method method user host | |
4278 (concat "tramp_set_exit_status () {" tramp-rsh-end-of-line | |
4279 "return $1" tramp-rsh-end-of-line | |
4280 "}")) | |
4281 (tramp-wait-for-output) | |
4282 ;; Set remote PATH variable. | |
4283 (tramp-set-remote-path multi-method method user host "PATH" tramp-remote-path) | |
4284 ;; Tell remote shell to use standard time format, needed for | |
4285 ;; parsing `ls -l' output. | |
4286 (tramp-send-command multi-method method user host | |
4287 "LC_TIME=C; export LC_TIME; echo huhu") | |
4288 (tramp-wait-for-output) | |
4289 (tramp-send-command multi-method method user host | |
4290 "mesg n; echo huhu") | |
4291 (tramp-wait-for-output) | |
4292 (tramp-send-command multi-method method user host | |
4293 "biff n ; echo huhu") | |
4294 (tramp-wait-for-output) | |
4295 ;; Unalias ls(1) to work around issues with those silly people who make it | |
4296 ;; spit out ANSI escapes or whatever. | |
4297 (tramp-send-command multi-method method user host | |
4298 "unalias ls; echo huhu") | |
4299 (tramp-wait-for-output) | |
4300 ;; Does `test A -nt B' work? Use abominable `find' construct if it | |
4301 ;; doesn't. BSD/OS 4.0 wants the parentheses around the command, | |
4302 ;; for otherwise the shell crashes. | |
4303 (erase-buffer) | |
4304 (make-local-variable 'tramp-test-groks-nt) | |
4305 (tramp-send-command multi-method method user host | |
4306 "( test / -nt / )") | |
4307 (tramp-wait-for-output) | |
4308 (goto-char (point-min)) | |
4309 (setq tramp-test-groks-nt | |
4310 (looking-at (format "\n%s\n" (regexp-quote tramp-end-of-output)))) | |
4311 (unless tramp-test-groks-nt | |
4312 (tramp-send-command | |
4313 multi-method method user host | |
4314 (concat "tramp_test_nt () {" tramp-rsh-end-of-line | |
4315 "test -n \"`find $1 -prune -newer $2 -print`\"" tramp-rsh-end-of-line | |
4316 "}"))) | |
4317 (tramp-wait-for-output) | |
4318 ;; Find a `perl'. | |
4319 (erase-buffer) | |
4320 (let ((tramp-remote-perl | |
4321 (or (tramp-find-executable multi-method method user host | |
4322 "perl5" tramp-remote-path nil) | |
4323 (tramp-find-executable multi-method method user host | |
4324 "perl" tramp-remote-path nil)))) | |
4325 (when tramp-remote-perl | |
4326 (tramp-set-connection-property "perl" tramp-remote-perl multi-method method user host) | |
4327 ;; Set up stat in Perl if we can. | |
4328 (when tramp-remote-perl | |
4329 (tramp-message 5 "Sending the Perl `file-attributes' implementation.") | |
4330 (tramp-send-linewise | |
4331 multi-method method user host | |
4332 (concat "tramp_file_attributes () {\n" | |
4333 tramp-remote-perl | |
4334 " -e '" tramp-perl-file-attributes "' $1 2>/dev/null\n" | |
4335 "}")) | |
4336 (tramp-wait-for-output) | |
4337 (when (string= (tramp-get-encoding-command multi-method method) | |
4338 "tramp_mimencode") | |
4339 (tramp-message 5 "Sending the Perl `mime-encode' implementation.") | |
4340 (tramp-send-linewise | |
4341 multi-method method user host | |
4342 (concat "tramp_mimencode () {\n" | |
4343 (if (tramp-find-executable multi-method method user host | |
4344 "mimencode" tramp-remote-path t) | |
4345 "mimencode -b $1" | |
4346 (concat tramp-remote-perl | |
4347 " -e '" tramp-perl-mime-encode "' $1 2>/dev/null")) | |
4348 "\n}")) | |
4349 (tramp-wait-for-output)) | |
4350 (when (string= (tramp-get-decoding-command multi-method method) | |
4351 "tramp_mimedecode") | |
4352 (tramp-message 5 "Sending the Perl `mime-decode' implementation.") | |
4353 (tramp-send-linewise | |
4354 multi-method method user host | |
4355 (concat "tramp_mimedecode () {\n" | |
4356 (if (tramp-find-executable multi-method method user host | |
4357 "mimencode" tramp-remote-path t) | |
4358 "mimencode -u -b $1" | |
4359 (concat tramp-remote-perl | |
4360 " -e '" tramp-perl-mime-decode "' $1 2>/dev/null")) | |
4361 "\n}")) | |
4362 (tramp-wait-for-output))))) | |
4363 ;; Find ln(1) | |
4364 (erase-buffer) | |
4365 (let ((ln (tramp-find-executable multi-method method user host | |
4366 "ln" tramp-remote-path nil))) | |
4367 (when ln | |
4368 (tramp-set-connection-property "ln" ln multi-method method user host))) | |
4369 (erase-buffer) | |
4370 ;; If encoding/decoding command are given, test to see if they work. | |
4371 ;; CCC: Maybe it would be useful to run the encoder both locally and | |
4372 ;; remotely to see if they produce the same result. | |
4373 (let ((decoding (tramp-get-decoding-command multi-method method)) | |
4374 (encoding (tramp-get-encoding-command multi-method method)) | |
4375 (magic-string "xyzzy")) | |
4376 (when (and (or decoding encoding) (not (and decoding encoding))) | |
4377 (tramp-kill-process multi-method method user host) | |
4378 (error | |
4379 "Must give both decoding and encoding command in method definition")) | |
4380 (when (and decoding encoding) | |
4381 (tramp-message | |
4382 5 | |
4383 "Checking to see if encoding/decoding commands work on remote host...") | |
4384 (tramp-send-command | |
4385 multi-method method user host | |
4386 (format "echo %s | %s | %s" | |
4387 (tramp-shell-quote-argument magic-string) encoding decoding)) | |
4388 (tramp-wait-for-output) | |
4389 (unless (looking-at (regexp-quote magic-string)) | |
4390 (tramp-kill-process multi-method method user host) | |
4391 (error "Remote host cannot execute de/encoding commands. See buffer `%s' for details" | |
4392 (buffer-name))) | |
4393 (erase-buffer) | |
4394 (tramp-message | |
4395 5 "Checking to see if encoding/decoding commands work on remote host...done")))) | |
4396 | |
4397 | |
4398 (defun tramp-maybe-open-connection (multi-method method user host) | |
4399 "Maybe open a connection to HOST, logging in as USER, using METHOD. | |
4400 Does not do anything if a connection is already open, but re-opens the | |
4401 connection if a previous connection has died for some reason." | |
4402 (let ((p (get-buffer-process (tramp-get-buffer multi-method method user host)))) | |
4403 (unless (and p | |
4404 (processp p) | |
4405 (memq (process-status p) '(run open))) | |
4406 (when (and p (processp p)) | |
4407 (delete-process p)) | |
4408 (funcall (tramp-get-connection-function multi-method method) | |
4409 multi-method method user host)))) | |
4410 | |
4411 (defun tramp-send-command | |
4412 (multi-method method user host command &optional noerase) | |
4413 "Send the COMMAND to USER at HOST (logged in using METHOD). | |
4414 Erases temporary buffer before sending the command (unless NOERASE | |
4415 is true)." | |
4416 (tramp-maybe-open-connection multi-method method user host) | |
4417 (when tramp-debug-buffer | |
4418 (save-excursion | |
4419 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
4420 (goto-char (point-max)) | |
4421 (tramp-insert-with-face 'bold (format "$ %s\n" command)))) | |
4422 (let ((proc nil)) | |
4423 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4424 (unless noerase (erase-buffer)) | |
4425 (setq proc (get-buffer-process (current-buffer))) | |
4426 (process-send-string proc | |
4427 (concat command tramp-rsh-end-of-line)))) | |
4428 | |
4429 ;; It seems that Tru64 Unix does not like it if long strings are sent | |
4430 ;; to it in one go. (This happens when sending the Perl | |
4431 ;; `file-attributes' implementation, for instance.) Therefore, we | |
4432 ;; have this function which waits a bit at each line. | |
4433 (defun tramp-send-linewise | |
4434 (multi-method method user host string &optional noerase) | |
4435 "Send the STRING to USER at HOST linewise. | |
4436 Erases temporary buffer before sending the STRING (unless NOERASE | |
4437 is true). | |
4438 | |
4439 The STRING is expected to use Unix line-endings, but the lines sent to | |
4440 the remote host use line-endings as defined in the variable | |
4441 `tramp-rsh-end-of-line'." | |
4442 (tramp-maybe-open-connection multi-method method user host) | |
4443 (when tramp-debug-buffer | |
4444 (save-excursion | |
4445 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
4446 (goto-char (point-max)) | |
4447 (tramp-insert-with-face 'bold (format "$ %s\n" string)))) | |
4448 (let ((proc nil) | |
4449 (lines (split-string string "\n"))) | |
4450 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4451 (unless noerase (erase-buffer)) | |
4452 (setq proc (get-buffer-process (current-buffer))) | |
4453 (mapcar (lambda (x) | |
4454 (sleep-for 0.1) | |
4455 (process-send-string proc | |
4456 (concat x tramp-rsh-end-of-line))) | |
4457 lines))) | |
4458 | |
4459 (defun tramp-wait-for-output (&optional timeout) | |
4460 "Wait for output from remote rsh command." | |
4461 (let ((proc (get-buffer-process (current-buffer))) | |
4462 (found nil) | |
4463 (start-time (current-time)) | |
4464 (end-of-output (concat "^" | |
4465 (regexp-quote tramp-end-of-output) | |
4466 "$"))) | |
4467 ;; Algorithm: get waiting output. See if last line contains | |
4468 ;; end-of-output sentinel. If not, wait a bit and again get | |
4469 ;; waiting output. Repeat until timeout expires or end-of-output | |
4470 ;; sentinel is seen. Will hang if timeout is nil and | |
4471 ;; end-of-output sentinel never appears. | |
4472 (save-match-data | |
4473 (cond (timeout | |
4474 ;; Work around an XEmacs bug, where the timeout expires | |
4475 ;; faster than it should. This degenerates into polling | |
4476 ;; for buggy XEmacsen, but oh, well. | |
4477 (while (and (not found) | |
4478 (< (tramp-time-diff (current-time) start-time) | |
4479 timeout)) | |
4480 (with-timeout (timeout) | |
4481 (while (not found) | |
4482 (accept-process-output proc 1) | |
4483 (goto-char (point-max)) | |
4484 (forward-line -1) | |
4485 (setq found (looking-at end-of-output)))))) | |
4486 (t | |
4487 (while (not found) | |
4488 (accept-process-output proc 1) | |
4489 (goto-char (point-max)) | |
4490 (forward-line -1) | |
4491 (setq found (looking-at end-of-output)))))) | |
4492 ;; At this point, either the timeout has expired or we have found | |
4493 ;; the end-of-output sentinel. | |
4494 (when found | |
4495 (goto-char (point-max)) | |
4496 (forward-line -2) | |
4497 (delete-region (point) (point-max))) | |
4498 ;; Add output to debug buffer if appropriate. | |
4499 (when tramp-debug-buffer | |
4500 (append-to-buffer | |
4501 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4502 tramp-current-user tramp-current-host) | |
4503 (point-min) (point-max)) | |
4504 (when (not found) | |
4505 (save-excursion | |
4506 (set-buffer | |
4507 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4508 tramp-current-user tramp-current-host)) | |
4509 (goto-char (point-max)) | |
4510 (insert "[[Remote prompt `" end-of-output "' not found" | |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
4511 (if timeout (format " in %d secs" timeout) "") |
45861 | 4512 "]]")))) |
4513 (goto-char (point-min)) | |
4514 ;; Return value is whether end-of-output sentinel was found. | |
4515 found)) | |
4516 | |
4517 (defun tramp-match-string-list (&optional string) | |
4518 "Returns list of all match strings. | |
4519 That is, (list (match-string 0) (match-string 1) ...), according to the | |
4520 number of matches." | |
4521 (let* ((nmatches (/ (length (match-data)) 2)) | |
4522 (i (- nmatches 1)) | |
4523 (res nil)) | |
4524 (while (>= i 0) | |
4525 (setq res (cons (match-string i string) res)) | |
4526 (setq i (- i 1))) | |
4527 res)) | |
4528 | |
4529 (defun tramp-send-command-and-check (multi-method method user host command | |
4530 &optional subshell) | |
4531 "Run COMMAND and check its exit status. | |
4532 MULTI-METHOD and METHOD specify how to log in (as USER) to the remote HOST. | |
4533 Sends `echo $?' along with the COMMAND for checking the exit status. If | |
4534 COMMAND is nil, just sends `echo $?'. Returns the exit status found. | |
4535 | |
4536 If the optional argument SUBSHELL is non-nil, the command is executed in | |
4537 a subshell, ie surrounded by parentheses." | |
4538 (tramp-send-command multi-method method user host | |
4539 (concat (if subshell "( " "") | |
4540 command | |
4541 (if command " 2>/dev/null; " "") | |
4542 "echo tramp_exit_status $?" | |
4543 (if subshell " )" " "))) | |
4544 (tramp-wait-for-output) | |
4545 (goto-char (point-max)) | |
4546 (unless (search-backward "tramp_exit_status " nil t) | |
4547 (error "Couldn't find exit status of `%s'" command)) | |
4548 (skip-chars-forward "^ ") | |
4549 (read (current-buffer))) | |
4550 | |
4551 (defun tramp-barf-unless-okay (multi-method method user host command subshell | |
4552 signal fmt &rest args) | |
4553 "Run COMMAND, check exit status, throw error if exit status not okay. | |
4554 Similar to `tramp-send-command-and-check' but accepts two more arguments | |
4555 FMT and ARGS which are passed to `error'." | |
4556 (unless (zerop (tramp-send-command-and-check | |
4557 multi-method method user host command subshell)) | |
4558 ;; CCC: really pop-to-buffer? Maybe it's appropriate to be more | |
4559 ;; silent. | |
4560 (pop-to-buffer (current-buffer)) | |
4561 (funcall 'signal signal (apply 'format fmt args)))) | |
4562 | |
4563 (defun tramp-send-region (multi-method method user host start end) | |
4564 "Send the region from START to END to remote command | |
4565 running as USER on HOST using METHOD." | |
4566 (let ((proc (get-buffer-process | |
4567 (tramp-get-buffer multi-method method user host)))) | |
4568 (unless proc | |
4569 (error "Can't send region to remote host -- not logged in")) | |
4570 (process-send-region proc start end) | |
4571 (when tramp-debug-buffer | |
4572 (append-to-buffer | |
4573 (tramp-get-debug-buffer multi-method method user host) | |
4574 start end)))) | |
4575 | |
4576 (defun tramp-send-eof (multi-method method user host) | |
4577 "Send EOF to the remote end. | |
46151
eff75835ac2e
(tramp-send-eof): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
46060
diff
changeset
|
4578 METHOD, HOST and USER specify the connection." |
45861 | 4579 (let ((proc (get-buffer-process |
4580 (tramp-get-buffer multi-method method user host)))) | |
4581 (unless proc | |
4582 (error "Can't send EOF to remote host -- not logged in")) | |
4583 (process-send-eof proc))) | |
4584 ; (process-send-string proc "\^D"))) | |
4585 | |
4586 (defun tramp-kill-process (multi-method method user host) | |
4587 "Kill the connection process used by Tramp. | |
46151
eff75835ac2e
(tramp-send-eof): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
46060
diff
changeset
|
4588 MULTI-METHOD, METHOD, USER, and HOST specify the connection." |
45861 | 4589 (let ((proc (get-buffer-process |
4590 (tramp-get-buffer multi-method method user host)))) | |
4591 (kill-process proc))) | |
4592 | |
4593 (defun tramp-discard-garbage-erase-buffer (p multi-method method user host) | |
4594 "Erase buffer, then discard subsequent garbage. | |
4595 If `tramp-discard-garbage' is nil, just erase buffer." | |
4596 (if (not tramp-discard-garbage) | |
4597 (erase-buffer) | |
4598 (while (prog1 (erase-buffer) (accept-process-output p 0.25)) | |
4599 (when tramp-debug-buffer | |
4600 (save-excursion | |
4601 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
4602 (goto-char (point-max)) | |
4603 (tramp-insert-with-face | |
4604 'bold (format "Additional characters detected\n"))))))) | |
4605 | |
4606 (defun tramp-mode-string-to-int (mode-string) | |
4607 "Converts a ten-letter `drwxrwxrwx'-style mode string into mode bits." | |
4608 (let* ((mode-chars (string-to-vector mode-string)) | |
4609 (owner-read (aref mode-chars 1)) | |
4610 (owner-write (aref mode-chars 2)) | |
4611 (owner-execute-or-setid (aref mode-chars 3)) | |
4612 (group-read (aref mode-chars 4)) | |
4613 (group-write (aref mode-chars 5)) | |
4614 (group-execute-or-setid (aref mode-chars 6)) | |
4615 (other-read (aref mode-chars 7)) | |
4616 (other-write (aref mode-chars 8)) | |
4617 (other-execute-or-sticky (aref mode-chars 9))) | |
4618 (save-match-data | |
4619 (logior | |
4620 (case owner-read | |
4621 (?r (tramp-octal-to-decimal "00400")) (?- 0) | |
4622 (t (error "Second char `%c' must be one of `r-'" owner-read))) | |
4623 (case owner-write | |
4624 (?w (tramp-octal-to-decimal "00200")) (?- 0) | |
4625 (t (error "Third char `%c' must be one of `w-'" owner-write))) | |
4626 (case owner-execute-or-setid | |
4627 (?x (tramp-octal-to-decimal "00100")) | |
4628 (?S (tramp-octal-to-decimal "04000")) | |
4629 (?s (tramp-octal-to-decimal "04100")) | |
4630 (?- 0) | |
4631 (t (error "Fourth char `%c' must be one of `xsS-'" | |
4632 owner-execute-or-setid))) | |
4633 (case group-read | |
4634 (?r (tramp-octal-to-decimal "00040")) (?- 0) | |
4635 (t (error "Fifth char `%c' must be one of `r-'" group-read))) | |
4636 (case group-write | |
4637 (?w (tramp-octal-to-decimal "00020")) (?- 0) | |
4638 (t (error "Sixth char `%c' must be one of `w-'" group-write))) | |
4639 (case group-execute-or-setid | |
4640 (?x (tramp-octal-to-decimal "00010")) | |
4641 (?S (tramp-octal-to-decimal "02000")) | |
4642 (?s (tramp-octal-to-decimal "02010")) | |
4643 (?- 0) | |
4644 (t (error "Seventh char `%c' must be one of `xsS-'" | |
4645 group-execute-or-setid))) | |
4646 (case other-read | |
4647 (?r (tramp-octal-to-decimal "00004")) (?- 0) | |
4648 (t (error "Eighth char `%c' must be one of `r-'" other-read))) | |
4649 (case other-write | |
4650 (?w (tramp-octal-to-decimal "00002")) (?- 0) | |
4651 (t (error "Nineth char `%c' must be one of `w-'" other-write))) | |
4652 (case other-execute-or-sticky | |
4653 (?x (tramp-octal-to-decimal "00001")) | |
4654 (?T (tramp-octal-to-decimal "01000")) | |
4655 (?t (tramp-octal-to-decimal "01001")) | |
4656 (?- 0) | |
4657 (t (error "Tenth char `%c' must be one of `xtT-'" | |
4658 other-execute-or-sticky))))))) | |
4659 | |
4660 | |
4661 (defun tramp-file-mode-from-int (mode) | |
4662 "Turn an integer representing a file mode into an ls(1)-like string." | |
4663 (let ((type (cdr (assoc (logand (lsh mode -12) 15) tramp-file-mode-type-map))) | |
4664 (user (logand (lsh mode -6) 7)) | |
4665 (group (logand (lsh mode -3) 7)) | |
4666 (other (logand (lsh mode -0) 7)) | |
4667 (suid (> (logand (lsh mode -9) 4) 0)) | |
4668 (sgid (> (logand (lsh mode -9) 2) 0)) | |
4669 (sticky (> (logand (lsh mode -9) 1) 0))) | |
4670 (setq user (tramp-file-mode-permissions user suid "s")) | |
4671 (setq group (tramp-file-mode-permissions group sgid "s")) | |
4672 (setq other (tramp-file-mode-permissions other sticky "t")) | |
4673 (concat type user group other))) | |
4674 | |
4675 | |
4676 (defun tramp-file-mode-permissions (perm suid suid-text) | |
4677 "Convert a permission bitset into a string. | |
4678 This is used internally by `tramp-file-mode-from-int'." | |
4679 (let ((r (> (logand perm 4) 0)) | |
4680 (w (> (logand perm 2) 0)) | |
4681 (x (> (logand perm 1) 0))) | |
4682 (concat (or (and r "r") "-") | |
4683 (or (and w "w") "-") | |
4684 (or (and suid x suid-text) ; suid, execute | |
4685 (and suid (upcase suid-text)) ; suid, !execute | |
4686 (and x "x") "-")))) ; !suid | |
4687 | |
4688 | |
4689 (defun tramp-decimal-to-octal (i) | |
4690 "Return a string consisting of the octal digits of I. | |
4691 Not actually used. Use `(format \"%o\" i)' instead?" | |
4692 (cond ((< i 0) (error "Cannot convert negative number to octal")) | |
4693 ((not (integerp i)) (error "Cannot convert non-integer to octal")) | |
4694 ((zerop i) "0") | |
4695 (t (concat (tramp-decimal-to-octal (/ i 8)) | |
4696 (number-to-string (% i 8)))))) | |
4697 | |
4698 | |
4699 ;;(defun tramp-octal-to-decimal (ostr) | |
4700 ;; "Given a string of octal digits, return a decimal number." | |
4701 ;; (cond ((null ostr) 0) | |
4702 ;; ((string= "" ostr) 0) | |
4703 ;; (t (let ((last (aref ostr (1- (length ostr)))) | |
4704 ;; (rest (substring ostr 0 (1- (length ostr))))) | |
4705 ;; (unless (and (>= last ?0) | |
4706 ;; (<= last ?7)) | |
4707 ;; (error "Not an octal digit: %c" last)) | |
4708 ;; (+ (- last ?0) (* 8 (tramp-octal-to-decimal rest))))))) | |
4709 ;; Kudos to Gerd Moellmann for this suggestion. | |
4710 (defun tramp-octal-to-decimal (ostr) | |
4711 "Given a string of octal digits, return a decimal number." | |
4712 (let ((x (or ostr ""))) | |
4713 ;; `save-match' is in `tramp-mode-string-to-int' which calls this. | |
4714 (unless (string-match "\\`[0-7]*\\'" x) | |
4715 (error "Non-octal junk in string `%s'" x)) | |
4716 (string-to-number ostr 8))) | |
4717 | |
4718 (defun tramp-shell-case-fold (string) | |
4719 "Converts STRING to shell glob pattern which ignores case." | |
4720 (mapconcat | |
4721 (lambda (c) | |
4722 (if (equal (downcase c) (upcase c)) | |
4723 (vector c) | |
4724 (format "[%c%c]" (downcase c) (upcase c)))) | |
4725 string | |
4726 "")) | |
4727 | |
4728 | |
4729 ;; ------------------------------------------------------------ | |
4730 ;; -- TRAMP file names -- | |
4731 ;; ------------------------------------------------------------ | |
4732 ;; Conversion functions between external representation and | |
4733 ;; internal data structure. Convenience functions for internal | |
4734 ;; data structure. | |
4735 | |
4736 (defstruct tramp-file-name multi-method method user host path) | |
4737 | |
4738 (defun tramp-tramp-file-p (name) | |
4739 "Return t iff NAME is a tramp file." | |
4740 (save-match-data | |
4741 (string-match tramp-file-name-regexp name))) | |
4742 | |
4743 ;; HHH: Changed. Used to assign the return value of (user-login-name) | |
4744 ;; to the `user' part of the structure if a user name was not | |
4745 ;; provided, now it assigns nil. | |
4746 (defun tramp-dissect-file-name (name) | |
4747 "Return an `tramp-file-name' structure. | |
4748 The structure consists of remote method, remote user, remote host and | |
4749 remote path name." | |
4750 (let (method) | |
4751 (save-match-data | |
4752 (unless (string-match (nth 0 tramp-file-name-structure) name) | |
4753 (error "Not a tramp file name: %s" name)) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4754 (setq method (match-string (nth 1 tramp-file-name-structure) name)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4755 (if (and method (member method tramp-multi-methods)) |
45861 | 4756 ;; If it's a multi method, the file name structure contains |
4757 ;; arrays of method, user and host. | |
4758 (tramp-dissect-multi-file-name name) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4759 ;; Normal method. First, find out default method. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4760 (let ((user (match-string (nth 2 tramp-file-name-structure) name)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4761 (host (match-string (nth 3 tramp-file-name-structure) name)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4762 (path (match-string (nth 4 tramp-file-name-structure) name))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4763 (when (not method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4764 (setq method (tramp-find-default-method user host))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4765 (make-tramp-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4766 :multi-method nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4767 :method method |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4768 :user (or user nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4769 :host host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4770 :path path)))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4771 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4772 (defun tramp-find-default-method (user host) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4773 "Look up the right method to use in `tramp-default-method-alist'." |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4774 (let ((choices tramp-default-method-alist) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4775 (method tramp-default-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4776 item) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4777 (while choices |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4778 (setq item (pop choices)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4779 (when (and (string-match (nth 0 item) host) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4780 (string-match (nth 1 item) (or user ""))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4781 (setq method (nth 2 item)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4782 (setq choices nil))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4783 method)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4784 |
45861 | 4785 ;; HHH: Not Changed. Multi method. Will probably not handle the case where |
4786 ;; a user name is not provided in the "file name" very well. | |
4787 (defun tramp-dissect-multi-file-name (name) | |
4788 "Not implemented yet." | |
4789 (let ((regexp (nth 0 tramp-multi-file-name-structure)) | |
4790 (method-index (nth 1 tramp-multi-file-name-structure)) | |
4791 (hops-index (nth 2 tramp-multi-file-name-structure)) | |
4792 (path-index (nth 3 tramp-multi-file-name-structure)) | |
4793 (hop-regexp (nth 0 tramp-multi-file-name-hop-structure)) | |
4794 (hop-method-index (nth 1 tramp-multi-file-name-hop-structure)) | |
4795 (hop-user-index (nth 2 tramp-multi-file-name-hop-structure)) | |
4796 (hop-host-index (nth 3 tramp-multi-file-name-hop-structure)) | |
4797 method hops len hop-methods hop-users hop-hosts path) | |
4798 (unless (string-match (format regexp hop-regexp) name) | |
4799 (error "Not a multi tramp file name: %s" name)) | |
4800 (setq method (match-string method-index name)) | |
4801 (setq hops (match-string hops-index name)) | |
4802 (setq len (/ (length (match-data t)) 2)) | |
4803 (when (< path-index 0) (incf path-index len)) | |
4804 (setq path (match-string path-index name)) | |
4805 (let ((index 0)) | |
4806 (while (string-match hop-regexp hops index) | |
4807 (setq index (match-end 0)) | |
4808 (setq hop-methods | |
4809 (cons (match-string hop-method-index hops) hop-methods)) | |
4810 (setq hop-users | |
4811 (cons (match-string hop-user-index hops) hop-users)) | |
4812 (setq hop-hosts | |
4813 (cons (match-string hop-host-index hops) hop-hosts)))) | |
4814 (make-tramp-file-name | |
4815 :multi-method method | |
4816 :method (apply 'vector (reverse hop-methods)) | |
4817 :user (apply 'vector (reverse hop-users)) | |
4818 :host (apply 'vector (reverse hop-hosts)) | |
4819 :path path))) | |
4820 | |
4821 (defun tramp-make-tramp-file-name (multi-method method user host path) | |
4822 "Constructs a tramp file name from METHOD, USER, HOST and PATH." | |
4823 (unless tramp-make-tramp-file-format | |
4824 (error "`tramp-make-tramp-file-format' is nil")) | |
4825 (if multi-method | |
4826 (tramp-make-tramp-multi-file-name multi-method method user host path) | |
4827 (if user | |
4828 (format-spec tramp-make-tramp-file-format | |
4829 (list (cons ?m method) | |
4830 (cons ?u user) | |
4831 (cons ?h host) | |
4832 (cons ?p path))) | |
4833 (format-spec tramp-make-tramp-file-user-nil-format | |
4834 (list (cons ?m method) | |
4835 (cons ?h host) | |
4836 (cons ?p path)))))) | |
4837 | |
4838 ;; CCC: Henrik Holm: Not Changed. Multi Method. What should be done | |
4839 ;; with this when USER is nil? | |
4840 (defun tramp-make-tramp-multi-file-name (multi-method method user host path) | |
4841 "Constructs a tramp file name for a multi-hop method." | |
4842 (unless tramp-make-multi-tramp-file-format | |
4843 (error "`tramp-make-multi-tramp-file-format' is nil")) | |
4844 (let* ((prefix-format (nth 0 tramp-make-multi-tramp-file-format)) | |
4845 (hop-format (nth 1 tramp-make-multi-tramp-file-format)) | |
4846 (path-format (nth 2 tramp-make-multi-tramp-file-format)) | |
4847 (prefix (format-spec prefix-format (list (cons ?m multi-method)))) | |
4848 (hops "") | |
4849 (path (format-spec path-format (list (cons ?p path)))) | |
4850 (i 0) | |
4851 (len (length method))) | |
4852 (while (< i len) | |
4853 (let ((m (aref method i)) | |
4854 (u (aref user i)) | |
4855 (h (aref host i))) | |
4856 (setq hops (concat hops | |
4857 (format-spec | |
4858 hop-format | |
4859 (list (cons ?m m) | |
4860 (cons ?u u) | |
4861 (cons ?h h))))) | |
4862 (incf i))) | |
4863 (concat prefix hops path))) | |
4864 | |
4865 (defun tramp-make-rcp-program-file-name (user host path) | |
4866 "Create a file name suitable to be passed to `rcp'." | |
4867 (if user | |
4868 (format "%s@%s:%s" user host path) | |
4869 (format "%s:%s" host path))) | |
4870 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4871 (defun tramp-make-ange-ftp-file-name (user host path) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4872 "Given user, host, and path, return an Ange-FTP filename." |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4873 (if user |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4874 (format "/%s@%s:%s" user host path) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4875 (format "/%s:%s" host path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4876 |
45861 | 4877 (defun tramp-method-out-of-band-p (multi-method method) |
4878 "Return t if this is an out-of-band method, nil otherwise. | |
4879 It is important to check for this condition, since it is not possible | |
4880 to enter a password for the `tramp-rcp-program'." | |
4881 (tramp-get-rcp-program multi-method method)) | |
4882 | |
4883 ;; Variables local to connection. | |
4884 | |
4885 (defun tramp-get-ls-command (multi-method method user host) | |
4886 (save-excursion | |
4887 (tramp-maybe-open-connection multi-method method user host) | |
4888 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4889 tramp-ls-command)) | |
4890 | |
4891 (defun tramp-get-test-groks-nt (multi-method method user host) | |
4892 (save-excursion | |
4893 (tramp-maybe-open-connection multi-method method user host) | |
4894 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4895 tramp-test-groks-nt)) | |
4896 | |
4897 (defun tramp-get-file-exists-command (multi-method method user host) | |
4898 (save-excursion | |
4899 (tramp-maybe-open-connection multi-method method user host) | |
4900 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4901 tramp-file-exists-command)) | |
4902 | |
4903 (defun tramp-get-remote-perl (multi-method method user host) | |
4904 (tramp-get-connection-property "perl" nil multi-method method user host)) | |
4905 | |
4906 (defun tramp-get-remote-ln (multi-method method user host) | |
4907 (tramp-get-connection-property "ln" nil multi-method method user host)) | |
4908 | |
4909 ;; Get a property of a TRAMP connection. | |
4910 (defun tramp-get-connection-property (property default multi-method method user host) | |
4911 "Get the named property for the connection. | |
4912 If the value is not set for the connection, return `default'" | |
4913 (tramp-maybe-open-connection multi-method method user host) | |
4914 (with-current-buffer (tramp-get-buffer multi-method method user host) | |
4915 (let (error) | |
4916 (condition-case nil | |
4917 (symbol-value (intern (concat "tramp-connection-property-" property))) | |
4918 (error default))))) | |
4919 | |
4920 ;; Set a property of a TRAMP connection. | |
4921 (defun tramp-set-connection-property (property value multi-method method user host) | |
4922 "Set the named property of a TRAMP connection." | |
4923 (tramp-maybe-open-connection multi-method method user host) | |
4924 (with-current-buffer (tramp-get-buffer multi-method method user host) | |
4925 (set (make-local-variable | |
4926 (intern (concat "tramp-connection-property-" property))) | |
4927 value))) | |
4928 | |
4929 | |
4930 | |
4931 (defun tramp-get-connection-function (multi-method method) | |
4932 (second (or (assoc 'tramp-connection-function | |
4933 (assoc (or multi-method method tramp-default-method) | |
4934 tramp-methods)) | |
4935 (error "Method `%s' didn't specify a connection function" | |
4936 (or multi-method method))))) | |
4937 | |
4938 (defun tramp-get-remote-sh (multi-method method) | |
4939 (second (or (assoc 'tramp-remote-sh | |
4940 (assoc (or multi-method method tramp-default-method) | |
4941 tramp-methods)) | |
4942 (error "Method `%s' didn't specify a remote shell" | |
4943 (or multi-method method))))) | |
4944 | |
4945 (defun tramp-get-rsh-program (multi-method method) | |
4946 (second (or (assoc 'tramp-rsh-program | |
4947 (assoc (or multi-method method tramp-default-method) | |
4948 tramp-methods)) | |
4949 (error "Method `%s' didn't specify an rsh program" | |
4950 (or multi-method method))))) | |
4951 | |
4952 (defun tramp-get-rsh-args (multi-method method) | |
4953 (second (or (assoc 'tramp-rsh-args | |
4954 (assoc (or multi-method method tramp-default-method) | |
4955 tramp-methods)) | |
4956 (error "Method `%s' didn't specify rsh args" | |
4957 (or multi-method method))))) | |
4958 | |
4959 (defun tramp-get-rcp-program (multi-method method) | |
4960 (second (or (assoc 'tramp-rcp-program | |
4961 (assoc (or multi-method method tramp-default-method) | |
4962 tramp-methods)) | |
4963 (error "Method `%s' didn't specify an rcp program" | |
4964 (or multi-method method))))) | |
4965 | |
4966 (defun tramp-get-rcp-args (multi-method method) | |
4967 (second (or (assoc 'tramp-rcp-args | |
4968 (assoc (or multi-method method tramp-default-method) | |
4969 tramp-methods)) | |
4970 (error "Method `%s' didn't specify rcp args" | |
4971 (or multi-method method))))) | |
4972 | |
4973 (defun tramp-get-rcp-keep-date-arg (multi-method method) | |
4974 (second (or (assoc 'tramp-rcp-keep-date-arg | |
4975 (assoc (or multi-method method tramp-default-method) | |
4976 tramp-methods)) | |
4977 (error "Method `%s' didn't specify `keep-date' arg for tramp" | |
4978 (or multi-method method))))) | |
4979 | |
4980 (defun tramp-get-su-program (multi-method method) | |
4981 (second (or (assoc 'tramp-su-program | |
4982 (assoc (or multi-method method tramp-default-method) | |
4983 tramp-methods)) | |
4984 (error "Method `%s' didn't specify a su program" | |
4985 (or multi-method method))))) | |
4986 | |
4987 (defun tramp-get-su-args (multi-method method) | |
4988 (second (or (assoc 'tramp-su-args | |
4989 (assoc (or multi-method method tramp-default-method) | |
4990 tramp-methods)) | |
4991 (error "Method `%s' didn't specify su args" | |
4992 (or multi-method method))))) | |
4993 | |
4994 (defun tramp-get-encoding-command (multi-method method) | |
4995 (second (or (assoc 'tramp-encoding-command | |
4996 (assoc (or multi-method method tramp-default-method) | |
4997 tramp-methods)) | |
4998 (error "Method `%s' didn't specify an encoding command" | |
4999 (or multi-method method))))) | |
5000 | |
5001 (defun tramp-get-decoding-command (multi-method method) | |
5002 (second (or (assoc 'tramp-decoding-command | |
5003 (assoc (or multi-method method tramp-default-method) | |
5004 tramp-methods)) | |
5005 (error "Method `%s' didn't specify a decoding command" | |
5006 (or multi-method method))))) | |
5007 | |
5008 (defun tramp-get-encoding-function (multi-method method) | |
5009 (second (or (assoc 'tramp-encoding-function | |
5010 (assoc (or multi-method method tramp-default-method) | |
5011 tramp-methods)) | |
5012 (error "Method `%s' didn't specify an encoding function" | |
5013 (or multi-method method))))) | |
5014 | |
5015 (defun tramp-get-decoding-function (multi-method method) | |
5016 (second (or (assoc 'tramp-decoding-function | |
5017 (assoc (or multi-method method tramp-default-method) | |
5018 tramp-methods)) | |
5019 (error "Method `%s' didn't specify a decoding function" | |
5020 (or multi-method method))))) | |
5021 | |
5022 (defun tramp-get-telnet-program (multi-method method) | |
5023 (second (or (assoc 'tramp-telnet-program | |
5024 (assoc (or multi-method method tramp-default-method) | |
5025 tramp-methods)) | |
5026 (error "Method `%s' didn't specify a telnet program" | |
5027 (or multi-method method))))) | |
5028 | |
5029 (defun tramp-get-telnet-args (multi-method method) | |
5030 (second (or (assoc 'tramp-telnet-args | |
5031 (assoc (or multi-method method tramp-default-method) | |
5032 tramp-methods)) | |
5033 (error "Method `%s' didn't specify telnet args" | |
5034 (or multi-method method))))) | |
5035 | |
5036 ;; Auto saving to a special directory. | |
5037 | |
5038 (defun tramp-make-auto-save-file-name (fn) | |
5039 "Returns a file name in `tramp-auto-save-directory' for autosaving this file." | |
5040 (when tramp-auto-save-directory | |
5041 (unless (file-exists-p tramp-auto-save-directory) | |
5042 (make-directory tramp-auto-save-directory t))) | |
5043 ;; jka-compr doesn't like auto-saving, so by appending "~" to the | |
5044 ;; file name we make sure that jka-compr isn't used for the | |
5045 ;; auto-save file. | |
5046 (let ((buffer-file-name (expand-file-name | |
5047 (tramp-subst-strs-in-string '(("_" . "|") | |
5048 ("/" . "_a") | |
5049 (":" . "_b") | |
5050 ("|" . "__") | |
5051 ("[" . "_l") | |
5052 ("]" . "_r")) | |
5053 fn) | |
5054 tramp-auto-save-directory))) | |
5055 (make-auto-save-file-name))) | |
5056 | |
5057 (defadvice make-auto-save-file-name | |
5058 (around tramp-advice-make-auto-save-file-name () activate) | |
5059 "Invoke `tramp-make-auto-save-file-name' for tramp files." | |
5060 (if (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)) | |
5061 tramp-auto-save-directory) | |
5062 (setq ad-return-value | |
5063 (tramp-make-auto-save-file-name (buffer-file-name))) | |
5064 ad-do-it)) | |
5065 | |
5066 (defun tramp-subst-strs-in-string (alist string) | |
5067 "Replace all occurrences of the string FROM with TO in STRING. | |
5068 ALIST is of the form ((FROM . TO) ...)." | |
5069 (save-match-data | |
5070 (while alist | |
5071 (let* ((pr (car alist)) | |
5072 (from (car pr)) | |
5073 (to (cdr pr))) | |
5074 (while (string-match (regexp-quote from) string) | |
5075 (setq string (replace-match to t t string))) | |
5076 (setq alist (cdr alist)))) | |
5077 string)) | |
5078 | |
5079 (defun tramp-insert-with-face (face string) | |
5080 "Insert text with a specific face." | |
5081 (let ((start (point))) | |
5082 (insert string) | |
5083 (add-text-properties start (point) (list 'face face)))) | |
5084 | |
5085 ;; ------------------------------------------------------------ | |
5086 ;; -- Compatibility functions section -- | |
5087 ;; ------------------------------------------------------------ | |
5088 | |
5089 (defun tramp-temporary-file-directory () | |
5090 "Return name of directory for temporary files (compat function). | |
5091 For Emacs, this is the variable `temporary-file-directory', for XEmacs | |
5092 this is the function `temp-directory'." | |
5093 (cond ((boundp 'temporary-file-directory) | |
5094 (symbol-value 'temporary-file-directory)) | |
5095 ((fboundp 'temp-directory) | |
5096 (funcall (symbol-function 'temp-directory))) ;pacify byte-compiler | |
5097 ((let ((d (getenv "TEMP"))) (and d (file-directory-p d))) | |
5098 (file-name-as-directory (getenv "TEMP"))) | |
5099 ((let ((d (getenv "TMP"))) (and d (file-directory-p d))) | |
5100 (file-name-as-directory (getenv "TMP"))) | |
5101 ((let ((d (getenv "TMPDIR"))) (and d (file-directory-p d))) | |
5102 (file-name-as-directory (getenv "TMPDIR"))) | |
5103 ((file-exists-p "c:/temp") (file-name-as-directory "c:/temp")) | |
5104 (t (message (concat "Neither `temporary-file-directory' nor " | |
5105 "`temp-directory' is defined -- using /tmp.")) | |
5106 (file-name-as-directory "/tmp")))) | |
5107 | |
5108 (defun tramp-read-passwd (prompt) | |
5109 "Read a password from user (compat function). | |
5110 Invokes `read-passwd' if that is defined, else `ange-ftp-read-passwd'." | |
5111 (apply | |
5112 (if (fboundp 'read-passwd) #'read-passwd #'ange-ftp-read-passwd) | |
5113 (list prompt))) | |
5114 | |
5115 (defun tramp-time-diff (t1 t2) | |
5116 "Return the difference between the two times, in seconds. | |
5117 T1 and T2 are time values (as returned by `current-time' for example). | |
5118 | |
5119 NOTE: This function will fail if the time difference is too large to | |
5120 fit in an integer." | |
5121 ;; Pacify byte-compiler with `symbol-function'. | |
5122 (cond ((fboundp 'subtract-time) | |
5123 (cadr (funcall (symbol-function 'subtract-time) t1 t2))) | |
5124 ((fboundp 'itimer-time-difference) | |
5125 (floor (funcall | |
5126 (symbol-function 'itimer-time-difference) | |
5127 (if (< (length t1) 3) (append t1 '(0)) t1) | |
5128 (if (< (length t2) 3) (append t2 '(0)) t2)))) | |
5129 (t | |
5130 ;; snarfed from Emacs 21 time-date.el | |
5131 (cadr (let ((borrow (< (cadr t1) (cadr t2)))) | |
5132 (list (- (car t1) (car t2) (if borrow 1 0)) | |
5133 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))))) | |
5134 | |
5135 (defun tramp-coding-system-change-eol-conversion (coding-system eol-type) | |
5136 "Return a coding system like CODING-SYSTEM but with given EOL-TYPE. | |
5137 EOL-TYPE can be one of `dos', `unix', or `mac'." | |
5138 (cond ((fboundp 'coding-system-change-eol-conversion) | |
5139 (apply #'coding-system-change-eol-conversion | |
5140 (list coding-system eol-type))) | |
5141 ((fboundp 'subsidiary-coding-system) | |
5142 (apply | |
5143 #'subsidiary-coding-system | |
5144 (list coding-system | |
5145 (cond ((eq eol-type 'dos) 'crlf) | |
5146 ((eq eol-type 'unix) 'lf) | |
5147 ((eq eol-type 'mac) 'cr) | |
5148 (t | |
5149 (error "Unknown EOL-TYPE `%s', must be %s" | |
5150 eol-type | |
5151 "`dos', `unix', or `mac'")))))) | |
5152 (t (error "Can't change EOL conversion -- is MULE missing?")))) | |
5153 | |
5154 (defun tramp-split-string (string pattern) | |
5155 "Like `split-string' but omit empty strings. | |
5156 In Emacs, (split-string \"/foo/bar\" \"/\") returns (\"foo\" \"bar\"). | |
5157 This is, the first, empty, element is omitted. In XEmacs, the first | |
5158 element is not omitted. | |
5159 | |
5160 Note: this function has been written for `tramp-handle-file-truename'. | |
5161 If you want to use it for something else, you'll have to check whether | |
5162 it does the right thing." | |
5163 (delete "" (split-string string pattern))) | |
5164 | |
5165 ;; ------------------------------------------------------------ | |
5166 ;; -- Kludges section -- | |
5167 ;; ------------------------------------------------------------ | |
5168 | |
5169 ;; Currently (as of Emacs 20.5), the function `shell-quote-argument' | |
5170 ;; does not deal well with newline characters. Newline is replaced by | |
5171 ;; backslash newline. But if, say, the string `a backslash newline b' | |
5172 ;; is passed to a shell, the shell will expand this into "ab", | |
5173 ;; completely omitting the newline. This is not what was intended. | |
5174 ;; It does not appear to be possible to make the function | |
5175 ;; `shell-quote-argument' work with newlines without making it | |
5176 ;; dependent on the shell used. But within this package, we know that | |
5177 ;; we will always use a Bourne-like shell, so we use an approach which | |
5178 ;; groks newlines. | |
5179 ;; | |
5180 ;; The approach is simple: we call `shell-quote-argument', then | |
5181 ;; massage the newline part of the result. | |
5182 ;; | |
5183 ;; This function should produce a string which is grokked by a Unix | |
5184 ;; shell, even if the Emacs is running on Windows. Since this is the | |
5185 ;; kludges section, we bind `system-type' in such a way that | |
5186 ;; `shell-quote-arguments' behaves as if on Unix. | |
5187 ;; | |
5188 ;; Thanks to Mario DeWeerd for the hint that it is sufficient for this | |
5189 ;; function to work with Bourne-like shells. | |
5190 ;; | |
5191 ;; CCC: This function should be rewritten so that | |
5192 ;; `shell-quote-argument' is not used. This way, we are safe from | |
5193 ;; changes in `shell-quote-argument'. | |
5194 (defun tramp-shell-quote-argument (s) | |
5195 "Similar to `shell-quote-argument', but groks newlines. | |
5196 Only works for Bourne-like shells." | |
5197 (let ((system-type 'not-windows)) | |
5198 (save-match-data | |
5199 (let ((result (shell-quote-argument s)) | |
5200 (nl (regexp-quote (format "\\%s" tramp-rsh-end-of-line)))) | |
5201 (when (and (>= (length result) 2) | |
5202 (string= (substring result 0 2) "\\~")) | |
5203 (setq result (substring result 1))) | |
5204 (while (string-match nl result) | |
5205 (setq result (replace-match (format "'%s'" tramp-rsh-end-of-line) | |
5206 t t result))) | |
5207 result)))) | |
5208 | |
5209 ;; ;; EFS hooks itself into the file name handling stuff in more places | |
5210 ;; ;; than just `file-name-handler-alist'. The following tells EFS to stay | |
5211 ;; ;; away from tramp.el paths. | |
5212 ;; ;; | |
5213 ;; ;; This is needed because EFS installs (efs-dired-before-readin) into | |
5214 ;; ;; 'dired-before-readin-hook'. This prevents EFS from opening an FTP | |
5215 ;; ;; connection to help it's dired process. Not that I have any real | |
5216 ;; ;; idea *why* this is helpful to dired. | |
5217 ;; ;; | |
5218 ;; ;; Anyway, this advice fixes the problem (with a sledgehammer :) | |
5219 ;; ;; | |
5220 ;; ;; Daniel Pittman <daniel@danann.net> | |
5221 ;; ;; | |
5222 ;; ;; CCC: when the other defadvice calls have disappeared, make sure | |
5223 ;; ;; not to call defadvice unless it's necessary. How do we find out whether | |
5224 ;; ;; it is necessary? (featurep 'efs) is surely the wrong way -- | |
5225 ;; ;; EFS might nicht be loaded yet. | |
5226 ;; (defadvice efs-ftp-path (around dont-match-tramp-path activate protect) | |
5227 ;; "Cause efs-ftp-path to fail when the path is a TRAMP path." | |
5228 ;; (if (tramp-tramp-file-p (ad-get-arg 0)) | |
5229 ;; nil | |
5230 ;; ad-do-it)) | |
5231 | |
5232 ;; We currently use "[" and "]" in the filename format. In Emacs | |
5233 ;; 20.x, this means that Emacs wants to expand wildcards if | |
5234 ;; `find-file-wildcards' is non-nil, and then barfs because no | |
5235 ;; expansion could be found. We detect this situation and do | |
5236 ;; something really awful: we have `file-expand-wildcards' return the | |
5237 ;; original filename if it can't expand anything. Let's just hope | |
5238 ;; that this doesn't break anything else. | |
5239 ;; | |
5240 ;; Another problem is that the check is done by Emacs version, which | |
5241 ;; is really not what we want to do. Oh, well. | |
5242 | |
5243 ;;(when (and (not (featurep 'xemacs)) | |
5244 ;; (= emacs-major-version 20)) | |
5245 ;; It seems that this advice is needed in Emacs 21, too. | |
5246 (defadvice file-expand-wildcards (around tramp-fix activate) | |
5247 (let ((name (ad-get-arg 0))) | |
5248 (if (tramp-tramp-file-p name) | |
5249 ;; If it's a Tramp file, dissect it and look if wildcards | |
5250 ;; need to be expanded at all. | |
5251 (let ((v (tramp-dissect-file-name name))) | |
5252 (if (string-match "[[*?]" (tramp-file-name-path v)) | |
5253 (let ((res ad-do-it)) | |
5254 (setq ad-return-value (or res (list name)))) | |
5255 (setq ad-return-value (list name)))) | |
5256 ;; If it is not a Tramp file, just run the original function. | |
5257 (let ((res ad-do-it)) | |
5258 (setq ad-return-value (or res (list name))))))) | |
5259 ;; ) | |
5260 | |
5261 ;; Make the `reporter` functionality available for making bug reports about | |
5262 ;; the package. A most useful piece of code. | |
5263 | |
5264 (unless (fboundp 'reporter-submit-bug-report) | |
5265 (autoload 'reporter-submit-bug-report "reporter")) | |
5266 | |
5267 (defun tramp-bug () | |
5268 "Submit a bug report to the TRAMP developers." | |
5269 (interactive) | |
5270 (require 'reporter) | |
5271 (let ((reporter-prompt-for-summary-p t)) | |
5272 (reporter-submit-bug-report | |
5273 tramp-bug-report-address ; to-address | |
5274 (format "tramp (%s)" tramp-version) ; package name and version | |
5275 `(;; Current state | |
5276 tramp-ls-command | |
5277 tramp-test-groks-nt | |
5278 tramp-file-exists-command | |
5279 tramp-current-multi-method | |
5280 tramp-current-method | |
5281 tramp-current-user | |
5282 tramp-current-host | |
5283 | |
5284 ;; System defaults | |
5285 tramp-auto-save-directory ; vars to dump | |
5286 tramp-default-method | |
5287 tramp-rsh-end-of-line | |
5288 tramp-remote-path | |
5289 tramp-login-prompt-regexp | |
5290 tramp-password-prompt-regexp | |
5291 tramp-wrong-passwd-regexp | |
5292 tramp-temp-name-prefix | |
5293 tramp-file-name-structure | |
5294 tramp-file-name-regexp | |
5295 tramp-multi-file-name-structure | |
5296 tramp-multi-file-name-hop-structure | |
5297 tramp-multi-methods | |
5298 tramp-multi-connection-function-alist | |
5299 tramp-make-tramp-file-format | |
5300 tramp-end-of-output | |
5301 | |
5302 ;; Non-tramp variables of interest | |
5303 shell-prompt-pattern | |
5304 backup-by-copying | |
5305 backup-by-copying-when-linked | |
5306 backup-by-copying-when-mismatch | |
5307 ,(when (boundp 'backup-by-copying-when-privileged-mismatch) | |
5308 'backup-by-copying-when-privileged-mismatch) | |
5309 file-name-handler-alist) | |
5310 nil ; pre-hook | |
5311 nil ; post-hook | |
5312 "\ | |
5313 Enter your bug report in this message, including as much detail as you | |
5314 possibly can about the problem, what you did to cause it and what the | |
5315 local and remote machines are. | |
5316 | |
5317 If you can give a simple set of instructions to make this bug happen | |
5318 reliably, please include those. Thank you for helping kill bugs in | |
5319 TRAMP. | |
5320 --bug report follows this line--"))) | |
5321 | |
5322 (defalias 'tramp-submit-bug 'tramp-bug) | |
5323 | |
5324 (provide 'tramp) | |
5325 | |
5326 ;; Make sure that we get integration with the VC package. | |
5327 ;; When it is loaded, we need to pull in the integration module. | |
5328 ;; This must come after (provide 'tramp) because tramp-vc.el | |
5329 ;; requires tramp. | |
5330 (eval-after-load "vc" | |
5331 '(require 'tramp-vc)) | |
5332 | |
5333 ;;; TODO: | |
5334 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5335 ;; * Revise the comments near the beginning of the file. |
45861 | 5336 ;; * Cooperate with PCL-CVS. It uses start-process, which doesn't |
5337 ;; work for remote files. | |
5338 ;; * Rewrite `tramp-shell-quote-argument' to abstain from using | |
5339 ;; `shell-quote-argument'. | |
5340 ;; * Completion gets confused when you leave out the method name. | |
5341 ;; * Support `dired-compress-file' filename handler. | |
5342 ;; * In Emacs 21, `insert-directory' shows total number of bytes used | |
5343 ;; by the files in that directory. Add this here. | |
5344 ;; * Avoid screen blanking when hitting `g' in dired. (Eli Tziperman) | |
5345 ;; * Make ffap.el grok Tramp filenames. (Eli Tziperman) | |
5346 ;; * When logging in, keep looking for questions according to an alist | |
5347 ;; and then invoke the right function. | |
5348 ;; * Case-insensitive filename completion. (Norbert Goevert.) | |
5349 ;; * Running CVS remotely doesn't appear to work right. It thinks | |
5350 ;; files are locked by somebody else even if I'm the locking user. | |
5351 ;; Sometimes, one gets `No CVSROOT specified' errors from CVS. | |
5352 ;; (Skip Montanaro) | |
5353 ;; * Don't use globbing for directories with many files, as this is | |
5354 ;; likely to produce long command lines, and some shells choke on | |
5355 ;; long command lines. | |
5356 ;; * Find out about the new auto-save mechanism in Emacs 21 and | |
5357 ;; do the right thing. | |
5358 ;; * `vc-directory' does not work. It never displays any files, even | |
5359 ;; if it does show files when run locally. | |
5360 ;; * Allow correction of passwords, if the remote end allows this. | |
5361 ;; (Mark Hershberger) | |
5362 ;; * Make sure permissions of tmp file are good. | |
5363 ;; (Nelson Minar <nelson@media.mit.edu>) | |
5364 ;; * Grok passwd prompts with scp? (David Winter | |
5365 ;; <winter@nevis1.nevis.columbia.edu>). Maybe just do `ssh -l user | |
5366 ;; host', then wait a while for the passwd or passphrase prompt. If | |
5367 ;; there is one, remember the passwd/phrase. | |
5368 ;; * How to deal with MULE in `insert-file-contents' and `write-region'? | |
5369 ;; * Do asynchronous `shell-command's. | |
5370 ;; * Grok `append' parameter for `write-region'. | |
5371 ;; * Test remote ksh or bash for tilde expansion in `tramp-find-shell'? | |
5372 ;; * abbreviate-file-name | |
5373 ;; * grok ~ in tramp-remote-path (Henrik Holm <henrikh@tele.ntnu.no>) | |
5374 ;; * `C' in dired gives error `not tramp file name'. | |
5375 ;; * Also allow to omit user names when doing multi-hop. Not sure yet | |
5376 ;; what the user names should default to, though. | |
5377 ;; * better error checking. At least whenever we see something | |
5378 ;; strange when doing zerop, we should kill the process and start | |
5379 ;; again. (Greg Stark) | |
5380 ;; * Add caching for filename completion. (Greg Stark) | |
5381 ;; Of course, this has issues with usability (stale cache bites) | |
5382 ;; -- <daniel@danann.net> | |
5383 ;; * Provide a local cache of old versions of remote files for the rsync | |
5384 ;; transfer method to use. (Greg Stark) | |
5385 ;; * Remove unneeded parameters from methods. | |
5386 ;; * Invoke rsync once for copying a whole directory hierarchy. | |
5387 ;; (Francesco Potort́) | |
5388 ;; * Should we set PATH ourselves or should we rely on the remote end | |
5389 ;; to do it? | |
5390 ;; * Do the autoconf thing. | |
5391 ;; * Make it work for XEmacs 20, which is missing `with-timeout'. | |
5392 ;; * Allow non-Unix remote systems. (More a long-term thing.) | |
5393 ;; * Make it work for different encodings, and for different file name | |
5394 ;; encodings, too. (Daniel Pittman) | |
5395 ;; * Change applicable functions to pass a struct tramp-file-name rather | |
5396 ;; than the individual items MULTI-METHOD, METHOD, USER, HOST, PATH. | |
5397 ;; * Implement asynchronous shell commands. | |
5398 ;; * Clean up unused *tramp/foo* buffers after a while. (Pete Forman) | |
5399 ;; * Progress reports while copying files. (Michael Kifer) | |
5400 ;; * `Smart' connection method that uses inline for small and out of | |
5401 ;; band for large files. (Michael Kifer) | |
5402 ;; * Don't search for perl5 and perl. Instead, only search for perl and | |
5403 ;; then look if it's the right version (with `perl -v'). | |
5404 ;; * When editing a remote CVS controlled file as a different user, VC | |
5405 ;; gets confused about the file locking status. Try to find out why | |
5406 ;; the workaround doesn't work. | |
5407 ;; * When user is running ssh-agent, it would be useful to add the | |
5408 ;; passwords typed by the user to that agent. This way, the next time | |
5409 ;; round, the users don't have to type all this in again. | |
5410 ;; This would be especially useful for start-process, I think. | |
5411 ;; An easy way to implement start-process is to open a second shell | |
5412 ;; connection which is inconvenient if the user has to reenter | |
5413 ;; passwords. | |
5414 ;; * Change `copy-file' to grok the case where the filename handler | |
5415 ;; for the source and the target file are different. Right now, | |
5416 ;; it looks at the source file and then calls that handler, if | |
5417 ;; there is one. But since ange-ftp, for instance, does not know | |
5418 ;; about Tramp, it does not do the right thing if the target file | |
5419 ;; name is a Tramp name. | |
5420 | |
5421 ;; Functions for file-name-handler-alist: | |
5422 ;; diff-latest-backup-file -- in diff.el | |
5423 ;; dired-compress-file | |
5424 ;; dired-uncache -- this will be needed when we do insert-directory caching | |
5425 ;; file-name-as-directory -- use primitive? | |
5426 ;; file-name-directory -- use primitive? | |
5427 ;; file-name-nondirectory -- use primitive? | |
5428 ;; file-name-sans-versions -- use primitive? | |
5429 ;; file-newer-than-file-p | |
5430 ;; find-backup-file-name | |
5431 ;; get-file-buffer -- use primitive | |
5432 ;; load | |
5433 ;; unhandled-file-name-directory | |
5434 ;; vc-registered | |
5435 | |
5436 ;;; tramp.el ends here |