Mercurial > emacs
annotate lisp/net/tramp.el @ 46584:f548d7d0c651
Bump version to 2.0.2.
(tramp-methods): Rename methods invoking "ssh1" or "ssh2" to
longer names. Use old names "sm1", "sm2" and so on for methods
invoking "ssh -1" or "ssh -2".
(tramp-multi-file-name-structure-separate): Typo, its name was set
to "tramp-file-name-structure-separate". Trivial patch. From
Steve Youngs <youngs@xemacs.org>.
(tramp-multi-sh-program): New variable.
(tramp-open-connection-multi): Use it. Now you can use multi
methods from Windows (at least in principle).
(tramp-do-copy-or-rename-via-buffer): New function.
(tramp-do-copy-or-rename-file): Use it. Change and simplify
logic. Omit special case of invoking rcp directly to copy the
files.
(tramp-open-connection-su, tramp-multi-connect-telnet)
(tramp-multi-connect-rlogin, tramp-multi-connect-su)
(tramp-make-tramp-file-name, tramp-make-tramp-multi-file-name):
Use backticks in format-spec for brevity and to avoid
character/number confusion in XEmacs.
author | Kai Großjohann <kgrossjo@eu.uu.net> |
---|---|
date | Sun, 21 Jul 2002 13:49:06 +0000 |
parents | 3996ea20e5e3 |
children | 54b975949d6a |
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 | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
72 (defconst tramp-version "2.0.2" |
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 | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
134 (defcustom tramp-multi-sh-program |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
135 (if (memq system-type '(windows-nt)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
136 "cmd.exe" |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
137 tramp-sh-program) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
138 "*Use this program for bootstrapping multi-hop connections. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
139 This variable is similar to `tramp-sh-program', but it is only used |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
140 when initializing a multi-hop connection. Therefore, the set of |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
141 commands sent to this shell is quite restricted, and if you are |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
142 careful it works to use CMD.EXE under Windows (instead of a Bourne-ish |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
143 shell which does not normally exist on Windows anyway). |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
144 |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
145 To use multi-hop methods from Windows, you also need suitable entries |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
146 in `tramp-multi-connection-function-alist' for the first hop. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
147 |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
148 This variable defaults to CMD.EXE on Windows NT, and to the value of |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
149 `tramp-sh-program' on other systems." |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
150 :group 'tramp |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
151 :type '(file :must-match t)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
152 |
45861 | 153 ;; CCC I have changed all occurrences of comint-quote-filename with |
154 ;; tramp-shell-quote-argument, except in tramp-handle-expand-many-files. | |
155 ;; There, comint-quote-filename was removed altogether. If it turns | |
156 ;; out to be necessary there, something will need to be done. | |
157 ;;-(defcustom tramp-file-name-quote-list | |
158 ;;- '(?] ?[ ?\| ?& ?< ?> ?\( ?\) ?\; ?\ ?\* ?\? ?\! ?\" ?\' ?\` ?# ?\@ ?\+ ) | |
159 ;;- "*Protect these characters from the remote shell. | |
160 ;;-Any character in this list is quoted (preceded with a backslash) | |
161 ;;-because it means something special to the shell. This takes effect | |
162 ;;-when sending file and directory names to the remote shell. | |
163 ;;- | |
164 ;;-See `comint-file-name-quote-list' for details." | |
165 ;;- :group 'tramp | |
166 ;;- :type '(repeat character)) | |
167 | |
168 (defcustom tramp-methods | |
169 '( ("rcp" (tramp-connection-function tramp-open-connection-rsh) | |
170 (tramp-rsh-program "rsh") | |
171 (tramp-rcp-program "rcp") | |
172 (tramp-remote-sh "/bin/sh") | |
173 (tramp-rsh-args nil) | |
174 (tramp-rcp-args nil) | |
175 (tramp-rcp-keep-date-arg "-p") | |
176 (tramp-su-program nil) | |
177 (tramp-su-args nil) | |
178 (tramp-encoding-command nil) | |
179 (tramp-decoding-command nil) | |
180 (tramp-encoding-function nil) | |
181 (tramp-decoding-function nil) | |
182 (tramp-telnet-program nil) | |
183 (tramp-telnet-args nil)) | |
184 ("scp" (tramp-connection-function tramp-open-connection-rsh) | |
185 (tramp-rsh-program "ssh") | |
186 (tramp-rcp-program "scp") | |
187 (tramp-remote-sh "/bin/sh") | |
188 (tramp-rsh-args ("-e" "none")) | |
189 (tramp-rcp-args nil) | |
190 (tramp-rcp-keep-date-arg "-p") | |
191 (tramp-su-program nil) | |
192 (tramp-su-args nil) | |
193 (tramp-encoding-command nil) | |
194 (tramp-decoding-command nil) | |
195 (tramp-encoding-function nil) | |
196 (tramp-decoding-function nil) | |
197 (tramp-telnet-program nil) | |
198 (tramp-telnet-args nil)) | |
199 ("scp1" (tramp-connection-function tramp-open-connection-rsh) | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
200 (tramp-rsh-program "ssh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
201 (tramp-rcp-program "scp") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
202 (tramp-remote-sh "/bin/sh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
203 (tramp-rsh-args ("-1" "-e" "none")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
204 (tramp-rcp-args ("-1")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
205 (tramp-rcp-keep-date-arg "-p") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
206 (tramp-su-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
207 (tramp-su-args nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
208 (tramp-encoding-command nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
209 (tramp-decoding-command nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
210 (tramp-encoding-function nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
211 (tramp-decoding-function nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
212 (tramp-telnet-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
213 (tramp-telnet-args nil)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
214 ("scp2" (tramp-connection-function tramp-open-connection-rsh) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
215 (tramp-rsh-program "ssh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
216 (tramp-rcp-program "scp") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
217 (tramp-remote-sh "/bin/sh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
218 (tramp-rsh-args ("-2" "-e" "none")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
219 (tramp-rcp-args ("-2")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
220 (tramp-rcp-keep-date-arg "-p") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
221 (tramp-su-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
222 (tramp-su-args nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
223 (tramp-encoding-command nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
224 (tramp-decoding-command nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
225 (tramp-encoding-function nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
226 (tramp-decoding-function nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
227 (tramp-telnet-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
228 (tramp-telnet-args nil)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
229 ("scp-ssh1" (tramp-connection-function tramp-open-connection-rsh) |
45861 | 230 (tramp-rsh-program "ssh1") |
231 (tramp-rcp-program "scp1") | |
232 (tramp-remote-sh "/bin/sh") | |
233 (tramp-rsh-args ("-e" "none")) | |
234 (tramp-rcp-args nil) | |
235 (tramp-rcp-keep-date-arg "-p") | |
236 (tramp-su-program nil) | |
237 (tramp-su-args nil) | |
238 (tramp-encoding-command nil) | |
239 (tramp-decoding-command nil) | |
240 (tramp-encoding-function nil) | |
241 (tramp-decoding-function nil) | |
242 (tramp-telnet-program nil) | |
243 (tramp-telnet-args nil)) | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
244 ("scp-ssh2" (tramp-connection-function tramp-open-connection-rsh) |
45861 | 245 (tramp-rsh-program "ssh2") |
246 (tramp-rcp-program "scp2") | |
247 (tramp-remote-sh "/bin/sh") | |
248 (tramp-rsh-args ("-e" "none")) | |
249 (tramp-rcp-args nil) | |
250 (tramp-rcp-keep-date-arg "-p") | |
251 (tramp-su-program nil) | |
252 (tramp-su-args nil) | |
253 (tramp-encoding-command nil) | |
254 (tramp-decoding-command nil) | |
255 (tramp-encoding-function nil) | |
256 (tramp-decoding-function nil) | |
257 (tramp-telnet-program nil) | |
258 (tramp-telnet-args nil)) | |
259 ("rsync" (tramp-connection-function tramp-open-connection-rsh) | |
260 (tramp-rsh-program "ssh") | |
261 (tramp-rcp-program "rsync") | |
262 (tramp-remote-sh "/bin/sh") | |
263 (tramp-rsh-args ("-e" "none")) | |
264 (tramp-rcp-args ("-e" "ssh")) | |
265 (tramp-rcp-keep-date-arg "-t") | |
266 (tramp-su-program nil) | |
267 (tramp-su-args nil) | |
268 (tramp-encoding-command nil) | |
269 (tramp-decoding-command nil) | |
270 (tramp-encoding-function nil) | |
271 (tramp-decoding-function nil) | |
272 (tramp-telnet-program nil) | |
273 (tramp-telnet-args nil)) | |
274 ("ru" (tramp-connection-function tramp-open-connection-rsh) | |
275 (tramp-rsh-program "rsh") | |
276 (tramp-rcp-program nil) | |
277 (tramp-remote-sh "/bin/sh") | |
278 (tramp-rsh-args nil) | |
279 (tramp-rcp-args nil) | |
280 (tramp-rcp-keep-date-arg nil) | |
281 (tramp-su-program nil) | |
282 (tramp-su-args nil) | |
283 (tramp-encoding-command "uuencode xxx") | |
284 (tramp-decoding-command | |
285 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") | |
286 (tramp-encoding-function nil) | |
287 (tramp-decoding-function uudecode-decode-region) | |
288 (tramp-telnet-program nil) | |
289 (tramp-telnet-args nil)) | |
290 ("su" (tramp-connection-function tramp-open-connection-rsh) | |
291 (tramp-rsh-program "ssh") | |
292 (tramp-rcp-program nil) | |
293 (tramp-remote-sh "/bin/sh") | |
294 (tramp-rsh-args ("-e" "none")) | |
295 (tramp-rcp-args nil) | |
296 (tramp-rcp-keep-date-arg nil) | |
297 (tramp-su-program nil) | |
298 (tramp-su-args nil) | |
299 (tramp-encoding-command "uuencode xxx") | |
300 (tramp-decoding-command | |
301 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") | |
302 (tramp-encoding-function nil) | |
303 (tramp-decoding-function uudecode-decode-region) | |
304 (tramp-telnet-program nil) | |
305 (tramp-telnet-args nil)) | |
306 ("su1" (tramp-connection-function tramp-open-connection-rsh) | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
307 (tramp-rsh-program "ssh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
308 (tramp-rcp-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
309 (tramp-remote-sh "/bin/sh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
310 (tramp-rsh-args ("-1" "-e" "none")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
311 (tramp-rcp-args ("-1")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
312 (tramp-rcp-keep-date-arg nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
313 (tramp-su-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
314 (tramp-su-args nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
315 (tramp-encoding-command "uuencode xxx") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
316 (tramp-decoding-command |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
317 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
318 (tramp-encoding-function nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
319 (tramp-decoding-function uudecode-decode-region) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
320 (tramp-telnet-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
321 (tramp-telnet-args nil)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
322 ("su2" (tramp-connection-function tramp-open-connection-rsh) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
323 (tramp-rsh-program "ssh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
324 (tramp-rcp-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
325 (tramp-remote-sh "/bin/sh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
326 (tramp-rsh-args ("-2" "-e" "none")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
327 (tramp-rcp-args ("-2")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
328 (tramp-rcp-keep-date-arg nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
329 (tramp-su-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
330 (tramp-su-args nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
331 (tramp-encoding-command "uuencode xxx") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
332 (tramp-decoding-command |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
333 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
334 (tramp-encoding-function nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
335 (tramp-decoding-function uudecode-decode-region) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
336 (tramp-telnet-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
337 (tramp-telnet-args nil)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
338 ("su-ssh1" (tramp-connection-function tramp-open-connection-rsh) |
45861 | 339 (tramp-rsh-program "ssh1") |
340 (tramp-rcp-program nil) | |
341 (tramp-remote-sh "/bin/sh") | |
342 (tramp-rsh-args ("-e" "none")) | |
343 (tramp-rcp-args nil) | |
344 (tramp-rcp-keep-date-arg nil) | |
345 (tramp-su-program nil) | |
346 (tramp-su-args nil) | |
347 (tramp-encoding-command "uuencode xxx") | |
348 (tramp-decoding-command | |
349 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") | |
350 (tramp-encoding-function nil) | |
351 (tramp-decoding-function uudecode-decode-region) | |
352 (tramp-telnet-program nil) | |
353 (tramp-telnet-args nil)) | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
354 ("su-ssh2" (tramp-connection-function tramp-open-connection-rsh) |
45861 | 355 (tramp-rsh-program "ssh2") |
356 (tramp-rcp-program nil) | |
357 (tramp-remote-sh "/bin/sh") | |
358 (tramp-rsh-args ("-e" "none")) | |
359 (tramp-rcp-args nil) | |
360 (tramp-rcp-keep-date-arg nil) | |
361 (tramp-su-program nil) | |
362 (tramp-su-args nil) | |
363 (tramp-encoding-command "uuencode xxx") | |
364 (tramp-decoding-command | |
365 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") | |
366 (tramp-encoding-function nil) | |
367 (tramp-decoding-function uudecode-decode-region) | |
368 (tramp-telnet-program nil) | |
369 (tramp-telnet-args nil)) | |
370 ("rm" (tramp-connection-function tramp-open-connection-rsh) | |
371 (tramp-rsh-program "rsh") | |
372 (tramp-rcp-program nil) | |
373 (tramp-remote-sh "/bin/sh") | |
374 (tramp-rsh-args nil) | |
375 (tramp-rcp-args nil) | |
376 (tramp-rcp-keep-date-arg nil) | |
377 (tramp-su-program nil) | |
378 (tramp-su-args nil) | |
379 (tramp-encoding-command "mimencode -b") | |
380 (tramp-decoding-command "mimencode -u -b") | |
381 (tramp-encoding-function base64-encode-region) | |
382 (tramp-decoding-function base64-decode-region) | |
383 (tramp-telnet-program nil) | |
384 (tramp-telnet-args nil)) | |
385 ("sm" (tramp-connection-function tramp-open-connection-rsh) | |
386 (tramp-rsh-program "ssh") | |
387 (tramp-rcp-program nil) | |
388 (tramp-remote-sh "/bin/sh") | |
389 (tramp-rsh-args ("-e" "none")) | |
390 (tramp-rcp-args nil) | |
391 (tramp-rcp-keep-date-arg nil) | |
392 (tramp-su-program nil) | |
393 (tramp-su-args nil) | |
394 (tramp-encoding-command "mimencode -b") | |
395 (tramp-decoding-command "mimencode -u -b") | |
396 (tramp-encoding-function base64-encode-region) | |
397 (tramp-decoding-function base64-decode-region) | |
398 (tramp-telnet-program nil) | |
399 (tramp-telnet-args nil)) | |
400 ("smp" (tramp-connection-function tramp-open-connection-rsh) | |
401 (tramp-rsh-program "ssh") | |
402 (tramp-rcp-program nil) | |
403 (tramp-remote-sh "/bin/sh") | |
404 (tramp-rsh-args ("-e" "none")) | |
405 (tramp-rcp-args nil) | |
406 (tramp-rcp-keep-date-arg nil) | |
407 (tramp-su-program nil) | |
408 (tramp-su-args nil) | |
409 (tramp-encoding-command "tramp_mimencode") | |
410 (tramp-decoding-command "tramp_mimedecode") | |
411 (tramp-encoding-function base64-encode-region) | |
412 (tramp-decoding-function base64-decode-region) | |
413 (tramp-telnet-program nil)) | |
414 ("sm1" (tramp-connection-function tramp-open-connection-rsh) | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
415 (tramp-rsh-program "ssh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
416 (tramp-rcp-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
417 (tramp-remote-sh "/bin/sh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
418 (tramp-rsh-args ("-1" "-e" "none")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
419 (tramp-rcp-args ("-1")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
420 (tramp-rcp-keep-date-arg nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
421 (tramp-su-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
422 (tramp-su-args nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
423 (tramp-encoding-command "mimencode -b") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
424 (tramp-decoding-command "mimencode -u -b") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
425 (tramp-encoding-function base64-encode-region) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
426 (tramp-decoding-function base64-decode-region) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
427 (tramp-telnet-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
428 (tramp-telnet-args nil)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
429 ("sm2" (tramp-connection-function tramp-open-connection-rsh) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
430 (tramp-rsh-program "ssh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
431 (tramp-rcp-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
432 (tramp-remote-sh "/bin/sh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
433 (tramp-rsh-args ("-2" "-e" "none")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
434 (tramp-rcp-args ("-2")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
435 (tramp-rcp-keep-date-arg nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
436 (tramp-su-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
437 (tramp-su-args nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
438 (tramp-encoding-command "mimencode -b") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
439 (tramp-decoding-command "mimencode -u -b") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
440 (tramp-encoding-function base64-encode-region) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
441 (tramp-decoding-function base64-decode-region) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
442 (tramp-telnet-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
443 (tramp-telnet-args nil)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
444 ("sm-ssh1" (tramp-connection-function tramp-open-connection-rsh) |
45861 | 445 (tramp-rsh-program "ssh1") |
446 (tramp-rcp-program nil) | |
447 (tramp-remote-sh "/bin/sh") | |
448 (tramp-rsh-args ("-e" "none")) | |
449 (tramp-rcp-args nil) | |
450 (tramp-rcp-keep-date-arg nil) | |
451 (tramp-su-program nil) | |
452 (tramp-su-args nil) | |
453 (tramp-encoding-command "mimencode -b") | |
454 (tramp-decoding-command "mimencode -u -b") | |
455 (tramp-encoding-function base64-encode-region) | |
456 (tramp-decoding-function base64-decode-region) | |
457 (tramp-telnet-program nil) | |
458 (tramp-telnet-args nil)) | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
459 ("sm-ssh2" (tramp-connection-function tramp-open-connection-rsh) |
45861 | 460 (tramp-rsh-program "ssh2") |
461 (tramp-rcp-program nil) | |
462 (tramp-remote-sh "/bin/sh") | |
463 (tramp-rsh-args ("-e" "none")) | |
464 (tramp-rcp-args nil) | |
465 (tramp-rcp-keep-date-arg nil) | |
466 (tramp-su-program nil) | |
467 (tramp-su-args nil) | |
468 (tramp-encoding-command "mimencode -b") | |
469 (tramp-decoding-command "mimencode -u -b") | |
470 (tramp-encoding-function base64-encode-region) | |
471 (tramp-decoding-function base64-decode-region) | |
472 (tramp-telnet-program nil) | |
473 (tramp-telnet-args nil)) | |
474 ("tm" (tramp-connection-function tramp-open-connection-telnet) | |
475 (tramp-rsh-program nil) | |
476 (tramp-rcp-program nil) | |
477 (tramp-remote-sh "/bin/sh") | |
478 (tramp-rsh-args nil) | |
479 (tramp-rcp-args nil) | |
480 (tramp-rcp-keep-date-arg nil) | |
481 (tramp-su-program nil) | |
482 (tramp-su-args nil) | |
483 (tramp-encoding-command "mimencode -b") | |
484 (tramp-decoding-command "mimencode -u -b") | |
485 (tramp-encoding-function base64-encode-region) | |
486 (tramp-decoding-function base64-decode-region) | |
487 (tramp-telnet-program "telnet") | |
488 (tramp-telnet-args nil)) | |
489 ("tu" (tramp-connection-function tramp-open-connection-telnet) | |
490 (tramp-rsh-program nil) | |
491 (tramp-rcp-program nil) | |
492 (tramp-remote-sh "/bin/sh") | |
493 (tramp-rsh-args nil) | |
494 (tramp-rcp-args nil) | |
495 (tramp-rcp-keep-date-arg nil) | |
496 (tramp-su-program nil) | |
497 (tramp-su-args nil) | |
498 (tramp-encoding-command "uuencode xxx") | |
499 (tramp-decoding-command | |
500 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") | |
501 (tramp-encoding-function nil) | |
502 (tramp-decoding-function uudecode-decode-region) | |
503 (tramp-telnet-program "telnet") | |
504 (tramp-telnet-args nil)) | |
505 ("sum" (tramp-connection-function tramp-open-connection-su) | |
506 (tramp-rsh-program nil) | |
507 (tramp-rcp-program nil) | |
508 (tramp-remote-sh "/bin/sh") | |
509 (tramp-rsh-args nil) | |
510 (tramp-rcp-args nil) | |
511 (tramp-rcp-keep-date-arg nil) | |
512 (tramp-su-program "su") | |
513 (tramp-su-args ("-" "%u")) | |
514 (tramp-encoding-command "mimencode -b") | |
515 (tramp-decoding-command "mimencode -u -b") | |
516 (tramp-encoding-function base64-encode-region) | |
517 (tramp-decoding-function base64-decode-region) | |
518 (tramp-telnet-program nil) | |
519 (tramp-telnet-args nil)) | |
520 ("suu" (tramp-connection-function tramp-open-connection-su) | |
521 (tramp-rsh-program nil) | |
522 (tramp-rcp-program nil) | |
523 (tramp-remote-sh "/bin/sh") | |
524 (tramp-rsh-args nil) | |
525 (tramp-rcp-args nil) | |
526 (tramp-rcp-keep-date-arg nil) | |
527 (tramp-su-program "su") | |
528 (tramp-su-args ("-" "%u")) | |
529 (tramp-encoding-command "uuencode xxx") | |
530 (tramp-decoding-command | |
531 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") | |
532 (tramp-encoding-function nil) | |
533 (tramp-decoding-function uudecode-decode-region) | |
534 (tramp-telnet-program nil) | |
535 (tramp-telnet-args nil)) | |
536 ("sudm" (tramp-connection-function tramp-open-connection-su) | |
537 (tramp-rsh-program nil) | |
538 (tramp-rcp-program nil) | |
539 (tramp-remote-sh "/bin/sh") | |
540 (tramp-rsh-args nil) | |
541 (tramp-rcp-args nil) | |
542 (tramp-rcp-keep-date-arg nil) | |
543 (tramp-su-program "sudo") | |
544 (tramp-su-args ("-u" "%u" "-s")) | |
545 (tramp-encoding-command "mimencode -b") | |
546 (tramp-decoding-command "mimencode -u -b") | |
547 (tramp-encoding-function base64-encode-region) | |
548 (tramp-decoding-function base64-decode-region) | |
549 (tramp-telnet-program nil) | |
550 (tramp-telnet-args nil)) | |
551 ("sudu" (tramp-connection-function tramp-open-connection-su) | |
552 (tramp-rsh-program nil) | |
553 (tramp-rcp-program nil) | |
554 (tramp-remote-sh "/bin/sh") | |
555 (tramp-rsh-args nil) | |
556 (tramp-rcp-args nil) | |
557 (tramp-rcp-keep-date-arg nil) | |
558 (tramp-su-program "sudo") | |
559 (tramp-su-args ("-u" "%u" "-s")) | |
560 (tramp-encoding-command "uuencode xxx") | |
561 (tramp-decoding-command | |
562 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") | |
563 (tramp-encoding-function nil) | |
564 (tramp-decoding-function uudecode-decode-region) | |
565 (tramp-telnet-program nil) | |
566 (tramp-telnet-args nil)) | |
567 ("multi" (tramp-connection-function tramp-open-connection-multi) | |
568 (tramp-rsh-program nil) | |
569 (tramp-rcp-program nil) | |
570 (tramp-remote-sh "/bin/sh") | |
571 (tramp-rsh-args nil) | |
572 (tramp-rcp-args nil) | |
573 (tramp-rcp-keep-date-arg nil) | |
574 (tramp-su-program nil) | |
575 (tramp-su-args nil) | |
576 (tramp-encoding-command "mimencode -b") | |
577 (tramp-decoding-command "mimencode -u -b") | |
578 (tramp-encoding-function base64-encode-region) | |
579 (tramp-decoding-function base64-decode-region) | |
580 (tramp-telnet-program nil) | |
581 (tramp-telnet-args nil)) | |
582 ("multiu" (tramp-connection-function tramp-open-connection-multi) | |
583 (tramp-rsh-program nil) | |
584 (tramp-rcp-program nil) | |
585 (tramp-remote-sh "/bin/sh") | |
586 (tramp-rsh-args nil) | |
587 (tramp-rcp-args nil) | |
588 (tramp-rcp-keep-date-arg nil) | |
589 (tramp-su-program nil) | |
590 (tramp-su-args nil) | |
591 (tramp-encoding-command "uuencode xxx") | |
592 (tramp-decoding-command | |
593 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") | |
594 (tramp-encoding-function nil) | |
595 (tramp-decoding-function uudecode-decode-region) | |
596 (tramp-telnet-program nil) | |
597 (tramp-telnet-args nil)) | |
598 ("scpx" (tramp-connection-function tramp-open-connection-rsh) | |
599 (tramp-rsh-program "ssh") | |
600 (tramp-rcp-program "scp") | |
601 (tramp-remote-sh "/bin/sh") | |
602 (tramp-rsh-args ("-e" "none" "-t" "-t" "/bin/sh")) | |
603 (tramp-rcp-args nil) | |
604 (tramp-rcp-keep-date-arg "-p") | |
605 (tramp-encoding-command nil) | |
606 (tramp-decoding-command nil) | |
607 (tramp-encoding-function nil) | |
608 (tramp-decoding-function nil) | |
609 (tramp-telnet-program nil) | |
610 (tramp-telnet-args nil)) | |
611 ("smx" (tramp-connection-function tramp-open-connection-rsh) | |
612 (tramp-rsh-program "ssh") | |
613 (tramp-rcp-program nil) | |
614 (tramp-remote-sh "/bin/sh") | |
615 (tramp-rsh-args ("-e" "none" "-t" "-t" "/bin/sh")) | |
616 (tramp-rcp-args nil) | |
617 (tramp-rcp-keep-date-arg nil) | |
618 (tramp-su-program nil) | |
619 (tramp-su-args nil) | |
620 (tramp-encoding-command "mimencode -b") | |
621 (tramp-decoding-command "mimencode -u -b") | |
622 (tramp-encoding-function base64-encode-region) | |
623 (tramp-decoding-function base64-decode-region) | |
624 (tramp-telnet-program nil) | |
625 (tramp-telnet-args nil)) | |
626 ("km" | |
627 (tramp-connection-function tramp-open-connection-rsh) | |
628 (tramp-rsh-program "krlogin") | |
629 (tramp-rcp-program nil) | |
630 (tramp-remote-sh "/bin/sh") | |
631 (tramp-rsh-args ("-x")) | |
632 (tramp-rcp-args nil) | |
633 (tramp-rcp-keep-date-arg nil) | |
634 (tramp-su-program nil) | |
635 (tramp-su-args nil) | |
636 (tramp-encoding-command "mimencode -b") | |
637 (tramp-decoding-command "mimencode -u -b") | |
638 (tramp-encoding-function base64-encode-region) | |
639 (tramp-decoding-function base64-decode-region) | |
640 (tramp-telnet-program nil) | |
641 (tramp-telnet-args nil)) | |
642 ("plinku" | |
643 (tramp-connection-function tramp-open-connection-rsh) | |
644 (tramp-rsh-program "plink") | |
645 (tramp-rcp-program nil) | |
646 (tramp-remote-sh "/bin/sh") | |
647 (tramp-rsh-args ("-ssh")) ;optionally add "-v" | |
648 (tramp-rcp-args nil) | |
649 (tramp-rcp-keep-date-arg nil) | |
650 (tramp-su-program nil) | |
651 (tramp-su-args nil) | |
652 (tramp-encoding-command "uuencode xxx") | |
653 (tramp-decoding-command | |
654 "( uudecode -o - 2>/dev/null || uudecode -p 2>/dev/null )") | |
655 (tramp-encoding-function nil) | |
656 (tramp-decoding-function uudecode-decode-region) | |
657 (tramp-telnet-program nil) | |
658 (tramp-telnet-args nil)) | |
659 ("plinkm" | |
660 (tramp-connection-function tramp-open-connection-rsh) | |
661 (tramp-rsh-program "plink") | |
662 (tramp-rcp-program nil) | |
663 (tramp-remote-sh "/bin/sh") | |
664 (tramp-rsh-args ("-ssh")) ;optionally add "-v" | |
665 (tramp-rcp-args nil) | |
666 (tramp-rcp-keep-date-arg nil) | |
667 (tramp-su-program nil) | |
668 (tramp-su-args nil) | |
669 (tramp-encoding-command "mimencode -b") | |
670 (tramp-decoding-command "mimencode -u -b") | |
671 (tramp-encoding-function base64-encode-region) | |
672 (tramp-decoding-function base64-decode-region) | |
673 (tramp-telnet-program nil) | |
674 (tramp-telnet-args nil)) | |
675 ("pscp" | |
676 (tramp-connection-function tramp-open-connection-rsh) | |
677 (tramp-rsh-program "plink") | |
678 (tramp-rcp-program "pscp") | |
679 (tramp-remote-sh "/bin/sh") | |
680 (tramp-rsh-args ("-ssh")) | |
681 (tramp-rcp-args nil) | |
682 (tramp-rcp-keep-date-arg "-p") | |
683 (tramp-su-program nil) | |
684 (tramp-su-args nil) | |
685 (tramp-encoding-command nil) | |
686 (tramp-decoding-command nil) | |
687 (tramp-encoding-function nil) | |
688 (tramp-decoding-function nil) | |
689 (tramp-telnet-program nil) | |
690 (tramp-telnet-args nil)) | |
691 ("fcp" | |
692 (tramp-connection-function tramp-open-connection-rsh) | |
693 (tramp-rsh-program "fsh") | |
694 (tramp-rcp-program "fcp") | |
695 (tramp-remote-sh "/bin/sh -i") | |
696 (tramp-rsh-args ("sh" "-i")) | |
697 (tramp-rcp-args nil) | |
698 (tramp-rcp-keep-date-arg "-p") | |
699 (tramp-su-program nil) | |
700 (tramp-su-args nil) | |
701 (tramp-encoding-command nil) | |
702 (tramp-decoding-command nil) | |
703 (tramp-encoding-function nil) | |
704 (tramp-decoding-function nil) | |
705 (tramp-telnet-program nil) | |
706 (tramp-telnet-args nil)) | |
707 ) | |
708 "*Alist of methods for remote files. | |
709 This is a list of entries of the form (NAME PARAM1 PARAM2 ...). | |
710 Each NAME stands for a remote access method. Each PARAM is a | |
711 pair of the form (KEY VALUE). The following KEYs are defined: | |
712 * `tramp-connection-function' | |
713 This specifies the function to use to connect to the remote host. | |
714 Currently, `tramp-open-connection-rsh', `tramp-open-connection-telnet' | |
715 and `tramp-open-connection-su' are defined. See the documentation | |
716 of these functions for more details. | |
717 * `tramp-remote-sh' | |
718 This specifies the Bourne shell to use on the remote host. This | |
719 MUST be a Bourne-like shell. It is normally not necessary to set | |
720 this to any value other than \"/bin/sh\": tramp wants to use a shell | |
721 which groks tilde expansion, but it can search for it. Also note | |
722 that \"/bin/sh\" exists on all Unixen, this might not be true for | |
723 the value that you decide to use. You Have Been Warned. | |
724 * `tramp-rsh-program' | |
725 This specifies the name of the program to use for rsh; this might be | |
726 the full path to rsh or the name of a workalike program. | |
727 * `tramp-rsh-args' | |
728 This specifies the list of arguments to pass to the above | |
729 mentioned program. Please note that this is a list of arguments, | |
730 that is, normally you don't want to put \"-a -b\" or \"-f foo\" | |
731 here. Instead, you want two list elements, one for \"-a\" and one | |
732 for \"-b\", or one for \"-f\" and one for \"foo\". | |
733 * `tramp-rcp-program' | |
734 This specifies the name of the program to use for rcp; this might be | |
735 the full path to rcp or the name of a workalike program. | |
736 * `tramp-rcp-args' | |
737 This specifies the list of parameters to pass to the above mentioned | |
738 program, the hints for `tramp-rsh-args' also apply here. | |
739 * `tramp-rcp-keep-date-arg' | |
740 This specifies the parameter to use for `rcp' when the timestamp | |
741 of the original file should be kept. For `rcp', use `-p', for | |
742 `rsync', use `-t'. | |
743 * `tramp-su-program' | |
744 This specifies the name of the program to use for `su'. | |
745 * `tramp-su-args' | |
746 This specifies the list of arguments to pass to `su'. | |
747 \"%u\" is replaced by the user name, use \"%%\" for a literal | |
748 percent character. | |
749 * `tramp-encoding-command' | |
750 This specifies a command to use to encode the file contents for | |
751 transfer. The command should read the raw file contents from | |
752 standard input and write the encoded file contents to standard | |
753 output. In this string, the percent escape \"%f\" should be used | |
754 to indicate the file to convert. Use \"%%\" if you need a literal | |
755 percent character in your command. | |
756 * `tramp-decoding-command' | |
757 This specifies a command to use to decode file contents encoded | |
758 with `tramp-encoding-command'. The command should read from standard | |
759 input and write to standard output. | |
760 * `tramp-encoding-function' | |
761 This specifies a function to be called to encode the file contents | |
762 on the local side. This function should accept two arguments | |
763 START and END, the beginning and end of the region to encode. The | |
764 region should be replaced with the encoded contents. | |
765 * `tramp-decoding-function' | |
766 Same for decoding on the local side. | |
767 * `tramp-telnet-program' | |
768 Specifies the telnet program to use when using | |
769 `tramp-open-connection-telnet' to log in. | |
770 * `tramp-telnet-args' | |
771 Specifies list of arguments to pass to `telnet'. The hints for | |
772 `tramp-rsh-args' also apply here. | |
773 | |
774 What does all this mean? Well, you should specify `tramp-rsh-program', | |
775 `tramp-telnet-program' or `tramp-su-program' for all methods; this program | |
776 is used to log in to the remote site. Then, there are two ways to | |
777 actually transfer the files between the local and the remote side. | |
778 One way is using an additional rcp-like program. If you want to do | |
779 this, set `tramp-rcp-program' in the method. | |
780 | |
781 Another possibility for file transfer is inline transfer, i.e. the | |
782 file is passed through the same buffer used by `tramp-rsh-program'. In | |
783 this case, the file contents need to be protected since the | |
784 `tramp-rsh-program' might use escape codes or the connection might not | |
785 be eight-bit clean. Therefore, file contents are encoded for transit. | |
786 | |
787 Two possibilities for encoding are uuencode/uudecode and mimencode. | |
788 For uuencode/uudecode you want to set `tramp-encoding-command' to | |
789 something like \"uuencode\" and `tramp-decoding-command' to \"uudecode | |
790 -p\". For mimencode you want to set `tramp-encoding-command' to | |
791 something like \"mimencode -b\" and `tramp-decoding-command' to | |
792 \"mimencode -b -u\". | |
793 | |
794 When using inline transfer, you can use a program or a Lisp function | |
795 on the local side to encode or decode the file contents. Set the | |
796 `tramp-encoding-function' and `tramp-decoding-function' parameters to nil | |
797 in order to use the commands or to the function to use. It is | |
798 possible to specify one function and the other parameter as nil. | |
799 | |
800 So, to summarize: if the method is an inline method, you must specify | |
801 `tramp-encoding-command' and `tramp-decoding-command', and | |
802 `tramp-rcp-program' must be nil. If the method is out of band, then | |
803 you must specify `tramp-rcp-program' and `tramp-rcp-args' and | |
804 `tramp-encoding-command' and `tramp-decoding-command' must be nil. | |
805 Every method, inline or out of band, must specify | |
806 `tramp-connection-function' plus the associated arguments (for | |
807 example, the telnet program if you chose | |
808 `tramp-open-connection-telnet'). | |
809 | |
810 Notes: | |
811 | |
812 When using `tramp-open-connection-su' the phrase `open connection to a | |
813 remote host' sounds strange, but it is used nevertheless, for | |
814 consistency. No connection is opened to a remote host, but `su' is | |
815 started on the local host. You are not allowed to specify a remote | |
816 host other than `localhost' or the name of the local host. | |
817 | |
818 Using a uuencode/uudecode inline method is discouraged, please use one | |
819 of the base64 methods instead since base64 encoding is much more | |
820 reliable and the commands are more standardized between the different | |
821 Unix versions. But if you can't use base64 for some reason, please | |
822 note that the default uudecode command does not work well for some | |
823 Unices, in particular AIX and Irix. For AIX, you might want to use | |
824 the following command for uudecode: | |
825 | |
826 sed '/^begin/d;/^[` ]$/d;/^end/d' | iconv -f uucode -t ISO8859-1 | |
827 | |
828 For Irix, no solution is known yet." | |
829 :group 'tramp | |
830 :type '(repeat | |
831 (cons string | |
832 (set (list (const tramp-connection-function) function) | |
833 (list (const tramp-rsh-program) | |
834 (choice (const nil) string)) | |
835 (list (const tramp-rcp-program) | |
836 (choice (const nil) string)) | |
837 (list (const tramp-remote-sh) | |
838 (choice (const nil) string)) | |
839 (list (const tramp-rsh-args) (repeat string)) | |
840 (list (const tramp-rcp-args) (repeat string)) | |
841 (list (const tramp-rcp-keep-date-arg) | |
842 (choice (const nil) string)) | |
843 (list (const tramp-su-program) | |
844 (choice (const nil) string)) | |
845 (list (const tramp-su-args) (repeat string)) | |
846 (list (const tramp-encoding-command) | |
847 (choice (const nil) string)) | |
848 (list (const tramp-decoding-command) | |
849 (choice (const nil) string)) | |
850 (list (const tramp-encoding-function) | |
851 (choice (const nil) function)) | |
852 (list (const tramp-decoding-function) | |
853 (choice (const nil) function)) | |
854 (list (const tramp-telnet-program) | |
855 (choice (const nil) string)) | |
856 (list (const tramp-telnet-args) (repeat string)))))) | |
857 | |
858 (defcustom tramp-multi-methods '("multi" "multiu") | |
859 "*List of multi-hop methods. | |
860 Each entry in this list should be a method name as mentioned in the | |
861 variable `tramp-methods'." | |
862 :group 'tramp | |
863 :type '(repeat string)) | |
864 | |
865 (defcustom tramp-multi-connection-function-alist | |
866 '(("telnet" tramp-multi-connect-telnet "telnet %h%n") | |
867 ("rsh" tramp-multi-connect-rlogin "rsh %h -l %u%n") | |
868 ("ssh" tramp-multi-connect-rlogin "ssh %h -l %u%n") | |
869 ("su" tramp-multi-connect-su "su - %u%n") | |
870 ("sudo" tramp-multi-connect-su "sudo -u %u -s%n")) | |
871 "*List of connection functions for multi-hop methods. | |
872 Each list item is a list of three items (METHOD FUNCTION COMMAND), | |
873 where METHOD is the name as used in the file name, FUNCTION is the | |
874 function to be executed, and COMMAND is the shell command used for | |
875 connecting. | |
876 | |
877 COMMAND may contain percent escapes. `%u' will be replaced with the | |
878 user name, `%h' will be replaced with the host name, and `%n' will be | |
879 replaced with an end-of-line character, as specified in the variable | |
880 `tramp-rsh-end-of-line'. Use `%%' for a literal percent character. | |
881 Note that the interpretation of the percent escapes also depends on | |
882 the FUNCTION. For example, the `%u' escape is forbidden with the | |
883 function `tramp-multi-connect-telnet'. See the documentation of the | |
884 various functions for details." | |
885 :group 'tramp | |
886 :type '(repeat (list string function string))) | |
887 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
888 (defcustom tramp-default-method "sm" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
889 ;;(if (featurep 'xemacs) "sm" "ftp") |
45861 | 890 "*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
|
891 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
|
892 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
|
893 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
894 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
|
895 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
|
896 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
|
897 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
|
898 :group 'tramp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
899 :type 'string) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
900 |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
901 (defcustom tramp-default-method-alist |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
902 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
903 nil |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
904 '(("\\`ftp\\." "" "ftp") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
905 ("" "\\`\\(anonymous\\|ftp\\)\\'" "ftp"))) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
906 "*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
|
907 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
|
908 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
|
909 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
|
910 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
|
911 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
|
912 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
913 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
|
914 empty string for the user name. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
915 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
916 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
|
917 :group 'tramp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
918 :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
|
919 (regexp :tag "User regexp") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
920 (string :tag "Method")))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
921 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
922 (defcustom tramp-ftp-method "ftp" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
923 "*When this method name is used, forward all calls to Ange-FTP." |
45861 | 924 :group 'tramp |
925 :type 'string) | |
926 | |
927 (defcustom tramp-rsh-end-of-line "\n" | |
928 "*String used for end of line in rsh connections. | |
929 I don't think this ever needs to be changed, so please tell me about it | |
930 if you need to change this." | |
931 :group 'tramp | |
932 :type 'string) | |
933 | |
934 (defcustom tramp-remote-path | |
935 '("/bin" "/usr/bin" "/usr/sbin" "/usr/local/bin" "/usr/ccs/bin" | |
936 "/local/bin" "/local/freeware/bin" "/local/gnu/bin" | |
937 "/usr/freeware/bin" "/usr/pkg/bin" "/usr/contrib/bin") | |
938 "*List of directories to search for executables on remote host. | |
939 Please notify me about other semi-standard directories to include here. | |
940 | |
941 You can use `~' in this list, but when searching for a shell which groks | |
942 tilde expansion, all directory names starting with `~' will be ignored." | |
943 :group 'tramp | |
944 :type '(repeat string)) | |
945 | |
946 (defcustom tramp-login-prompt-regexp | |
947 ".*ogin: *$" | |
948 "*Regexp matching login-like prompts. | |
949 The regexp should match the whole line." | |
950 :group 'tramp | |
951 :type 'regexp) | |
952 | |
953 (defcustom tramp-password-prompt-regexp | |
954 "^.*\\([pP]assword\\|passphrase.*\\):\^@? *$" | |
955 "*Regexp matching password-like prompts. | |
956 The regexp should match the whole line. | |
957 | |
958 The `sudo' program appears to insert a `^@' character into the prompt." | |
959 :group 'tramp | |
960 :type 'regexp) | |
961 | |
962 (defcustom tramp-wrong-passwd-regexp | |
963 (concat "^.*\\(Permission denied.\\|Login [Ii]ncorrect\\|" | |
964 "Received signal [0-9]+\\|Connection \\(refused\\|closed\\)\\|" | |
965 "Sorry, try again.\\|Name or service not known\\).*$") | |
966 "*Regexp matching a `login failed' message. | |
967 The regexp should match the whole line." | |
968 :group 'tramp | |
969 :type 'regexp) | |
970 | |
971 (defcustom tramp-temp-name-prefix "tramp." | |
972 "*Prefix to use for temporary files. | |
973 If this is a relative file name (such as \"tramp.\"), it is considered | |
974 relative to the directory name returned by the function | |
975 `tramp-temporary-file-directory' (which see). It may also be an | |
976 absolute file name; don't forget to include a prefix for the filename | |
977 part, though." | |
978 :group 'tramp | |
979 :type 'string) | |
980 | |
981 (defcustom tramp-discard-garbage nil | |
982 "*If non-nil, try to discard garbage sent by remote shell. | |
983 Some shells send such garbage upon connection setup." | |
984 :group 'tramp | |
985 :type 'boolean) | |
986 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
987 (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
|
988 "*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
|
989 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
|
990 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
|
991 arguments. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
992 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
993 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
|
994 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
|
995 shell from reading its init file." |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
996 :group 'tramp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
997 :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
|
998 |
45861 | 999 ;; File name format. |
1000 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1001 (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
|
1002 (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
|
1003 "\\(\\([^:@/]+\\)@\\)?" ;user |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1004 "\\([^:/]+\\):" ;host |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1005 "\\(.*\\)\\'") ;path |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1006 2 4 5 6) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1007 "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
|
1008 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
|
1009 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
|
1010 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1011 (defconst tramp-file-name-structure-separate |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1012 (list (concat "\\`/\\[\\(\\([a-zA-Z0-9]+\\)/\\)?" ;method |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1013 "\\(\\([-a-zA-Z0-9_#/:]+\\)@\\)?" ;user |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1014 "\\([-a-zA-Z0-9_#/:@.]+\\)\\]" ;host |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1015 "\\(.*\\)\\'") ;path |
45861 | 1016 2 4 5 6) |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1017 "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
|
1018 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
|
1019 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
|
1020 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
|
1021 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1022 (defcustom tramp-file-name-structure |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1023 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1024 tramp-file-name-structure-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1025 tramp-file-name-structure-unified) |
45861 | 1026 "*List of five elements (REGEXP METHOD USER HOST FILE), detailing \ |
1027 the tramp file name structure. | |
1028 | |
1029 The first element REGEXP is a regular expression matching a tramp file | |
1030 name. The regex should contain parentheses around the method name, | |
1031 the user name, the host name, and the file name parts. | |
1032 | |
1033 The second element METHOD is a number, saying which pair of | |
1034 parentheses matches the method name. The third element USER is | |
1035 similar, but for the user name. The fourth element HOST is similar, | |
1036 but for the host name. The fifth element FILE is for the file name. | |
1037 These numbers are passed directly to `match-string', which see. That | |
1038 means the opening parentheses are counted to identify the pair. | |
1039 | |
1040 See also `tramp-file-name-regexp' and `tramp-make-tramp-file-format'." | |
1041 :group 'tramp | |
1042 :type '(list (regexp :tag "File name regexp") | |
1043 (integer :tag "Paren pair for method name") | |
1044 (integer :tag "Paren pair for user name ") | |
1045 (integer :tag "Paren pair for host name ") | |
1046 (integer :tag "Paren pair for file name "))) | |
1047 | |
1048 ;;;###autoload | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1049 (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
|
1050 "\\`/[^/:]+:" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1051 "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
|
1052 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
|
1053 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
|
1054 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1055 ;;;###autoload |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1056 (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
|
1057 "\\`/\\[.*\\]" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1058 "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
|
1059 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
|
1060 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
|
1061 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1062 ;;;###autoload |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1063 (defcustom tramp-file-name-regexp |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1064 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1065 tramp-file-name-regexp-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1066 tramp-file-name-regexp-unified) |
45861 | 1067 "*Regular expression matching file names handled by tramp. |
1068 This regexp should match tramp file names but no other file names. | |
1069 \(When tramp.el is loaded, this regular expression is prepended to | |
1070 `file-name-handler-alist', and that is searched sequentially. Thus, | |
1071 if the tramp entry appears rather early in the `file-name-handler-alist' | |
1072 and is a bit too general, then some files might be considered tramp | |
1073 files which are not really tramp files. | |
1074 | |
1075 Please note that the entry in `file-name-handler-alist' is made when | |
1076 this file (tramp.el) is loaded. This means that this variable must be set | |
1077 before loading tramp.el. Alternatively, `file-name-handler-alist' can be | |
1078 updated after changing this variable. | |
1079 | |
1080 Also see `tramp-file-name-structure' and `tramp-make-tramp-file-format'." | |
1081 :group 'tramp | |
1082 :type 'regexp) | |
1083 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1084 (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
|
1085 "/%m:%u@%h:%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1086 "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
|
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 more 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-make-tramp-file-format-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1091 "/[%m/%u@%h]%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1092 "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
|
1093 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
|
1094 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
|
1095 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1096 (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
|
1097 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1098 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
|
1099 tramp-make-tramp-file-format-unified) |
45861 | 1100 "*Format string saying how to construct tramp file name. |
1101 `%m' is replaced by the method name. | |
1102 `%u' is replaced by the user name. | |
1103 `%h' is replaced by the host name. | |
1104 `%p' is replaced by the file name. | |
1105 `%%' is replaced by %. | |
1106 | |
1107 Also see `tramp-file-name-structure' and `tramp-file-name-regexp'." | |
1108 :group 'tramp | |
1109 :type 'string) | |
1110 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1111 (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
|
1112 "/%m:%h:%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1113 "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
|
1114 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
|
1115 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
|
1116 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1117 (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
|
1118 "/[%m/%h]%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1119 "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
|
1120 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
|
1121 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
|
1122 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1123 (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
|
1124 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1125 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
|
1126 tramp-make-tramp-file-user-nil-format-unified) |
45861 | 1127 "*Format string saying how to construct tramp file name when the user name is not known. |
1128 `%m' is replaced by the method name. | |
1129 `%h' is replaced by the host name. | |
1130 `%p' is replaced by the file name. | |
1131 `%%' is replaced by %. | |
1132 | |
1133 Also see `tramp-make-tramp-file-format', `tramp-file-name-structure', and `tramp-file-name-regexp'." | |
1134 :group 'tramp | |
1135 :type 'string) | |
1136 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1137 (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
|
1138 (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
|
1139 "\\(\\(%s\\)+\\)" ;hops |
46347
3996ea20e5e3
(tramp-multi-file-name-structure-unified): Add
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46307
diff
changeset
|
1140 "\\(.*\\)\\'") ;path |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1141 2 3 -1) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1142 "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
|
1143 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
|
1144 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
|
1145 |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
1146 (defconst tramp-multi-file-name-structure-separate |
45861 | 1147 (list (concat |
1148 ;; prefix | |
46347
3996ea20e5e3
(tramp-multi-file-name-structure-unified): Add
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46307
diff
changeset
|
1149 "\\`/\\[\\(\\([a-z0-9]+\\)?\\)" |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1150 ;; regexp specifying the hops |
45861 | 1151 "\\(\\(%s\\)+\\)" |
1152 ;; path name | |
1153 "\\]\\(.*\\)\\'") | |
1154 2 ;number of pair to match method | |
1155 3 ;number of pair to match hops | |
1156 -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
|
1157 "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
|
1158 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
|
1159 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
|
1160 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1161 (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
|
1162 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1163 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
|
1164 tramp-multi-file-name-structure-unified) |
45861 | 1165 "*Describes the file name structure of `multi' files. |
1166 Multi files allow you to contact a remote host in several hops. | |
1167 This is a list of four elements (REGEXP METHOD HOP PATH). | |
1168 | |
1169 The first element, REGEXP, gives a regular expression to match against | |
1170 the file name. In this regular expression, `%s' is replaced with the | |
1171 value of `tramp-multi-file-name-hop-structure'. (Note: in order to | |
1172 allow multiple hops, you normally want to use something like | |
1173 \"\\\\(\\\\(%s\\\\)+\\\\)\" in the regular expression. The outer pair | |
1174 of parentheses is used for the HOP element, see below.) | |
1175 | |
1176 All remaining elements are numbers. METHOD gives the number of the | |
1177 paren pair which matches the method name. HOP gives the number of the | |
1178 paren pair which matches the hop sequence. PATH gives the number of | |
1179 the paren pair which matches the path name on the remote host. | |
1180 | |
1181 PATH can also be negative, which means to count from the end. Ie, a | |
1182 value of -1 means the last paren pair. | |
1183 | |
1184 I think it would be good if the regexp matches the whole of the | |
1185 string, but I haven't actually tried what happens if it doesn't..." | |
1186 :group 'tramp | |
1187 :type '(list (regexp :tag "File name regexp") | |
1188 (integer :tag "Paren pair for method name") | |
1189 (integer :tag "Paren pair for hops") | |
1190 (integer :tag "Paren pair to match path"))) | |
1191 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1192 (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
|
1193 (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
|
1194 "\\([^@:/]+\\)@" ;user |
46347
3996ea20e5e3
(tramp-multi-file-name-structure-unified): Add
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46307
diff
changeset
|
1195 "\\([^:/]+\\):") ;host |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1196 1 2 3) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1197 "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
|
1198 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
|
1199 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
|
1200 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1201 (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
|
1202 (list (concat "/\\([a-z0-9_]+\\):" ;hop method |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1203 "\\([a-z0-9_]+\\)@" ;user |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1204 "\\([a-z0-9.-]+\\)") ;host |
45861 | 1205 1 2 3) |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1206 "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
|
1207 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
|
1208 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
|
1209 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1210 (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
|
1211 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1212 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
|
1213 tramp-multi-file-name-hop-structure-unified) |
45861 | 1214 "*Describes the structure of a hop in multi files. |
1215 This is a list of four elements (REGEXP METHOD USER HOST). First | |
1216 element REGEXP is used to match against the hop. Pair number METHOD | |
1217 matches the method of one hop, pair number USER matches the user of | |
1218 one hop, pair number HOST matches the host of one hop. | |
1219 | |
1220 This regular expression should match exactly all of one hop." | |
1221 :group 'tramp | |
1222 :type '(list (regexp :tag "Hop regexp") | |
1223 (integer :tag "Paren pair for method name") | |
1224 (integer :tag "Paren pair for user name") | |
1225 (integer :tag "Paren pair for host name"))) | |
1226 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1227 (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
|
1228 (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
|
1229 "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
|
1230 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
|
1231 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
|
1232 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1233 (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
|
1234 (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
|
1235 "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
|
1236 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
|
1237 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
|
1238 |
45861 | 1239 (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
|
1240 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1241 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
|
1242 tramp-make-multi-tramp-file-format-unified) |
45861 | 1243 "*Describes how to construct a `multi' file name. |
1244 This is a list of three elements PREFIX, HOP and PATH. | |
1245 | |
1246 The first element PREFIX says how to construct the prefix, the second | |
1247 element HOP specifies what each hop looks like, and the final element | |
1248 PATH says how to construct the path name. | |
1249 | |
1250 In PREFIX, `%%' means `%' and `%m' means the method name. | |
1251 | |
1252 In HOP, `%%' means `%' and `%m', `%u', `%h' mean the hop method, hop | |
1253 user and hop host, respectively. | |
1254 | |
1255 In PATH, `%%' means `%' and `%p' means the path name. | |
1256 | |
1257 The resulting file name always contains one copy of PREFIX and one | |
1258 copy of PATH, but there is one copy of HOP for each hop in the file | |
1259 name. | |
1260 | |
1261 Note: the current implementation requires the prefix to contain the | |
1262 method name, followed by all the hops, and the path name must come | |
1263 last." | |
1264 :group 'tramp | |
1265 :type '(list string string string)) | |
1266 | |
1267 (defcustom tramp-terminal-type "dumb" | |
1268 "*Value of TERM environment variable for logging in to remote host. | |
1269 Because Tramp wants to parse the output of the remote shell, it is easily | |
1270 confused by ANSI color escape sequences and suchlike. Often, shell init | |
1271 files conditionalize this setup based on the TERM environment variable." | |
1272 :group 'tramp | |
1273 :type 'string) | |
1274 | |
1275 (defcustom tramp-completion-without-shell-p nil | |
1276 "*If nil, use shell wildcards for completion, else rely on Lisp only. | |
1277 Using shell wildcards for completions has the advantage that it can be | |
1278 fast even in large directories, but completion is always | |
1279 case-sensitive. Relying on Lisp only means that case-insensitive | |
1280 completion is possible (subject to the variable `completion-ignore-case'), | |
1281 but it might be slow on large directories." | |
1282 :group 'tramp | |
1283 :type 'boolean) | |
1284 | |
1285 ;;; Internal Variables: | |
1286 | |
1287 (defvar tramp-buffer-file-attributes nil | |
1288 "Holds the `ls -ild' output for the current buffer. | |
1289 This variable is local to each buffer. It is not used if the remote | |
1290 machine groks Perl. If it is used, it's used as an emulation for | |
1291 the visited file modtime.") | |
1292 (make-variable-buffer-local 'tramp-buffer-file-attributes) | |
1293 | |
1294 (defvar tramp-end-of-output "/////" | |
1295 "String used to recognize end of output.") | |
1296 | |
1297 (defvar tramp-connection-function nil | |
1298 "This internal variable holds a parameter for `tramp-methods'. | |
1299 In the connection buffer, this variable has the value of the like-named | |
1300 method parameter, as specified in `tramp-methods' (which see).") | |
1301 | |
1302 (defvar tramp-remote-sh nil | |
1303 "This internal variable holds a parameter for `tramp-methods'. | |
1304 In the connection buffer, this variable has the value of the like-named | |
1305 method parameter, as specified in `tramp-methods' (which see).") | |
1306 | |
1307 (defvar tramp-rsh-program nil | |
1308 "This internal variable holds a parameter for `tramp-methods'. | |
1309 In the connection buffer, this variable has the value of the like-named | |
1310 method parameter, as specified in `tramp-methods' (which see).") | |
1311 | |
1312 (defvar tramp-rsh-args nil | |
1313 "This internal variable holds a parameter for `tramp-methods'. | |
1314 In the connection buffer, this variable has the value of the like-named | |
1315 method parameter, as specified in `tramp-methods' (which see).") | |
1316 | |
1317 (defvar tramp-rcp-program nil | |
1318 "This internal variable holds a parameter for `tramp-methods'. | |
1319 In the connection buffer, this variable has the value of the like-named | |
1320 method parameter, as specified in `tramp-methods' (which see).") | |
1321 | |
1322 (defvar tramp-rcp-args nil | |
1323 "This internal variable holds a parameter for `tramp-methods'. | |
1324 In the connection buffer, this variable has the value of the like-named | |
1325 method parameter, as specified in `tramp-methods' (which see).") | |
1326 | |
1327 (defvar tramp-rcp-keep-date-arg nil | |
1328 "This internal variable holds a parameter for `tramp-methods'. | |
1329 In the connection buffer, this variable has the value of the like-named | |
1330 method parameter, as specified in `tramp-methods' (which see).") | |
1331 | |
1332 (defvar tramp-encoding-command nil | |
1333 "This internal variable holds a parameter for `tramp-methods'. | |
1334 In the connection buffer, this variable has the value of the like-named | |
1335 method parameter, as specified in `tramp-methods' (which see).") | |
1336 | |
1337 (defvar tramp-decoding-command nil | |
1338 "This internal variable holds a parameter for `tramp-methods'. | |
1339 In the connection buffer, this variable has the value of the like-named | |
1340 method parameter, as specified in `tramp-methods' (which see).") | |
1341 | |
1342 (defvar tramp-encoding-function nil | |
1343 "This internal variable holds a parameter for `tramp-methods'. | |
1344 In the connection buffer, this variable has the value of the like-named | |
1345 method parameter, as specified in `tramp-methods' (which see).") | |
1346 | |
1347 (defvar tramp-decoding-function nil | |
1348 "This internal variable holds a parameter for `tramp-methods'. | |
1349 In the connection buffer, this variable has the value of the like-named | |
1350 method parameter, as specified in `tramp-methods' (which see).") | |
1351 | |
1352 (defvar tramp-telnet-program nil | |
1353 "This internal variable holds a parameter for `tramp-methods'. | |
1354 In the connection buffer, this variable has the value of the like-named | |
1355 method parameter, as specified in `tramp-methods' (which see).") | |
1356 | |
1357 (defvar tramp-telnet-args nil | |
1358 "This internal variable holds a parameter for `tramp-methods'. | |
1359 In the connection buffer, this variable has the value of the like-named | |
1360 method parameter, as specified in `tramp-methods' (which see).") | |
1361 | |
1362 ;; CCC `local in each buffer'? | |
1363 (defvar tramp-ls-command nil | |
1364 "This command is used to get a long listing with numeric user and group ids. | |
1365 This variable is automatically made buffer-local to each rsh process buffer | |
1366 upon opening the connection.") | |
1367 | |
1368 (defvar tramp-current-multi-method nil | |
1369 "Name of `multi' connection method for this *tramp* buffer, or nil if not multi. | |
1370 This variable is automatically made buffer-local to each rsh process buffer | |
1371 upon opening the connection.") | |
1372 | |
1373 (defvar tramp-current-method nil | |
1374 "Connection method for this *tramp* buffer. | |
1375 This variable is automatically made buffer-local to each rsh process buffer | |
1376 upon opening the connection.") | |
1377 | |
1378 (defvar tramp-current-user nil | |
1379 "Remote login name for this *tramp* buffer. | |
1380 This variable is automatically made buffer-local to each rsh process buffer | |
1381 upon opening the connection.") | |
1382 | |
1383 (defvar tramp-current-host nil | |
1384 "Remote host for this *tramp* buffer. | |
1385 This variable is automatically made buffer-local to each rsh process buffer | |
1386 upon opening the connection.") | |
1387 | |
1388 (defvar tramp-test-groks-nt nil | |
1389 "Whether the `test' command groks the `-nt' switch. | |
1390 \(`test A -nt B' tests if file A is newer than file B.) | |
1391 This variable is automatically made buffer-local to each rsh process buffer | |
1392 upon opening the connection.") | |
1393 | |
1394 (defvar tramp-file-exists-command nil | |
1395 "Command to use for checking if a file exists. | |
1396 This variable is automatically made buffer-local to each rsh process buffer | |
1397 upon opening the connection.") | |
1398 | |
1399 ;; Perl script to implement `file-attributes' in a Lisp `read'able output. | |
1400 ;; If you are hacking on this, note that you get *no* output unless this | |
1401 ;; spits out a complete line, including the '\n' at the end. | |
1402 (defconst tramp-perl-file-attributes (concat | |
1403 "$f = $ARGV[0]; | |
1404 @s = lstat($f); | |
1405 if (($s[2] & 0170000) == 0120000) { $l = readlink($f); $l = \"\\\"$l\\\"\"; } | |
1406 elsif (($s[2] & 0170000) == 040000) { $l = \"t\"; } | |
1407 else { $l = \"nil\" }; | |
1408 printf(\"(%s %u %u %u (%u %u) (%u %u) (%u %u) %u %u t (%u . %u) (%u %u))\\n\", | |
1409 $l, $s[3], $s[4], $s[5], $s[8] >> 16 & 0xffff, $s[8] & 0xffff, | |
1410 $s[9] >> 16 & 0xffff, $s[9] & 0xffff, $s[10] >> 16 & 0xffff, $s[10] & 0xffff, | |
1411 $s[7], $s[2], $s[1] >> 16 & 0xffff, $s[1] & 0xffff, $s[0] >> 16 & 0xffff, $s[0] & 0xffff);" | |
1412 ) | |
1413 "Perl script to produce output suitable for use with `file-attributes' | |
1414 on the remote file system.") | |
1415 | |
1416 ;; Perl script to implement `mime-encode' | |
1417 (defvar tramp-perl-mime-encode (concat | |
1418 "sub encode_base64 ($); | |
1419 my $buf; | |
1420 while(read(STDIN, $buf, 60*57)) { print encode_base64($buf) } | |
1421 sub encode_base64 ($) { | |
1422 my $res = \"\"; | |
1423 my $eol = \"\n\"; | |
1424 pos($_[0]) = 0; # ensure start at the beginning | |
1425 while ($_[0] =~ /(.{1,45})/gs) { | |
1426 $res .= substr(pack(\"u\", $1), 1); | |
1427 chop($res); | |
1428 } | |
1429 $res =~ tr|` -_|AA-Za-z0-9+/|; # `# help emacs | |
1430 # fix padding at the end | |
1431 my $padding = (3 - length($_[0]) % 3) % 3; | |
1432 $res =~ s/.{$padding}$/\"=\" x $padding/e if $padding; | |
1433 # break encoded string into lines of no more than 76 characters each | |
1434 if (length $eol) { | |
1435 $res =~ s/(.{1,76})/$1$eol/g; | |
1436 } | |
1437 $res;}")) | |
1438 | |
1439 ;; Perl script to implement `mime-decode' | |
1440 (defvar tramp-perl-mime-decode (concat | |
1441 "sub decode_base64 ($); | |
1442 my $buf; | |
1443 while(read(STDIN, $buf, 60*57)) { print decode_base64($buf) } | |
1444 sub decode_base64 ($) { | |
1445 local($^W) = 0; # unpack(\"u\",...) gives bogus warning in 5.00[123] | |
1446 | |
1447 my $str = shift; | |
1448 my $res = \"\"; | |
1449 | |
1450 $str =~ tr|A-Za-z0-9+=/||cd; # remove non-base64 chars | |
1451 if (length($str) % 4) { | |
1452 warn(\"Length of base64 data not a multiple of 4\") | |
1453 } | |
1454 $str =~ s/=+$//; # remove padding | |
1455 $str =~ tr|A-Za-z0-9+/| -_|; # convert to uuencoded format | |
1456 while ($str =~ /(.{1,60})/gs) { | |
1457 my $len = chr(32 + length($1)*3/4); # compute length byte | |
1458 $res .= unpack(\"u\", $len . $1 ); # uudecode | |
1459 } | |
1460 $res;}")) | |
1461 | |
1462 ; These values conform to `file-attributes' from XEmacs 21.2. | |
1463 ; GNU Emacs and other tools not checked. | |
1464 (defconst tramp-file-mode-type-map '((0 . "-") ; Normal file (SVID-v2 and XPG2) | |
1465 (1 . "p") ; fifo | |
1466 (2 . "c") ; character device | |
1467 (3 . "m") ; multiplexed character device (v7) | |
1468 (4 . "d") ; directory | |
1469 (5 . "?") ; Named special file (XENIX) | |
1470 (6 . "b") ; block device | |
1471 (7 . "?") ; multiplexed block device (v7) | |
1472 (8 . "-") ; regular file | |
1473 (9 . "n") ; network special file (HP-UX) | |
1474 (10 . "l") ; symlink | |
1475 (11 . "?") ; ACL shadow inode (Solaris, not userspace) | |
1476 (12 . "s") ; socket | |
1477 (13 . "D") ; door special (Solaris) | |
1478 (14 . "w")) ; whiteout (BSD) | |
1479 "A list of file types returned from the `stat' system call. | |
1480 This is used to map a mode number to a permission string.") | |
1481 | |
1482 (defvar tramp-dos-coding-system | |
1483 (if (and (fboundp 'coding-system-p) | |
1484 (funcall 'coding-system-p '(dos))) | |
1485 'dos | |
1486 'undecided-dos) | |
1487 "Some Emacsen know the `dos' coding system, others need `undecided-dos'.") | |
1488 | |
1489 | |
1490 ;; New handlers should be added here. The following operations can be | |
1491 ;; handled using the normal primitives: file-name-as-directory, | |
1492 ;; file-name-directory, file-name-nondirectory, | |
1493 ;; file-name-sans-versions, get-file-buffer. | |
1494 (defconst tramp-file-name-handler-alist | |
1495 '( | |
1496 (load . tramp-handle-load) | |
1497 (make-symbolic-link . tramp-handle-make-symbolic-link) | |
1498 (file-name-directory . tramp-handle-file-name-directory) | |
1499 (file-name-nondirectory . tramp-handle-file-name-nondirectory) | |
1500 (file-truename . tramp-handle-file-truename) | |
1501 (file-exists-p . tramp-handle-file-exists-p) | |
1502 (file-directory-p . tramp-handle-file-directory-p) | |
1503 (file-executable-p . tramp-handle-file-executable-p) | |
1504 (file-accessible-directory-p . tramp-handle-file-accessible-directory-p) | |
1505 (file-readable-p . tramp-handle-file-readable-p) | |
1506 (file-regular-p . tramp-handle-file-regular-p) | |
1507 (file-symlink-p . tramp-handle-file-symlink-p) | |
1508 (file-writable-p . tramp-handle-file-writable-p) | |
1509 (file-ownership-preserved-p . tramp-handle-file-ownership-preserved-p) | |
1510 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) | |
1511 (file-attributes . tramp-handle-file-attributes) | |
1512 (file-modes . tramp-handle-file-modes) | |
1513 (file-directory-files . tramp-handle-file-directory-files) | |
1514 (directory-files . tramp-handle-directory-files) | |
1515 (file-name-all-completions . tramp-handle-file-name-all-completions) | |
1516 (file-name-completion . tramp-handle-file-name-completion) | |
1517 (add-name-to-file . tramp-handle-add-name-to-file) | |
1518 (copy-file . tramp-handle-copy-file) | |
1519 (rename-file . tramp-handle-rename-file) | |
1520 (set-file-modes . tramp-handle-set-file-modes) | |
1521 (make-directory . tramp-handle-make-directory) | |
1522 (delete-directory . tramp-handle-delete-directory) | |
1523 (delete-file . tramp-handle-delete-file) | |
1524 (directory-file-name . tramp-handle-directory-file-name) | |
1525 (shell-command . tramp-handle-shell-command) | |
1526 (insert-directory . tramp-handle-insert-directory) | |
1527 (expand-file-name . tramp-handle-expand-file-name) | |
1528 (file-local-copy . tramp-handle-file-local-copy) | |
1529 (insert-file-contents . tramp-handle-insert-file-contents) | |
1530 (write-region . tramp-handle-write-region) | |
1531 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory) | |
1532 (dired-call-process . tramp-handle-dired-call-process) | |
1533 (dired-recursive-delete-directory | |
1534 . tramp-handle-dired-recursive-delete-directory) | |
1535 (set-visited-file-modtime . tramp-handle-set-visited-file-modtime) | |
1536 (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)) | |
1537 "Alist of handler functions. | |
1538 Operations not mentioned here will be handled by the normal Emacs functions.") | |
1539 | |
1540 ;;; For better error reporting. | |
1541 | |
1542 (defun tramp-version (arg) | |
1543 "Print version number of tramp.el in minibuffer or current buffer." | |
1544 (interactive "P") | |
1545 (if arg (insert tramp-version) (message tramp-version))) | |
1546 | |
1547 ;;; Internal functions which must come first. | |
1548 | |
1549 (defsubst tramp-message (level fmt-string &rest args) | |
1550 "Emit a message depending on verbosity level. | |
1551 First arg LEVEL says to be quiet if `tramp-verbose' is less than LEVEL. The | |
1552 message is emitted only if `tramp-verbose' is greater than or equal to LEVEL. | |
1553 Calls function `message' with FMT-STRING as control string and the remaining | |
1554 ARGS to actually emit the message (if applicable). | |
1555 | |
1556 This function expects to be called from the tramp buffer only!" | |
1557 (when (<= level tramp-verbose) | |
1558 (apply #'message (concat "tramp: " fmt-string) args) | |
1559 (when tramp-debug-buffer | |
1560 (save-excursion | |
1561 (set-buffer | |
1562 (tramp-get-debug-buffer | |
1563 tramp-current-multi-method tramp-current-method | |
1564 tramp-current-user tramp-current-host)) | |
1565 (goto-char (point-max)) | |
1566 (tramp-insert-with-face | |
1567 'italic | |
1568 (concat "# " (apply #'format fmt-string args) "\n")))))) | |
1569 | |
1570 (defun tramp-message-for-buffer | |
1571 (multi-method method user host level fmt-string &rest args) | |
1572 "Like `tramp-message' but temporarily switches to the tramp buffer. | |
1573 First three args METHOD, USER, and HOST identify the tramp buffer to use, | |
1574 remaining args passed to `tramp-message'." | |
1575 (save-excursion | |
1576 (set-buffer (tramp-get-buffer multi-method method user host)) | |
1577 (apply 'tramp-message level fmt-string args))) | |
1578 | |
1579 (defsubst tramp-line-end-position nil | |
1580 "Return point at end of line. | |
1581 Calls `line-end-position' or `point-at-eol' if defined, else | |
1582 own implementation." | |
1583 (cond | |
1584 ((fboundp 'line-end-position) (funcall 'line-end-position)) | |
1585 ((fboundp 'point-at-eol) (funcall 'point-at-eol)) | |
1586 (t (save-excursion (end-of-line) (point))))) | |
1587 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1588 (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
|
1589 "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
|
1590 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1591 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
|
1592 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
|
1593 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
|
1594 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
|
1595 `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
|
1596 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
|
1597 `foo-user', `foo-host', `foo-path'. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1598 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1599 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
|
1600 `progn'). |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1601 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1602 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
|
1603 `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
|
1604 `(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
|
1605 (,(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
|
1606 (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
|
1607 (,(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
|
1608 (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
|
1609 (,(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
|
1610 (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
|
1611 (,(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
|
1612 (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
|
1613 (,(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
|
1614 (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
|
1615 ,@body)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1616 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1617 (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
|
1618 |
45861 | 1619 ;;; File Name Handler Functions: |
1620 | |
1621 (defun tramp-handle-make-symbolic-link | |
1622 (filename linkname &optional ok-if-already-exists) | |
1623 "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
|
1624 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
|
1625 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
|
1626 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
|
1627 |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1628 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
|
1629 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
|
1630 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
|
1631 target of the symlink differ." |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1632 (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
|
1633 (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
|
1634 (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
|
1635 filename linkname ok-if-already-exists)) |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1636 (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
|
1637 (cwd (file-name-directory l-path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1638 (unless ln |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1639 (signal 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1640 (list "Making a symbolic link." |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1641 "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
|
1642 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1643 ;; 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
|
1644 (when (file-exists-p linkname) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1645 ;; What to do? |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1646 (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
|
1647 (and (numberp ok-if-already-exists) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1648 (not (yes-or-no-p |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1649 (format |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1650 "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
|
1651 l-path))))) |
46307
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1652 (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
|
1653 (delete-file linkname))) |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1654 |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1655 ;; 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
|
1656 (when (tramp-tramp-file-p filename) |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1657 (setq filename (tramp-file-name-path |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1658 (tramp-dissect-file-name |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1659 (expand-file-name filename))))) |
45861 | 1660 |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1661 ;; 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
|
1662 ;; 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
|
1663 ;; that FILENAME belongs to. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1664 (zerop |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1665 (tramp-send-command-and-check |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1666 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
|
1667 (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
|
1668 cwd ln |
46307
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1669 filename |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1670 l-path) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1671 t))))) |
45861 | 1672 |
1673 | |
1674 (defun tramp-handle-load (file &optional noerror nomessage nosuffix must-suffix) | |
1675 "Like `load' for tramp files. Not implemented!" | |
1676 (unless (file-name-absolute-p file) | |
1677 (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
|
1678 (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
|
1679 (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
|
1680 (tramp-invoke-ange-ftp 'load |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1681 file noerror nomessage nosuffix must-suffix)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1682 (unless nosuffix |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1683 (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
|
1684 (setq file (concat file ".elc"))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1685 ((file-exists-p (concat file ".el")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1686 (setq file (concat file ".el"))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1687 (when must-suffix |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1688 ;; 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
|
1689 ;; Included for safety's sake. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1690 (unless (or (file-name-directory file) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1691 (string-match "\\.elc?\\'" file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1692 (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
|
1693 file))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1694 (unless noerror |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1695 (when (not (file-exists-p file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1696 (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
|
1697 (if (not (file-exists-p file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1698 nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1699 (unless nomessage |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1700 (message "Loading %s..." file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1701 (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
|
1702 ;; 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
|
1703 (load local-copy noerror t t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1704 (delete-file local-copy)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1705 (unless nomessage |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1706 (message "Loading %s...done" file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1707 t))) |
45861 | 1708 |
1709 ;; Path manipulation functions that grok TRAMP paths... | |
1710 (defun tramp-handle-file-name-directory (file) | |
1711 "Like `file-name-directory' but aware of TRAMP files." | |
1712 ;; 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
|
1713 (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
|
1714 (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
|
1715 (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
|
1716 ;; 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
|
1717 ;; (1) (string= path "") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1718 ;; (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
|
1719 ;; 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
|
1720 ;; 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
|
1721 ;; "/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
|
1722 ;; We should do some investigation. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1723 (if (string= path "") |
45861 | 1724 ;; For a filename like "/[foo]", we return "/". The `else' |
1725 ;; case would return "/[foo]" unchanged. But if we do that, | |
1726 ;; then `file-expand-wildcards' ceases to work. It's not | |
1727 ;; quite clear to me what's the intuition that tells that this | |
1728 ;; behavior is the right behavior, but oh, well. | |
1729 "/" | |
1730 ;; run the command on the path portion only | |
1731 ;; CCC: This should take into account the remote machine type, no? | |
1732 ;; --daniel <daniel@danann.net> | |
1733 (tramp-make-tramp-file-name multi-method method user host | |
1734 ;; This will not recurse... | |
1735 (or (file-name-directory path) ""))))) | |
1736 | |
1737 (defun tramp-handle-file-name-nondirectory (file) | |
1738 "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
|
1739 (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
|
1740 (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
|
1741 (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
|
1742 (file-name-nondirectory path))) |
45861 | 1743 |
1744 (defun tramp-handle-file-truename (filename &optional counter prev-dirs) | |
1745 "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
|
1746 (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
|
1747 ;; 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
|
1748 ;; 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
|
1749 (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
|
1750 filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1751 (let* ((steps (tramp-split-string path "/")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1752 (pathdir (let ((directory-sep-char ?/)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1753 (file-name-as-directory path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1754 (is-dir (string= path pathdir)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1755 (thisstep nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1756 (numchase 0) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1757 ;; 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
|
1758 ;; 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
|
1759 ;; 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
|
1760 ;; 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
|
1761 (numchase-limit 20) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1762 (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
|
1763 (curstri "") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1764 symlink-target) |
45861 | 1765 (tramp-message-for-buffer |
1766 multi-method method user host | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1767 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
|
1768 (while (and steps (< numchase numchase-limit)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1769 (setq thisstep (pop steps)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1770 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1771 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1772 10 "Check %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1773 (mapconcat 'identity |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1774 (append '("") (reverse result) (list thisstep)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1775 "/")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1776 (setq symlink-target |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1777 (nth 0 (tramp-handle-file-attributes |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1778 (tramp-make-tramp-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1779 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1780 (mapconcat 'identity |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1781 (append '("") (reverse result) (list thisstep)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1782 "/"))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1783 (cond ((string= "." thisstep) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1784 (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
|
1785 10 "Ignoring step `.'")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1786 ((string= ".." thisstep) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1787 (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
|
1788 10 "Processing step `..'") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1789 (pop result)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1790 ((stringp symlink-target) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1791 ;; It's a symlink, follow it. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1792 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1793 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1794 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
|
1795 (setq numchase (1+ numchase)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1796 (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
|
1797 (setq result nil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1798 (setq steps |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1799 (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
|
1800 (t |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1801 ;; It's a file. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1802 (setq result (cons thisstep result))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1803 (when (>= numchase numchase-limit) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1804 (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
|
1805 (setq result (reverse result)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1806 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1807 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1808 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
|
1809 filename (mapconcat 'identity (cons "" result) "/")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1810 (tramp-make-tramp-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1811 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1812 (concat (mapconcat 'identity (cons "" result) "/") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1813 (if is-dir "/" "")))))) |
45861 | 1814 |
1815 ;; Basic functions. | |
1816 | |
1817 (defun tramp-handle-file-exists-p (filename) | |
1818 "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
|
1819 (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
|
1820 (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
|
1821 (tramp-invoke-ange-ftp 'file-exists-p filename)) |
45861 | 1822 (save-excursion |
1823 (zerop (tramp-send-command-and-check | |
1824 multi-method method user host | |
1825 (format | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1826 (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
|
1827 (tramp-shell-quote-argument path))))))) |
45861 | 1828 |
1829 ;; CCC: This should check for an error condition and signal failure | |
1830 ;; when something goes wrong. | |
1831 ;; Daniel Pittman <daniel@danann.net> | |
1832 (defun tramp-handle-file-attributes (filename &optional nonnumeric) | |
1833 "Like `file-attributes' for tramp files. | |
1834 Optional argument NONNUMERIC means return user and group name | |
1835 rather than as numbers." | |
1836 (if (tramp-handle-file-exists-p filename) | |
1837 ;; file exists, find out stuff | |
1838 (save-excursion | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1839 (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
|
1840 (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
|
1841 (tramp-invoke-ange-ftp 'file-attributes file)) |
45861 | 1842 (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
|
1843 (tramp-handle-file-attributes-with-perl |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1844 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
|
1845 (tramp-handle-file-attributes-with-ls |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1846 multi-method method user host path nonnumeric)))) |
45861 | 1847 nil)) ; no file |
1848 | |
1849 | |
1850 (defun tramp-handle-file-attributes-with-ls | |
1851 (multi-method method user host path &optional nonnumeric) | |
1852 "Implement `file-attributes' for tramp files using the ls(1) command." | |
1853 (let (symlinkp dirp | |
1854 res-inode res-filemodes res-numlinks | |
1855 res-uid res-gid res-size res-symlink-target) | |
1856 (tramp-send-command | |
1857 multi-method method user host | |
1858 (format "%s %s %s" | |
1859 (tramp-get-ls-command multi-method method user host) | |
1860 (if nonnumeric "-ild" "-ildn") | |
1861 (tramp-shell-quote-argument path))) | |
1862 (tramp-wait-for-output) | |
1863 ;; parse `ls -l' output ... | |
1864 ;; ... inode | |
1865 (setq res-inode | |
1866 (condition-case err | |
1867 (read (current-buffer)) | |
1868 (invalid-read-syntax | |
1869 (when (and (equal (cadr err) | |
1870 "Integer constant overflow in reader") | |
1871 (string-match | |
1872 "^[0-9]+\\([0-9][0-9][0-9][0-9][0-9]\\)\\'" | |
1873 (caddr err))) | |
1874 (let* ((big (read (substring (caddr err) 0 | |
1875 (match-beginning 1)))) | |
1876 (small (read (match-string 1 (caddr err)))) | |
1877 (twiddle (/ small 65536))) | |
1878 (cons (+ big twiddle) | |
1879 (- small (* twiddle 65536)))))))) | |
1880 ;; ... file mode flags | |
1881 (setq res-filemodes (symbol-name (read (current-buffer)))) | |
1882 ;; ... number links | |
1883 (setq res-numlinks (read (current-buffer))) | |
1884 ;; ... uid and gid | |
1885 (setq res-uid (read (current-buffer))) | |
1886 (setq res-gid (read (current-buffer))) | |
1887 (unless nonnumeric | |
1888 (unless (numberp res-uid) (setq res-uid -1)) | |
1889 (unless (numberp res-gid) (setq res-gid -1))) | |
1890 ;; ... size | |
1891 (setq res-size (read (current-buffer))) | |
1892 ;; From the file modes, figure out other stuff. | |
1893 (setq symlinkp (eq ?l (aref res-filemodes 0))) | |
1894 (setq dirp (eq ?d (aref res-filemodes 0))) | |
1895 ;; if symlink, find out file name pointed to | |
1896 (when symlinkp | |
1897 (search-forward "-> ") | |
1898 (setq res-symlink-target | |
1899 (buffer-substring (point) | |
1900 (tramp-line-end-position)))) | |
1901 ;; return data gathered | |
1902 (list | |
1903 ;; 0. t for directory, string (name linked to) for symbolic | |
1904 ;; link, or nil. | |
1905 (or dirp res-symlink-target nil) | |
1906 ;; 1. Number of links to file. | |
1907 res-numlinks | |
1908 ;; 2. File uid. | |
1909 res-uid | |
1910 ;; 3. File gid. | |
1911 res-gid | |
1912 ;; 4. Last access time, as a list of two integers. First | |
1913 ;; integer has high-order 16 bits of time, second has low 16 | |
1914 ;; bits. | |
1915 ;; 5. Last modification time, likewise. | |
1916 ;; 6. Last status change time, likewise. | |
1917 '(0 0) '(0 0) '(0 0) ;CCC how to find out? | |
1918 ;; 7. Size in bytes (-1, if number is out of range). | |
1919 res-size | |
1920 ;; 8. File modes, as a string of ten letters or dashes as in ls -l. | |
1921 res-filemodes | |
1922 ;; 9. t iff file's gid would change if file were deleted and | |
1923 ;; recreated. | |
1924 nil ;hm? | |
1925 ;; 10. inode number. | |
1926 res-inode | |
1927 ;; 11. Device number. | |
1928 -1 ;hm? | |
1929 ))) | |
1930 | |
1931 (defun tramp-handle-file-attributes-with-perl | |
1932 (multi-method method user host path &optional nonnumeric) | |
1933 "Implement `file-attributes' for tramp files using a Perl script. | |
1934 | |
1935 The Perl command is sent to the remote machine when the connection | |
1936 is initially created and is kept cached by the remote shell." | |
1937 (tramp-send-command | |
1938 multi-method method user host | |
1939 (format "tramp_file_attributes %s" | |
1940 (tramp-shell-quote-argument path))) | |
1941 (tramp-wait-for-output) | |
1942 (let ((result (read (current-buffer)))) | |
1943 (setcar (nthcdr 8 result) | |
1944 (tramp-file-mode-from-int (nth 8 result))) | |
1945 result)) | |
1946 | |
1947 (defun tramp-handle-set-visited-file-modtime (&optional time-list) | |
1948 "Like `set-visited-file-modtime' for tramp files." | |
1949 (unless (buffer-file-name) | |
1950 (error "Can't set-visited-file-modtime: buffer `%s' not visiting a file" | |
1951 (buffer-name))) | |
1952 (when time-list | |
1953 (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
|
1954 (let ((f (buffer-file-name)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1955 (coding-system-used nil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1956 (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
|
1957 ;; 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
|
1958 (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
|
1959 (throw 'tramp-forward-to-ange-ftp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1960 (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
|
1961 (list time-list)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1962 (let* ((attr (file-attributes f)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1963 (modtime (nth 5 attr))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1964 ;; 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
|
1965 ;; `tramp-handle-file-attributes-with-ls'. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1966 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1967 (setq coding-system-used last-coding-system-used)) |
45861 | 1968 (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
|
1969 (tramp-run-real-handler 'set-visited-file-modtime (list modtime)) |
45861 | 1970 (save-excursion |
1971 (tramp-send-command | |
1972 multi-method method user host | |
1973 (format "%s -ild %s" | |
1974 (tramp-get-ls-command multi-method method user host) | |
1975 (tramp-shell-quote-argument path))) | |
1976 (tramp-wait-for-output) | |
1977 (setq attr (buffer-substring (point) | |
1978 (progn (end-of-line) (point))))) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1979 (setq tramp-buffer-file-attributes attr)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1980 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1981 (setq last-coding-system-used coding-system-used)) |
45861 | 1982 nil)))) |
1983 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1984 ;; CCC continue here |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1985 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1986 ;; 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
|
1987 ;; `tramp-handle-set-visited-file-modtime'. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1988 (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
|
1989 "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
|
1990 (with-current-buffer buf |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1991 (let ((f (buffer-file-name))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1992 (with-parsed-tramp-file-name f nil |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1993 (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
|
1994 ;; 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
|
1995 ;; on the arg list. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1996 (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
|
1997 user host path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1998 (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
|
1999 (let* ((attr (file-attributes f)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2000 (modtime (nth 5 attr))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2001 (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
|
2002 ;; 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
|
2003 ;; 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
|
2004 ;; (HIGH . LOW)? |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2005 (let ((mt (visited-file-modtime))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2006 (< (abs (tramp-time-diff |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2007 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
|
2008 (attr |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2009 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2010 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2011 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2012 (format "%s -ild %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2013 (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
|
2014 user host) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2015 (tramp-shell-quote-argument path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2016 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2017 (setq attr (buffer-substring |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2018 (point) (progn (end-of-line) (point))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2019 (equal tramp-buffer-file-attributes attr)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2020 ;; 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
|
2021 (t nil))))))) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2022 |
45861 | 2023 (defadvice clear-visited-file-modtime (after tramp activate) |
2024 "Set `tramp-buffer-file-attributes' back to nil. | |
2025 Tramp uses this variable as an emulation for the actual modtime of the file, | |
2026 if the remote host can't provide the modtime." | |
2027 (setq tramp-buffer-file-attributes nil)) | |
2028 | |
2029 (defun tramp-handle-set-file-modes (filename mode) | |
2030 "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
|
2031 (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
|
2032 (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
|
2033 (tramp-invoke-ange-ftp 'set-file-modes filename mode)) |
45861 | 2034 (save-excursion |
2035 (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
|
2036 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2037 (format "chmod %s %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2038 (tramp-decimal-to-octal mode) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2039 (tramp-shell-quote-argument path)))) |
45861 | 2040 (signal 'file-error |
2041 (list "Doing chmod" | |
2042 ;; FIXME: extract the proper text from chmod's stderr. | |
2043 "error while changing file's mode" | |
2044 filename)))))) | |
2045 | |
2046 ;; Simple functions using the `test' command. | |
2047 | |
2048 (defun tramp-handle-file-executable-p (filename) | |
2049 "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
|
2050 (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
|
2051 (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
|
2052 (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
|
2053 (zerop (tramp-run-test "-x" filename)))) |
45861 | 2054 |
2055 (defun tramp-handle-file-readable-p (filename) | |
2056 "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
|
2057 (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
|
2058 (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
|
2059 (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
|
2060 (zerop (tramp-run-test "-r" filename)))) |
45861 | 2061 |
2062 (defun tramp-handle-file-accessible-directory-p (filename) | |
2063 "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
|
2064 (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
|
2065 (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
|
2066 (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
|
2067 (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
|
2068 (zerop (tramp-run-test "-r" filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2069 (zerop (tramp-run-test "-x" filename))))) |
45861 | 2070 |
2071 ;; When the remote shell is started, it looks for a shell which groks | |
2072 ;; tilde expansion. Here, we assume that all shells which grok tilde | |
2073 ;; expansion will also provide a `test' command which groks `-nt' (for | |
2074 ;; newer than). If this breaks, tell me about it and I'll try to do | |
2075 ;; something smarter about it. | |
2076 (defun tramp-handle-file-newer-than-file-p (file1 file2) | |
2077 "Like `file-newer-than-file-p' for tramp files." | |
2078 (cond ((not (file-exists-p file1)) | |
2079 nil) | |
2080 ((not (file-exists-p file2)) | |
2081 t) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2082 ;; 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
|
2083 ;; 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
|
2084 ;; message. Todo: make a better error message. |
45861 | 2085 (t |
2086 (save-excursion | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2087 (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
|
2088 (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
|
2089 (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
|
2090 (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
|
2091 (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
|
2092 file1 file2)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2093 (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
|
2094 (equal v1-method v2-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2095 (equal v1-user v2-user) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2096 (equal v1-host v2-host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2097 (signal 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2098 (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
|
2099 file1 file2))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2100 (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
|
2101 (tramp-tramp-file-p file2)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2102 (signal 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2103 (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
|
2104 file1 file2))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2105 (if (tramp-get-test-groks-nt |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2106 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
|
2107 (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
|
2108 (zerop (tramp-run-test2 "tramp_test_nt" file1 file2))))))))) |
45861 | 2109 |
2110 ;; Functions implemented using the basic functions above. | |
2111 | |
2112 (defun tramp-handle-file-modes (filename) | |
2113 "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
|
2114 (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
|
2115 (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
|
2116 (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
|
2117 (when (file-exists-p filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2118 (tramp-mode-string-to-int |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2119 (nth 8 (tramp-handle-file-attributes filename)))))) |
45861 | 2120 |
2121 (defun tramp-handle-file-directory-p (filename) | |
2122 "Like `file-directory-p' for tramp files." | |
2123 ;; Care must be taken that this function returns `t' for symlinks | |
2124 ;; pointing to directories. Surely the most obvious implementation | |
2125 ;; would be `test -d', but that returns false for such symlinks. | |
2126 ;; CCC: Stefan Monnier says that `test -d' follows symlinks. And | |
2127 ;; I now think he's right. So we could be using `test -d', couldn't | |
2128 ;; we? | |
2129 ;; | |
2130 ;; 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
|
2131 (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
|
2132 (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
|
2133 (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
|
2134 (save-excursion |
45861 | 2135 (zerop |
2136 (tramp-send-command-and-check | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2137 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2138 (format "test -d %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2139 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2140 t))))) ;run command in subshell |
45861 | 2141 |
2142 (defun tramp-handle-file-regular-p (filename) | |
2143 "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
|
2144 (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
|
2145 (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
|
2146 (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
|
2147 (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
|
2148 (eq ?- (aref (nth 8 (tramp-handle-file-attributes filename)) 0))))) |
45861 | 2149 |
2150 (defun tramp-handle-file-symlink-p (filename) | |
2151 "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
|
2152 (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
|
2153 (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
|
2154 (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
|
2155 (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
|
2156 (when (stringp x) x)))) |
45861 | 2157 |
2158 (defun tramp-handle-file-writable-p (filename) | |
2159 "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
|
2160 (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
|
2161 (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
|
2162 (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
|
2163 (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
|
2164 ;; Existing files must be writable. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2165 (zerop (tramp-run-test "-w" filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2166 ;; 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
|
2167 (and (zerop (tramp-run-test |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2168 "-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
|
2169 (zerop (tramp-run-test |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2170 "-w" (tramp-handle-file-name-directory filename))))))) |
45861 | 2171 |
2172 (defun tramp-handle-file-ownership-preserved-p (filename) | |
2173 "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
|
2174 (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
|
2175 (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
|
2176 (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
|
2177 (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
|
2178 ;; Existing files must be writable. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2179 (zerop (tramp-run-test "-O" filename))))) |
45861 | 2180 |
2181 ;; Other file name ops. | |
2182 | |
2183 ;; ;; Matthias Köppe <mkoeppe@mail.math.uni-magdeburg.de> | |
2184 ;; (defun tramp-handle-directory-file-name (directory) | |
2185 ;; "Like `directory-file-name' for tramp files." | |
2186 ;; (if (and (eq (aref directory (- (length directory) 1)) ?/) | |
2187 ;; (not (eq (aref directory (- (length directory) 2)) ?:))) | |
2188 ;; (substring directory 0 (- (length directory) 1)) | |
2189 ;; directory)) | |
2190 | |
2191 ;; Philippe Troin <phil@fifi.org> | |
2192 (defun tramp-handle-directory-file-name (directory) | |
2193 "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
|
2194 (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
|
2195 (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
|
2196 (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
|
2197 (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
|
2198 (save-match-data |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2199 (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
|
2200 (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
|
2201 (/= (match-end 0) directory-length-1)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2202 (substring directory 0 directory-length-1) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2203 directory))))) |
45861 | 2204 |
2205 ;; Directory listings. | |
2206 | |
2207 (defun tramp-handle-directory-files (directory &optional full match nosort) | |
2208 "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
|
2209 (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
|
2210 (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
|
2211 (tramp-invoke-ange-ftp 'directory-files |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2212 directory full match nosort)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2213 (let (result x) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2214 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2215 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2216 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2217 (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
|
2218 nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2219 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2220 "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
|
2221 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2222 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2223 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2224 (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
|
2225 " -a | cat")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2226 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2227 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2228 (while (zerop (forward-line -1)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2229 (setq x (buffer-substring (point) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2230 (tramp-line-end-position))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2231 (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
|
2232 (if full |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2233 (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
|
2234 x) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2235 result) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2236 (push x result)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2237 (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
|
2238 (tramp-wait-for-output)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2239 result))) |
45861 | 2240 |
2241 ;; This function should return "foo/" for directories and "bar" for | |
2242 ;; files. We use `ls -ad' to get a list of files (including | |
2243 ;; directories), and `find . -type d \! -name . -prune' to get a list | |
2244 ;; of directories. | |
2245 (defun tramp-handle-file-name-all-completions (filename directory) | |
2246 "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
|
2247 (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
|
2248 (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
|
2249 (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
|
2250 filename directory)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2251 (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
|
2252 (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
|
2253 result) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2254 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2255 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2256 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2257 (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
|
2258 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2259 "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
|
2260 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2261 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2262 ;; 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
|
2263 ;; 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
|
2264 ;; rock. --daniel@danann.net |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2265 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2266 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2267 (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
|
2268 "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
|
2269 "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
|
2270 (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
|
2271 (if (or nowild (zerop (length filename))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2272 "" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2273 (format "-d %s*" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2274 (tramp-shell-quote-argument filename))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2275 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2276 ;; Now grab the output. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2277 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2278 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2279 (while (zerop (forward-line -1)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2280 (push (buffer-substring (point) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2281 (tramp-line-end-position)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2282 result)) |
45861 | 2283 |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2284 (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
|
2285 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2286 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2287 ;; Return the list. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2288 (if nowild |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2289 (all-completions filename (mapcar 'list result)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2290 result)))))) |
45861 | 2291 |
2292 | |
2293 ;; The following isn't needed for Emacs 20 but for 19.34? | |
2294 (defun tramp-handle-file-name-completion (filename directory) | |
2295 "Like `file-name-completion' for tramp files." | |
2296 (unless (tramp-tramp-file-p directory) | |
2297 (error | |
2298 "tramp-handle-file-name-completion invoked on non-tramp directory `%s'" | |
2299 directory)) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2300 (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
|
2301 (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
|
2302 (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
|
2303 filename directory)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2304 (try-completion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2305 filename |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2306 (mapcar (lambda (x) (cons x nil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2307 (tramp-handle-file-name-all-completions filename directory))))) |
45861 | 2308 |
2309 ;; cp, mv and ln | |
2310 | |
2311 (defun tramp-handle-add-name-to-file | |
2312 (filename newname &optional ok-if-already-exists) | |
2313 "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
|
2314 (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
|
2315 (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
|
2316 (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
|
2317 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
|
2318 (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
|
2319 (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
|
2320 (equal v1-method v2-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2321 (equal v1-user v2-user) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2322 (equal v1-host v2-host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2323 (error "add-name-to-file: %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2324 "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
|
2325 (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
|
2326 (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
|
2327 (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
|
2328 filename newname ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2329 (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
|
2330 (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
|
2331 filename newname ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2332 (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
|
2333 (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
|
2334 filename newname ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2335 (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
|
2336 (file-exists-p newname) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2337 (not (numberp ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2338 (y-or-n-p |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2339 (format |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2340 "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
|
2341 newname))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2342 (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
|
2343 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2344 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
|
2345 (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
|
2346 (tramp-shell-quote-argument v2-path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2347 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2348 "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
|
2349 (buffer-name)))))) |
45861 | 2350 |
2351 (defun tramp-handle-copy-file | |
2352 (filename newname &optional ok-if-already-exists keep-date) | |
2353 "Like `copy-file' for tramp files." | |
2354 ;; Check if both files are local -- invoke normal copy-file. | |
2355 ;; Otherwise, use tramp from local system. | |
2356 (setq filename (expand-file-name filename)) | |
2357 (setq newname (expand-file-name newname)) | |
2358 ;; At least one file a tramp file? | |
2359 (if (or (tramp-tramp-file-p filename) | |
2360 (tramp-tramp-file-p newname)) | |
2361 (tramp-do-copy-or-rename-file | |
2362 'copy filename newname ok-if-already-exists keep-date) | |
2363 (tramp-run-real-handler | |
2364 'copy-file | |
2365 (list filename newname ok-if-already-exists keep-date)))) | |
2366 | |
2367 (defun tramp-handle-rename-file | |
2368 (filename newname &optional ok-if-already-exists) | |
2369 "Like `rename-file' for tramp files." | |
2370 ;; Check if both files are local -- invoke normal rename-file. | |
2371 ;; Otherwise, use tramp from local system. | |
2372 (setq filename (expand-file-name filename)) | |
2373 (setq newname (expand-file-name newname)) | |
2374 ;; At least one file a tramp file? | |
2375 (if (or (tramp-tramp-file-p filename) | |
2376 (tramp-tramp-file-p newname)) | |
2377 (tramp-do-copy-or-rename-file | |
2378 'rename filename newname ok-if-already-exists) | |
2379 (tramp-run-real-handler 'rename-file | |
2380 (list filename newname ok-if-already-exists)))) | |
2381 | |
2382 (defun tramp-do-copy-or-rename-file | |
2383 (op filename newname &optional ok-if-already-exists keep-date) | |
2384 "Copy or rename a remote file. | |
2385 OP must be `copy' or `rename' and indicates the operation to perform. | |
2386 FILENAME specifies the file to copy or rename, NEWNAME is the name of | |
2387 the new file (for copy) or the new name of the file (for rename). | |
2388 OK-IF-ALREADY-EXISTS means don't barf if NEWNAME exists already. | |
2389 KEEP-DATE means to make sure that NEWNAME has the same timestamp | |
2390 as FILENAME. | |
2391 | |
2392 This function is invoked by `tramp-handle-copy-file' and | |
2393 `tramp-handle-rename-file'. It is an error if OP is neither of `copy' | |
2394 and `rename'. FILENAME and NEWNAME must be absolute file names." | |
2395 (unless (memq op '(copy rename)) | |
2396 (error "Unknown operation `%s', must be `copy' or `rename'" op)) | |
2397 (unless ok-if-already-exists | |
2398 (when (file-exists-p newname) | |
2399 (signal 'file-already-exists | |
2400 (list newname)))) | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2401 (let ((t1 (tramp-tramp-file-p filename)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2402 (t2 (tramp-tramp-file-p newname))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2403 ;; Check which ones of source and target are Tramp files. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2404 (cond |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2405 ((and t1 t2) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2406 ;; Both are Tramp files. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2407 (with-parsed-tramp-file-name filename v1 |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2408 (with-parsed-tramp-file-name newname v2 |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2409 ;; Possibly invoke Ange-FTP. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2410 (when (and (tramp-ange-ftp-file-name-p v1-multi-method v1-method) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2411 (tramp-ange-ftp-file-name-p v2-multi-method v2-method)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2412 (tramp-invoke-ange-ftp |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2413 (if (eq op 'copy) 'copy-file 'rename-file) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2414 filename newname ok-if-already-exists keep-date)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2415 ;; Check if we can use a shortcut. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2416 (if (and (equal v1-multi-method v2-multi-method) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2417 (equal v1-method v2-method) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2418 (equal v1-host v2-host) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2419 (equal v1-user v2-user)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2420 ;; Shortcut: if method, host, user are the same for both |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2421 ;; files, we invoke `cp' or `mv' on the remote host |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2422 ;; directly. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2423 (tramp-do-copy-or-rename-file-directly |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2424 op v1-multi-method v1-method v1-user v1-host |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2425 v1-path v2-path keep-date) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2426 ;; The shortcut was not possible. So we copy the |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2427 ;; file first. If the operation was `rename', we go |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2428 ;; back and delete the original file (if the copy was |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2429 ;; successful). The approach is simple-minded: we |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2430 ;; create a new buffer, insert the contents of the |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2431 ;; source file into it, then write out the buffer to |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2432 ;; the target file. The advantage is that it doesn't |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2433 ;; matter which filename handlers are used for the |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2434 ;; source and target file. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2435 |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2436 ;; CCC: If both source and target are Tramp files, |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2437 ;; and both are using the same rcp-program, then we |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2438 ;; can invoke rcp directly. Note that |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2439 ;; default-directory should point to a local |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2440 ;; directory if we want to invoke rcp. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2441 (tramp-do-copy-or-rename-via-buffer |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2442 op filename newname keep-date))))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2443 ((or t1 t2) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2444 ;; Use the generic method via a Tramp buffer. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2445 (tramp-do-copy-or-rename-via-buffer op filename newname keep-date)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2446 (t |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2447 ;; One of them must be a Tramp file. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2448 (error "Tramp implementation says this cannot happen"))))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2449 |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2450 (defun tramp-do-copy-or-rename-via-buffer (op filename newname keep-date) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2451 "Use an Emacs buffer to copy or rename a file. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2452 First arg OP is either `copy' or `rename' and indicates the operation. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2453 FILENAME is the source file, NEWNAME the target file. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2454 KEEP-DATE is non-nil if NEWNAME should have the same timestamp as FILENAME." |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2455 (let ((trampbuf (get-buffer-create "*tramp output*"))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2456 (when keep-date |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2457 (tramp-message |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2458 1 (concat "Warning: cannot preserve file time stamp" |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2459 " with inline copying across machines"))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2460 (save-excursion |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2461 (set-buffer trampbuf) (erase-buffer) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2462 (insert-file-contents-literally filename) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2463 (let ((coding-system-for-write 'no-conversion)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2464 (write-region (point-min) (point-max) newname))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2465 ;; If the operation was `rename', delete the original file. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2466 (unless (eq op 'copy) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2467 (delete-file filename)))) |
45861 | 2468 |
2469 (defun tramp-do-copy-or-rename-file-directly | |
2470 (op multi-method method user host path1 path2 keep-date) | |
2471 "Invokes `cp' or `mv' on the remote system. | |
2472 OP must be one of `copy' or `rename', indicating `cp' or `mv', | |
2473 respectively. METHOD, USER, and HOST specify the connection. | |
2474 PATH1 and PATH2 specify the two arguments of `cp' or `mv'. | |
2475 If KEEP-DATE is non-nil, preserve the time stamp when copying." | |
2476 ;; CCC: What happens to the timestamp when renaming? | |
2477 (let ((cmd (cond ((and (eq op 'copy) keep-date) "cp -f -p") | |
2478 ((eq op 'copy) "cp -f") | |
2479 ((eq op 'rename) "mv -f") | |
2480 (t (error | |
2481 "Unknown operation `%s', must be `copy' or `rename'" | |
2482 op))))) | |
2483 (save-excursion | |
2484 (tramp-barf-unless-okay | |
2485 multi-method method user host | |
2486 (format "%s %s %s" | |
2487 cmd | |
2488 (tramp-shell-quote-argument path1) | |
2489 (tramp-shell-quote-argument path2)) | |
2490 nil 'file-error | |
2491 "Copying directly failed, see buffer `%s' for details." | |
2492 (buffer-name))))) | |
2493 | |
2494 ;; mkdir | |
2495 (defun tramp-handle-make-directory (dir &optional parents) | |
2496 "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
|
2497 (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
|
2498 (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
|
2499 (tramp-invoke-ange-ftp 'make-directory dir parents)) |
45861 | 2500 (tramp-barf-unless-okay |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2501 multi-method method user host |
45861 | 2502 (format " %s %s" |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2503 (if parents "mkdir -p" "mkdir") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2504 (tramp-shell-quote-argument path)) |
45861 | 2505 nil 'file-error |
2506 "Couldn't make directory %s" dir))) | |
2507 | |
2508 ;; CCC error checking? | |
2509 (defun tramp-handle-delete-directory (directory) | |
2510 "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
|
2511 (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
|
2512 (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
|
2513 (tramp-invoke-ange-ftp 'delete-directory directory)) |
45861 | 2514 (save-excursion |
2515 (tramp-send-command | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2516 multi-method method user host |
45861 | 2517 (format "rmdir %s ; echo ok" |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2518 (tramp-shell-quote-argument path))) |
45861 | 2519 (tramp-wait-for-output)))) |
2520 | |
2521 (defun tramp-handle-delete-file (filename) | |
2522 "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
|
2523 (with-parsed-tramp-file-name filename nil |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2524 (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
|
2525 (tramp-invoke-ange-ftp 'delete-file filename)) |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2526 (save-excursion |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2527 (unless (zerop (tramp-send-command-and-check |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2528 multi-method method user host |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2529 (format "rm -f %s" |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2530 (tramp-shell-quote-argument path)))) |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2531 (signal 'file-error "Couldn't delete Tramp file"))))) |
45861 | 2532 |
2533 ;; Dired. | |
2534 | |
2535 ;; CCC: This does not seem to be enough. Something dies when | |
2536 ;; we try and delete two directories under TRAMP :/ | |
2537 (defun tramp-handle-dired-recursive-delete-directory (filename) | |
2538 "Recursively delete the directory given. | |
2539 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
|
2540 (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
|
2541 (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
|
2542 (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
|
2543 filename)) |
45861 | 2544 ;; run a shell command 'rm -r <path>' |
2545 ;; Code shamelessly stolen for the dired implementation and, um, hacked :) | |
2546 (or (tramp-handle-file-exists-p filename) | |
2547 (signal | |
2548 'file-error | |
2549 (list "Removing old file name" "no such directory" filename))) | |
2550 ;; Which is better, -r or -R? (-r works for me <daniel@danann.net>) | |
2551 (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
|
2552 (format "rm -r %s" (tramp-shell-quote-argument path))) |
45861 | 2553 ;; Wait for the remote system to return to us... |
2554 ;; This might take a while, allow it plenty of time. | |
2555 (tramp-wait-for-output 120) | |
2556 ;; Make sure that it worked... | |
2557 (and (tramp-handle-file-exists-p filename) | |
2558 (error "Failed to recusively delete %s" filename)))) | |
2559 | |
2560 | |
2561 (defun tramp-handle-dired-call-process (program discard &rest arguments) | |
2562 "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
|
2563 (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
|
2564 (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
|
2565 (let ((default-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2566 (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
|
2567 (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
|
2568 program discard arguments))) |
45861 | 2569 (save-excursion |
2570 (tramp-barf-unless-okay | |
2571 multi-method method user host | |
2572 (format "cd %s" (tramp-shell-quote-argument path)) | |
2573 nil 'file-error | |
2574 "tramp-handle-dired-call-process: Couldn't `cd %s'" | |
2575 (tramp-shell-quote-argument path)) | |
2576 (tramp-send-command | |
2577 multi-method method user host | |
2578 (mapconcat #'tramp-shell-quote-argument (cons program arguments) " ")) | |
2579 (tramp-wait-for-output)) | |
2580 (unless discard | |
2581 (insert-buffer (tramp-get-buffer multi-method method user host))) | |
2582 (save-excursion | |
2583 (prog1 | |
2584 (tramp-send-command-and-check multi-method method user host nil) | |
2585 (tramp-send-command multi-method method user host "cd") | |
2586 (tramp-wait-for-output))))) | |
2587 | |
2588 ;; Pacify byte-compiler. The function is needed on XEmacs only. I'm | |
2589 ;; not sure at all that this is the right way to do it, but let's hope | |
2590 ;; it works for now, and wait for a guru to point out the Right Way to | |
2591 ;; achieve this. | |
2592 ;;(eval-when-compile | |
2593 ;; (unless (fboundp 'dired-insert-set-properties) | |
2594 ;; (fset 'dired-insert-set-properties 'ignore))) | |
2595 ;; Gerd suggests this: | |
2596 (eval-when-compile (require 'dired)) | |
2597 ;; Note that dired is required at run-time, too, when it is needed. | |
2598 ;; It is only needed on XEmacs for the function | |
2599 ;; `dired-insert-set-properties'. | |
2600 | |
2601 (defun tramp-handle-insert-directory | |
2602 (filename switches &optional wildcard full-directory-p) | |
2603 "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
|
2604 (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
|
2605 (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
|
2606 (tramp-invoke-ange-ftp 'insert-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2607 filename switches wildcard full-directory-p)) |
45861 | 2608 (tramp-message-for-buffer |
2609 multi-method method user host 10 | |
2610 "Inserting directory `ls %s %s', wildcard %s, fulldir %s" | |
2611 switches filename (if wildcard "yes" "no") | |
2612 (if full-directory-p "yes" "no")) | |
2613 (when wildcard | |
2614 (setq wildcard (file-name-nondirectory path)) | |
2615 (setq path (file-name-directory path))) | |
2616 (when (listp switches) | |
2617 (setq switches (mapconcat 'identity switches " "))) | |
2618 (unless full-directory-p | |
2619 (setq switches (concat "-d " switches))) | |
2620 (when wildcard | |
2621 (setq switches (concat switches " " wildcard))) | |
2622 (save-excursion | |
2623 ;; If `full-directory-p', we just say `ls -l FILENAME'. | |
2624 ;; Else we chdir to the parent directory, then say `ls -ld BASENAME'. | |
2625 (if full-directory-p | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2626 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2627 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2628 (format "%s %s %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2629 (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
|
2630 switches |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2631 (if wildcard |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2632 path |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2633 (tramp-shell-quote-argument (concat path "."))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2634 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2635 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2636 (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
|
2637 (file-name-directory path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2638 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2639 "Couldn't `cd %s'" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2640 (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
|
2641 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2642 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2643 (format "%s %s %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2644 (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
|
2645 switches |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2646 (if full-directory-p |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2647 ;; 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
|
2648 ;; listing for symlinks, too. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2649 (concat (file-name-as-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2650 (file-name-nondirectory path)) ".") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2651 (file-name-nondirectory path))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2652 (sit-for 1) ;needed for rsh but not ssh? |
45861 | 2653 (tramp-wait-for-output)) |
2654 (insert-buffer (tramp-get-buffer multi-method method user host)) | |
2655 ;; On XEmacs, we want to call (exchange-point-and-mark t), but | |
2656 ;; that doesn't exist on Emacs, so we use this workaround instead. | |
2657 ;; Since zmacs-region-stays doesn't exist in Emacs, this ought to | |
2658 ;; be safe. Thanks to Daniel Pittman <daniel@danann.net>. | |
2659 (let ((zmacs-region-stays t)) | |
2660 (exchange-point-and-mark)) | |
2661 (save-excursion | |
2662 (tramp-send-command multi-method method user host "cd") | |
2663 (tramp-wait-for-output)) | |
2664 ;; Another XEmacs specialty follows. What's the right way to do | |
2665 ;; it? | |
2666 (when (and (featurep 'xemacs) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2667 (eq major-mode 'dired-mode)) |
45861 | 2668 (save-excursion |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2669 (require 'dired) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2670 (dired-insert-set-properties (point) (mark t)))))) |
45861 | 2671 |
2672 ;; Continuation of kluge to pacify byte-compiler. | |
2673 ;;(eval-when-compile | |
2674 ;; (when (eq (symbol-function 'dired-insert-set-properties) 'ignore) | |
2675 ;; (fmakunbound 'dired-insert-set-properties))) | |
2676 | |
2677 ;; CCC is this the right thing to do? | |
2678 (defun tramp-handle-unhandled-file-name-directory (filename) | |
2679 "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
|
2680 (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
|
2681 (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
|
2682 (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
|
2683 filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2684 (expand-file-name "~/"))) |
45861 | 2685 |
2686 ;; Canonicalization of file names. | |
2687 | |
2688 (defun tramp-drop-volume-letter (name) | |
2689 "Cut off unnecessary drive letter from file NAME. | |
2690 The function `tramp-handle-expand-file-name' calls `expand-file-name' | |
2691 locally on a remote file name. When the local system is a W32 system | |
2692 but the remote system is Unix, this introduces a superfluous drive | |
2693 letter into the file name. This function removes it. | |
2694 | |
2695 Doesn't do anything if the NAME does not start with a drive letter." | |
2696 (if (and (> (length name) 1) | |
2697 (char-equal (aref name 1) ?:) | |
2698 (let ((c1 (aref name 0))) | |
2699 (or (and (>= c1 ?A) (<= c1 ?Z)) | |
2700 (and (>= c1 ?a) (<= c1 ?z))))) | |
2701 (substring name 2) | |
2702 name)) | |
2703 | |
2704 (defun tramp-handle-expand-file-name (name &optional dir) | |
2705 "Like `expand-file-name' for tramp files." | |
2706 ;; If DIR is not given, use DEFAULT-DIRECTORY or "/". | |
2707 (setq dir (or dir default-directory "/")) | |
2708 ;; Unless NAME is absolute, concat DIR and NAME. | |
2709 (unless (file-name-absolute-p name) | |
2710 (setq name (concat (file-name-as-directory dir) name))) | |
2711 ;; If NAME is not a tramp file, run the real handler | |
2712 (if (not (tramp-tramp-file-p name)) | |
2713 (tramp-run-real-handler 'expand-file-name | |
2714 (list name nil)) | |
2715 ;; Dissect NAME. | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2716 (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
|
2717 (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
|
2718 (tramp-invoke-ange-ftp 'expand-file-name name nil)) |
45861 | 2719 (unless (file-name-absolute-p path) |
2720 (setq path (concat "~/" path))) | |
2721 (save-excursion | |
2722 ;; Tilde expansion if necessary. This needs a shell which | |
2723 ;; groks tilde expansion! The function `tramp-find-shell' is | |
2724 ;; supposed to find such a shell on the remote host. Please | |
2725 ;; tell me about it when this doesn't work on your system. | |
2726 (when (string-match "\\`\\(~[^/]*\\)\\(.*\\)\\'" path) | |
2727 (let ((uname (match-string 1 path)) | |
2728 (fname (match-string 2 path))) | |
2729 ;; CCC fanatic error checking? | |
2730 (set-buffer (tramp-get-buffer multi-method method user host)) | |
2731 (erase-buffer) | |
2732 (tramp-send-command | |
2733 multi-method method user host | |
2734 (format "cd %s; pwd" uname) | |
2735 t) | |
2736 (tramp-wait-for-output) | |
2737 (goto-char (point-min)) | |
2738 (setq uname (buffer-substring (point) (tramp-line-end-position))) | |
2739 (setq path (concat uname fname)) | |
2740 (erase-buffer))) | |
2741 ;; No tilde characters in file name, do normal | |
2742 ;; expand-file-name (this does "/./" and "/../"). We bind | |
2743 ;; directory-sep-char here for XEmacs on Windows, which would | |
2744 ;; otherwise use backslash. | |
2745 (let ((directory-sep-char ?/)) | |
2746 (tramp-make-tramp-file-name | |
2747 multi-method method user host | |
2748 (tramp-drop-volume-letter | |
2749 (tramp-run-real-handler 'expand-file-name (list path))))))))) | |
2750 | |
2751 ;; Remote commands. | |
2752 | |
2753 (defun tramp-handle-shell-command (command &optional output-buffer error-buffer) | |
2754 "Like `shell-command' for tramp files. | |
2755 This will break if COMMAND prints a newline, followed by the value of | |
2756 `tramp-end-of-output', followed by another newline." | |
2757 (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
|
2758 (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
|
2759 (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
|
2760 (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
|
2761 user host path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2762 (tramp-invoke-ange-ftp 'shell-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2763 command output-buffer error-buffer))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2764 (let (status) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2765 (when (string-match "&[ \t]*\\'" command) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2766 (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
|
2767 (when error-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2768 (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
|
2769 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2770 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2771 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2772 (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
|
2773 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2774 "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
|
2775 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2776 (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
|
2777 (concat command "; tramp_old_status=$?")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2778 ;; 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
|
2779 ;; 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
|
2780 (tramp-wait-for-output)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2781 (unless output-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2782 (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
|
2783 (set-buffer output-buffer) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2784 (erase-buffer)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2785 (unless (bufferp output-buffer) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2786 (setq output-buffer (current-buffer))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2787 (set-buffer output-buffer) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2788 (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
|
2789 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2790 (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
|
2791 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2792 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2793 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2794 (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
|
2795 " echo tramp_exit_status $?")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2796 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2797 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2798 (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
|
2799 (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
|
2800 (skip-chars-forward "^ ") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2801 (setq status (read (current-buffer)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2802 (unless (zerop (buffer-size)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2803 (pop-to-buffer output-buffer)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2804 status))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2805 ;; 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
|
2806 ;; 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
|
2807 (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
|
2808 default-directory) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2809 (tramp-run-real-handler 'shell-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2810 (list command output-buffer error-buffer))) |
45861 | 2811 |
2812 ;; File Editing. | |
2813 | |
2814 (defsubst tramp-make-temp-file () | |
2815 (funcall (if (fboundp 'make-temp-file) 'make-temp-file 'make-temp-name) | |
2816 (expand-file-name tramp-temp-name-prefix | |
2817 (tramp-temporary-file-directory)))) | |
2818 | |
2819 (defun tramp-handle-file-local-copy (filename) | |
2820 "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
|
2821 (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
|
2822 (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
|
2823 (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
|
2824 (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
|
2825 tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2826 (unless (file-exists-p filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2827 (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
|
2828 filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2829 (setq tmpfil (tramp-make-temp-file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2830 (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
|
2831 ;; 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
|
2832 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2833 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2834 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
|
2835 (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
|
2836 (unless (equal |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2837 0 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2838 (apply #'call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2839 (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
|
2840 nil trampbuf nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2841 (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
|
2842 (list |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2843 (tramp-make-rcp-program-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2844 user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2845 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2846 tmpfil)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2847 (pop-to-buffer trampbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2848 (error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2849 (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
|
2850 "see buffer `%s' for details") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2851 (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
|
2852 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2853 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2854 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
|
2855 ((and (tramp-get-encoding-command multi-method method) |
45861 | 2856 (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
|
2857 ;; Use inline encoding for file transfer. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2858 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2859 ;; 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
|
2860 ;; tramp-current-user, tramp-current-host. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2861 (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
|
2862 (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
|
2863 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2864 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2865 (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
|
2866 " < " (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2867 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2868 "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
|
2869 (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
|
2870 ;; Remove trailing status code |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2871 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2872 (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
|
2873 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2874 (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
|
2875 (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
|
2876 (fboundp (tramp-get-decoding-function |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2877 multi-method method))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2878 ;; 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
|
2879 ;; method, we call it. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2880 (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
|
2881 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2882 (erase-buffer) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2883 (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
|
2884 user host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2885 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2886 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2887 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
|
2888 filename |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2889 (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
|
2890 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2891 (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
|
2892 (funcall (tramp-get-decoding-function |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2893 multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2894 (point-min) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2895 (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2896 (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
|
2897 (kill-buffer tmpbuf)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2898 ;; 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
|
2899 ;; 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
|
2900 (let ((tmpfil2 (tramp-make-temp-file))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2901 (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
|
2902 (tramp-message |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2903 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
|
2904 filename |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2905 (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
|
2906 (call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2907 tramp-sh-program |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2908 tmpfil2 ;input |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2909 nil ;output |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2910 nil ;display |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2911 "-c" (concat (tramp-get-decoding-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2912 multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2913 " > " tmpfil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2914 (delete-file tmpfil2))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2915 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2916 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2917 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
|
2918 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2919 (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
|
2920 tmpfil))) |
45861 | 2921 |
2922 | |
2923 (defun tramp-handle-insert-file-contents | |
2924 (filename &optional visit beg end replace) | |
2925 "Like `insert-file-contents' for tramp files." | |
2926 (barf-if-buffer-read-only) | |
2927 (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
|
2928 (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
|
2929 (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
|
2930 (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
|
2931 filename visit beg end replace)) |
45861 | 2932 (if (not (tramp-handle-file-exists-p filename)) |
2933 (progn | |
2934 (when visit | |
2935 (setq buffer-file-name filename) | |
2936 (set-visited-file-modtime) | |
2937 (set-buffer-modified-p nil)) | |
2938 (signal 'file-error | |
2939 (format "File `%s' not found on remote host" filename)) | |
2940 (list (tramp-handle-expand-file-name filename) 0)) | |
2941 (let ((local-copy (tramp-handle-file-local-copy filename)) | |
2942 (coding-system-used nil) | |
2943 (result nil)) | |
2944 (when visit | |
2945 (setq buffer-file-name filename) | |
2946 (set-visited-file-modtime) | |
2947 (set-buffer-modified-p nil)) | |
2948 (tramp-message-for-buffer | |
2949 multi-method method user host | |
2950 9 "Inserting local temp file `%s'..." local-copy) | |
2951 (setq result | |
2952 (tramp-run-real-handler 'insert-file-contents | |
2953 (list local-copy nil beg end replace))) | |
2954 ;; Now `last-coding-system-used' has right value. Remember it. | |
2955 (when (boundp 'last-coding-system-used) | |
2956 (setq coding-system-used last-coding-system-used)) | |
2957 (tramp-message 9 "Inserting local temp file `%s'...done" local-copy) | |
2958 (delete-file local-copy) | |
2959 (when (boundp 'last-coding-system-used) | |
2960 (setq last-coding-system-used coding-system-used)) | |
2961 (list (expand-file-name filename) | |
2962 (second result)))))) | |
2963 | |
2964 ;; CCC grok APPEND, LOCKNAME, CONFIRM | |
2965 (defun tramp-handle-write-region | |
2966 (start end filename &optional append visit lockname confirm) | |
2967 "Like `write-region' for tramp files." | |
2968 (unless (eq append nil) | |
2969 (error "Cannot append to file using tramp (`%s')" filename)) | |
2970 (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
|
2971 ;; 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
|
2972 ;; 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
|
2973 ;; Ange-ftp ignores it, too. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2974 ;; (when (and lockname (stringp lockname)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2975 ;; (setq lockname (expand-file-name lockname))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2976 ;; (unless (or (eq lockname nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2977 ;; (string= lockname filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2978 ;; (error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2979 ;; "tramp-handle-write-region: LOCKNAME must be nil or equal FILENAME")) |
45861 | 2980 ;; XEmacs takes a coding system as the sevent argument, not `confirm' |
2981 (when (and (not (featurep 'xemacs)) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2982 confirm (file-exists-p filename)) |
45861 | 2983 (unless (y-or-n-p (format "File %s exists; overwrite anyway? " |
2984 filename)) | |
2985 (error "File not overwritten"))) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2986 (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
|
2987 (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
|
2988 (tramp-invoke-ange-ftp 'write-region |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2989 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
|
2990 (let ((curbuf (current-buffer)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2991 (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
|
2992 (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
|
2993 (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
|
2994 (encoding-function |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2995 (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
|
2996 (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
|
2997 (trampbuf (get-buffer-create "*tramp output*")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2998 ;; 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
|
2999 ;; 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
|
3000 ;; 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
|
3001 ;; 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
|
3002 ;; 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
|
3003 ;; 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
|
3004 coding-system-used |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3005 tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3006 ;; 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
|
3007 ;; 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
|
3008 ;; because this makes the logic simpler. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3009 (setq tmpfil (tramp-make-temp-file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3010 ;; 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
|
3011 ;; 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
|
3012 ;; `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
|
3013 (tramp-run-real-handler |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3014 'write-region |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3015 (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
|
3016 (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
|
3017 (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
|
3018 ;; 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
|
3019 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3020 (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
|
3021 ;; 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
|
3022 ;; 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
|
3023 ;; 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
|
3024 ;; 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
|
3025 ;; _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
|
3026 ;; 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
|
3027 (cond (rcp-program |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3028 ;; 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
|
3029 (let ((argl (append rcp-args |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3030 (list |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3031 tmpfil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3032 (tramp-make-rcp-program-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3033 user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3034 (tramp-shell-quote-argument path)))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3035 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3036 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3037 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
|
3038 (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
|
3039 (when tramp-debug-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3040 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3041 (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
|
3042 method user host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3043 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3044 (tramp-insert-with-face |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3045 '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
|
3046 (mapconcat 'identity argl " "))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3047 (unless (equal 0 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3048 (apply #'call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3049 rcp-program nil trampbuf nil argl)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3050 (pop-to-buffer trampbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3051 (error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3052 "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
|
3053 filename rcp-program)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3054 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3055 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3056 6 "Transferring file using `%s'...done" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3057 rcp-program))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3058 ((and encoding-command decoding-command) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3059 ;; Use inline file transfer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3060 (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
|
3061 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3062 ;; Encode tmpfil into tmpbuf |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3063 (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
|
3064 5 "Encoding region...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3065 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3066 (erase-buffer) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3067 ;; Use encoding function or command. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3068 (if (and encoding-function |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3069 (fboundp encoding-function)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3070 (progn |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3071 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3072 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3073 6 "Encoding region using function...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3074 (insert-file-contents-literally tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3075 ;; 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
|
3076 ;; 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
|
3077 ;; both of the following conditions are |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3078 ;; 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
|
3079 ;; 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
|
3080 ;; default-directory is remote. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3081 ;; (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
|
3082 ;; 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
|
3083 ;; tmp file anyway. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3084 (let ((default-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3085 (tramp-temporary-file-directory))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3086 (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
|
3087 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3088 (unless (bolp) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3089 (newline))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3090 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3091 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3092 6 "Encoding region using command...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3093 (unless (equal 0 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3094 (call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3095 tramp-sh-program |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3096 tmpfil ;input = local tmp file |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3097 t ;output is current buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3098 nil ;don't redisplay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3099 "-c" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3100 encoding-command)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3101 (pop-to-buffer trampbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3102 (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
|
3103 " command `%s' failed") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3104 filename encoding-command))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3105 ;; 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
|
3106 ;; 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
|
3107 ;; 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
|
3108 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3109 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3110 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
|
3111 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3112 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3113 (format "%s >%s <<'EOF'" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3114 decoding-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3115 (tramp-shell-quote-argument path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3116 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3117 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3118 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3119 6 "Sending data to remote host...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3120 (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
|
3121 (point-min) (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3122 ;; wait for remote decoding to complete |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3123 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3124 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3125 6 "Sending end of data token...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3126 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3127 multi-method method user host "EOF") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3128 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3129 multi-method method user host 6 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3130 "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
|
3131 (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
|
3132 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3133 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3134 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
|
3135 (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
|
3136 " decode using `%s' failed") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3137 filename decoding-command) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3138 (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
|
3139 filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3140 (kill-buffer tmpbuf)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3141 (t |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3142 (error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3143 (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
|
3144 "decoding command or an rcp program") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3145 method))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3146 (delete-file tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3147 (unless (equal curbuf (current-buffer)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3148 (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
|
3149 curbuf (current-buffer))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3150 (when (eq visit t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3151 (set-visited-file-modtime)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3152 ;; 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
|
3153 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3154 (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
|
3155 (when (or (eq visit t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3156 (eq visit nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3157 (stringp visit)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3158 (message "Wrote %s" filename))))) |
45861 | 3159 |
3160 ;; Call down to the real handler. | |
3161 ;; Because EFS does not play nicely with TRAMP (both systems match an | |
3162 ;; TRAMP path) it is needed to disable efs as well as tramp for the | |
3163 ;; operation. | |
3164 ;; | |
3165 ;; Other than that, this is the canon file-handler code that the doco | |
3166 ;; says should be used here. Which is nice. | |
3167 ;; | |
3168 ;; Under XEmacs current, EFS also hooks in as | |
3169 ;; efs-sifn-handler-function to handle any path with environment | |
3170 ;; variables. This has two implications: | |
3171 ;; 1) That EFS may not be completely dead (yet) for TRAMP paths | |
3172 ;; 2) That TRAMP might want to do the same thing. | |
3173 ;; Details as they come in. | |
3174 ;; | |
3175 ;; Daniel Pittman <daniel@danann.net> | |
3176 | |
3177 ;; (defun tramp-run-real-handler (operation args) | |
3178 ;; "Invoke normal file name handler for OPERATION. | |
3179 ;; This inhibits EFS and Ange-FTP, too, because they conflict with tramp. | |
3180 ;; First arg specifies the OPERATION, remaining ARGS are passed to the | |
3181 ;; OPERATION." | |
3182 ;; (let ((inhibit-file-name-handlers | |
3183 ;; (list 'tramp-file-name-handler | |
3184 ;; 'efs-file-handler-function | |
3185 ;; 'ange-ftp-hook-function | |
3186 ;; (and (eq inhibit-file-name-operation operation) | |
3187 ;; inhibit-file-name-handlers))) | |
3188 ;; (inhibit-file-name-operation operation)) | |
3189 ;; (apply operation args))) | |
3190 | |
3191 (defun tramp-run-real-handler (operation args) | |
3192 "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
|
3193 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
|
3194 pass to the OPERATION." |
45861 | 3195 (let ((inhibit-file-name-handlers |
3196 (list 'tramp-file-name-handler | |
3197 (and (eq inhibit-file-name-operation operation) | |
3198 inhibit-file-name-handlers))) | |
3199 (inhibit-file-name-operation operation)) | |
3200 (apply operation args))) | |
3201 | |
3202 ;; Main function. | |
3203 ;;;###autoload | |
3204 (defun tramp-file-name-handler (operation &rest args) | |
3205 "Invoke tramp file name handler. | |
3206 Falls back to normal file name handler if no tramp file name handler exists." | |
3207 (let ((fn (assoc operation tramp-file-name-handler-alist))) | |
3208 (if fn | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3209 (catch 'tramp-forward-to-ange-ftp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3210 (save-match-data (apply (cdr fn) args))) |
45861 | 3211 (tramp-run-real-handler operation args)))) |
3212 | |
3213 ;; Register in file name handler alist | |
3214 ;;;###autoload | |
3215 (add-to-list 'file-name-handler-alist | |
3216 (cons tramp-file-name-regexp 'tramp-file-name-handler)) | |
3217 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3218 ;; 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
|
3219 ;; |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3220 ;; * 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
|
3221 ;; * 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
|
3222 ;; 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
|
3223 ;; * 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
|
3224 ;; |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3225 ;; 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
|
3226 ;; 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
|
3227 (defun tramp-disable-ange-ftp () |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3228 "Turn Ange-FTP off. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3229 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
|
3230 `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
|
3231 `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
|
3232 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
|
3233 `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
|
3234 `tramp-default-method-alist'. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3235 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3236 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
|
3237 present for backward compatibility." |
46060
40298ba8e901
(tramp-handle-ange-ftp): Fix typo.
Andreas Schwab <schwab@suse.de>
parents:
46048
diff
changeset
|
3238 (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
|
3239 (a2 (rassq 'ange-ftp-completion-hook-function file-name-handler-alist))) |
45861 | 3240 (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
|
3241 (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
|
3242 (tramp-disable-ange-ftp) |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3243 |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3244 (defun tramp-repair-jka-compr () |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3245 "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
|
3246 `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
|
3247 necessary anymore." |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3248 (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
|
3249 (when jka |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3250 (setq file-name-handler-alist |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3251 (cons jka (delete jka file-name-handler-alist)))))) |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3252 (tramp-repair-jka-compr) |
45861 | 3253 |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3254 (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
|
3255 "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
|
3256 (let ((ange-ftp-name-format |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3257 (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
|
3258 (nth 3 tramp-file-name-structure) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3259 (nth 2 tramp-file-name-structure) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3260 (nth 4 tramp-file-name-structure)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3261 (throw 'tramp-forward-to-ange-ftp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3262 (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
|
3263 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3264 (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
|
3265 "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
|
3266 (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
|
3267 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3268 |
45861 | 3269 ;;; Interactions with other packages: |
3270 | |
3271 ;; -- complete.el -- | |
3272 | |
3273 ;; This function contributed by Ed Sabol | |
3274 (defun tramp-handle-expand-many-files (name) | |
3275 "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
|
3276 (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
|
3277 (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
|
3278 (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
|
3279 (save-match-data |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3280 (if (or (string-match "\\*" name) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3281 (string-match "\\?" name) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3282 (string-match "\\[.*\\]" name)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3283 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3284 ;; Dissect NAME. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3285 (let (bufstr) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3286 ;; Perhaps invoke Ange-FTP. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3287 (when (string= method tramp-ftp-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3288 (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
|
3289 ;; 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
|
3290 ;; 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
|
3291 ;; 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
|
3292 ;; don't bother. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3293 ;;-(let ((comint-file-name-quote-list |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3294 ;;- (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
|
3295 ;;- '(?\* ?\? ?[ ?])))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3296 ;;- (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3297 ;;- multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3298 ;;- (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
|
3299 ;;- (tramp-wait-for-output)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3300 (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
|
3301 (format "echo %s" path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3302 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3303 (setq bufstr (buffer-substring (point-min) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3304 (tramp-line-end-position))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3305 (goto-char (point-min)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3306 (if (string-equal path bufstr) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3307 nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3308 (insert "(\"") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3309 (while (search-forward " " nil t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3310 (delete-backward-char 1) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3311 (insert "\" \"")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3312 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3313 (delete-backward-char 1) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3314 (insert "\")") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3315 (goto-char (point-min)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3316 (mapcar |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3317 (function (lambda (x) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3318 (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
|
3319 user host x))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3320 (read (current-buffer)))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3321 (list (tramp-handle-expand-file-name name)))))) |
45861 | 3322 |
3323 ;; Check for complete.el and override PC-expand-many-files if appropriate. | |
3324 (eval-when-compile | |
3325 (defun tramp-save-PC-expand-many-files (name))); avoid compiler warning | |
3326 | |
3327 (defun tramp-setup-complete () | |
3328 (fset 'tramp-save-PC-expand-many-files | |
3329 (symbol-function 'PC-expand-many-files)) | |
3330 (defun PC-expand-many-files (name) | |
3331 (if (tramp-tramp-file-p name) | |
3332 (tramp-handle-expand-many-files name) | |
3333 (tramp-save-PC-expand-many-files name)))) | |
3334 | |
3335 ;; Why isn't eval-after-load sufficient? | |
3336 (if (fboundp 'PC-expand-many-files) | |
3337 (tramp-setup-complete) | |
3338 (eval-after-load "complete" '(tramp-setup-complete))) | |
3339 | |
3340 | |
3341 | |
3342 | |
3343 ;;; Internal Functions: | |
3344 | |
3345 (defun tramp-set-auto-save () | |
3346 (when (and (buffer-file-name) | |
3347 (tramp-tramp-file-p (buffer-file-name)) | |
3348 auto-save-default) | |
3349 (auto-save-mode 1))) | |
3350 (add-hook 'find-file-hooks 'tramp-set-auto-save t) | |
3351 | |
3352 (defun tramp-run-test (switch filename) | |
3353 "Run `test' on the remote system, given a SWITCH and a FILENAME. | |
3354 Returns the exit code of the `test' program." | |
3355 (let ((v (tramp-dissect-file-name filename))) | |
3356 (save-excursion | |
3357 (tramp-send-command-and-check | |
3358 (tramp-file-name-multi-method v) (tramp-file-name-method v) | |
3359 (tramp-file-name-user v) (tramp-file-name-host v) | |
3360 (format "test %s %s" switch | |
3361 (tramp-shell-quote-argument (tramp-file-name-path v))))))) | |
3362 | |
3363 (defun tramp-run-test2 (program file1 file2 &optional switch) | |
3364 "Run `test'-like PROGRAM on the remote system, given FILE1, FILE2. | |
3365 The optional SWITCH is inserted between the two files. | |
3366 Returns the exit code of the `test' PROGRAM. Barfs if the methods, | |
3367 hosts, or files, disagree." | |
3368 (let* ((v1 (tramp-dissect-file-name file1)) | |
3369 (v2 (tramp-dissect-file-name file2)) | |
3370 (mmethod1 (tramp-file-name-multi-method v1)) | |
3371 (mmethod2 (tramp-file-name-multi-method v2)) | |
3372 (method1 (tramp-file-name-method v1)) | |
3373 (method2 (tramp-file-name-method v2)) | |
3374 (user1 (tramp-file-name-user v1)) | |
3375 (user2 (tramp-file-name-user v2)) | |
3376 (host1 (tramp-file-name-host v1)) | |
3377 (host2 (tramp-file-name-host v2)) | |
3378 (path1 (tramp-file-name-path v1)) | |
3379 (path2 (tramp-file-name-path v2))) | |
3380 (unless (and method1 method2 host1 host2 | |
3381 (equal mmethod1 mmethod2) | |
3382 (equal method1 method2) | |
3383 (equal user1 user2) | |
3384 (equal host1 host2)) | |
3385 (error "tramp-run-test2: %s" | |
3386 "only implemented for same method, same user, same host")) | |
3387 (save-excursion | |
3388 (tramp-send-command-and-check | |
3389 mmethod1 method1 user1 host1 | |
3390 (format "%s %s %s %s" | |
3391 program | |
3392 (tramp-shell-quote-argument path1) | |
3393 (or switch "") | |
3394 (tramp-shell-quote-argument path2)))))) | |
3395 | |
3396 (defun tramp-buffer-name (multi-method method user host) | |
3397 "A name for the connection buffer for USER at HOST using METHOD." | |
3398 (cond (multi-method | |
3399 (tramp-buffer-name-multi-method "tramp" multi-method method user host)) | |
3400 (user | |
3401 (format "*tramp/%s %s@%s*" method user host)) | |
3402 (t | |
3403 (format "*tramp/%s %s*" method host)))) | |
3404 | |
3405 (defun tramp-buffer-name-multi-method (prefix multi-method method user host) | |
3406 "A name for the multi method connection buffer. | |
3407 MULTI-METHOD gives the multi method, METHOD the array of methods, | |
3408 USER the array of user names, HOST the array of host names." | |
3409 (unless (and (= (length method) (length user)) | |
3410 (= (length method) (length host))) | |
3411 (error "Syntax error in multi method (implementation error)")) | |
3412 (let ((len (length method)) | |
3413 (i 0) | |
3414 string-list) | |
3415 (while (< i len) | |
3416 (setq string-list | |
3417 (cons (if (aref user i) | |
3418 (format "%s#%s@%s:" (aref method i) | |
3419 (aref user i) (aref host i)) | |
3420 (format "%s@%s:" (aref method i) (aref host i))) | |
3421 string-list)) | |
3422 (incf i)) | |
3423 (format "*%s/%s %s*" | |
3424 prefix multi-method | |
3425 (apply 'concat (reverse string-list))))) | |
3426 | |
3427 (defun tramp-get-buffer (multi-method method user host) | |
3428 "Get the connection buffer to be used for USER at HOST using METHOD." | |
3429 (get-buffer-create (tramp-buffer-name multi-method method user host))) | |
3430 | |
3431 (defun tramp-debug-buffer-name (multi-method method user host) | |
3432 "A name for the debug buffer for USER at HOST using METHOD." | |
3433 (cond (multi-method | |
3434 (tramp-buffer-name-multi-method "debug tramp" | |
3435 multi-method method user host)) | |
3436 (user | |
3437 (format "*debug tramp/%s %s@%s*" method user host)) | |
3438 (t | |
3439 (format "*debug tramp/%s %s*" method host)))) | |
3440 | |
3441 (defun tramp-get-debug-buffer (multi-method method user host) | |
3442 "Get the debug buffer for USER at HOST using METHOD." | |
3443 (get-buffer-create (tramp-debug-buffer-name multi-method method user host))) | |
3444 | |
3445 (defun tramp-find-executable (multi-method method user host | |
3446 progname dirlist ignore-tilde) | |
3447 "Searches for PROGNAME in all directories mentioned in DIRLIST. | |
3448 First args METHOD, USER and HOST specify the connection, PROGNAME | |
3449 is the program to search for, and DIRLIST gives the list of directories | |
3450 to search. If IGNORE-TILDE is non-nil, directory names starting | |
3451 with `~' will be ignored. | |
3452 | |
3453 Returns the full path name of PROGNAME, if found, and nil otherwise. | |
3454 | |
3455 This function expects to be in the right *tramp* buffer." | |
3456 (let (result) | |
3457 (when ignore-tilde | |
3458 ;; Remove all ~/foo directories from dirlist. In Emacs 20, | |
3459 ;; `remove' is in CL, and we want to avoid CL dependencies. | |
3460 (let (newdl d) | |
3461 (while dirlist | |
3462 (setq d (car dirlist)) | |
3463 (setq dirlist (cdr dirlist)) | |
3464 (unless (char-equal ?~ (aref d 0)) | |
3465 (setq newdl (cons d newdl)))) | |
3466 (setq dirlist (nreverse newdl)))) | |
3467 (tramp-send-command | |
3468 multi-method method user host | |
3469 (format (concat "while read d; " | |
3470 "do if test -x $d/%s -a -f $d/%s; " | |
3471 "then echo tramp_executable $d/%s; " | |
3472 "break; fi; done <<'EOF'") | |
3473 progname progname progname)) | |
3474 (mapcar (lambda (d) | |
3475 (tramp-send-command multi-method method user host d)) | |
3476 dirlist) | |
3477 (tramp-send-command multi-method method user host "EOF") | |
3478 (tramp-wait-for-output) | |
3479 (goto-char (point-max)) | |
3480 (when (search-backward "tramp_executable " nil t) | |
3481 (skip-chars-forward "^ ") | |
3482 (skip-chars-forward " ") | |
3483 (buffer-substring (point) (tramp-line-end-position))))) | |
3484 | |
3485 (defun tramp-set-remote-path (multi-method method user host var dirlist) | |
3486 "Sets the remote environment VAR to existing directories from DIRLIST. | |
3487 I.e., for each directory in DIRLIST, it is tested whether it exists and if | |
3488 so, it is added to the environment variable VAR." | |
3489 (let ((existing-dirs | |
3490 (mapcar | |
3491 (lambda (x) | |
3492 (when (and | |
3493 (file-exists-p | |
3494 (tramp-make-tramp-file-name multi-method method user host x)) | |
3495 (file-directory-p | |
3496 (tramp-make-tramp-file-name multi-method method user host x))) | |
3497 x)) | |
3498 dirlist))) | |
3499 (tramp-send-command | |
3500 multi-method method user host | |
3501 (concat var "=" | |
3502 (mapconcat 'identity (delq nil existing-dirs) ":") | |
3503 "; export " var)) | |
3504 (tramp-wait-for-output))) | |
3505 | |
3506 ;; -- communication with external shell -- | |
3507 | |
3508 (defun tramp-find-file-exists-command (multi-method method user host) | |
3509 "Find a command on the remote host for checking if a file exists. | |
3510 Here, we are looking for a command which has zero exit status if the | |
3511 file exists and nonzero exit status otherwise." | |
3512 (make-local-variable 'tramp-file-exists-command) | |
3513 (tramp-message 10 "Finding command to check if file exists") | |
3514 (let ((existing | |
3515 (tramp-make-tramp-file-name | |
3516 multi-method method user host | |
3517 "/")) ;assume this file always exists | |
3518 (nonexisting | |
3519 (tramp-make-tramp-file-name | |
3520 multi-method method user host | |
3521 "/ this file does not exist "))) ;assume this never exists | |
3522 ;; The algorithm is as follows: we try a list of several commands. | |
3523 ;; For each command, we first run `$cmd /' -- this should return | |
3524 ;; true, as the root directory always exists. And then we run | |
3525 ;; `$cmd /this\ file\ does\ not\ exist', hoping that the file indeed | |
3526 ;; does not exist. This should return false. We use the first | |
3527 ;; command we find that seems to work. | |
3528 ;; The list of commands to try is as follows: | |
3529 ;; `ls -d' This works on most systems, but NetBSD 1.4 | |
3530 ;; has a bug: `ls' always returns zero exit | |
3531 ;; status, even for files which don't exist. | |
3532 ;; `test -e' Some Bourne shells have a `test' builtin | |
3533 ;; which does not know the `-e' option. | |
3534 ;; `/bin/test -e' For those, the `test' binary on disk normally | |
3535 ;; provides the option. Alas, the binary | |
3536 ;; is sometimes `/bin/test' and sometimes it's | |
3537 ;; `/usr/bin/test'. | |
3538 ;; `/usr/bin/test -e' In case `/bin/test' does not exist. | |
3539 (unless (or | |
3540 (and (setq tramp-file-exists-command "ls -d %s") | |
3541 (tramp-handle-file-exists-p existing) | |
3542 (not (tramp-handle-file-exists-p nonexisting))) | |
3543 (and (setq tramp-file-exists-command "test -e %s") | |
3544 (tramp-handle-file-exists-p existing) | |
3545 (not (tramp-handle-file-exists-p nonexisting))) | |
3546 (and (setq tramp-file-exists-command "/bin/test -e %s") | |
3547 (tramp-handle-file-exists-p existing) | |
3548 (not (tramp-handle-file-exists-p nonexisting))) | |
3549 (and (setq tramp-file-exists-command "/usr/bin/test -e %s") | |
3550 (tramp-handle-file-exists-p existing) | |
3551 (not (tramp-handle-file-exists-p nonexisting)))) | |
3552 (error "Couldn't find command to check if file exists.")))) | |
3553 | |
3554 | |
3555 ;; CCC test ksh or bash found for tilde expansion? | |
3556 (defun tramp-find-shell (multi-method method user host) | |
3557 "Find a shell on the remote host which groks tilde expansion." | |
3558 (let ((shell nil)) | |
3559 (tramp-send-command multi-method method user host "echo ~root") | |
3560 (tramp-wait-for-output) | |
3561 (cond | |
3562 ((string-match "^~root$" (buffer-string)) | |
3563 (setq shell | |
3564 (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
|
3565 "bash" tramp-remote-path t) |
45861 | 3566 (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
|
3567 "ksh" tramp-remote-path t))) |
45861 | 3568 (unless shell |
3569 (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
|
3570 ;; Find arguments for this shell. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3571 (let ((alist tramp-sh-extra-args) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3572 item extra-args) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3573 (while (and alist (null extra-args)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3574 (setq item (pop alist)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3575 (when (string-match (car item) shell) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3576 (setq extra-args (cdr item)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3577 (when extra-args (setq shell (concat shell " " extra-args)))) |
45861 | 3578 (tramp-message |
3579 5 "Starting remote shell `%s' for tilde expansion..." shell) | |
3580 (tramp-send-command | |
3581 multi-method method user host | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3582 (concat "PS1='$ ' ; exec " shell)) ; |
45861 | 3583 (unless (tramp-wait-for-regexp |
3584 (get-buffer-process (current-buffer)) | |
3585 60 (format "\\(\\$ *\\|\\(%s\\)\\'\\)" shell-prompt-pattern)) | |
3586 (pop-to-buffer (buffer-name)) | |
3587 (error "Couldn't find remote `%s' prompt." shell)) | |
3588 (process-send-string nil (format "PS1='%s%s%s'; PS2=''; PS3=''%s" | |
3589 tramp-rsh-end-of-line | |
3590 tramp-end-of-output | |
3591 tramp-rsh-end-of-line | |
3592 tramp-rsh-end-of-line)) | |
3593 (tramp-wait-for-output) | |
3594 (tramp-send-command multi-method method user host "echo hello") | |
3595 (tramp-message 5 "Waiting for remote `%s' to start up..." shell) | |
3596 (unless (tramp-wait-for-output 5) | |
3597 (unless (tramp-wait-for-output 5) | |
3598 (pop-to-buffer (buffer-name)) | |
3599 (error "Couldn't start remote `%s', see buffer `%s' for details" | |
3600 shell (buffer-name)))) | |
3601 (tramp-message 5 "Waiting for remote `%s' to start up...done" shell)) | |
3602 (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
|
3603 (tramp-get-remote-sh multi-method method)))))) |
45861 | 3604 |
3605 (defun tramp-check-ls-command (multi-method method user host cmd) | |
3606 "Checks whether the given `ls' executable groks `-n'. | |
3607 METHOD, USER and HOST specify the connection, CMD (the full path name of) | |
3608 the `ls' executable. Returns t if CMD supports the `-n' option, nil | |
3609 otherwise." | |
3610 (tramp-message 9 "Checking remote `%s' command for `-n' option" | |
3611 cmd) | |
3612 (when (tramp-handle-file-executable-p | |
3613 (tramp-make-tramp-file-name multi-method method user host cmd)) | |
3614 (let ((result nil)) | |
3615 (tramp-message 7 "Testing remote command `%s' for -n..." cmd) | |
3616 (setq result | |
3617 (tramp-send-command-and-check | |
3618 multi-method method user host | |
3619 (format "%s -lnd / >/dev/null" | |
3620 cmd))) | |
3621 (tramp-message 7 "Testing remote command `%s' for -n...%s" | |
3622 cmd | |
3623 (if (zerop result) "okay" "failed")) | |
3624 (zerop result)))) | |
3625 | |
3626 (defun tramp-check-ls-commands (multi-method method user host cmd dirlist) | |
3627 "Checks whether the given `ls' executable in one of the dirs groks `-n'. | |
3628 Returns nil if none was found, else the command is returned." | |
3629 (let ((dl dirlist) | |
3630 (result nil)) | |
3631 ;; It would be better to use the CL function `find', but | |
3632 ;; we don't want run-time dependencies on CL. | |
3633 (while (and dl (not result)) | |
3634 (let ((x (concat (file-name-as-directory (car dl)) cmd))) | |
3635 (when (tramp-check-ls-command multi-method method user host x) | |
3636 (setq result x))) | |
3637 (setq dl (cdr dl))) | |
3638 result)) | |
3639 | |
3640 (defun tramp-find-ls-command (multi-method method user host) | |
3641 "Finds an `ls' command which groks the `-n' option, returning nil if failed. | |
3642 \(This option prints numeric user and group ids in a long listing.)" | |
3643 (tramp-message 9 "Finding a suitable `ls' command") | |
3644 (or | |
3645 (tramp-check-ls-commands multi-method method user host "ls" tramp-remote-path) | |
3646 (tramp-check-ls-commands multi-method method user host "gnuls" tramp-remote-path) | |
3647 (tramp-check-ls-commands multi-method method user host "gls" tramp-remote-path))) | |
3648 | |
3649 ;; ------------------------------------------------------------ | |
3650 ;; -- Functions for establishing connection -- | |
3651 ;; ------------------------------------------------------------ | |
3652 | |
3653 (defun tramp-process-actions | |
3654 (multi-method method user host actions &optional timeout) | |
3655 "Process given ACTIONS for login specified via first four args. | |
3656 ACTIONS is a list of items (REGEXP FUN), where REGEXP specifies what | |
3657 output from the remote end to look for, and FUN specifies the action | |
3658 to take when the regexp matches." | |
3659 nil) | |
3660 | |
3661 (defun tramp-open-connection-telnet (multi-method method user host) | |
3662 "Open a connection using a telnet METHOD. | |
3663 This starts the command `telnet HOST ARGS'[*], then waits for a remote | |
3664 login prompt, then sends the user name USER, then waits for a remote | |
3665 password prompt. It queries the user for the password, then sends the | |
3666 password to the remote host. | |
3667 | |
3668 If USER is nil, uses value returned by `(user-login-name)' instead. | |
3669 | |
3670 Recognition of the remote shell prompt is based on the variable | |
3671 `shell-prompt-pattern' which must be set up correctly. | |
3672 | |
3673 Please note that it is NOT possible to use this connection method | |
3674 together with an out-of-band transfer method! You must use an inline | |
3675 transfer method. | |
3676 | |
3677 Maybe the different regular expressions need to be tuned. | |
3678 | |
3679 * Actually, the telnet program as well as the args to be used can be | |
3680 specified in the method parameters, see the variable `tramp-methods'." | |
3681 (save-match-data | |
3682 (when (tramp-method-out-of-band-p multi-method method) | |
3683 (error "Cannot use out-of-band method `%s' with telnet connection method" | |
3684 method)) | |
3685 (when multi-method | |
3686 (error "Cannot multi-connect using telnet connection method")) | |
3687 (tramp-pre-connection multi-method method user host) | |
3688 (tramp-message 7 "Opening connection for %s@%s using %s..." | |
3689 (or user (user-login-name)) host method) | |
3690 (let ((process-environment (copy-sequence process-environment))) | |
3691 (setenv "TERM" tramp-terminal-type) | |
3692 (let* ((default-directory (tramp-temporary-file-directory)) | |
3693 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
3694 (> emacs-major-version 20)) | |
3695 tramp-dos-coding-system)) | |
3696 (p (apply 'start-process | |
3697 (tramp-buffer-name multi-method method user host) | |
3698 (tramp-get-buffer multi-method method user host) | |
3699 (tramp-get-telnet-program multi-method method) | |
3700 host | |
3701 (tramp-get-telnet-args multi-method method))) | |
3702 (found nil) | |
3703 (pw nil)) | |
3704 (process-kill-without-query p) | |
3705 (tramp-message 9 "Waiting for login prompt...") | |
3706 (unless (tramp-wait-for-regexp p nil tramp-login-prompt-regexp) | |
3707 (pop-to-buffer (buffer-name)) | |
3708 (kill-process p) | |
3709 (error "Couldn't find remote login prompt")) | |
3710 (erase-buffer) | |
3711 ;; Remote login defaults to local one. | |
3712 (tramp-message 9 "Sending login name %s" (or user (user-login-name))) | |
3713 (process-send-string p (concat (or user (user-login-name)) | |
3714 tramp-rsh-end-of-line)) | |
3715 (tramp-message 9 "Waiting for password prompt...") | |
3716 (unless (setq found (tramp-wait-for-regexp | |
3717 p nil tramp-password-prompt-regexp)) | |
3718 (pop-to-buffer (buffer-name)) | |
3719 (kill-process p) | |
3720 (error "Couldn't find remote password prompt")) | |
3721 (erase-buffer) | |
3722 (setq pw (tramp-read-passwd (car found))) | |
3723 (tramp-message 9 "Sending password") | |
3724 (process-send-string p (concat pw tramp-rsh-end-of-line)) | |
3725 (tramp-message 9 "Waiting 30s for remote shell to come up...") | |
3726 (unless (setq found | |
3727 (tramp-wait-for-regexp | |
3728 p 30 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3729 tramp-wrong-passwd-regexp | |
3730 shell-prompt-pattern))) | |
3731 (pop-to-buffer (buffer-name)) | |
3732 (kill-process p) | |
3733 (error "Couldn't find remote shell prompt")) | |
3734 (when (nth 1 found) | |
3735 (pop-to-buffer (buffer-name)) | |
3736 (kill-process p) | |
3737 (error "Login failed: %s" (nth 1 found))) | |
3738 (tramp-open-connection-setup-interactive-shell | |
3739 p multi-method method user host) | |
3740 (tramp-post-connection multi-method method user host))))) | |
3741 | |
3742 ;; HHH: Changed to handle the case when USER is nil. | |
3743 (defun tramp-open-connection-rsh (multi-method method user host) | |
3744 "Open a connection using an rsh METHOD. | |
3745 This starts the command `rsh HOST -l USER'[*], then waits for a remote | |
3746 password or shell prompt. If a password prompt is seen, the user is | |
3747 queried for a password, this function sends the password to the remote | |
3748 host and waits for a shell prompt. | |
3749 | |
3750 If USER is nil, start the command `rsh HOST'[*] instead | |
3751 | |
3752 Recognition of the remote shell prompt is based on the variable | |
3753 `shell-prompt-pattern' which must be set up correctly. | |
3754 | |
3755 Please note that it is NOT possible to use this connection method with | |
3756 an out-of-band transfer method if this function asks the user for a | |
3757 password! You must use an inline transfer method in this case. | |
3758 Sadly, the transfer method cannot be switched on the fly, instead you | |
3759 must specify the right method in the file name. | |
3760 | |
46010
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3761 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
|
3762 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
|
3763 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
|
3764 |
45861 | 3765 * Actually, the rsh program to be used can be specified in the |
3766 method parameters, see the variable `tramp-methods'." | |
3767 (save-match-data | |
3768 (when multi-method | |
3769 (error "Cannot multi-connect using rsh connection method")) | |
3770 (tramp-pre-connection multi-method method user host) | |
3771 (if user | |
3772 (tramp-message 7 "Opening connection for %s@%s using %s..." | |
3773 user host method) | |
3774 (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
|
3775 (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
|
3776 (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
|
3777 (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
|
3778 (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
|
3779 (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
|
3780 ;; 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
|
3781 ;; 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
|
3782 (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
|
3783 (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
|
3784 (setq host (match-string 1 host))) |
45861 | 3785 (setenv "TERM" tramp-terminal-type) |
3786 (let* ((default-directory (tramp-temporary-file-directory)) | |
3787 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
3788 (> emacs-major-version 20)) | |
3789 tramp-dos-coding-system)) | |
3790 (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
|
3791 (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
|
3792 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
|
3793 (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
|
3794 host rsh-args))) |
45861 | 3795 (found nil)) |
3796 (process-kill-without-query p) | |
3797 (tramp-message 9 "Waiting 60s for shell or passwd prompt from %s" host) | |
3798 (setq found | |
3799 (tramp-wait-for-regexp | |
3800 p 60 | |
3801 (format | |
3802 "\\(%s\\)\\|\\(%s\\)\\'" | |
3803 tramp-password-prompt-regexp | |
3804 shell-prompt-pattern))) | |
3805 (unless found | |
3806 (pop-to-buffer (buffer-name)) | |
3807 (kill-process p) | |
3808 (error "Couldn't find remote shell or passwd prompt")) | |
3809 (when (nth 1 found) | |
3810 (when (tramp-method-out-of-band-p multi-method method) | |
3811 (pop-to-buffer (buffer-name)) | |
3812 (kill-process p) | |
3813 (error (concat "Out of band method `%s' not applicable" | |
3814 " for remote shell asking for a password") | |
3815 method)) | |
3816 (erase-buffer) | |
3817 (tramp-message 9 "Sending password...") | |
3818 (tramp-enter-password p (nth 1 found)) | |
3819 (tramp-message 9 "Sent password, waiting 60s for remote shell prompt") | |
3820 (setq found (tramp-wait-for-regexp p 60 | |
3821 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3822 tramp-wrong-passwd-regexp | |
3823 shell-prompt-pattern)))) | |
3824 (unless found | |
3825 (pop-to-buffer (buffer-name)) | |
3826 (kill-process p) | |
3827 (error "Couldn't find remote shell prompt")) | |
3828 (when (nth 1 found) | |
3829 (pop-to-buffer (buffer-name)) | |
3830 (kill-process p) | |
3831 (error "Login failed: %s" (nth 1 found))) | |
3832 (tramp-message 7 "Initializing remote shell") | |
3833 (tramp-open-connection-setup-interactive-shell | |
3834 p multi-method method user host) | |
3835 (tramp-post-connection multi-method method user host))))) | |
3836 | |
3837 ;; HHH: Changed. Now utilizes (or user (user-login-name)) instead of USER. | |
3838 (defun tramp-open-connection-su (multi-method method user host) | |
3839 "Open a connection using the `su' program with METHOD. | |
3840 This starts `su - USER', then waits for a password prompt. The HOST | |
3841 name must be equal to the local host name or to `localhost'. | |
3842 | |
3843 If USER is nil, uses value returned by user-login-name instead. | |
3844 | |
3845 Recognition of the remote shell prompt is based on the variable | |
3846 `shell-prompt-pattern' which must be set up correctly. Note that the | |
3847 other user may have a different shell prompt than you do, so it is not | |
3848 at all unlikely that this variable is set up wrongly!" | |
3849 (save-match-data | |
3850 (when (tramp-method-out-of-band-p multi-method method) | |
3851 (error "Cannot use out-of-band method `%s' with `su' connection method" | |
3852 method)) | |
3853 (unless (or (string-match (concat "^" (regexp-quote host)) | |
3854 (system-name)) | |
3855 (string= "localhost" host)) | |
3856 (error | |
3857 "Cannot connect to different host `%s' with `su' connection method" | |
3858 host)) | |
3859 (when (not user) | |
3860 (error "Must give user name for `su' connection method")) | |
3861 (tramp-pre-connection multi-method method user host) | |
3862 (tramp-message 7 "Opening connection for `%s' using `%s'..." | |
3863 (or user (user-login-name)) method) | |
3864 (let ((process-environment (copy-sequence process-environment))) | |
3865 (setenv "TERM" tramp-terminal-type) | |
3866 (let* ((default-directory (tramp-temporary-file-directory)) | |
3867 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
3868 (> emacs-major-version 20)) | |
3869 tramp-dos-coding-system)) | |
3870 (p (apply 'start-process | |
3871 (tramp-buffer-name multi-method method | |
3872 user host) | |
3873 (tramp-get-buffer multi-method method | |
3874 user host) | |
3875 (tramp-get-su-program multi-method method) | |
3876 (mapcar | |
3877 '(lambda (x) | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
3878 (format-spec x `((?u ,user)))) |
45861 | 3879 (tramp-get-su-args multi-method method)))) |
3880 (found nil) | |
3881 (pw nil)) | |
3882 (process-kill-without-query p) | |
3883 (tramp-message 9 "Waiting 30s for shell or password prompt...") | |
3884 (unless (setq found (tramp-wait-for-regexp | |
3885 p 30 | |
3886 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3887 tramp-password-prompt-regexp | |
3888 shell-prompt-pattern))) | |
3889 (pop-to-buffer (buffer-name)) | |
3890 (kill-process p) | |
3891 (error "Couldn't find shell or password prompt")) | |
3892 (when (nth 1 found) | |
3893 (erase-buffer) | |
3894 (setq pw (tramp-read-passwd (car found))) | |
3895 (tramp-message 9 "Sending password") | |
3896 (process-send-string p (concat pw tramp-rsh-end-of-line)) | |
3897 (tramp-message 9 "Waiting 30s for remote shell to come up...") | |
3898 (unless (setq found | |
3899 (tramp-wait-for-regexp | |
3900 p 30 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3901 tramp-wrong-passwd-regexp | |
3902 shell-prompt-pattern))) | |
3903 (pop-to-buffer (buffer-name)) | |
3904 (kill-process p) | |
3905 (error "Couldn't find remote shell prompt")) | |
3906 (when (nth 1 found) | |
3907 (pop-to-buffer (buffer-name)) | |
3908 (kill-process p) | |
3909 (error "`su' failed: %s" (nth 1 found)))) | |
3910 (tramp-open-connection-setup-interactive-shell | |
3911 p multi-method method user host) | |
3912 (tramp-post-connection multi-method method | |
3913 user host))))) | |
3914 | |
3915 ;; HHH: Not Changed. Multi method. It is not clear to me how this can | |
3916 ;; handle not giving a user name in the "file name". | |
3917 ;; | |
3918 ;; This is more difficult than for the single-hop method. In the | |
3919 ;; multi-hop-method, the desired behaviour should be that the | |
3920 ;; user must specify names for the telnet hops of which the user | |
3921 ;; name is different than the "original" name (or different from | |
3922 ;; the previous hop. | |
3923 (defun tramp-open-connection-multi (multi-method method user host) | |
3924 "Open a multi-hop connection using METHOD. | |
3925 This uses a slightly changed file name syntax. The idea is to say | |
3926 [multi/telnet:u1@h1/rsh:u2@h2]/path/to/file | |
3927 This will use telnet to log in as u1 to h1, then use rsh from there to | |
3928 log in as u2 to h2." | |
3929 (save-match-data | |
3930 (unless multi-method | |
3931 (error "Multi-hop open connection function called on non-multi method")) | |
3932 (when (tramp-method-out-of-band-p multi-method method) | |
3933 (error "No out of band multi-hop connections")) | |
3934 (unless (and (arrayp method) (not (stringp method))) | |
3935 (error "METHOD must be an array of strings for multi methods")) | |
3936 (unless (and (arrayp user) (not (stringp user))) | |
3937 (error "USER must be an array of strings for multi methods")) | |
3938 (unless (and (arrayp host) (not (stringp host))) | |
3939 (error "HOST must be an array of strings for multi methods")) | |
3940 (unless (and (= (length method) (length user)) | |
3941 (= (length method) (length host))) | |
3942 (error "Arrays METHOD, USER, HOST must have equal length")) | |
3943 (tramp-pre-connection multi-method method user host) | |
3944 (tramp-message 7 "Opening `%s' connection..." multi-method) | |
3945 (let ((process-environment (copy-sequence process-environment))) | |
3946 (setenv "TERM" tramp-terminal-type) | |
3947 (let* ((default-directory (tramp-temporary-file-directory)) | |
3948 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
3949 (> emacs-major-version 20)) | |
3950 tramp-dos-coding-system)) | |
3951 (p (start-process (tramp-buffer-name multi-method method user host) | |
3952 (tramp-get-buffer multi-method method user host) | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
3953 tramp-multi-sh-program)) |
45861 | 3954 (num-hops (length method)) |
3955 (i 0)) | |
3956 (process-kill-without-query p) | |
3957 (tramp-message 9 "Waiting 60s for local shell to come up...") | |
3958 (unless (tramp-wait-for-regexp | |
3959 p 60 (format "%s\\'" shell-prompt-pattern)) | |
3960 (pop-to-buffer (buffer-name)) | |
3961 (kill-process p) | |
3962 (error "Couldn't find local shell prompt")) | |
3963 ;; Now do all the connections as specified. | |
3964 (while (< i num-hops) | |
3965 (let* ((m (aref method i)) | |
3966 (u (aref user i)) | |
3967 (h (aref host i)) | |
3968 (entry (assoc m tramp-multi-connection-function-alist)) | |
3969 (multi-func (nth 1 entry)) | |
3970 (command (nth 2 entry))) | |
3971 ;; The multi-funcs don't need to do save-match-data, as that | |
3972 ;; is done here. | |
3973 (funcall multi-func p m u h command) | |
3974 (erase-buffer) | |
3975 (incf i))) | |
3976 (tramp-open-connection-setup-interactive-shell | |
3977 p multi-method method user host) | |
3978 (tramp-post-connection multi-method method user host))))) | |
3979 | |
3980 ;; HHH: Changed. Multi method. Don't know how to handle this in the case | |
3981 ;; of no user name provided. Hack to make it work as it did before: | |
3982 ;; changed `user' to `(or user (user-login-name))' in the places where | |
3983 ;; the value is actually used. | |
3984 (defun tramp-multi-connect-telnet (p method user host command) | |
3985 "Issue `telnet' command. | |
3986 Uses shell COMMAND to issue a `telnet' command to log in as USER to | |
3987 HOST. You can use percent escapes in COMMAND: `%h' is replaced with | |
3988 the host name, and `%n' is replaced with an end of line character, as | |
3989 set in `tramp-rsh-end-of-line'. Use `%%' if you want a literal percent | |
3990 character. | |
3991 | |
3992 If USER is nil, uses the return value of (user-login-name) instead." | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
3993 (let ((cmd (format-spec command `((?h ,host) (?n ,tramp-rsh-end-of-line)))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
3994 (cmd1 (format-spec command `((?h ,host) (?n "")))) |
45861 | 3995 found pw) |
3996 (erase-buffer) | |
3997 (tramp-message 9 "Sending telnet command `%s'" cmd1) | |
3998 (process-send-string p cmd) | |
3999 (tramp-message 9 "Waiting 30s for login prompt from %s" host) | |
4000 (unless (tramp-wait-for-regexp p 30 tramp-login-prompt-regexp) | |
4001 (pop-to-buffer (buffer-name)) | |
4002 (kill-process p) | |
4003 (error "Couldn't find login prompt from host %s" host)) | |
4004 (erase-buffer) | |
4005 (tramp-message 9 "Sending login name %s" (or user (user-login-name))) | |
4006 (process-send-string p (concat (or user (user-login-name)) tramp-rsh-end-of-line)) | |
4007 (tramp-message 9 "Waiting for password prompt") | |
4008 (unless (setq found (tramp-wait-for-regexp p nil tramp-password-prompt-regexp)) | |
4009 (pop-to-buffer (buffer-name)) | |
4010 (kill-process p) | |
4011 (error "Couldn't find password prompt from host %s" host)) | |
4012 (erase-buffer) | |
4013 (setq pw (tramp-read-passwd | |
4014 (format "Password for %s@%s, %s" (or user (user-login-name)) host found))) | |
4015 (tramp-message 9 "Sending password") | |
4016 (process-send-string p (concat pw tramp-rsh-end-of-line)) | |
4017 (tramp-message 9 "Waiting 60s for remote shell to come up...") | |
4018 (unless (setq found (tramp-wait-for-regexp | |
4019 p 60 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
4020 tramp-wrong-passwd-regexp | |
4021 shell-prompt-pattern))) | |
4022 (pop-to-buffer (buffer-name)) | |
4023 (kill-process p) | |
4024 (error "Couldn't find shell prompt from host %s" host)) | |
4025 (when (nth 1 found) | |
4026 (pop-to-buffer (buffer-name)) | |
4027 (kill-process p) | |
4028 (error "Login to %s failed: %s" (nth 2 found))))) | |
4029 | |
4030 ;; HHH: Changed. Multi method. Don't know how to handle this in the case | |
4031 ;; of no user name provided. Hack to make it work as it did before: | |
4032 ;; changed `user' to `(or user (user-login-name))' in the places where | |
4033 ;; the value is actually used. | |
4034 (defun tramp-multi-connect-rlogin (p method user host command) | |
4035 "Issue `rlogin' command. | |
4036 Uses shell COMMAND to issue an `rlogin' command to log in as USER to | |
4037 HOST. You can use percent escapes in COMMAND. `%u' will be replaced | |
4038 with the user name, `%h' will be replaced with the host name, and `%n' | |
4039 will be replaced with the value of `tramp-rsh-end-of-line'. You can use | |
4040 `%%' if you want to use a literal percent character. | |
4041 | |
4042 If USER is nil, uses the return value of (user-login-name) instead." | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
4043 (let ((cmd (format-spec command `((?h ,host) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
4044 (?u ,(or user (user-login-name))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
4045 (?n ,tramp-rsh-end-of-line)))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
4046 (cmd1 (format-spec command `((?h ,host) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
4047 (?u ,(or user (user-login-name))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
4048 (?n "")))) |
45861 | 4049 found) |
4050 (erase-buffer) | |
4051 (tramp-message 9 "Sending rlogin command `%s'" cmd1) | |
4052 (process-send-string p cmd) | |
4053 (tramp-message 9 "Waiting 60s for shell or passwd prompt from %s" host) | |
4054 (unless (setq found | |
4055 (tramp-wait-for-regexp p 60 | |
4056 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
4057 tramp-password-prompt-regexp | |
4058 shell-prompt-pattern))) | |
4059 (pop-to-buffer (buffer-name)) | |
4060 (kill-process p) | |
4061 (error "Couldn't find remote shell or passwd prompt")) | |
4062 (when (nth 1 found) | |
4063 (erase-buffer) | |
4064 (tramp-message 9 "Sending password...") | |
4065 (tramp-enter-password p (nth 1 found)) | |
4066 (tramp-message 9 "Sent password, waiting 60s for remote shell prompt") | |
4067 (setq found (tramp-wait-for-regexp p 60 | |
4068 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
4069 tramp-wrong-passwd-regexp | |
4070 shell-prompt-pattern)))) | |
4071 (unless found | |
4072 (pop-to-buffer (buffer-name)) | |
4073 (kill-process p) | |
4074 (error "Couldn't find remote shell prompt")) | |
4075 (when (nth 1 found) | |
4076 (pop-to-buffer (buffer-name)) | |
4077 (kill-process p) | |
4078 (error "Login failed: %s" (nth 1 found))))) | |
4079 | |
4080 ;; HHH: Changed. Multi method. Don't know how to handle this in the case | |
4081 ;; of no user name provided. Hack to make it work as it did before: | |
4082 ;; changed `user' to `(or user (user-login-name))' in the places where | |
4083 ;; the value is actually used. | |
4084 (defun tramp-multi-connect-su (p method user host command) | |
4085 "Issue `su' command. | |
4086 Uses shell COMMAND to issue a `su' command to log in as USER on | |
4087 HOST. The HOST name is ignored, this just changes the user id on the | |
4088 host currently logged in to. | |
4089 | |
4090 If USER is nil, uses the return value of (user-login-name) instead. | |
4091 | |
4092 You can use percent escapes in the COMMAND. `%u' is replaced with the | |
4093 user name, and `%n' is replaced with the value of | |
4094 `tramp-rsh-end-of-line'. Use `%%' if you want a literal percent | |
4095 character." | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
4096 (let ((cmd (format-spec command `((?u ,(or user (user-login-name))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
4097 (?n ,tramp-rsh-end-of-line)))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
4098 (cmd1 (format-spec command `((?u ,(or user (user-login-name))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
4099 (?n "")))) |
45861 | 4100 found) |
4101 (erase-buffer) | |
4102 (tramp-message 9 "Sending su command `%s'" cmd1) | |
4103 (process-send-string p cmd) | |
4104 (tramp-message 9 "Waiting 60s for shell or passwd prompt for %s" (or user (user-login-name))) | |
4105 (unless (setq found (tramp-wait-for-regexp | |
4106 p 60 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
4107 tramp-password-prompt-regexp | |
4108 shell-prompt-pattern))) | |
4109 (pop-to-buffer (buffer-name)) | |
4110 (kill-process p) | |
4111 (error "Couldn't find shell or passwd prompt for %s" | |
4112 (or user (user-login-name)))) | |
4113 (when (nth 1 found) | |
4114 (tramp-message 9 "Sending password...") | |
4115 (tramp-enter-password p (nth 1 found)) | |
4116 (erase-buffer) | |
4117 (tramp-message 9 "Sent password, waiting 60s for remote shell prompt") | |
4118 (setq found (tramp-wait-for-regexp p 60 | |
4119 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
4120 tramp-wrong-passwd-regexp | |
4121 shell-prompt-pattern)))) | |
4122 (unless found | |
4123 (pop-to-buffer (buffer-name)) | |
4124 (kill-process p) | |
4125 (error "Couldn't find remote shell prompt")) | |
4126 (when (nth 1 found) | |
4127 (pop-to-buffer (buffer-name)) | |
4128 (kill-process p) | |
4129 (error "Login failed: %s" (nth 1 found))))) | |
4130 | |
4131 ;; Utility functions. | |
4132 | |
4133 (defun tramp-wait-for-regexp (proc timeout regexp) | |
4134 "Wait for a REGEXP to appear from process PROC within TIMEOUT seconds. | |
4135 Expects the output of PROC to be sent to the current buffer. Returns | |
4136 the string that matched, or nil. Waits indefinitely if TIMEOUT is | |
4137 nil." | |
4138 (let ((found nil) | |
4139 (start-time (current-time))) | |
4140 (cond (timeout | |
4141 ;; Work around a bug in XEmacs 21, where the timeout | |
4142 ;; expires faster than it should. This degenerates | |
4143 ;; to polling for buggy XEmacsen, but oh, well. | |
4144 (while (and (not found) | |
4145 (< (tramp-time-diff (current-time) start-time) | |
4146 timeout)) | |
4147 (with-timeout (timeout) | |
4148 (while (not found) | |
4149 (accept-process-output proc 1) | |
4150 (goto-char (point-min)) | |
4151 (setq found (when (re-search-forward regexp nil t) | |
4152 (tramp-match-string-list))))))) | |
4153 (t | |
4154 (while (not found) | |
4155 (accept-process-output proc 1) | |
4156 (goto-char (point-min)) | |
4157 (setq found (when (re-search-forward regexp nil t) | |
4158 (tramp-match-string-list)))))) | |
4159 (when tramp-debug-buffer | |
4160 (append-to-buffer | |
4161 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4162 tramp-current-user tramp-current-host) | |
4163 (point-min) (point-max)) | |
4164 (when (not found) | |
4165 (save-excursion | |
4166 (set-buffer | |
4167 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4168 tramp-current-user tramp-current-host)) | |
4169 (goto-char (point-max)) | |
4170 (insert "[[Regexp `" regexp "' not found" | |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
4171 (if timeout (format " in %d secs" timeout) "") |
45861 | 4172 "]]")))) |
4173 found)) | |
4174 | |
4175 (defun tramp-enter-password (p prompt) | |
4176 "Prompt for a password and send it to the remote end. | |
4177 Uses PROMPT as a prompt and sends the password to process P." | |
4178 (let ((pw (tramp-read-passwd prompt))) | |
4179 (process-send-string p (concat pw tramp-rsh-end-of-line)))) | |
4180 | |
4181 ;; HHH: Not Changed. This might handle the case where USER is not | |
4182 ;; given in the "File name" very poorly. Then, the local | |
4183 ;; variable tramp-current user will be set to nil. | |
4184 (defun tramp-pre-connection (multi-method method user host) | |
4185 "Do some setup before actually logging in. | |
4186 METHOD, USER and HOST specify the connection." | |
4187 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4188 (set (make-local-variable 'tramp-current-multi-method) multi-method) | |
4189 (set (make-local-variable 'tramp-current-method) method) | |
4190 (set (make-local-variable 'tramp-current-user) user) | |
4191 (set (make-local-variable 'tramp-current-host) host) | |
4192 (set (make-local-variable 'inhibit-eol-conversion) nil) | |
4193 (erase-buffer)) | |
4194 | |
4195 (defun tramp-open-connection-setup-interactive-shell | |
4196 (p multi-method method user host) | |
4197 "Set up an interactive shell. | |
4198 Mainly sets the prompt and the echo correctly. P is the shell process | |
4199 to set up. METHOD, USER and HOST specify the connection." | |
4200 ;; Wait a bit in case the remote end feels like sending a little | |
4201 ;; junk first. It seems that fencepost.gnu.org does this when doing | |
4202 ;; a Kerberos login. | |
4203 (sit-for 1) | |
4204 (tramp-discard-garbage-erase-buffer p multi-method method user host) | |
4205 (process-send-string nil (format "exec %s%s" | |
4206 (tramp-get-remote-sh multi-method method) | |
4207 tramp-rsh-end-of-line)) | |
4208 (when tramp-debug-buffer | |
4209 (save-excursion | |
4210 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
4211 (goto-char (point-max)) | |
4212 (tramp-insert-with-face | |
4213 'bold (format "$ exec %s\n" (tramp-get-remote-sh multi-method method))))) | |
4214 (tramp-message 9 "Waiting 30s for remote `%s' to come up..." | |
4215 (tramp-get-remote-sh multi-method method)) | |
4216 (unless (tramp-wait-for-regexp | |
4217 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4218 (pop-to-buffer (buffer-name)) | |
4219 (error "Remote `%s' didn't come up. See buffer `%s' for details" | |
4220 (tramp-get-remote-sh multi-method method) (buffer-name))) | |
4221 (tramp-message 9 "Setting up remote shell environment") | |
4222 (tramp-discard-garbage-erase-buffer p multi-method method user host) | |
4223 (process-send-string | |
4224 nil (format "stty -inlcr -echo kill '^U'%s" tramp-rsh-end-of-line)) | |
4225 (unless (tramp-wait-for-regexp | |
4226 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4227 (pop-to-buffer (buffer-name)) | |
4228 (error "Couldn't `stty -echo', see buffer `%s'" (buffer-name))) | |
4229 (erase-buffer) | |
4230 (process-send-string nil (format "TERM=dumb; export TERM%s" | |
4231 tramp-rsh-end-of-line)) | |
4232 (unless (tramp-wait-for-regexp | |
4233 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4234 (pop-to-buffer (buffer-name)) | |
4235 (error "Couldn't `TERM=dumb; export TERM', see buffer `%s'" (buffer-name))) | |
4236 ;; Try to set up the coding system correctly. | |
4237 ;; CCC this can't be the right way to do it. Hm. | |
4238 (save-excursion | |
4239 (erase-buffer) | |
4240 (tramp-message 9 "Determining coding system") | |
4241 (process-send-string nil (format "echo foo ; echo bar %s" | |
4242 tramp-rsh-end-of-line)) | |
4243 (unless (tramp-wait-for-regexp | |
4244 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4245 (pop-to-buffer (buffer-name)) | |
4246 (error "Couldn't `echo foo; echo bar' to determine line endings'")) | |
4247 (goto-char (point-min)) | |
4248 (if (featurep 'mule) | |
4249 ;; Use MULE to select the right EOL convention for communicating | |
4250 ;; with the process. | |
4251 (let* ((cs (or (process-coding-system p) (cons 'undecided 'undecided))) | |
4252 cs-decode cs-encode) | |
4253 (when (symbolp cs) (setq cs (cons cs cs))) | |
4254 (setq cs-decode (car cs)) | |
4255 (setq cs-encode (cdr cs)) | |
4256 (unless cs-decode (setq cs-decode 'undecided)) | |
4257 (unless cs-encode (setq cs-encode 'undecided)) | |
4258 (setq cs-encode (tramp-coding-system-change-eol-conversion | |
4259 cs-encode 'unix)) | |
4260 (when (search-forward "\r" nil t) | |
4261 (setq cs-decode (tramp-coding-system-change-eol-conversion | |
4262 cs-decode 'dos))) | |
4263 (set-buffer-process-coding-system cs-decode cs-encode)) | |
4264 ;; Look for ^M and do something useful if found. | |
4265 (when (search-forward "\r" nil t) | |
4266 ;; We have found a ^M but cannot frob the process coding system | |
4267 ;; because we're running on a non-MULE Emacs. Let's try | |
4268 ;; stty, instead. | |
4269 (tramp-message 9 "Trying `stty -onlcr'") | |
4270 (process-send-string nil (format "stty -onlcr%s" tramp-rsh-end-of-line)) | |
4271 (unless (tramp-wait-for-regexp | |
4272 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4273 (pop-to-buffer (buffer-name)) | |
4274 (error "Couldn't `stty -onlcr', see buffer `%s'" (buffer-name)))))) | |
4275 (erase-buffer) | |
4276 (tramp-message | |
4277 9 "Waiting 30s for `HISTFILE=$HOME/.tramp_history; HISTSIZE=1'") | |
4278 (process-send-string | |
4279 nil (format "HISTFILE=$HOME/.tramp_history; HISTSIZE=1%s" | |
4280 tramp-rsh-end-of-line)) | |
4281 (unless (tramp-wait-for-regexp | |
4282 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4283 (pop-to-buffer (buffer-name)) | |
4284 (error (concat "Couldn't `HISTFILE=$HOME/.tramp_history; " | |
4285 "HISTSIZE=1', see buffer `%s'") | |
4286 (buffer-name))) | |
4287 (erase-buffer) | |
4288 (tramp-message 9 "Waiting 30s for `set +o vi +o emacs'") | |
4289 (process-send-string | |
4290 nil (format "set +o vi +o emacs%s" ;mustn't `>/dev/null' with AIX? | |
4291 tramp-rsh-end-of-line)) | |
4292 (unless (tramp-wait-for-regexp | |
4293 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4294 (pop-to-buffer (buffer-name)) | |
4295 (error "Couldn't `set +o vi +o emacs', see buffer `%s'" | |
4296 (buffer-name))) | |
4297 (erase-buffer) | |
4298 (tramp-message 9 "Waiting 30s for `unset MAIL MAILCHECK MAILPATH'") | |
4299 (process-send-string | |
4300 nil (format "unset MAIL MAILCHECK MAILPATH 1>/dev/null 2>/dev/null%s" | |
4301 tramp-rsh-end-of-line)) | |
4302 (unless (tramp-wait-for-regexp | |
4303 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4304 (pop-to-buffer (buffer-name)) | |
4305 (error "Couldn't `unset MAIL MAILCHECK MAILPATH', see buffer `%s'" | |
4306 (buffer-name))) | |
4307 (erase-buffer) | |
4308 (tramp-message 9 "Waiting 30s for `unset CDPATH'") | |
4309 (process-send-string | |
4310 nil (format "unset CDPATH%s" tramp-rsh-end-of-line)) | |
4311 (unless (tramp-wait-for-regexp | |
4312 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4313 (pop-to-buffer (buffer-name)) | |
4314 (error "Couldn't `unset CDPATH', see buffer `%s'" | |
4315 (buffer-name))) | |
4316 (erase-buffer) | |
4317 (tramp-message 9 "Setting shell prompt") | |
4318 (tramp-send-command | |
4319 multi-method method user host | |
4320 (format "PS1='%s%s%s'; PS2=''; PS3=''" | |
4321 tramp-rsh-end-of-line | |
4322 tramp-end-of-output | |
4323 tramp-rsh-end-of-line)) | |
4324 (tramp-wait-for-output) | |
4325 (tramp-send-command multi-method method user host "echo hello") | |
4326 (tramp-message 9 "Waiting for remote `%s' to come up..." | |
4327 (tramp-get-remote-sh multi-method method)) | |
4328 (unless (tramp-wait-for-output 5) | |
4329 (unless (tramp-wait-for-output 5) | |
4330 (pop-to-buffer (buffer-name)) | |
4331 (error "Couldn't set remote shell prompt. See buffer `%s' for details" | |
4332 (buffer-name)))) | |
4333 (tramp-message 7 "Waiting for remote `%s' to come up...done" | |
4334 (tramp-get-remote-sh multi-method method))) | |
4335 | |
4336 (defun tramp-post-connection (multi-method method user host) | |
4337 "Prepare a remote shell before being able to work on it. | |
4338 METHOD, USER and HOST specify the connection. | |
4339 Among other things, this finds a shell which groks tilde expansion, | |
4340 tries to find an `ls' command which groks the `-n' option, sets the | |
4341 locale to C and sets up the remote shell search path." | |
4342 ;; Search for a good shell before searching for a command which | |
4343 ;; checks if a file exists. This is done because Tramp wants to use | |
4344 ;; "test foo; echo $?" to check if various conditions hold, and | |
4345 ;; there are buggy /bin/sh implementations which don't execute the | |
4346 ;; "echo $?" part if the "test" part has an error. In particular, | |
4347 ;; the Solaris /bin/sh is a problem. I'm betting that all systems | |
4348 ;; with buggy /bin/sh implementations will have a working bash or | |
4349 ;; ksh. Whee... | |
4350 (tramp-find-shell multi-method method user host) | |
4351 (tramp-find-file-exists-command multi-method method user host) | |
4352 (sit-for 1) | |
4353 ;; Without (sit-for 0.1) at least, my machine will almost always blow | |
4354 ;; up on 'not numberp /root' - a race that causes the 'echo ~root' | |
4355 ;; output of (tramp-find-shell) to show up along with the output of | |
4356 ;; (tramp-find-ls-command) testing. | |
4357 ;; | |
4358 ;; I can't work out why this is a problem though. The (tramp-wait-for-output) | |
4359 ;; call in (tramp-find-shell) *should* make this not happen, I thought. | |
4360 ;; | |
4361 ;; After much debugging I couldn't find any problem with the implementation | |
4362 ;; of that function though. The workaround stays for me at least. :/ | |
4363 ;; | |
4364 ;; Daniel Pittman <daniel@danann.net> | |
4365 (make-local-variable 'tramp-ls-command) | |
4366 (setq tramp-ls-command (tramp-find-ls-command multi-method method user host)) | |
4367 (unless tramp-ls-command | |
4368 (tramp-message | |
4369 1 | |
4370 "Danger! Couldn't find ls which groks -n. Muddling through anyway") | |
4371 (setq tramp-ls-command | |
4372 (tramp-find-executable multi-method method user host | |
4373 "ls" tramp-remote-path nil))) | |
4374 (unless tramp-ls-command | |
4375 (error "Fatal error: Couldn't find remote executable `ls'")) | |
4376 (tramp-message 5 "Using remote command `%s' for getting directory listings" | |
4377 tramp-ls-command) | |
4378 (tramp-send-command multi-method method user host | |
4379 (concat "tramp_set_exit_status () {" tramp-rsh-end-of-line | |
4380 "return $1" tramp-rsh-end-of-line | |
4381 "}")) | |
4382 (tramp-wait-for-output) | |
4383 ;; Set remote PATH variable. | |
4384 (tramp-set-remote-path multi-method method user host "PATH" tramp-remote-path) | |
4385 ;; Tell remote shell to use standard time format, needed for | |
4386 ;; parsing `ls -l' output. | |
4387 (tramp-send-command multi-method method user host | |
4388 "LC_TIME=C; export LC_TIME; echo huhu") | |
4389 (tramp-wait-for-output) | |
4390 (tramp-send-command multi-method method user host | |
4391 "mesg n; echo huhu") | |
4392 (tramp-wait-for-output) | |
4393 (tramp-send-command multi-method method user host | |
4394 "biff n ; echo huhu") | |
4395 (tramp-wait-for-output) | |
4396 ;; Unalias ls(1) to work around issues with those silly people who make it | |
4397 ;; spit out ANSI escapes or whatever. | |
4398 (tramp-send-command multi-method method user host | |
4399 "unalias ls; echo huhu") | |
4400 (tramp-wait-for-output) | |
4401 ;; Does `test A -nt B' work? Use abominable `find' construct if it | |
4402 ;; doesn't. BSD/OS 4.0 wants the parentheses around the command, | |
4403 ;; for otherwise the shell crashes. | |
4404 (erase-buffer) | |
4405 (make-local-variable 'tramp-test-groks-nt) | |
4406 (tramp-send-command multi-method method user host | |
4407 "( test / -nt / )") | |
4408 (tramp-wait-for-output) | |
4409 (goto-char (point-min)) | |
4410 (setq tramp-test-groks-nt | |
4411 (looking-at (format "\n%s\n" (regexp-quote tramp-end-of-output)))) | |
4412 (unless tramp-test-groks-nt | |
4413 (tramp-send-command | |
4414 multi-method method user host | |
4415 (concat "tramp_test_nt () {" tramp-rsh-end-of-line | |
4416 "test -n \"`find $1 -prune -newer $2 -print`\"" tramp-rsh-end-of-line | |
4417 "}"))) | |
4418 (tramp-wait-for-output) | |
4419 ;; Find a `perl'. | |
4420 (erase-buffer) | |
4421 (let ((tramp-remote-perl | |
4422 (or (tramp-find-executable multi-method method user host | |
4423 "perl5" tramp-remote-path nil) | |
4424 (tramp-find-executable multi-method method user host | |
4425 "perl" tramp-remote-path nil)))) | |
4426 (when tramp-remote-perl | |
4427 (tramp-set-connection-property "perl" tramp-remote-perl multi-method method user host) | |
4428 ;; Set up stat in Perl if we can. | |
4429 (when tramp-remote-perl | |
4430 (tramp-message 5 "Sending the Perl `file-attributes' implementation.") | |
4431 (tramp-send-linewise | |
4432 multi-method method user host | |
4433 (concat "tramp_file_attributes () {\n" | |
4434 tramp-remote-perl | |
4435 " -e '" tramp-perl-file-attributes "' $1 2>/dev/null\n" | |
4436 "}")) | |
4437 (tramp-wait-for-output) | |
4438 (when (string= (tramp-get-encoding-command multi-method method) | |
4439 "tramp_mimencode") | |
4440 (tramp-message 5 "Sending the Perl `mime-encode' implementation.") | |
4441 (tramp-send-linewise | |
4442 multi-method method user host | |
4443 (concat "tramp_mimencode () {\n" | |
4444 (if (tramp-find-executable multi-method method user host | |
4445 "mimencode" tramp-remote-path t) | |
4446 "mimencode -b $1" | |
4447 (concat tramp-remote-perl | |
4448 " -e '" tramp-perl-mime-encode "' $1 2>/dev/null")) | |
4449 "\n}")) | |
4450 (tramp-wait-for-output)) | |
4451 (when (string= (tramp-get-decoding-command multi-method method) | |
4452 "tramp_mimedecode") | |
4453 (tramp-message 5 "Sending the Perl `mime-decode' implementation.") | |
4454 (tramp-send-linewise | |
4455 multi-method method user host | |
4456 (concat "tramp_mimedecode () {\n" | |
4457 (if (tramp-find-executable multi-method method user host | |
4458 "mimencode" tramp-remote-path t) | |
4459 "mimencode -u -b $1" | |
4460 (concat tramp-remote-perl | |
4461 " -e '" tramp-perl-mime-decode "' $1 2>/dev/null")) | |
4462 "\n}")) | |
4463 (tramp-wait-for-output))))) | |
4464 ;; Find ln(1) | |
4465 (erase-buffer) | |
4466 (let ((ln (tramp-find-executable multi-method method user host | |
4467 "ln" tramp-remote-path nil))) | |
4468 (when ln | |
4469 (tramp-set-connection-property "ln" ln multi-method method user host))) | |
4470 (erase-buffer) | |
4471 ;; If encoding/decoding command are given, test to see if they work. | |
4472 ;; CCC: Maybe it would be useful to run the encoder both locally and | |
4473 ;; remotely to see if they produce the same result. | |
4474 (let ((decoding (tramp-get-decoding-command multi-method method)) | |
4475 (encoding (tramp-get-encoding-command multi-method method)) | |
4476 (magic-string "xyzzy")) | |
4477 (when (and (or decoding encoding) (not (and decoding encoding))) | |
4478 (tramp-kill-process multi-method method user host) | |
4479 (error | |
4480 "Must give both decoding and encoding command in method definition")) | |
4481 (when (and decoding encoding) | |
4482 (tramp-message | |
4483 5 | |
4484 "Checking to see if encoding/decoding commands work on remote host...") | |
4485 (tramp-send-command | |
4486 multi-method method user host | |
4487 (format "echo %s | %s | %s" | |
4488 (tramp-shell-quote-argument magic-string) encoding decoding)) | |
4489 (tramp-wait-for-output) | |
4490 (unless (looking-at (regexp-quote magic-string)) | |
4491 (tramp-kill-process multi-method method user host) | |
4492 (error "Remote host cannot execute de/encoding commands. See buffer `%s' for details" | |
4493 (buffer-name))) | |
4494 (erase-buffer) | |
4495 (tramp-message | |
4496 5 "Checking to see if encoding/decoding commands work on remote host...done")))) | |
4497 | |
4498 | |
4499 (defun tramp-maybe-open-connection (multi-method method user host) | |
4500 "Maybe open a connection to HOST, logging in as USER, using METHOD. | |
4501 Does not do anything if a connection is already open, but re-opens the | |
4502 connection if a previous connection has died for some reason." | |
4503 (let ((p (get-buffer-process (tramp-get-buffer multi-method method user host)))) | |
4504 (unless (and p | |
4505 (processp p) | |
4506 (memq (process-status p) '(run open))) | |
4507 (when (and p (processp p)) | |
4508 (delete-process p)) | |
4509 (funcall (tramp-get-connection-function multi-method method) | |
4510 multi-method method user host)))) | |
4511 | |
4512 (defun tramp-send-command | |
4513 (multi-method method user host command &optional noerase) | |
4514 "Send the COMMAND to USER at HOST (logged in using METHOD). | |
4515 Erases temporary buffer before sending the command (unless NOERASE | |
4516 is true)." | |
4517 (tramp-maybe-open-connection multi-method method user host) | |
4518 (when tramp-debug-buffer | |
4519 (save-excursion | |
4520 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
4521 (goto-char (point-max)) | |
4522 (tramp-insert-with-face 'bold (format "$ %s\n" command)))) | |
4523 (let ((proc nil)) | |
4524 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4525 (unless noerase (erase-buffer)) | |
4526 (setq proc (get-buffer-process (current-buffer))) | |
4527 (process-send-string proc | |
4528 (concat command tramp-rsh-end-of-line)))) | |
4529 | |
4530 ;; It seems that Tru64 Unix does not like it if long strings are sent | |
4531 ;; to it in one go. (This happens when sending the Perl | |
4532 ;; `file-attributes' implementation, for instance.) Therefore, we | |
4533 ;; have this function which waits a bit at each line. | |
4534 (defun tramp-send-linewise | |
4535 (multi-method method user host string &optional noerase) | |
4536 "Send the STRING to USER at HOST linewise. | |
4537 Erases temporary buffer before sending the STRING (unless NOERASE | |
4538 is true). | |
4539 | |
4540 The STRING is expected to use Unix line-endings, but the lines sent to | |
4541 the remote host use line-endings as defined in the variable | |
4542 `tramp-rsh-end-of-line'." | |
4543 (tramp-maybe-open-connection multi-method method user host) | |
4544 (when tramp-debug-buffer | |
4545 (save-excursion | |
4546 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
4547 (goto-char (point-max)) | |
4548 (tramp-insert-with-face 'bold (format "$ %s\n" string)))) | |
4549 (let ((proc nil) | |
4550 (lines (split-string string "\n"))) | |
4551 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4552 (unless noerase (erase-buffer)) | |
4553 (setq proc (get-buffer-process (current-buffer))) | |
4554 (mapcar (lambda (x) | |
4555 (sleep-for 0.1) | |
4556 (process-send-string proc | |
4557 (concat x tramp-rsh-end-of-line))) | |
4558 lines))) | |
4559 | |
4560 (defun tramp-wait-for-output (&optional timeout) | |
4561 "Wait for output from remote rsh command." | |
4562 (let ((proc (get-buffer-process (current-buffer))) | |
4563 (found nil) | |
4564 (start-time (current-time)) | |
4565 (end-of-output (concat "^" | |
4566 (regexp-quote tramp-end-of-output) | |
4567 "$"))) | |
4568 ;; Algorithm: get waiting output. See if last line contains | |
4569 ;; end-of-output sentinel. If not, wait a bit and again get | |
4570 ;; waiting output. Repeat until timeout expires or end-of-output | |
4571 ;; sentinel is seen. Will hang if timeout is nil and | |
4572 ;; end-of-output sentinel never appears. | |
4573 (save-match-data | |
4574 (cond (timeout | |
4575 ;; Work around an XEmacs bug, where the timeout expires | |
4576 ;; faster than it should. This degenerates into polling | |
4577 ;; for buggy XEmacsen, but oh, well. | |
4578 (while (and (not found) | |
4579 (< (tramp-time-diff (current-time) start-time) | |
4580 timeout)) | |
4581 (with-timeout (timeout) | |
4582 (while (not found) | |
4583 (accept-process-output proc 1) | |
4584 (goto-char (point-max)) | |
4585 (forward-line -1) | |
4586 (setq found (looking-at end-of-output)))))) | |
4587 (t | |
4588 (while (not found) | |
4589 (accept-process-output proc 1) | |
4590 (goto-char (point-max)) | |
4591 (forward-line -1) | |
4592 (setq found (looking-at end-of-output)))))) | |
4593 ;; At this point, either the timeout has expired or we have found | |
4594 ;; the end-of-output sentinel. | |
4595 (when found | |
4596 (goto-char (point-max)) | |
4597 (forward-line -2) | |
4598 (delete-region (point) (point-max))) | |
4599 ;; Add output to debug buffer if appropriate. | |
4600 (when tramp-debug-buffer | |
4601 (append-to-buffer | |
4602 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4603 tramp-current-user tramp-current-host) | |
4604 (point-min) (point-max)) | |
4605 (when (not found) | |
4606 (save-excursion | |
4607 (set-buffer | |
4608 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4609 tramp-current-user tramp-current-host)) | |
4610 (goto-char (point-max)) | |
4611 (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
|
4612 (if timeout (format " in %d secs" timeout) "") |
45861 | 4613 "]]")))) |
4614 (goto-char (point-min)) | |
4615 ;; Return value is whether end-of-output sentinel was found. | |
4616 found)) | |
4617 | |
4618 (defun tramp-match-string-list (&optional string) | |
4619 "Returns list of all match strings. | |
4620 That is, (list (match-string 0) (match-string 1) ...), according to the | |
4621 number of matches." | |
4622 (let* ((nmatches (/ (length (match-data)) 2)) | |
4623 (i (- nmatches 1)) | |
4624 (res nil)) | |
4625 (while (>= i 0) | |
4626 (setq res (cons (match-string i string) res)) | |
4627 (setq i (- i 1))) | |
4628 res)) | |
4629 | |
4630 (defun tramp-send-command-and-check (multi-method method user host command | |
4631 &optional subshell) | |
4632 "Run COMMAND and check its exit status. | |
4633 MULTI-METHOD and METHOD specify how to log in (as USER) to the remote HOST. | |
4634 Sends `echo $?' along with the COMMAND for checking the exit status. If | |
4635 COMMAND is nil, just sends `echo $?'. Returns the exit status found. | |
4636 | |
4637 If the optional argument SUBSHELL is non-nil, the command is executed in | |
4638 a subshell, ie surrounded by parentheses." | |
4639 (tramp-send-command multi-method method user host | |
4640 (concat (if subshell "( " "") | |
4641 command | |
4642 (if command " 2>/dev/null; " "") | |
4643 "echo tramp_exit_status $?" | |
4644 (if subshell " )" " "))) | |
4645 (tramp-wait-for-output) | |
4646 (goto-char (point-max)) | |
4647 (unless (search-backward "tramp_exit_status " nil t) | |
4648 (error "Couldn't find exit status of `%s'" command)) | |
4649 (skip-chars-forward "^ ") | |
4650 (read (current-buffer))) | |
4651 | |
4652 (defun tramp-barf-unless-okay (multi-method method user host command subshell | |
4653 signal fmt &rest args) | |
4654 "Run COMMAND, check exit status, throw error if exit status not okay. | |
4655 Similar to `tramp-send-command-and-check' but accepts two more arguments | |
4656 FMT and ARGS which are passed to `error'." | |
4657 (unless (zerop (tramp-send-command-and-check | |
4658 multi-method method user host command subshell)) | |
4659 ;; CCC: really pop-to-buffer? Maybe it's appropriate to be more | |
4660 ;; silent. | |
4661 (pop-to-buffer (current-buffer)) | |
4662 (funcall 'signal signal (apply 'format fmt args)))) | |
4663 | |
4664 (defun tramp-send-region (multi-method method user host start end) | |
4665 "Send the region from START to END to remote command | |
4666 running as USER on HOST using METHOD." | |
4667 (let ((proc (get-buffer-process | |
4668 (tramp-get-buffer multi-method method user host)))) | |
4669 (unless proc | |
4670 (error "Can't send region to remote host -- not logged in")) | |
4671 (process-send-region proc start end) | |
4672 (when tramp-debug-buffer | |
4673 (append-to-buffer | |
4674 (tramp-get-debug-buffer multi-method method user host) | |
4675 start end)))) | |
4676 | |
4677 (defun tramp-send-eof (multi-method method user host) | |
4678 "Send EOF to the remote end. | |
46151
eff75835ac2e
(tramp-send-eof): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
46060
diff
changeset
|
4679 METHOD, HOST and USER specify the connection." |
45861 | 4680 (let ((proc (get-buffer-process |
4681 (tramp-get-buffer multi-method method user host)))) | |
4682 (unless proc | |
4683 (error "Can't send EOF to remote host -- not logged in")) | |
4684 (process-send-eof proc))) | |
4685 ; (process-send-string proc "\^D"))) | |
4686 | |
4687 (defun tramp-kill-process (multi-method method user host) | |
4688 "Kill the connection process used by Tramp. | |
46151
eff75835ac2e
(tramp-send-eof): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
46060
diff
changeset
|
4689 MULTI-METHOD, METHOD, USER, and HOST specify the connection." |
45861 | 4690 (let ((proc (get-buffer-process |
4691 (tramp-get-buffer multi-method method user host)))) | |
4692 (kill-process proc))) | |
4693 | |
4694 (defun tramp-discard-garbage-erase-buffer (p multi-method method user host) | |
4695 "Erase buffer, then discard subsequent garbage. | |
4696 If `tramp-discard-garbage' is nil, just erase buffer." | |
4697 (if (not tramp-discard-garbage) | |
4698 (erase-buffer) | |
4699 (while (prog1 (erase-buffer) (accept-process-output p 0.25)) | |
4700 (when tramp-debug-buffer | |
4701 (save-excursion | |
4702 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
4703 (goto-char (point-max)) | |
4704 (tramp-insert-with-face | |
4705 'bold (format "Additional characters detected\n"))))))) | |
4706 | |
4707 (defun tramp-mode-string-to-int (mode-string) | |
4708 "Converts a ten-letter `drwxrwxrwx'-style mode string into mode bits." | |
4709 (let* ((mode-chars (string-to-vector mode-string)) | |
4710 (owner-read (aref mode-chars 1)) | |
4711 (owner-write (aref mode-chars 2)) | |
4712 (owner-execute-or-setid (aref mode-chars 3)) | |
4713 (group-read (aref mode-chars 4)) | |
4714 (group-write (aref mode-chars 5)) | |
4715 (group-execute-or-setid (aref mode-chars 6)) | |
4716 (other-read (aref mode-chars 7)) | |
4717 (other-write (aref mode-chars 8)) | |
4718 (other-execute-or-sticky (aref mode-chars 9))) | |
4719 (save-match-data | |
4720 (logior | |
4721 (case owner-read | |
4722 (?r (tramp-octal-to-decimal "00400")) (?- 0) | |
4723 (t (error "Second char `%c' must be one of `r-'" owner-read))) | |
4724 (case owner-write | |
4725 (?w (tramp-octal-to-decimal "00200")) (?- 0) | |
4726 (t (error "Third char `%c' must be one of `w-'" owner-write))) | |
4727 (case owner-execute-or-setid | |
4728 (?x (tramp-octal-to-decimal "00100")) | |
4729 (?S (tramp-octal-to-decimal "04000")) | |
4730 (?s (tramp-octal-to-decimal "04100")) | |
4731 (?- 0) | |
4732 (t (error "Fourth char `%c' must be one of `xsS-'" | |
4733 owner-execute-or-setid))) | |
4734 (case group-read | |
4735 (?r (tramp-octal-to-decimal "00040")) (?- 0) | |
4736 (t (error "Fifth char `%c' must be one of `r-'" group-read))) | |
4737 (case group-write | |
4738 (?w (tramp-octal-to-decimal "00020")) (?- 0) | |
4739 (t (error "Sixth char `%c' must be one of `w-'" group-write))) | |
4740 (case group-execute-or-setid | |
4741 (?x (tramp-octal-to-decimal "00010")) | |
4742 (?S (tramp-octal-to-decimal "02000")) | |
4743 (?s (tramp-octal-to-decimal "02010")) | |
4744 (?- 0) | |
4745 (t (error "Seventh char `%c' must be one of `xsS-'" | |
4746 group-execute-or-setid))) | |
4747 (case other-read | |
4748 (?r (tramp-octal-to-decimal "00004")) (?- 0) | |
4749 (t (error "Eighth char `%c' must be one of `r-'" other-read))) | |
4750 (case other-write | |
4751 (?w (tramp-octal-to-decimal "00002")) (?- 0) | |
4752 (t (error "Nineth char `%c' must be one of `w-'" other-write))) | |
4753 (case other-execute-or-sticky | |
4754 (?x (tramp-octal-to-decimal "00001")) | |
4755 (?T (tramp-octal-to-decimal "01000")) | |
4756 (?t (tramp-octal-to-decimal "01001")) | |
4757 (?- 0) | |
4758 (t (error "Tenth char `%c' must be one of `xtT-'" | |
4759 other-execute-or-sticky))))))) | |
4760 | |
4761 | |
4762 (defun tramp-file-mode-from-int (mode) | |
4763 "Turn an integer representing a file mode into an ls(1)-like string." | |
4764 (let ((type (cdr (assoc (logand (lsh mode -12) 15) tramp-file-mode-type-map))) | |
4765 (user (logand (lsh mode -6) 7)) | |
4766 (group (logand (lsh mode -3) 7)) | |
4767 (other (logand (lsh mode -0) 7)) | |
4768 (suid (> (logand (lsh mode -9) 4) 0)) | |
4769 (sgid (> (logand (lsh mode -9) 2) 0)) | |
4770 (sticky (> (logand (lsh mode -9) 1) 0))) | |
4771 (setq user (tramp-file-mode-permissions user suid "s")) | |
4772 (setq group (tramp-file-mode-permissions group sgid "s")) | |
4773 (setq other (tramp-file-mode-permissions other sticky "t")) | |
4774 (concat type user group other))) | |
4775 | |
4776 | |
4777 (defun tramp-file-mode-permissions (perm suid suid-text) | |
4778 "Convert a permission bitset into a string. | |
4779 This is used internally by `tramp-file-mode-from-int'." | |
4780 (let ((r (> (logand perm 4) 0)) | |
4781 (w (> (logand perm 2) 0)) | |
4782 (x (> (logand perm 1) 0))) | |
4783 (concat (or (and r "r") "-") | |
4784 (or (and w "w") "-") | |
4785 (or (and suid x suid-text) ; suid, execute | |
4786 (and suid (upcase suid-text)) ; suid, !execute | |
4787 (and x "x") "-")))) ; !suid | |
4788 | |
4789 | |
4790 (defun tramp-decimal-to-octal (i) | |
4791 "Return a string consisting of the octal digits of I. | |
4792 Not actually used. Use `(format \"%o\" i)' instead?" | |
4793 (cond ((< i 0) (error "Cannot convert negative number to octal")) | |
4794 ((not (integerp i)) (error "Cannot convert non-integer to octal")) | |
4795 ((zerop i) "0") | |
4796 (t (concat (tramp-decimal-to-octal (/ i 8)) | |
4797 (number-to-string (% i 8)))))) | |
4798 | |
4799 | |
4800 ;;(defun tramp-octal-to-decimal (ostr) | |
4801 ;; "Given a string of octal digits, return a decimal number." | |
4802 ;; (cond ((null ostr) 0) | |
4803 ;; ((string= "" ostr) 0) | |
4804 ;; (t (let ((last (aref ostr (1- (length ostr)))) | |
4805 ;; (rest (substring ostr 0 (1- (length ostr))))) | |
4806 ;; (unless (and (>= last ?0) | |
4807 ;; (<= last ?7)) | |
4808 ;; (error "Not an octal digit: %c" last)) | |
4809 ;; (+ (- last ?0) (* 8 (tramp-octal-to-decimal rest))))))) | |
4810 ;; Kudos to Gerd Moellmann for this suggestion. | |
4811 (defun tramp-octal-to-decimal (ostr) | |
4812 "Given a string of octal digits, return a decimal number." | |
4813 (let ((x (or ostr ""))) | |
4814 ;; `save-match' is in `tramp-mode-string-to-int' which calls this. | |
4815 (unless (string-match "\\`[0-7]*\\'" x) | |
4816 (error "Non-octal junk in string `%s'" x)) | |
4817 (string-to-number ostr 8))) | |
4818 | |
4819 (defun tramp-shell-case-fold (string) | |
4820 "Converts STRING to shell glob pattern which ignores case." | |
4821 (mapconcat | |
4822 (lambda (c) | |
4823 (if (equal (downcase c) (upcase c)) | |
4824 (vector c) | |
4825 (format "[%c%c]" (downcase c) (upcase c)))) | |
4826 string | |
4827 "")) | |
4828 | |
4829 | |
4830 ;; ------------------------------------------------------------ | |
4831 ;; -- TRAMP file names -- | |
4832 ;; ------------------------------------------------------------ | |
4833 ;; Conversion functions between external representation and | |
4834 ;; internal data structure. Convenience functions for internal | |
4835 ;; data structure. | |
4836 | |
4837 (defstruct tramp-file-name multi-method method user host path) | |
4838 | |
4839 (defun tramp-tramp-file-p (name) | |
4840 "Return t iff NAME is a tramp file." | |
4841 (save-match-data | |
4842 (string-match tramp-file-name-regexp name))) | |
4843 | |
4844 ;; HHH: Changed. Used to assign the return value of (user-login-name) | |
4845 ;; to the `user' part of the structure if a user name was not | |
4846 ;; provided, now it assigns nil. | |
4847 (defun tramp-dissect-file-name (name) | |
4848 "Return an `tramp-file-name' structure. | |
4849 The structure consists of remote method, remote user, remote host and | |
4850 remote path name." | |
4851 (let (method) | |
4852 (save-match-data | |
4853 (unless (string-match (nth 0 tramp-file-name-structure) name) | |
4854 (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
|
4855 (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
|
4856 (if (and method (member method tramp-multi-methods)) |
45861 | 4857 ;; If it's a multi method, the file name structure contains |
4858 ;; arrays of method, user and host. | |
4859 (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
|
4860 ;; 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
|
4861 (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
|
4862 (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
|
4863 (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
|
4864 (when (not method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4865 (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
|
4866 (make-tramp-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4867 :multi-method nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4868 :method method |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4869 :user (or user nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4870 :host host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4871 :path path)))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4872 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4873 (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
|
4874 "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
|
4875 (let ((choices tramp-default-method-alist) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4876 (method tramp-default-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4877 item) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4878 (while choices |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4879 (setq item (pop choices)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4880 (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
|
4881 (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
|
4882 (setq method (nth 2 item)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4883 (setq choices nil))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4884 method)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4885 |
45861 | 4886 ;; HHH: Not Changed. Multi method. Will probably not handle the case where |
4887 ;; a user name is not provided in the "file name" very well. | |
4888 (defun tramp-dissect-multi-file-name (name) | |
4889 "Not implemented yet." | |
4890 (let ((regexp (nth 0 tramp-multi-file-name-structure)) | |
4891 (method-index (nth 1 tramp-multi-file-name-structure)) | |
4892 (hops-index (nth 2 tramp-multi-file-name-structure)) | |
4893 (path-index (nth 3 tramp-multi-file-name-structure)) | |
4894 (hop-regexp (nth 0 tramp-multi-file-name-hop-structure)) | |
4895 (hop-method-index (nth 1 tramp-multi-file-name-hop-structure)) | |
4896 (hop-user-index (nth 2 tramp-multi-file-name-hop-structure)) | |
4897 (hop-host-index (nth 3 tramp-multi-file-name-hop-structure)) | |
4898 method hops len hop-methods hop-users hop-hosts path) | |
4899 (unless (string-match (format regexp hop-regexp) name) | |
4900 (error "Not a multi tramp file name: %s" name)) | |
4901 (setq method (match-string method-index name)) | |
4902 (setq hops (match-string hops-index name)) | |
4903 (setq len (/ (length (match-data t)) 2)) | |
4904 (when (< path-index 0) (incf path-index len)) | |
4905 (setq path (match-string path-index name)) | |
4906 (let ((index 0)) | |
4907 (while (string-match hop-regexp hops index) | |
4908 (setq index (match-end 0)) | |
4909 (setq hop-methods | |
4910 (cons (match-string hop-method-index hops) hop-methods)) | |
4911 (setq hop-users | |
4912 (cons (match-string hop-user-index hops) hop-users)) | |
4913 (setq hop-hosts | |
4914 (cons (match-string hop-host-index hops) hop-hosts)))) | |
4915 (make-tramp-file-name | |
4916 :multi-method method | |
4917 :method (apply 'vector (reverse hop-methods)) | |
4918 :user (apply 'vector (reverse hop-users)) | |
4919 :host (apply 'vector (reverse hop-hosts)) | |
4920 :path path))) | |
4921 | |
4922 (defun tramp-make-tramp-file-name (multi-method method user host path) | |
4923 "Constructs a tramp file name from METHOD, USER, HOST and PATH." | |
4924 (unless tramp-make-tramp-file-format | |
4925 (error "`tramp-make-tramp-file-format' is nil")) | |
4926 (if multi-method | |
4927 (tramp-make-tramp-multi-file-name multi-method method user host path) | |
4928 (if user | |
4929 (format-spec tramp-make-tramp-file-format | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
4930 `((?m ,method) (?u ,user) (?h ,host) (?p ,path))) |
45861 | 4931 (format-spec tramp-make-tramp-file-user-nil-format |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
4932 `((?m ,method) (?h ,host) (?p ,path)))))) |
45861 | 4933 |
4934 ;; CCC: Henrik Holm: Not Changed. Multi Method. What should be done | |
4935 ;; with this when USER is nil? | |
4936 (defun tramp-make-tramp-multi-file-name (multi-method method user host path) | |
4937 "Constructs a tramp file name for a multi-hop method." | |
4938 (unless tramp-make-multi-tramp-file-format | |
4939 (error "`tramp-make-multi-tramp-file-format' is nil")) | |
4940 (let* ((prefix-format (nth 0 tramp-make-multi-tramp-file-format)) | |
4941 (hop-format (nth 1 tramp-make-multi-tramp-file-format)) | |
4942 (path-format (nth 2 tramp-make-multi-tramp-file-format)) | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
4943 (prefix (format-spec prefix-format `((?m ,multi-method)))) |
45861 | 4944 (hops "") |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
4945 (path (format-spec path-format `((?p ,path)))) |
45861 | 4946 (i 0) |
4947 (len (length method))) | |
4948 (while (< i len) | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
4949 (let ((m (aref method i)) (u (aref user i)) (h (aref host i))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
4950 (setq hops (concat hops (format-spec hop-format |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
4951 `((?m ,m) (?u ,u) (?h ,h))))) |
45861 | 4952 (incf i))) |
4953 (concat prefix hops path))) | |
4954 | |
4955 (defun tramp-make-rcp-program-file-name (user host path) | |
4956 "Create a file name suitable to be passed to `rcp'." | |
4957 (if user | |
4958 (format "%s@%s:%s" user host path) | |
4959 (format "%s:%s" host path))) | |
4960 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4961 (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
|
4962 "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
|
4963 (if user |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4964 (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
|
4965 (format "/%s:%s" host path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4966 |
45861 | 4967 (defun tramp-method-out-of-band-p (multi-method method) |
4968 "Return t if this is an out-of-band method, nil otherwise. | |
4969 It is important to check for this condition, since it is not possible | |
4970 to enter a password for the `tramp-rcp-program'." | |
4971 (tramp-get-rcp-program multi-method method)) | |
4972 | |
4973 ;; Variables local to connection. | |
4974 | |
4975 (defun tramp-get-ls-command (multi-method method user host) | |
4976 (save-excursion | |
4977 (tramp-maybe-open-connection multi-method method user host) | |
4978 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4979 tramp-ls-command)) | |
4980 | |
4981 (defun tramp-get-test-groks-nt (multi-method method user host) | |
4982 (save-excursion | |
4983 (tramp-maybe-open-connection multi-method method user host) | |
4984 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4985 tramp-test-groks-nt)) | |
4986 | |
4987 (defun tramp-get-file-exists-command (multi-method method user host) | |
4988 (save-excursion | |
4989 (tramp-maybe-open-connection multi-method method user host) | |
4990 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4991 tramp-file-exists-command)) | |
4992 | |
4993 (defun tramp-get-remote-perl (multi-method method user host) | |
4994 (tramp-get-connection-property "perl" nil multi-method method user host)) | |
4995 | |
4996 (defun tramp-get-remote-ln (multi-method method user host) | |
4997 (tramp-get-connection-property "ln" nil multi-method method user host)) | |
4998 | |
4999 ;; Get a property of a TRAMP connection. | |
5000 (defun tramp-get-connection-property (property default multi-method method user host) | |
5001 "Get the named property for the connection. | |
5002 If the value is not set for the connection, return `default'" | |
5003 (tramp-maybe-open-connection multi-method method user host) | |
5004 (with-current-buffer (tramp-get-buffer multi-method method user host) | |
5005 (let (error) | |
5006 (condition-case nil | |
5007 (symbol-value (intern (concat "tramp-connection-property-" property))) | |
5008 (error default))))) | |
5009 | |
5010 ;; Set a property of a TRAMP connection. | |
5011 (defun tramp-set-connection-property (property value multi-method method user host) | |
5012 "Set the named property of a TRAMP connection." | |
5013 (tramp-maybe-open-connection multi-method method user host) | |
5014 (with-current-buffer (tramp-get-buffer multi-method method user host) | |
5015 (set (make-local-variable | |
5016 (intern (concat "tramp-connection-property-" property))) | |
5017 value))) | |
5018 | |
5019 | |
5020 | |
5021 (defun tramp-get-connection-function (multi-method method) | |
5022 (second (or (assoc 'tramp-connection-function | |
5023 (assoc (or multi-method method tramp-default-method) | |
5024 tramp-methods)) | |
5025 (error "Method `%s' didn't specify a connection function" | |
5026 (or multi-method method))))) | |
5027 | |
5028 (defun tramp-get-remote-sh (multi-method method) | |
5029 (second (or (assoc 'tramp-remote-sh | |
5030 (assoc (or multi-method method tramp-default-method) | |
5031 tramp-methods)) | |
5032 (error "Method `%s' didn't specify a remote shell" | |
5033 (or multi-method method))))) | |
5034 | |
5035 (defun tramp-get-rsh-program (multi-method method) | |
5036 (second (or (assoc 'tramp-rsh-program | |
5037 (assoc (or multi-method method tramp-default-method) | |
5038 tramp-methods)) | |
5039 (error "Method `%s' didn't specify an rsh program" | |
5040 (or multi-method method))))) | |
5041 | |
5042 (defun tramp-get-rsh-args (multi-method method) | |
5043 (second (or (assoc 'tramp-rsh-args | |
5044 (assoc (or multi-method method tramp-default-method) | |
5045 tramp-methods)) | |
5046 (error "Method `%s' didn't specify rsh args" | |
5047 (or multi-method method))))) | |
5048 | |
5049 (defun tramp-get-rcp-program (multi-method method) | |
5050 (second (or (assoc 'tramp-rcp-program | |
5051 (assoc (or multi-method method tramp-default-method) | |
5052 tramp-methods)) | |
5053 (error "Method `%s' didn't specify an rcp program" | |
5054 (or multi-method method))))) | |
5055 | |
5056 (defun tramp-get-rcp-args (multi-method method) | |
5057 (second (or (assoc 'tramp-rcp-args | |
5058 (assoc (or multi-method method tramp-default-method) | |
5059 tramp-methods)) | |
5060 (error "Method `%s' didn't specify rcp args" | |
5061 (or multi-method method))))) | |
5062 | |
5063 (defun tramp-get-rcp-keep-date-arg (multi-method method) | |
5064 (second (or (assoc 'tramp-rcp-keep-date-arg | |
5065 (assoc (or multi-method method tramp-default-method) | |
5066 tramp-methods)) | |
5067 (error "Method `%s' didn't specify `keep-date' arg for tramp" | |
5068 (or multi-method method))))) | |
5069 | |
5070 (defun tramp-get-su-program (multi-method method) | |
5071 (second (or (assoc 'tramp-su-program | |
5072 (assoc (or multi-method method tramp-default-method) | |
5073 tramp-methods)) | |
5074 (error "Method `%s' didn't specify a su program" | |
5075 (or multi-method method))))) | |
5076 | |
5077 (defun tramp-get-su-args (multi-method method) | |
5078 (second (or (assoc 'tramp-su-args | |
5079 (assoc (or multi-method method tramp-default-method) | |
5080 tramp-methods)) | |
5081 (error "Method `%s' didn't specify su args" | |
5082 (or multi-method method))))) | |
5083 | |
5084 (defun tramp-get-encoding-command (multi-method method) | |
5085 (second (or (assoc 'tramp-encoding-command | |
5086 (assoc (or multi-method method tramp-default-method) | |
5087 tramp-methods)) | |
5088 (error "Method `%s' didn't specify an encoding command" | |
5089 (or multi-method method))))) | |
5090 | |
5091 (defun tramp-get-decoding-command (multi-method method) | |
5092 (second (or (assoc 'tramp-decoding-command | |
5093 (assoc (or multi-method method tramp-default-method) | |
5094 tramp-methods)) | |
5095 (error "Method `%s' didn't specify a decoding command" | |
5096 (or multi-method method))))) | |
5097 | |
5098 (defun tramp-get-encoding-function (multi-method method) | |
5099 (second (or (assoc 'tramp-encoding-function | |
5100 (assoc (or multi-method method tramp-default-method) | |
5101 tramp-methods)) | |
5102 (error "Method `%s' didn't specify an encoding function" | |
5103 (or multi-method method))))) | |
5104 | |
5105 (defun tramp-get-decoding-function (multi-method method) | |
5106 (second (or (assoc 'tramp-decoding-function | |
5107 (assoc (or multi-method method tramp-default-method) | |
5108 tramp-methods)) | |
5109 (error "Method `%s' didn't specify a decoding function" | |
5110 (or multi-method method))))) | |
5111 | |
5112 (defun tramp-get-telnet-program (multi-method method) | |
5113 (second (or (assoc 'tramp-telnet-program | |
5114 (assoc (or multi-method method tramp-default-method) | |
5115 tramp-methods)) | |
5116 (error "Method `%s' didn't specify a telnet program" | |
5117 (or multi-method method))))) | |
5118 | |
5119 (defun tramp-get-telnet-args (multi-method method) | |
5120 (second (or (assoc 'tramp-telnet-args | |
5121 (assoc (or multi-method method tramp-default-method) | |
5122 tramp-methods)) | |
5123 (error "Method `%s' didn't specify telnet args" | |
5124 (or multi-method method))))) | |
5125 | |
5126 ;; Auto saving to a special directory. | |
5127 | |
5128 (defun tramp-make-auto-save-file-name (fn) | |
5129 "Returns a file name in `tramp-auto-save-directory' for autosaving this file." | |
5130 (when tramp-auto-save-directory | |
5131 (unless (file-exists-p tramp-auto-save-directory) | |
5132 (make-directory tramp-auto-save-directory t))) | |
5133 ;; jka-compr doesn't like auto-saving, so by appending "~" to the | |
5134 ;; file name we make sure that jka-compr isn't used for the | |
5135 ;; auto-save file. | |
5136 (let ((buffer-file-name (expand-file-name | |
5137 (tramp-subst-strs-in-string '(("_" . "|") | |
5138 ("/" . "_a") | |
5139 (":" . "_b") | |
5140 ("|" . "__") | |
5141 ("[" . "_l") | |
5142 ("]" . "_r")) | |
5143 fn) | |
5144 tramp-auto-save-directory))) | |
5145 (make-auto-save-file-name))) | |
5146 | |
5147 (defadvice make-auto-save-file-name | |
5148 (around tramp-advice-make-auto-save-file-name () activate) | |
5149 "Invoke `tramp-make-auto-save-file-name' for tramp files." | |
5150 (if (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)) | |
5151 tramp-auto-save-directory) | |
5152 (setq ad-return-value | |
5153 (tramp-make-auto-save-file-name (buffer-file-name))) | |
5154 ad-do-it)) | |
5155 | |
5156 (defun tramp-subst-strs-in-string (alist string) | |
5157 "Replace all occurrences of the string FROM with TO in STRING. | |
5158 ALIST is of the form ((FROM . TO) ...)." | |
5159 (save-match-data | |
5160 (while alist | |
5161 (let* ((pr (car alist)) | |
5162 (from (car pr)) | |
5163 (to (cdr pr))) | |
5164 (while (string-match (regexp-quote from) string) | |
5165 (setq string (replace-match to t t string))) | |
5166 (setq alist (cdr alist)))) | |
5167 string)) | |
5168 | |
5169 (defun tramp-insert-with-face (face string) | |
5170 "Insert text with a specific face." | |
5171 (let ((start (point))) | |
5172 (insert string) | |
5173 (add-text-properties start (point) (list 'face face)))) | |
5174 | |
5175 ;; ------------------------------------------------------------ | |
5176 ;; -- Compatibility functions section -- | |
5177 ;; ------------------------------------------------------------ | |
5178 | |
5179 (defun tramp-temporary-file-directory () | |
5180 "Return name of directory for temporary files (compat function). | |
5181 For Emacs, this is the variable `temporary-file-directory', for XEmacs | |
5182 this is the function `temp-directory'." | |
5183 (cond ((boundp 'temporary-file-directory) | |
5184 (symbol-value 'temporary-file-directory)) | |
5185 ((fboundp 'temp-directory) | |
5186 (funcall (symbol-function 'temp-directory))) ;pacify byte-compiler | |
5187 ((let ((d (getenv "TEMP"))) (and d (file-directory-p d))) | |
5188 (file-name-as-directory (getenv "TEMP"))) | |
5189 ((let ((d (getenv "TMP"))) (and d (file-directory-p d))) | |
5190 (file-name-as-directory (getenv "TMP"))) | |
5191 ((let ((d (getenv "TMPDIR"))) (and d (file-directory-p d))) | |
5192 (file-name-as-directory (getenv "TMPDIR"))) | |
5193 ((file-exists-p "c:/temp") (file-name-as-directory "c:/temp")) | |
5194 (t (message (concat "Neither `temporary-file-directory' nor " | |
5195 "`temp-directory' is defined -- using /tmp.")) | |
5196 (file-name-as-directory "/tmp")))) | |
5197 | |
5198 (defun tramp-read-passwd (prompt) | |
5199 "Read a password from user (compat function). | |
5200 Invokes `read-passwd' if that is defined, else `ange-ftp-read-passwd'." | |
5201 (apply | |
5202 (if (fboundp 'read-passwd) #'read-passwd #'ange-ftp-read-passwd) | |
5203 (list prompt))) | |
5204 | |
5205 (defun tramp-time-diff (t1 t2) | |
5206 "Return the difference between the two times, in seconds. | |
5207 T1 and T2 are time values (as returned by `current-time' for example). | |
5208 | |
5209 NOTE: This function will fail if the time difference is too large to | |
5210 fit in an integer." | |
5211 ;; Pacify byte-compiler with `symbol-function'. | |
5212 (cond ((fboundp 'subtract-time) | |
5213 (cadr (funcall (symbol-function 'subtract-time) t1 t2))) | |
5214 ((fboundp 'itimer-time-difference) | |
5215 (floor (funcall | |
5216 (symbol-function 'itimer-time-difference) | |
5217 (if (< (length t1) 3) (append t1 '(0)) t1) | |
5218 (if (< (length t2) 3) (append t2 '(0)) t2)))) | |
5219 (t | |
5220 ;; snarfed from Emacs 21 time-date.el | |
5221 (cadr (let ((borrow (< (cadr t1) (cadr t2)))) | |
5222 (list (- (car t1) (car t2) (if borrow 1 0)) | |
5223 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))))) | |
5224 | |
5225 (defun tramp-coding-system-change-eol-conversion (coding-system eol-type) | |
5226 "Return a coding system like CODING-SYSTEM but with given EOL-TYPE. | |
5227 EOL-TYPE can be one of `dos', `unix', or `mac'." | |
5228 (cond ((fboundp 'coding-system-change-eol-conversion) | |
5229 (apply #'coding-system-change-eol-conversion | |
5230 (list coding-system eol-type))) | |
5231 ((fboundp 'subsidiary-coding-system) | |
5232 (apply | |
5233 #'subsidiary-coding-system | |
5234 (list coding-system | |
5235 (cond ((eq eol-type 'dos) 'crlf) | |
5236 ((eq eol-type 'unix) 'lf) | |
5237 ((eq eol-type 'mac) 'cr) | |
5238 (t | |
5239 (error "Unknown EOL-TYPE `%s', must be %s" | |
5240 eol-type | |
5241 "`dos', `unix', or `mac'")))))) | |
5242 (t (error "Can't change EOL conversion -- is MULE missing?")))) | |
5243 | |
5244 (defun tramp-split-string (string pattern) | |
5245 "Like `split-string' but omit empty strings. | |
5246 In Emacs, (split-string \"/foo/bar\" \"/\") returns (\"foo\" \"bar\"). | |
5247 This is, the first, empty, element is omitted. In XEmacs, the first | |
5248 element is not omitted. | |
5249 | |
5250 Note: this function has been written for `tramp-handle-file-truename'. | |
5251 If you want to use it for something else, you'll have to check whether | |
5252 it does the right thing." | |
5253 (delete "" (split-string string pattern))) | |
5254 | |
5255 ;; ------------------------------------------------------------ | |
5256 ;; -- Kludges section -- | |
5257 ;; ------------------------------------------------------------ | |
5258 | |
5259 ;; Currently (as of Emacs 20.5), the function `shell-quote-argument' | |
5260 ;; does not deal well with newline characters. Newline is replaced by | |
5261 ;; backslash newline. But if, say, the string `a backslash newline b' | |
5262 ;; is passed to a shell, the shell will expand this into "ab", | |
5263 ;; completely omitting the newline. This is not what was intended. | |
5264 ;; It does not appear to be possible to make the function | |
5265 ;; `shell-quote-argument' work with newlines without making it | |
5266 ;; dependent on the shell used. But within this package, we know that | |
5267 ;; we will always use a Bourne-like shell, so we use an approach which | |
5268 ;; groks newlines. | |
5269 ;; | |
5270 ;; The approach is simple: we call `shell-quote-argument', then | |
5271 ;; massage the newline part of the result. | |
5272 ;; | |
5273 ;; This function should produce a string which is grokked by a Unix | |
5274 ;; shell, even if the Emacs is running on Windows. Since this is the | |
5275 ;; kludges section, we bind `system-type' in such a way that | |
5276 ;; `shell-quote-arguments' behaves as if on Unix. | |
5277 ;; | |
5278 ;; Thanks to Mario DeWeerd for the hint that it is sufficient for this | |
5279 ;; function to work with Bourne-like shells. | |
5280 ;; | |
5281 ;; CCC: This function should be rewritten so that | |
5282 ;; `shell-quote-argument' is not used. This way, we are safe from | |
5283 ;; changes in `shell-quote-argument'. | |
5284 (defun tramp-shell-quote-argument (s) | |
5285 "Similar to `shell-quote-argument', but groks newlines. | |
5286 Only works for Bourne-like shells." | |
5287 (let ((system-type 'not-windows)) | |
5288 (save-match-data | |
5289 (let ((result (shell-quote-argument s)) | |
5290 (nl (regexp-quote (format "\\%s" tramp-rsh-end-of-line)))) | |
5291 (when (and (>= (length result) 2) | |
5292 (string= (substring result 0 2) "\\~")) | |
5293 (setq result (substring result 1))) | |
5294 (while (string-match nl result) | |
5295 (setq result (replace-match (format "'%s'" tramp-rsh-end-of-line) | |
5296 t t result))) | |
5297 result)))) | |
5298 | |
5299 ;; ;; EFS hooks itself into the file name handling stuff in more places | |
5300 ;; ;; than just `file-name-handler-alist'. The following tells EFS to stay | |
5301 ;; ;; away from tramp.el paths. | |
5302 ;; ;; | |
5303 ;; ;; This is needed because EFS installs (efs-dired-before-readin) into | |
5304 ;; ;; 'dired-before-readin-hook'. This prevents EFS from opening an FTP | |
5305 ;; ;; connection to help it's dired process. Not that I have any real | |
5306 ;; ;; idea *why* this is helpful to dired. | |
5307 ;; ;; | |
5308 ;; ;; Anyway, this advice fixes the problem (with a sledgehammer :) | |
5309 ;; ;; | |
5310 ;; ;; Daniel Pittman <daniel@danann.net> | |
5311 ;; ;; | |
5312 ;; ;; CCC: when the other defadvice calls have disappeared, make sure | |
5313 ;; ;; not to call defadvice unless it's necessary. How do we find out whether | |
5314 ;; ;; it is necessary? (featurep 'efs) is surely the wrong way -- | |
5315 ;; ;; EFS might nicht be loaded yet. | |
5316 ;; (defadvice efs-ftp-path (around dont-match-tramp-path activate protect) | |
5317 ;; "Cause efs-ftp-path to fail when the path is a TRAMP path." | |
5318 ;; (if (tramp-tramp-file-p (ad-get-arg 0)) | |
5319 ;; nil | |
5320 ;; ad-do-it)) | |
5321 | |
5322 ;; We currently use "[" and "]" in the filename format. In Emacs | |
5323 ;; 20.x, this means that Emacs wants to expand wildcards if | |
5324 ;; `find-file-wildcards' is non-nil, and then barfs because no | |
5325 ;; expansion could be found. We detect this situation and do | |
5326 ;; something really awful: we have `file-expand-wildcards' return the | |
5327 ;; original filename if it can't expand anything. Let's just hope | |
5328 ;; that this doesn't break anything else. | |
5329 ;; | |
5330 ;; Another problem is that the check is done by Emacs version, which | |
5331 ;; is really not what we want to do. Oh, well. | |
5332 | |
5333 ;;(when (and (not (featurep 'xemacs)) | |
5334 ;; (= emacs-major-version 20)) | |
5335 ;; It seems that this advice is needed in Emacs 21, too. | |
5336 (defadvice file-expand-wildcards (around tramp-fix activate) | |
5337 (let ((name (ad-get-arg 0))) | |
5338 (if (tramp-tramp-file-p name) | |
5339 ;; If it's a Tramp file, dissect it and look if wildcards | |
5340 ;; need to be expanded at all. | |
5341 (let ((v (tramp-dissect-file-name name))) | |
5342 (if (string-match "[[*?]" (tramp-file-name-path v)) | |
5343 (let ((res ad-do-it)) | |
5344 (setq ad-return-value (or res (list name)))) | |
5345 (setq ad-return-value (list name)))) | |
5346 ;; If it is not a Tramp file, just run the original function. | |
5347 (let ((res ad-do-it)) | |
5348 (setq ad-return-value (or res (list name))))))) | |
5349 ;; ) | |
5350 | |
5351 ;; Make the `reporter` functionality available for making bug reports about | |
5352 ;; the package. A most useful piece of code. | |
5353 | |
5354 (unless (fboundp 'reporter-submit-bug-report) | |
5355 (autoload 'reporter-submit-bug-report "reporter")) | |
5356 | |
5357 (defun tramp-bug () | |
5358 "Submit a bug report to the TRAMP developers." | |
5359 (interactive) | |
5360 (require 'reporter) | |
5361 (let ((reporter-prompt-for-summary-p t)) | |
5362 (reporter-submit-bug-report | |
5363 tramp-bug-report-address ; to-address | |
5364 (format "tramp (%s)" tramp-version) ; package name and version | |
5365 `(;; Current state | |
5366 tramp-ls-command | |
5367 tramp-test-groks-nt | |
5368 tramp-file-exists-command | |
5369 tramp-current-multi-method | |
5370 tramp-current-method | |
5371 tramp-current-user | |
5372 tramp-current-host | |
5373 | |
5374 ;; System defaults | |
5375 tramp-auto-save-directory ; vars to dump | |
5376 tramp-default-method | |
5377 tramp-rsh-end-of-line | |
5378 tramp-remote-path | |
5379 tramp-login-prompt-regexp | |
5380 tramp-password-prompt-regexp | |
5381 tramp-wrong-passwd-regexp | |
5382 tramp-temp-name-prefix | |
5383 tramp-file-name-structure | |
5384 tramp-file-name-regexp | |
5385 tramp-multi-file-name-structure | |
5386 tramp-multi-file-name-hop-structure | |
5387 tramp-multi-methods | |
5388 tramp-multi-connection-function-alist | |
5389 tramp-make-tramp-file-format | |
5390 tramp-end-of-output | |
5391 | |
5392 ;; Non-tramp variables of interest | |
5393 shell-prompt-pattern | |
5394 backup-by-copying | |
5395 backup-by-copying-when-linked | |
5396 backup-by-copying-when-mismatch | |
5397 ,(when (boundp 'backup-by-copying-when-privileged-mismatch) | |
5398 'backup-by-copying-when-privileged-mismatch) | |
5399 file-name-handler-alist) | |
5400 nil ; pre-hook | |
5401 nil ; post-hook | |
5402 "\ | |
5403 Enter your bug report in this message, including as much detail as you | |
5404 possibly can about the problem, what you did to cause it and what the | |
5405 local and remote machines are. | |
5406 | |
5407 If you can give a simple set of instructions to make this bug happen | |
5408 reliably, please include those. Thank you for helping kill bugs in | |
5409 TRAMP. | |
5410 --bug report follows this line--"))) | |
5411 | |
5412 (defalias 'tramp-submit-bug 'tramp-bug) | |
5413 | |
5414 (provide 'tramp) | |
5415 | |
5416 ;; Make sure that we get integration with the VC package. | |
5417 ;; When it is loaded, we need to pull in the integration module. | |
5418 ;; This must come after (provide 'tramp) because tramp-vc.el | |
5419 ;; requires tramp. | |
5420 (eval-after-load "vc" | |
5421 '(require 'tramp-vc)) | |
5422 | |
5423 ;;; TODO: | |
5424 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5425 ;; * Revise the comments near the beginning of the file. |
45861 | 5426 ;; * Cooperate with PCL-CVS. It uses start-process, which doesn't |
5427 ;; work for remote files. | |
5428 ;; * Rewrite `tramp-shell-quote-argument' to abstain from using | |
5429 ;; `shell-quote-argument'. | |
5430 ;; * Completion gets confused when you leave out the method name. | |
5431 ;; * Support `dired-compress-file' filename handler. | |
5432 ;; * In Emacs 21, `insert-directory' shows total number of bytes used | |
5433 ;; by the files in that directory. Add this here. | |
5434 ;; * Avoid screen blanking when hitting `g' in dired. (Eli Tziperman) | |
5435 ;; * Make ffap.el grok Tramp filenames. (Eli Tziperman) | |
5436 ;; * When logging in, keep looking for questions according to an alist | |
5437 ;; and then invoke the right function. | |
5438 ;; * Case-insensitive filename completion. (Norbert Goevert.) | |
5439 ;; * Running CVS remotely doesn't appear to work right. It thinks | |
5440 ;; files are locked by somebody else even if I'm the locking user. | |
5441 ;; Sometimes, one gets `No CVSROOT specified' errors from CVS. | |
5442 ;; (Skip Montanaro) | |
5443 ;; * Don't use globbing for directories with many files, as this is | |
5444 ;; likely to produce long command lines, and some shells choke on | |
5445 ;; long command lines. | |
5446 ;; * Find out about the new auto-save mechanism in Emacs 21 and | |
5447 ;; do the right thing. | |
5448 ;; * `vc-directory' does not work. It never displays any files, even | |
5449 ;; if it does show files when run locally. | |
5450 ;; * Allow correction of passwords, if the remote end allows this. | |
5451 ;; (Mark Hershberger) | |
5452 ;; * Make sure permissions of tmp file are good. | |
5453 ;; (Nelson Minar <nelson@media.mit.edu>) | |
5454 ;; * Grok passwd prompts with scp? (David Winter | |
5455 ;; <winter@nevis1.nevis.columbia.edu>). Maybe just do `ssh -l user | |
5456 ;; host', then wait a while for the passwd or passphrase prompt. If | |
5457 ;; there is one, remember the passwd/phrase. | |
5458 ;; * How to deal with MULE in `insert-file-contents' and `write-region'? | |
5459 ;; * Do asynchronous `shell-command's. | |
5460 ;; * Grok `append' parameter for `write-region'. | |
5461 ;; * Test remote ksh or bash for tilde expansion in `tramp-find-shell'? | |
5462 ;; * abbreviate-file-name | |
5463 ;; * grok ~ in tramp-remote-path (Henrik Holm <henrikh@tele.ntnu.no>) | |
5464 ;; * `C' in dired gives error `not tramp file name'. | |
5465 ;; * Also allow to omit user names when doing multi-hop. Not sure yet | |
5466 ;; what the user names should default to, though. | |
5467 ;; * better error checking. At least whenever we see something | |
5468 ;; strange when doing zerop, we should kill the process and start | |
5469 ;; again. (Greg Stark) | |
5470 ;; * Add caching for filename completion. (Greg Stark) | |
5471 ;; Of course, this has issues with usability (stale cache bites) | |
5472 ;; -- <daniel@danann.net> | |
5473 ;; * Provide a local cache of old versions of remote files for the rsync | |
5474 ;; transfer method to use. (Greg Stark) | |
5475 ;; * Remove unneeded parameters from methods. | |
5476 ;; * Invoke rsync once for copying a whole directory hierarchy. | |
5477 ;; (Francesco Potort́) | |
5478 ;; * Should we set PATH ourselves or should we rely on the remote end | |
5479 ;; to do it? | |
5480 ;; * Do the autoconf thing. | |
5481 ;; * Make it work for XEmacs 20, which is missing `with-timeout'. | |
5482 ;; * Allow non-Unix remote systems. (More a long-term thing.) | |
5483 ;; * Make it work for different encodings, and for different file name | |
5484 ;; encodings, too. (Daniel Pittman) | |
5485 ;; * Change applicable functions to pass a struct tramp-file-name rather | |
5486 ;; than the individual items MULTI-METHOD, METHOD, USER, HOST, PATH. | |
5487 ;; * Implement asynchronous shell commands. | |
5488 ;; * Clean up unused *tramp/foo* buffers after a while. (Pete Forman) | |
5489 ;; * Progress reports while copying files. (Michael Kifer) | |
5490 ;; * `Smart' connection method that uses inline for small and out of | |
5491 ;; band for large files. (Michael Kifer) | |
5492 ;; * Don't search for perl5 and perl. Instead, only search for perl and | |
5493 ;; then look if it's the right version (with `perl -v'). | |
5494 ;; * When editing a remote CVS controlled file as a different user, VC | |
5495 ;; gets confused about the file locking status. Try to find out why | |
5496 ;; the workaround doesn't work. | |
5497 ;; * When user is running ssh-agent, it would be useful to add the | |
5498 ;; passwords typed by the user to that agent. This way, the next time | |
5499 ;; round, the users don't have to type all this in again. | |
5500 ;; This would be especially useful for start-process, I think. | |
5501 ;; An easy way to implement start-process is to open a second shell | |
5502 ;; connection which is inconvenient if the user has to reenter | |
5503 ;; passwords. | |
5504 ;; * Change `copy-file' to grok the case where the filename handler | |
5505 ;; for the source and the target file are different. Right now, | |
5506 ;; it looks at the source file and then calls that handler, if | |
5507 ;; there is one. But since ange-ftp, for instance, does not know | |
5508 ;; about Tramp, it does not do the right thing if the target file | |
5509 ;; name is a Tramp name. | |
5510 | |
5511 ;; Functions for file-name-handler-alist: | |
5512 ;; diff-latest-backup-file -- in diff.el | |
5513 ;; dired-compress-file | |
5514 ;; dired-uncache -- this will be needed when we do insert-directory caching | |
5515 ;; file-name-as-directory -- use primitive? | |
5516 ;; file-name-directory -- use primitive? | |
5517 ;; file-name-nondirectory -- use primitive? | |
5518 ;; file-name-sans-versions -- use primitive? | |
5519 ;; file-newer-than-file-p | |
5520 ;; find-backup-file-name | |
5521 ;; get-file-buffer -- use primitive | |
5522 ;; load | |
5523 ;; unhandled-file-name-directory | |
5524 ;; vc-registered | |
5525 | |
5526 ;;; tramp.el ends here |