Mercurial > emacs
annotate lisp/net/tramp.el @ 47090:9c336e422221
(find-buffer-visiting): Compare file attributes using buffer-file-truename.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Wed, 28 Aug 2002 22:23:17 +0000 |
parents | 9d6aef07c793 |
children | 8a2bf9dded0f |
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 | |
46790 | 72 ;; In the Tramp CVS repository, the version numer is auto-frobbed from |
73 ;; the Makefile, so you should edit the top-level Makefile to change | |
74 ;; the version number. | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
75 (defconst tramp-version "2.0.14" |
45861 | 76 "This version of tramp.") |
46752 | 77 |
45861 | 78 (defconst tramp-bug-report-address "tramp-devel@mail.freesoftware.fsf.org" |
79 "Email address to send bug reports to.") | |
80 | |
81 (require 'timer) | |
82 (require 'format-spec) ;from Gnus 5.8, also in tar ball | |
83 (require 'base64) ;for the mimencode methods | |
84 (require 'shell) | |
85 (require 'advice) | |
86 | |
87 ;; ;; It does not work to load EFS after loading TRAMP. | |
88 ;; (when (fboundp 'efs-file-handler-function) | |
89 ;; (require 'efs)) | |
90 | |
91 (eval-when-compile | |
92 (require 'cl) | |
93 (require 'custom) | |
94 ;; Emacs 19.34 compatibility hack -- is this needed? | |
95 (or (>= emacs-major-version 20) | |
96 (load "cl-seq"))) | |
97 | |
98 (unless (boundp 'custom-print-functions) | |
99 (defvar custom-print-functions nil)) ; not autoloaded before Emacs 20.4 | |
100 | |
101 ;;; User Customizable Internal Variables: | |
102 | |
103 (defgroup tramp nil | |
104 "Edit remote files with a combination of rsh and rcp or similar programs." | |
105 :group 'files) | |
106 | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
107 (defcustom tramp-verbose 9 |
45861 | 108 "*Verbosity level for tramp.el. 0 means be silent, 10 is most verbose." |
109 :group 'tramp | |
110 :type 'integer) | |
111 | |
112 (defcustom tramp-debug-buffer nil | |
113 "*Whether to send all commands and responses to a debug buffer." | |
114 :group 'tramp | |
115 :type 'boolean) | |
116 | |
117 (defcustom tramp-auto-save-directory nil | |
118 "*Put auto-save files in this directory, if set. | |
119 The idea is to use a local directory so that auto-saving is faster." | |
120 :group 'tramp | |
121 :type '(choice (const nil) | |
122 string)) | |
123 | |
124 (defcustom tramp-sh-program "/bin/sh" | |
125 "*Use this program for shell commands on the local host. | |
126 This MUST be a Bourne-like shell. This shell is used to execute | |
127 the encoding and decoding command on the local host, so if you | |
128 want to use `~' in those commands, you should choose a shell here | |
129 which groks tilde expansion. `/bin/sh' normally does not | |
130 understand tilde expansion. | |
131 | |
132 Note that this variable is not used for remote commands. There are | |
133 mechanisms in tramp.el which automatically determine the right shell to | |
134 use for the remote host." | |
135 :group 'tramp | |
136 :type '(file :must-match t)) | |
137 | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
138 (defcustom tramp-multi-sh-program |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
139 (if (memq system-type '(windows-nt)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
140 "cmd.exe" |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
141 tramp-sh-program) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
142 "*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
|
143 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
|
144 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
|
145 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
|
146 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
|
147 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
|
148 |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
149 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
|
150 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
|
151 |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
152 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
|
153 `tramp-sh-program' on other systems." |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
154 :group 'tramp |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
155 :type '(file :must-match t)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
156 |
45861 | 157 ;; CCC I have changed all occurrences of comint-quote-filename with |
158 ;; tramp-shell-quote-argument, except in tramp-handle-expand-many-files. | |
159 ;; There, comint-quote-filename was removed altogether. If it turns | |
160 ;; out to be necessary there, something will need to be done. | |
161 ;;-(defcustom tramp-file-name-quote-list | |
162 ;;- '(?] ?[ ?\| ?& ?< ?> ?\( ?\) ?\; ?\ ?\* ?\? ?\! ?\" ?\' ?\` ?# ?\@ ?\+ ) | |
163 ;;- "*Protect these characters from the remote shell. | |
164 ;;-Any character in this list is quoted (preceded with a backslash) | |
165 ;;-because it means something special to the shell. This takes effect | |
166 ;;-when sending file and directory names to the remote shell. | |
167 ;;- | |
168 ;;-See `comint-file-name-quote-list' for details." | |
169 ;;- :group 'tramp | |
170 ;;- :type '(repeat character)) | |
171 | |
172 (defcustom tramp-methods | |
173 '( ("rcp" (tramp-connection-function tramp-open-connection-rsh) | |
174 (tramp-rsh-program "rsh") | |
175 (tramp-rcp-program "rcp") | |
176 (tramp-remote-sh "/bin/sh") | |
177 (tramp-rsh-args nil) | |
178 (tramp-rcp-args nil) | |
179 (tramp-rcp-keep-date-arg "-p") | |
180 (tramp-su-program nil) | |
181 (tramp-su-args 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-telnet-program nil) | |
194 (tramp-telnet-args nil)) | |
195 ("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
|
196 (tramp-rsh-program "ssh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
197 (tramp-rcp-program "scp") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
198 (tramp-remote-sh "/bin/sh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
199 (tramp-rsh-args ("-1" "-e" "none")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
200 (tramp-rcp-args ("-1")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
201 (tramp-rcp-keep-date-arg "-p") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
202 (tramp-su-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
203 (tramp-su-args nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
204 (tramp-telnet-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
205 (tramp-telnet-args nil)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
206 ("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
|
207 (tramp-rsh-program "ssh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
208 (tramp-rcp-program "scp") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
209 (tramp-remote-sh "/bin/sh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
210 (tramp-rsh-args ("-2" "-e" "none")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
211 (tramp-rcp-args ("-2")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
212 (tramp-rcp-keep-date-arg "-p") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
213 (tramp-su-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
214 (tramp-su-args nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
215 (tramp-telnet-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
216 (tramp-telnet-args nil)) |
46752 | 217 ("scp1-old" |
218 (tramp-connection-function tramp-open-connection-rsh) | |
45861 | 219 (tramp-rsh-program "ssh1") |
220 (tramp-rcp-program "scp1") | |
221 (tramp-remote-sh "/bin/sh") | |
222 (tramp-rsh-args ("-e" "none")) | |
223 (tramp-rcp-args nil) | |
224 (tramp-rcp-keep-date-arg "-p") | |
225 (tramp-su-program nil) | |
226 (tramp-su-args nil) | |
227 (tramp-telnet-program nil) | |
228 (tramp-telnet-args nil)) | |
46752 | 229 ("scp2-old" |
230 (tramp-connection-function tramp-open-connection-rsh) | |
45861 | 231 (tramp-rsh-program "ssh2") |
232 (tramp-rcp-program "scp2") | |
233 (tramp-remote-sh "/bin/sh") | |
234 (tramp-rsh-args ("-e" "none")) | |
235 (tramp-rcp-args nil) | |
236 (tramp-rcp-keep-date-arg "-p") | |
237 (tramp-su-program nil) | |
238 (tramp-su-args nil) | |
239 (tramp-telnet-program nil) | |
240 (tramp-telnet-args nil)) | |
241 ("rsync" (tramp-connection-function tramp-open-connection-rsh) | |
242 (tramp-rsh-program "ssh") | |
243 (tramp-rcp-program "rsync") | |
244 (tramp-remote-sh "/bin/sh") | |
245 (tramp-rsh-args ("-e" "none")) | |
246 (tramp-rcp-args ("-e" "ssh")) | |
247 (tramp-rcp-keep-date-arg "-t") | |
248 (tramp-su-program nil) | |
249 (tramp-su-args nil) | |
250 (tramp-telnet-program nil) | |
251 (tramp-telnet-args nil)) | |
46752 | 252 ("rsh" (tramp-connection-function tramp-open-connection-rsh) |
45861 | 253 (tramp-rsh-program "rsh") |
254 (tramp-rcp-program nil) | |
255 (tramp-remote-sh "/bin/sh") | |
256 (tramp-rsh-args nil) | |
257 (tramp-rcp-args nil) | |
258 (tramp-rcp-keep-date-arg nil) | |
259 (tramp-su-program nil) | |
260 (tramp-su-args nil) | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
261 (tramp-telnet-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
262 (tramp-telnet-args nil)) |
46752 | 263 ("ssh" (tramp-connection-function tramp-open-connection-rsh) |
45861 | 264 (tramp-rsh-program "ssh") |
265 (tramp-rcp-program nil) | |
266 (tramp-remote-sh "/bin/sh") | |
267 (tramp-rsh-args ("-e" "none")) | |
268 (tramp-rcp-args nil) | |
269 (tramp-rcp-keep-date-arg nil) | |
270 (tramp-su-program nil) | |
271 (tramp-su-args nil) | |
46752 | 272 (tramp-telnet-program nil) |
273 (tramp-telnet-args nil)) | |
274 ("ssh1" (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
|
275 (tramp-rsh-program "ssh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
276 (tramp-rcp-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
277 (tramp-remote-sh "/bin/sh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
278 (tramp-rsh-args ("-1" "-e" "none")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
279 (tramp-rcp-args ("-1")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
280 (tramp-rcp-keep-date-arg nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
281 (tramp-su-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
282 (tramp-su-args nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
283 (tramp-telnet-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
284 (tramp-telnet-args nil)) |
46752 | 285 ("ssh2" (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
|
286 (tramp-rsh-program "ssh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
287 (tramp-rcp-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
288 (tramp-remote-sh "/bin/sh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
289 (tramp-rsh-args ("-2" "-e" "none")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
290 (tramp-rcp-args ("-2")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
291 (tramp-rcp-keep-date-arg nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
292 (tramp-su-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
293 (tramp-su-args nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
294 (tramp-telnet-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
295 (tramp-telnet-args nil)) |
46752 | 296 ("ssh1-old" |
297 (tramp-connection-function tramp-open-connection-rsh) | |
45861 | 298 (tramp-rsh-program "ssh1") |
299 (tramp-rcp-program nil) | |
300 (tramp-remote-sh "/bin/sh") | |
301 (tramp-rsh-args ("-e" "none")) | |
302 (tramp-rcp-args nil) | |
303 (tramp-rcp-keep-date-arg nil) | |
304 (tramp-su-program nil) | |
305 (tramp-su-args nil) | |
306 (tramp-telnet-program nil) | |
307 (tramp-telnet-args nil)) | |
46752 | 308 ("ssh2-old" |
309 (tramp-connection-function tramp-open-connection-rsh) | |
45861 | 310 (tramp-rsh-program "ssh2") |
311 (tramp-rcp-program nil) | |
312 (tramp-remote-sh "/bin/sh") | |
313 (tramp-rsh-args ("-e" "none")) | |
314 (tramp-rcp-args nil) | |
315 (tramp-rcp-keep-date-arg nil) | |
316 (tramp-su-program nil) | |
317 (tramp-su-args nil) | |
46752 | 318 (tramp-telnet-program nil) |
319 (tramp-telnet-args nil)) | |
320 ("ssh1-old" | |
321 (tramp-connection-function tramp-open-connection-rsh) | |
322 (tramp-rsh-program "ssh1") | |
323 (tramp-rcp-program nil) | |
324 (tramp-remote-sh "/bin/sh") | |
325 (tramp-rsh-args ("-e" "none")) | |
326 (tramp-rcp-args nil) | |
327 (tramp-rcp-keep-date-arg nil) | |
328 (tramp-su-program nil) | |
329 (tramp-su-args nil) | |
45861 | 330 (tramp-telnet-program nil) |
331 (tramp-telnet-args nil)) | |
46752 | 332 ("ssh2-old" |
333 (tramp-connection-function tramp-open-connection-rsh) | |
334 (tramp-rsh-program "ssh2") | |
335 (tramp-rcp-program nil) | |
336 (tramp-remote-sh "/bin/sh") | |
337 (tramp-rsh-args ("-e" "none")) | |
338 (tramp-rcp-args nil) | |
339 (tramp-rcp-keep-date-arg nil) | |
340 (tramp-su-program nil) | |
341 (tramp-su-args nil) | |
342 (tramp-telnet-program nil) | |
343 (tramp-telnet-args nil)) | |
344 ("telnet" | |
345 (tramp-connection-function tramp-open-connection-telnet) | |
45861 | 346 (tramp-rsh-program nil) |
347 (tramp-rcp-program nil) | |
348 (tramp-remote-sh "/bin/sh") | |
349 (tramp-rsh-args nil) | |
350 (tramp-rcp-args nil) | |
351 (tramp-rcp-keep-date-arg nil) | |
352 (tramp-su-program nil) | |
353 (tramp-su-args nil) | |
354 (tramp-telnet-program "telnet") | |
355 (tramp-telnet-args nil)) | |
46752 | 356 ("su" (tramp-connection-function tramp-open-connection-su) |
45861 | 357 (tramp-rsh-program nil) |
358 (tramp-rcp-program nil) | |
359 (tramp-remote-sh "/bin/sh") | |
360 (tramp-rsh-args nil) | |
361 (tramp-rcp-args nil) | |
362 (tramp-rcp-keep-date-arg nil) | |
363 (tramp-su-program "su") | |
364 (tramp-su-args ("-" "%u")) | |
365 (tramp-telnet-program nil) | |
366 (tramp-telnet-args nil)) | |
46752 | 367 ("sudo" (tramp-connection-function tramp-open-connection-su) |
45861 | 368 (tramp-rsh-program nil) |
369 (tramp-rcp-program nil) | |
370 (tramp-remote-sh "/bin/sh") | |
371 (tramp-rsh-args nil) | |
372 (tramp-rcp-args nil) | |
373 (tramp-rcp-keep-date-arg nil) | |
374 (tramp-su-program "sudo") | |
375 (tramp-su-args ("-u" "%u" "-s")) | |
376 (tramp-telnet-program nil) | |
377 (tramp-telnet-args nil)) | |
378 ("multi" (tramp-connection-function tramp-open-connection-multi) | |
379 (tramp-rsh-program nil) | |
380 (tramp-rcp-program nil) | |
381 (tramp-remote-sh "/bin/sh") | |
382 (tramp-rsh-args nil) | |
383 (tramp-rcp-args nil) | |
384 (tramp-rcp-keep-date-arg nil) | |
385 (tramp-su-program nil) | |
386 (tramp-su-args nil) | |
387 (tramp-telnet-program nil) | |
388 (tramp-telnet-args nil)) | |
389 ("scpx" (tramp-connection-function tramp-open-connection-rsh) | |
390 (tramp-rsh-program "ssh") | |
391 (tramp-rcp-program "scp") | |
392 (tramp-remote-sh "/bin/sh") | |
393 (tramp-rsh-args ("-e" "none" "-t" "-t" "/bin/sh")) | |
394 (tramp-rcp-args nil) | |
395 (tramp-rcp-keep-date-arg "-p") | |
396 (tramp-telnet-program nil) | |
397 (tramp-telnet-args nil)) | |
46752 | 398 ("sshx" (tramp-connection-function tramp-open-connection-rsh) |
45861 | 399 (tramp-rsh-program "ssh") |
400 (tramp-rcp-program nil) | |
401 (tramp-remote-sh "/bin/sh") | |
402 (tramp-rsh-args ("-e" "none" "-t" "-t" "/bin/sh")) | |
403 (tramp-rcp-args nil) | |
404 (tramp-rcp-keep-date-arg nil) | |
405 (tramp-su-program nil) | |
406 (tramp-su-args nil) | |
407 (tramp-telnet-program nil) | |
408 (tramp-telnet-args nil)) | |
46752 | 409 ("krlogin" |
45861 | 410 (tramp-connection-function tramp-open-connection-rsh) |
411 (tramp-rsh-program "krlogin") | |
412 (tramp-rcp-program nil) | |
413 (tramp-remote-sh "/bin/sh") | |
414 (tramp-rsh-args ("-x")) | |
415 (tramp-rcp-args nil) | |
416 (tramp-rcp-keep-date-arg nil) | |
417 (tramp-su-program nil) | |
418 (tramp-su-args nil) | |
419 (tramp-telnet-program nil) | |
420 (tramp-telnet-args nil)) | |
46752 | 421 ("plink" |
45861 | 422 (tramp-connection-function tramp-open-connection-rsh) |
423 (tramp-rsh-program "plink") | |
424 (tramp-rcp-program nil) | |
425 (tramp-remote-sh "/bin/sh") | |
426 (tramp-rsh-args ("-ssh")) ;optionally add "-v" | |
427 (tramp-rcp-args nil) | |
428 (tramp-rcp-keep-date-arg nil) | |
429 (tramp-su-program nil) | |
430 (tramp-su-args nil) | |
431 (tramp-telnet-program nil) | |
432 (tramp-telnet-args nil)) | |
433 ("pscp" | |
434 (tramp-connection-function tramp-open-connection-rsh) | |
435 (tramp-rsh-program "plink") | |
436 (tramp-rcp-program "pscp") | |
437 (tramp-remote-sh "/bin/sh") | |
438 (tramp-rsh-args ("-ssh")) | |
439 (tramp-rcp-args nil) | |
440 (tramp-rcp-keep-date-arg "-p") | |
441 (tramp-su-program nil) | |
442 (tramp-su-args nil) | |
443 (tramp-telnet-program nil) | |
444 (tramp-telnet-args nil)) | |
445 ("fcp" | |
446 (tramp-connection-function tramp-open-connection-rsh) | |
447 (tramp-rsh-program "fsh") | |
448 (tramp-rcp-program "fcp") | |
449 (tramp-remote-sh "/bin/sh -i") | |
450 (tramp-rsh-args ("sh" "-i")) | |
451 (tramp-rcp-args nil) | |
452 (tramp-rcp-keep-date-arg "-p") | |
453 (tramp-su-program nil) | |
454 (tramp-su-args nil) | |
455 (tramp-telnet-program nil) | |
456 (tramp-telnet-args nil)) | |
457 ) | |
458 "*Alist of methods for remote files. | |
459 This is a list of entries of the form (NAME PARAM1 PARAM2 ...). | |
460 Each NAME stands for a remote access method. Each PARAM is a | |
461 pair of the form (KEY VALUE). The following KEYs are defined: | |
462 * `tramp-connection-function' | |
463 This specifies the function to use to connect to the remote host. | |
464 Currently, `tramp-open-connection-rsh', `tramp-open-connection-telnet' | |
465 and `tramp-open-connection-su' are defined. See the documentation | |
466 of these functions for more details. | |
467 * `tramp-remote-sh' | |
468 This specifies the Bourne shell to use on the remote host. This | |
469 MUST be a Bourne-like shell. It is normally not necessary to set | |
470 this to any value other than \"/bin/sh\": tramp wants to use a shell | |
471 which groks tilde expansion, but it can search for it. Also note | |
472 that \"/bin/sh\" exists on all Unixen, this might not be true for | |
473 the value that you decide to use. You Have Been Warned. | |
474 * `tramp-rsh-program' | |
475 This specifies the name of the program to use for rsh; this might be | |
476 the full path to rsh or the name of a workalike program. | |
477 * `tramp-rsh-args' | |
478 This specifies the list of arguments to pass to the above | |
479 mentioned program. Please note that this is a list of arguments, | |
480 that is, normally you don't want to put \"-a -b\" or \"-f foo\" | |
481 here. Instead, you want two list elements, one for \"-a\" and one | |
482 for \"-b\", or one for \"-f\" and one for \"foo\". | |
483 * `tramp-rcp-program' | |
484 This specifies the name of the program to use for rcp; this might be | |
485 the full path to rcp or the name of a workalike program. | |
486 * `tramp-rcp-args' | |
487 This specifies the list of parameters to pass to the above mentioned | |
488 program, the hints for `tramp-rsh-args' also apply here. | |
489 * `tramp-rcp-keep-date-arg' | |
490 This specifies the parameter to use for `rcp' when the timestamp | |
491 of the original file should be kept. For `rcp', use `-p', for | |
492 `rsync', use `-t'. | |
493 * `tramp-su-program' | |
494 This specifies the name of the program to use for `su'. | |
495 * `tramp-su-args' | |
496 This specifies the list of arguments to pass to `su'. | |
497 \"%u\" is replaced by the user name, use \"%%\" for a literal | |
498 percent character. | |
499 * `tramp-encoding-command' | |
500 This specifies a command to use to encode the file contents for | |
501 transfer. The command should read the raw file contents from | |
502 standard input and write the encoded file contents to standard | |
503 output. In this string, the percent escape \"%f\" should be used | |
504 to indicate the file to convert. Use \"%%\" if you need a literal | |
505 percent character in your command. | |
506 * `tramp-decoding-command' | |
507 This specifies a command to use to decode file contents encoded | |
508 with `tramp-encoding-command'. The command should read from standard | |
509 input and write to standard output. | |
510 * `tramp-encoding-function' | |
511 This specifies a function to be called to encode the file contents | |
512 on the local side. This function should accept two arguments | |
513 START and END, the beginning and end of the region to encode. The | |
514 region should be replaced with the encoded contents. | |
515 * `tramp-decoding-function' | |
516 Same for decoding on the local side. | |
517 * `tramp-telnet-program' | |
518 Specifies the telnet program to use when using | |
519 `tramp-open-connection-telnet' to log in. | |
520 * `tramp-telnet-args' | |
521 Specifies list of arguments to pass to `telnet'. The hints for | |
522 `tramp-rsh-args' also apply here. | |
523 | |
524 What does all this mean? Well, you should specify `tramp-rsh-program', | |
525 `tramp-telnet-program' or `tramp-su-program' for all methods; this program | |
526 is used to log in to the remote site. Then, there are two ways to | |
527 actually transfer the files between the local and the remote side. | |
528 One way is using an additional rcp-like program. If you want to do | |
529 this, set `tramp-rcp-program' in the method. | |
530 | |
531 Another possibility for file transfer is inline transfer, i.e. the | |
532 file is passed through the same buffer used by `tramp-rsh-program'. In | |
533 this case, the file contents need to be protected since the | |
534 `tramp-rsh-program' might use escape codes or the connection might not | |
535 be eight-bit clean. Therefore, file contents are encoded for transit. | |
536 | |
537 Two possibilities for encoding are uuencode/uudecode and mimencode. | |
538 For uuencode/uudecode you want to set `tramp-encoding-command' to | |
539 something like \"uuencode\" and `tramp-decoding-command' to \"uudecode | |
540 -p\". For mimencode you want to set `tramp-encoding-command' to | |
541 something like \"mimencode -b\" and `tramp-decoding-command' to | |
542 \"mimencode -b -u\". | |
543 | |
544 When using inline transfer, you can use a program or a Lisp function | |
545 on the local side to encode or decode the file contents. Set the | |
546 `tramp-encoding-function' and `tramp-decoding-function' parameters to nil | |
547 in order to use the commands or to the function to use. It is | |
548 possible to specify one function and the other parameter as nil. | |
549 | |
550 So, to summarize: if the method is an inline method, you must specify | |
551 `tramp-encoding-command' and `tramp-decoding-command', and | |
552 `tramp-rcp-program' must be nil. If the method is out of band, then | |
553 you must specify `tramp-rcp-program' and `tramp-rcp-args' and | |
554 `tramp-encoding-command' and `tramp-decoding-command' must be nil. | |
555 Every method, inline or out of band, must specify | |
556 `tramp-connection-function' plus the associated arguments (for | |
557 example, the telnet program if you chose | |
558 `tramp-open-connection-telnet'). | |
559 | |
560 Notes: | |
561 | |
562 When using `tramp-open-connection-su' the phrase `open connection to a | |
563 remote host' sounds strange, but it is used nevertheless, for | |
564 consistency. No connection is opened to a remote host, but `su' is | |
565 started on the local host. You are not allowed to specify a remote | |
566 host other than `localhost' or the name of the local host. | |
567 | |
568 Using a uuencode/uudecode inline method is discouraged, please use one | |
569 of the base64 methods instead since base64 encoding is much more | |
570 reliable and the commands are more standardized between the different | |
571 Unix versions. But if you can't use base64 for some reason, please | |
572 note that the default uudecode command does not work well for some | |
573 Unices, in particular AIX and Irix. For AIX, you might want to use | |
574 the following command for uudecode: | |
575 | |
576 sed '/^begin/d;/^[` ]$/d;/^end/d' | iconv -f uucode -t ISO8859-1 | |
577 | |
578 For Irix, no solution is known yet." | |
579 :group 'tramp | |
580 :type '(repeat | |
581 (cons string | |
582 (set (list (const tramp-connection-function) function) | |
583 (list (const tramp-rsh-program) | |
584 (choice (const nil) string)) | |
585 (list (const tramp-rcp-program) | |
586 (choice (const nil) string)) | |
587 (list (const tramp-remote-sh) | |
588 (choice (const nil) string)) | |
589 (list (const tramp-rsh-args) (repeat string)) | |
590 (list (const tramp-rcp-args) (repeat string)) | |
591 (list (const tramp-rcp-keep-date-arg) | |
592 (choice (const nil) string)) | |
593 (list (const tramp-su-program) | |
594 (choice (const nil) string)) | |
595 (list (const tramp-su-args) (repeat string)) | |
596 (list (const tramp-encoding-command) | |
597 (choice (const nil) string)) | |
598 (list (const tramp-decoding-command) | |
599 (choice (const nil) string)) | |
600 (list (const tramp-encoding-function) | |
601 (choice (const nil) function)) | |
602 (list (const tramp-decoding-function) | |
603 (choice (const nil) function)) | |
604 (list (const tramp-telnet-program) | |
605 (choice (const nil) string)) | |
606 (list (const tramp-telnet-args) (repeat string)))))) | |
607 | |
608 (defcustom tramp-multi-methods '("multi" "multiu") | |
609 "*List of multi-hop methods. | |
610 Each entry in this list should be a method name as mentioned in the | |
611 variable `tramp-methods'." | |
612 :group 'tramp | |
613 :type '(repeat string)) | |
614 | |
615 (defcustom tramp-multi-connection-function-alist | |
616 '(("telnet" tramp-multi-connect-telnet "telnet %h%n") | |
617 ("rsh" tramp-multi-connect-rlogin "rsh %h -l %u%n") | |
618 ("ssh" tramp-multi-connect-rlogin "ssh %h -l %u%n") | |
619 ("su" tramp-multi-connect-su "su - %u%n") | |
620 ("sudo" tramp-multi-connect-su "sudo -u %u -s%n")) | |
621 "*List of connection functions for multi-hop methods. | |
622 Each list item is a list of three items (METHOD FUNCTION COMMAND), | |
623 where METHOD is the name as used in the file name, FUNCTION is the | |
624 function to be executed, and COMMAND is the shell command used for | |
625 connecting. | |
626 | |
627 COMMAND may contain percent escapes. `%u' will be replaced with the | |
628 user name, `%h' will be replaced with the host name, and `%n' will be | |
629 replaced with an end-of-line character, as specified in the variable | |
630 `tramp-rsh-end-of-line'. Use `%%' for a literal percent character. | |
631 Note that the interpretation of the percent escapes also depends on | |
632 the FUNCTION. For example, the `%u' escape is forbidden with the | |
633 function `tramp-multi-connect-telnet'. See the documentation of the | |
634 various functions for details." | |
635 :group 'tramp | |
636 :type '(repeat (list string function string))) | |
637 | |
46790 | 638 (defcustom tramp-default-method "ssh" |
45861 | 639 "*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
|
640 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
|
641 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
|
642 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
643 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
|
644 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
|
645 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
|
646 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
|
647 :group 'tramp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
648 :type 'string) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
649 |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
650 (defcustom tramp-default-method-alist |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
651 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
652 nil |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
653 '(("\\`ftp\\." "" "ftp") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
654 ("" "\\`\\(anonymous\\|ftp\\)\\'" "ftp"))) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
655 "*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
|
656 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
|
657 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
|
658 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
|
659 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
|
660 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
|
661 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
662 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
|
663 empty string for the user name. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
664 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
665 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
|
666 :group 'tramp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
667 :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
|
668 (regexp :tag "User regexp") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
669 (string :tag "Method")))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
670 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
671 (defcustom tramp-ftp-method "ftp" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
672 "*When this method name is used, forward all calls to Ange-FTP." |
45861 | 673 :group 'tramp |
674 :type 'string) | |
675 | |
676 (defcustom tramp-rsh-end-of-line "\n" | |
677 "*String used for end of line in rsh connections. | |
678 I don't think this ever needs to be changed, so please tell me about it | |
679 if you need to change this." | |
680 :group 'tramp | |
681 :type 'string) | |
682 | |
683 (defcustom tramp-remote-path | |
684 '("/bin" "/usr/bin" "/usr/sbin" "/usr/local/bin" "/usr/ccs/bin" | |
685 "/local/bin" "/local/freeware/bin" "/local/gnu/bin" | |
686 "/usr/freeware/bin" "/usr/pkg/bin" "/usr/contrib/bin") | |
687 "*List of directories to search for executables on remote host. | |
688 Please notify me about other semi-standard directories to include here. | |
689 | |
690 You can use `~' in this list, but when searching for a shell which groks | |
691 tilde expansion, all directory names starting with `~' will be ignored." | |
692 :group 'tramp | |
693 :type '(repeat string)) | |
694 | |
695 (defcustom tramp-login-prompt-regexp | |
46752 | 696 ".*ogin: *" |
45861 | 697 "*Regexp matching login-like prompts. |
46752 | 698 The regexp should match at end of buffer." |
45861 | 699 :group 'tramp |
700 :type 'regexp) | |
701 | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
702 (defcustom tramp-shell-prompt-pattern |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
703 "^[^#$%>\n]*[#$%>] *" |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
704 "Regexp to match prompts from remote shell. |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
705 Normally, Tramp expects you to configure `shell-prompt-pattern' |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
706 correctly, but sometimes it happens that you are connecting to a |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
707 remote host which sends a different kind of shell prompt. Therefore, |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
708 Tramp recognizes things matched by `shell-prompt-pattern' as prompt, |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
709 and also things matched by this variable. The default value of this |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
710 variable is the same as the default value of `shell-prompt-pattern', |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
711 which should work well in many cases." |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
712 :group 'tramp |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
713 :type 'regexp) |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
714 |
45861 | 715 (defcustom tramp-password-prompt-regexp |
46752 | 716 "^.*\\([pP]assword\\|passphrase.*\\):\^@? *" |
45861 | 717 "*Regexp matching password-like prompts. |
46752 | 718 The regexp should match at end of buffer. |
45861 | 719 |
720 The `sudo' program appears to insert a `^@' character into the prompt." | |
721 :group 'tramp | |
722 :type 'regexp) | |
723 | |
724 (defcustom tramp-wrong-passwd-regexp | |
46790 | 725 (concat "^.*" |
726 ;; These strings should be on the last line | |
727 (regexp-opt '("Permission denied." | |
728 "Login incorrect" | |
729 "Login Incorrect" | |
730 "Connection refused" | |
731 "Connection closed" | |
732 "Sorry, try again." | |
733 "Name or service not known" | |
734 "Host key verification failed.") t) | |
735 ".*" | |
736 "\\|" | |
737 "^.*\\(" | |
738 ;; Here comes a list of regexes, separated by \\| | |
739 "Received signal [0-9]+" | |
740 "\\).*") | |
45861 | 741 "*Regexp matching a `login failed' message. |
46752 | 742 The regexp should match at end of buffer." |
743 :group 'tramp | |
744 :type 'regexp) | |
745 | |
746 (defcustom tramp-yesno-prompt-regexp | |
46992
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
747 (concat |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
748 (regexp-opt '("Are you sure you want to continue connecting (yes/no)?") t) |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
749 "\\s-*") |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
750 "Regular expression matching all yes/no queries which need to be confirmed. |
46752 | 751 The confirmation should be done with yes or no. |
46992
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
752 The regexp should match at end of buffer. |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
753 See also `tramp-yn-prompt-regexp'." |
45861 | 754 :group 'tramp |
755 :type 'regexp) | |
756 | |
46992
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
757 (defcustom tramp-yn-prompt-regexp |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
758 (concat (regexp-opt '("Store key in cache? (y/n)") t) |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
759 "\\s-*") |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
760 "Regular expression matching all y/n queries which need to be confirmed. |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
761 The confirmation should be done with y or n. |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
762 The regexp should match at end of buffer. |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
763 See also `tramp-yesno-prompt-regexp'." |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
764 :group 'tramp |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
765 :type 'regexp) |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
766 |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
767 |
45861 | 768 (defcustom tramp-temp-name-prefix "tramp." |
769 "*Prefix to use for temporary files. | |
770 If this is a relative file name (such as \"tramp.\"), it is considered | |
771 relative to the directory name returned by the function | |
772 `tramp-temporary-file-directory' (which see). It may also be an | |
773 absolute file name; don't forget to include a prefix for the filename | |
774 part, though." | |
775 :group 'tramp | |
776 :type 'string) | |
777 | |
778 (defcustom tramp-discard-garbage nil | |
779 "*If non-nil, try to discard garbage sent by remote shell. | |
780 Some shells send such garbage upon connection setup." | |
781 :group 'tramp | |
782 :type 'boolean) | |
783 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
784 (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
|
785 "*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
|
786 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
|
787 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
|
788 arguments. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
789 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
790 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
|
791 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
|
792 shell from reading its init file." |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
793 :group 'tramp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
794 :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
|
795 |
45861 | 796 ;; File name format. |
797 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
798 (defconst tramp-file-name-structure-unified |
46752 | 799 (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
|
800 "\\(\\([^:@/]+\\)@\\)?" ;user |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
801 "\\([^:/]+\\):" ;host |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
802 "\\(.*\\)\\'") ;path |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
803 2 4 5 6) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
804 "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
|
805 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
|
806 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
|
807 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
808 (defconst tramp-file-name-structure-separate |
46752 | 809 (list (concat "\\`/\\[\\(\\([a-zA-Z0-9-]+\\)/\\)?" ;method |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
810 "\\(\\([-a-zA-Z0-9_#/:]+\\)@\\)?" ;user |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
811 "\\([-a-zA-Z0-9_#/:@.]+\\)\\]" ;host |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
812 "\\(.*\\)\\'") ;path |
45861 | 813 2 4 5 6) |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
814 "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
|
815 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
|
816 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
|
817 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
|
818 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
819 (defcustom tramp-file-name-structure |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
820 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
821 tramp-file-name-structure-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
822 tramp-file-name-structure-unified) |
45861 | 823 "*List of five elements (REGEXP METHOD USER HOST FILE), detailing \ |
824 the tramp file name structure. | |
825 | |
826 The first element REGEXP is a regular expression matching a tramp file | |
827 name. The regex should contain parentheses around the method name, | |
828 the user name, the host name, and the file name parts. | |
829 | |
830 The second element METHOD is a number, saying which pair of | |
831 parentheses matches the method name. The third element USER is | |
832 similar, but for the user name. The fourth element HOST is similar, | |
833 but for the host name. The fifth element FILE is for the file name. | |
834 These numbers are passed directly to `match-string', which see. That | |
835 means the opening parentheses are counted to identify the pair. | |
836 | |
837 See also `tramp-file-name-regexp' and `tramp-make-tramp-file-format'." | |
838 :group 'tramp | |
839 :type '(list (regexp :tag "File name regexp") | |
840 (integer :tag "Paren pair for method name") | |
841 (integer :tag "Paren pair for user name ") | |
842 (integer :tag "Paren pair for host name ") | |
843 (integer :tag "Paren pair for file name "))) | |
844 | |
845 ;;;###autoload | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
846 (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
|
847 "\\`/[^/:]+:" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
848 "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
|
849 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
|
850 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
|
851 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
852 ;;;###autoload |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
853 (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
|
854 "\\`/\\[.*\\]" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
855 "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
|
856 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
|
857 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
|
858 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
859 ;;;###autoload |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
860 (defcustom tramp-file-name-regexp |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
861 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
862 tramp-file-name-regexp-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
863 tramp-file-name-regexp-unified) |
45861 | 864 "*Regular expression matching file names handled by tramp. |
865 This regexp should match tramp file names but no other file names. | |
866 \(When tramp.el is loaded, this regular expression is prepended to | |
867 `file-name-handler-alist', and that is searched sequentially. Thus, | |
868 if the tramp entry appears rather early in the `file-name-handler-alist' | |
869 and is a bit too general, then some files might be considered tramp | |
870 files which are not really tramp files. | |
871 | |
872 Please note that the entry in `file-name-handler-alist' is made when | |
873 this file (tramp.el) is loaded. This means that this variable must be set | |
874 before loading tramp.el. Alternatively, `file-name-handler-alist' can be | |
875 updated after changing this variable. | |
876 | |
877 Also see `tramp-file-name-structure' and `tramp-make-tramp-file-format'." | |
878 :group 'tramp | |
879 :type 'regexp) | |
880 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
881 (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
|
882 "/%m:%u@%h:%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
883 "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
|
884 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
|
885 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
|
886 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
887 (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
|
888 "/[%m/%u@%h]%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
889 "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
|
890 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
|
891 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
|
892 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
893 (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
|
894 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
895 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
|
896 tramp-make-tramp-file-format-unified) |
45861 | 897 "*Format string saying how to construct tramp file name. |
898 `%m' is replaced by the method name. | |
899 `%u' is replaced by the user name. | |
900 `%h' is replaced by the host name. | |
901 `%p' is replaced by the file name. | |
902 `%%' is replaced by %. | |
903 | |
904 Also see `tramp-file-name-structure' and `tramp-file-name-regexp'." | |
905 :group 'tramp | |
906 :type 'string) | |
907 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
908 (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
|
909 "/%m:%h:%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
910 "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
|
911 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
|
912 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
|
913 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
914 (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
|
915 "/[%m/%h]%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
916 "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
|
917 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
|
918 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
|
919 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
920 (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
|
921 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
922 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
|
923 tramp-make-tramp-file-user-nil-format-unified) |
45861 | 924 "*Format string saying how to construct tramp file name when the user name is not known. |
925 `%m' is replaced by the method name. | |
926 `%h' is replaced by the host name. | |
927 `%p' is replaced by the file name. | |
928 `%%' is replaced by %. | |
929 | |
930 Also see `tramp-make-tramp-file-format', `tramp-file-name-structure', and `tramp-file-name-regexp'." | |
931 :group 'tramp | |
932 :type 'string) | |
933 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
934 (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
|
935 (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
|
936 "\\(\\(%s\\)+\\)" ;hops |
46347
3996ea20e5e3
(tramp-multi-file-name-structure-unified): Add
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46307
diff
changeset
|
937 "\\(.*\\)\\'") ;path |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
938 2 3 -1) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
939 "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
|
940 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
|
941 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
|
942 |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
943 (defconst tramp-multi-file-name-structure-separate |
45861 | 944 (list (concat |
945 ;; prefix | |
46347
3996ea20e5e3
(tramp-multi-file-name-structure-unified): Add
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46307
diff
changeset
|
946 "\\`/\\[\\(\\([a-z0-9]+\\)?\\)" |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
947 ;; regexp specifying the hops |
45861 | 948 "\\(\\(%s\\)+\\)" |
949 ;; path name | |
950 "\\]\\(.*\\)\\'") | |
951 2 ;number of pair to match method | |
952 3 ;number of pair to match hops | |
953 -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
|
954 "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
|
955 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
|
956 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
|
957 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
958 (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
|
959 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
960 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
|
961 tramp-multi-file-name-structure-unified) |
45861 | 962 "*Describes the file name structure of `multi' files. |
963 Multi files allow you to contact a remote host in several hops. | |
964 This is a list of four elements (REGEXP METHOD HOP PATH). | |
965 | |
966 The first element, REGEXP, gives a regular expression to match against | |
967 the file name. In this regular expression, `%s' is replaced with the | |
968 value of `tramp-multi-file-name-hop-structure'. (Note: in order to | |
969 allow multiple hops, you normally want to use something like | |
970 \"\\\\(\\\\(%s\\\\)+\\\\)\" in the regular expression. The outer pair | |
971 of parentheses is used for the HOP element, see below.) | |
972 | |
973 All remaining elements are numbers. METHOD gives the number of the | |
974 paren pair which matches the method name. HOP gives the number of the | |
975 paren pair which matches the hop sequence. PATH gives the number of | |
976 the paren pair which matches the path name on the remote host. | |
977 | |
978 PATH can also be negative, which means to count from the end. Ie, a | |
979 value of -1 means the last paren pair. | |
980 | |
981 I think it would be good if the regexp matches the whole of the | |
982 string, but I haven't actually tried what happens if it doesn't..." | |
983 :group 'tramp | |
984 :type '(list (regexp :tag "File name regexp") | |
985 (integer :tag "Paren pair for method name") | |
986 (integer :tag "Paren pair for hops") | |
987 (integer :tag "Paren pair to match path"))) | |
988 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
989 (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
|
990 (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
|
991 "\\([^@:/]+\\)@" ;user |
46347
3996ea20e5e3
(tramp-multi-file-name-structure-unified): Add
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46307
diff
changeset
|
992 "\\([^:/]+\\):") ;host |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
993 1 2 3) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
994 "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
|
995 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
|
996 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
|
997 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
998 (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
|
999 (list (concat "/\\([a-z0-9_]+\\):" ;hop method |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1000 "\\([a-z0-9_]+\\)@" ;user |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1001 "\\([a-z0-9.-]+\\)") ;host |
45861 | 1002 1 2 3) |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1003 "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
|
1004 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
|
1005 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
|
1006 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1007 (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
|
1008 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1009 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
|
1010 tramp-multi-file-name-hop-structure-unified) |
45861 | 1011 "*Describes the structure of a hop in multi files. |
1012 This is a list of four elements (REGEXP METHOD USER HOST). First | |
1013 element REGEXP is used to match against the hop. Pair number METHOD | |
1014 matches the method of one hop, pair number USER matches the user of | |
1015 one hop, pair number HOST matches the host of one hop. | |
1016 | |
1017 This regular expression should match exactly all of one hop." | |
1018 :group 'tramp | |
1019 :type '(list (regexp :tag "Hop regexp") | |
1020 (integer :tag "Paren pair for method name") | |
1021 (integer :tag "Paren pair for user name") | |
1022 (integer :tag "Paren pair for host name"))) | |
1023 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1024 (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
|
1025 (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
|
1026 "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
|
1027 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
|
1028 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
|
1029 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1030 (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
|
1031 (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
|
1032 "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
|
1033 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
|
1034 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
|
1035 |
45861 | 1036 (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
|
1037 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1038 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
|
1039 tramp-make-multi-tramp-file-format-unified) |
45861 | 1040 "*Describes how to construct a `multi' file name. |
1041 This is a list of three elements PREFIX, HOP and PATH. | |
1042 | |
1043 The first element PREFIX says how to construct the prefix, the second | |
1044 element HOP specifies what each hop looks like, and the final element | |
1045 PATH says how to construct the path name. | |
1046 | |
1047 In PREFIX, `%%' means `%' and `%m' means the method name. | |
1048 | |
1049 In HOP, `%%' means `%' and `%m', `%u', `%h' mean the hop method, hop | |
1050 user and hop host, respectively. | |
1051 | |
1052 In PATH, `%%' means `%' and `%p' means the path name. | |
1053 | |
1054 The resulting file name always contains one copy of PREFIX and one | |
1055 copy of PATH, but there is one copy of HOP for each hop in the file | |
1056 name. | |
1057 | |
1058 Note: the current implementation requires the prefix to contain the | |
1059 method name, followed by all the hops, and the path name must come | |
1060 last." | |
1061 :group 'tramp | |
1062 :type '(list string string string)) | |
1063 | |
1064 (defcustom tramp-terminal-type "dumb" | |
1065 "*Value of TERM environment variable for logging in to remote host. | |
1066 Because Tramp wants to parse the output of the remote shell, it is easily | |
1067 confused by ANSI color escape sequences and suchlike. Often, shell init | |
1068 files conditionalize this setup based on the TERM environment variable." | |
1069 :group 'tramp | |
1070 :type 'string) | |
1071 | |
1072 (defcustom tramp-completion-without-shell-p nil | |
1073 "*If nil, use shell wildcards for completion, else rely on Lisp only. | |
1074 Using shell wildcards for completions has the advantage that it can be | |
1075 fast even in large directories, but completion is always | |
1076 case-sensitive. Relying on Lisp only means that case-insensitive | |
1077 completion is possible (subject to the variable `completion-ignore-case'), | |
1078 but it might be slow on large directories." | |
1079 :group 'tramp | |
1080 :type 'boolean) | |
1081 | |
46752 | 1082 (defcustom tramp-actions-before-shell |
1083 '((tramp-password-prompt-regexp tramp-action-password) | |
1084 (tramp-login-prompt-regexp tramp-action-login) | |
1085 (shell-prompt-pattern tramp-action-succeed) | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
1086 (tramp-shell-prompt-pattern tramp-action-succeed) |
46752 | 1087 (tramp-wrong-passwd-regexp tramp-action-permission-denied) |
46992
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
1088 (tramp-yesno-prompt-regexp tramp-action-yesno) |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
1089 (tramp-yn-prompt-regexp tramp-action-yn)) |
46752 | 1090 "List of pattern/action pairs. |
1091 Whenever a pattern matches, the corresponding action is performed. | |
1092 Each item looks like (PATTERN ACTION). | |
1093 | |
1094 The PATTERN should be a symbol, a variable. The value of this | |
1095 variable gives the regular expression to search for. Note that the | |
1096 regexp must match at the end of the buffer, \"\\'\" is implicitly | |
1097 appended to it. | |
1098 | |
1099 The ACTION should also be a symbol, but a function. When the | |
1100 corresponding PATTERN matches, the ACTION function is called." | |
1101 :group 'tramp | |
1102 :type '(repeat (list variable function))) | |
1103 | |
1104 (defcustom tramp-multi-actions | |
1105 '((tramp-password-prompt-regexp tramp-multi-action-password) | |
1106 (tramp-login-prompt-regexp tramp-multi-action-login) | |
1107 (shell-prompt-pattern tramp-multi-action-succeed) | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
1108 (tramp-shell-prompt-pattern tramp-multi-action-succeed) |
46752 | 1109 (tramp-wrong-passwd-regexp tramp-multi-action-permission-denied)) |
1110 "List of pattern/action pairs. | |
1111 This list is used for each hop in multi-hop connections. | |
1112 See `tramp-actions-before-shell' for more info." | |
1113 :group 'tramp | |
1114 :type '(repeat (list variable function))) | |
1115 | |
45861 | 1116 ;;; Internal Variables: |
1117 | |
1118 (defvar tramp-buffer-file-attributes nil | |
1119 "Holds the `ls -ild' output for the current buffer. | |
1120 This variable is local to each buffer. It is not used if the remote | |
1121 machine groks Perl. If it is used, it's used as an emulation for | |
1122 the visited file modtime.") | |
1123 (make-variable-buffer-local 'tramp-buffer-file-attributes) | |
1124 | |
1125 (defvar tramp-end-of-output "/////" | |
1126 "String used to recognize end of output.") | |
1127 | |
1128 (defvar tramp-connection-function nil | |
1129 "This internal variable holds a parameter for `tramp-methods'. | |
1130 In the connection buffer, this variable has the value of the like-named | |
1131 method parameter, as specified in `tramp-methods' (which see).") | |
1132 | |
1133 (defvar tramp-remote-sh nil | |
1134 "This internal variable holds a parameter for `tramp-methods'. | |
1135 In the connection buffer, this variable has the value of the like-named | |
1136 method parameter, as specified in `tramp-methods' (which see).") | |
1137 | |
1138 (defvar tramp-rsh-program nil | |
1139 "This internal variable holds a parameter for `tramp-methods'. | |
1140 In the connection buffer, this variable has the value of the like-named | |
1141 method parameter, as specified in `tramp-methods' (which see).") | |
1142 | |
1143 (defvar tramp-rsh-args nil | |
1144 "This internal variable holds a parameter for `tramp-methods'. | |
1145 In the connection buffer, this variable has the value of the like-named | |
1146 method parameter, as specified in `tramp-methods' (which see).") | |
1147 | |
1148 (defvar tramp-rcp-program nil | |
1149 "This internal variable holds a parameter for `tramp-methods'. | |
1150 In the connection buffer, this variable has the value of the like-named | |
1151 method parameter, as specified in `tramp-methods' (which see).") | |
1152 | |
1153 (defvar tramp-rcp-args nil | |
1154 "This internal variable holds a parameter for `tramp-methods'. | |
1155 In the connection buffer, this variable has the value of the like-named | |
1156 method parameter, as specified in `tramp-methods' (which see).") | |
1157 | |
1158 (defvar tramp-rcp-keep-date-arg nil | |
1159 "This internal variable holds a parameter for `tramp-methods'. | |
1160 In the connection buffer, this variable has the value of the like-named | |
1161 method parameter, as specified in `tramp-methods' (which see).") | |
1162 | |
1163 (defvar tramp-encoding-command nil | |
1164 "This internal variable holds a parameter for `tramp-methods'. | |
1165 In the connection buffer, this variable has the value of the like-named | |
1166 method parameter, as specified in `tramp-methods' (which see).") | |
1167 | |
1168 (defvar tramp-decoding-command nil | |
1169 "This internal variable holds a parameter for `tramp-methods'. | |
1170 In the connection buffer, this variable has the value of the like-named | |
1171 method parameter, as specified in `tramp-methods' (which see).") | |
1172 | |
1173 (defvar tramp-encoding-function nil | |
1174 "This internal variable holds a parameter for `tramp-methods'. | |
1175 In the connection buffer, this variable has the value of the like-named | |
1176 method parameter, as specified in `tramp-methods' (which see).") | |
1177 | |
1178 (defvar tramp-decoding-function nil | |
1179 "This internal variable holds a parameter for `tramp-methods'. | |
1180 In the connection buffer, this variable has the value of the like-named | |
1181 method parameter, as specified in `tramp-methods' (which see).") | |
1182 | |
1183 (defvar tramp-telnet-program nil | |
1184 "This internal variable holds a parameter for `tramp-methods'. | |
1185 In the connection buffer, this variable has the value of the like-named | |
1186 method parameter, as specified in `tramp-methods' (which see).") | |
1187 | |
1188 (defvar tramp-telnet-args nil | |
1189 "This internal variable holds a parameter for `tramp-methods'. | |
1190 In the connection buffer, this variable has the value of the like-named | |
1191 method parameter, as specified in `tramp-methods' (which see).") | |
1192 | |
46790 | 1193 (defvar tramp-su-program nil |
1194 "This internal variable holds a parameter for `tramp-methods'. | |
1195 In the connection buffer, this variable has the value of the like-named | |
1196 method parameter, as specified in `tramp-methods' (which see).") | |
1197 | |
45861 | 1198 ;; CCC `local in each buffer'? |
1199 (defvar tramp-ls-command nil | |
1200 "This command is used to get a long listing with numeric user and group ids. | |
1201 This variable is automatically made buffer-local to each rsh process buffer | |
1202 upon opening the connection.") | |
1203 | |
1204 (defvar tramp-current-multi-method nil | |
1205 "Name of `multi' connection method for this *tramp* buffer, or nil if not multi. | |
1206 This variable is automatically made buffer-local to each rsh process buffer | |
1207 upon opening the connection.") | |
1208 | |
1209 (defvar tramp-current-method nil | |
1210 "Connection method for this *tramp* buffer. | |
1211 This variable is automatically made buffer-local to each rsh process buffer | |
1212 upon opening the connection.") | |
1213 | |
1214 (defvar tramp-current-user nil | |
1215 "Remote login name for this *tramp* buffer. | |
1216 This variable is automatically made buffer-local to each rsh process buffer | |
1217 upon opening the connection.") | |
1218 | |
1219 (defvar tramp-current-host nil | |
1220 "Remote host for this *tramp* buffer. | |
1221 This variable is automatically made buffer-local to each rsh process buffer | |
1222 upon opening the connection.") | |
1223 | |
1224 (defvar tramp-test-groks-nt nil | |
1225 "Whether the `test' command groks the `-nt' switch. | |
1226 \(`test A -nt B' tests if file A is newer than file B.) | |
1227 This variable is automatically made buffer-local to each rsh process buffer | |
1228 upon opening the connection.") | |
1229 | |
1230 (defvar tramp-file-exists-command nil | |
1231 "Command to use for checking if a file exists. | |
1232 This variable is automatically made buffer-local to each rsh process buffer | |
1233 upon opening the connection.") | |
1234 | |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1235 (defconst tramp-uudecode "\ |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1236 tramp_uudecode () { |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1237 \(echo begin 600 /tmp/tramp.$$; tail +2) | uudecode |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1238 cat /tmp/tramp.$$ |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1239 rm -f /tmp/tramp.$$ |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1240 }" |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1241 "Shell function to implement `uudecode' to standard output. |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1242 Many systems support `uudecode -o -' for this or `uudecode -p', but |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1243 some systems don't, and for them we have this shell function.") |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1244 |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1245 ;; Perl script to implement `file-attributes' in a Lisp `read'able |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1246 ;; output. If you are hacking on this, note that you get *no* output |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1247 ;; unless this spits out a complete line, including the '\n' at the |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1248 ;; end. |
46808
cf225aed7a75
Version 2.0.11 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46802
diff
changeset
|
1249 (defconst tramp-perl-file-attributes "\ |
cf225aed7a75
Version 2.0.11 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46802
diff
changeset
|
1250 $f = $ARGV[0]; |
45861 | 1251 @s = lstat($f); |
1252 if (($s[2] & 0170000) == 0120000) { $l = readlink($f); $l = \"\\\"$l\\\"\"; } | |
1253 elsif (($s[2] & 0170000) == 040000) { $l = \"t\"; } | |
1254 else { $l = \"nil\" }; | |
46808
cf225aed7a75
Version 2.0.11 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46802
diff
changeset
|
1255 printf(\"(%s %u %d %d (%u %u) (%u %u) (%u %u) %u %u t (%u . %u) (%u %u))\\n\", |
45861 | 1256 $l, $s[3], $s[4], $s[5], $s[8] >> 16 & 0xffff, $s[8] & 0xffff, |
1257 $s[9] >> 16 & 0xffff, $s[9] & 0xffff, $s[10] >> 16 & 0xffff, $s[10] & 0xffff, | |
1258 $s[7], $s[2], $s[1] >> 16 & 0xffff, $s[1] & 0xffff, $s[0] >> 16 & 0xffff, $s[0] & 0xffff);" | |
1259 "Perl script to produce output suitable for use with `file-attributes' | |
1260 on the remote file system.") | |
1261 | |
46752 | 1262 ;; ;; These two use uu encoding. |
1263 ;; (defvar tramp-perl-encode "%s -e'\ | |
1264 ;; print qq(begin 644 xxx\n); | |
1265 ;; my $s = q(); | |
1266 ;; my $res = q(); | |
1267 ;; while (read(STDIN, $s, 45)) { | |
1268 ;; print pack(q(u), $s); | |
1269 ;; } | |
1270 ;; print qq(`\n); | |
1271 ;; print qq(end\n); | |
1272 ;; '" | |
1273 ;; "Perl program to use for encoding a file. | |
1274 ;; Escape sequence %s is replaced with name of Perl binary.") | |
1275 | |
1276 ;; (defvar tramp-perl-decode "%s -ne ' | |
1277 ;; print unpack q(u), $_; | |
1278 ;; '" | |
1279 ;; "Perl program to use for decoding a file. | |
1280 ;; Escape sequence %s is replaced with name of Perl binary.") | |
1281 | |
1282 ;; These two use base64 encoding. | |
46790 | 1283 (defvar tramp-perl-encode-with-module |
1284 "perl -MMIME::Base64 -0777 -ne 'print encode_base64($_)'" | |
1285 "Perl program to use for encoding a file. | |
1286 Escape sequence %s is replaced with name of Perl binary. | |
46801
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
1287 This string is passed to `format', so percent characters need to be doubled. |
46790 | 1288 This implementation requires the MIME::Base64 Perl module to be installed |
1289 on the remote host.") | |
1290 | |
1291 (defvar tramp-perl-decode-with-module | |
1292 "perl -MMIME::Base64 -0777 -ne 'print decode_base64($_)'" | |
1293 "Perl program to use for decoding a file. | |
1294 Escape sequence %s is replaced with name of Perl binary. | |
46801
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
1295 This string is passed to `format', so percent characters need to be doubled. |
46790 | 1296 This implementation requires the MIME::Base64 Perl module to be installed |
1297 on the remote host.") | |
1298 | |
46752 | 1299 (defvar tramp-perl-encode |
46790 | 1300 "%s -e ' |
1301 # This script contributed by Juanma Barranquero <lektu@terra.es>. | |
1302 # Copyright (C) 2002 Free Software Foundation, Inc. | |
1303 use strict; | |
1304 | |
46795 | 1305 my %%trans = do { |
46790 | 1306 my $i = 0; |
1307 map {(substr(unpack(q(B8), chr $i++), 2, 6), $_)} | |
1308 split //, q(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/); | |
1309 }; | |
1310 | |
46797 | 1311 binmode(\\*STDIN); |
46790 | 1312 |
1313 # We read in chunks of 54 bytes, to generate output lines | |
1314 # of 72 chars (plus end of line) | |
46797 | 1315 $/ = \\54; |
46790 | 1316 |
1317 while (my $data = <STDIN>) { | |
1318 my $pad = q(); | |
1319 | |
1320 # Only for the last chunk, and only if did not fill the last three-byte packet | |
1321 if (eof) { | |
46795 | 1322 my $mod = length($data) %% 3; |
46790 | 1323 $pad = q(=) x (3 - $mod) if $mod; |
1324 } | |
1325 | |
1326 # Not the fastest method, but it is simple: unpack to binary string, split | |
1327 # by groups of 6 bits and convert back from binary to byte; then map into | |
1328 # the translation table | |
1329 print | |
1330 join q(), | |
1331 map($trans{$_}, | |
1332 (substr(unpack(q(B*), $data) . q(00000), 0, 432) =~ /....../g)), | |
1333 $pad, | |
46797 | 1334 qq(\\n); |
46790 | 1335 } |
1336 '" | |
46752 | 1337 "Perl program to use for encoding a file. |
46795 | 1338 Escape sequence %s is replaced with name of Perl binary. |
46799
c9fab7d532d1
(tramp-perl-encode, tramp-perl-decode): Doc fix.
Andreas Schwab <schwab@suse.de>
parents:
46797
diff
changeset
|
1339 This string is passed to `format', so percent characters need to be doubled.") |
46752 | 1340 |
1341 (defvar tramp-perl-decode | |
46790 | 1342 "%s -e ' |
1343 # This script contributed by Juanma Barranquero <lektu@terra.es>. | |
1344 # Copyright (C) 2002 Free Software Foundation, Inc. | |
1345 use strict; | |
1346 | |
46795 | 1347 my %%trans = do { |
46790 | 1348 my $i = 0; |
46795 | 1349 map {($_, sprintf(q(%%06b), $i++))} |
46790 | 1350 split //, q(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/) |
1351 }; | |
1352 | |
46795 | 1353 my %%bytes = map {(unpack(q(B8), chr $_), chr $_)} 0 .. 255; |
46790 | 1354 |
46797 | 1355 binmode(\\*STDOUT); |
46790 | 1356 |
1357 # We are going to accumulate into $pending to accept any line length | |
1358 # (we do not check they are <= 76 chars as the RFC says) | |
1359 my $pending = q(); | |
1360 | |
1361 while (my $data = <STDIN>) { | |
1362 chomp $data; | |
1363 | |
1364 # If we find one or two =, we have reached the end and | |
1365 # any following data is to be discarded | |
1366 my $finished = $data =~ s/(==?).*/$1/; | |
1367 $pending .= $data; | |
1368 | |
1369 my $len = length($pending); | |
1370 my $chunk = substr($pending, 0, $len & ~3, q()); | |
1371 | |
1372 # Easy method: translate from chars to (pregenerated) six-bit packets, join, | |
1373 # split in 8-bit chunks and convert back to char. | |
1374 print join q(), | |
1375 map $bytes{$_}, | |
1376 ((join q(), map {$trans{$_} || q()} split //, $chunk) =~ /......../g); | |
1377 | |
1378 last if $finished; | |
1379 } | |
1380 '" | |
46752 | 1381 "Perl program to use for decoding a file. |
46795 | 1382 Escape sequence %s is replaced with name of Perl binary. |
46799
c9fab7d532d1
(tramp-perl-encode, tramp-perl-decode): Doc fix.
Andreas Schwab <schwab@suse.de>
parents:
46797
diff
changeset
|
1383 This string is passed to `format', so percent characters need to be doubled.") |
45861 | 1384 |
1385 ; These values conform to `file-attributes' from XEmacs 21.2. | |
1386 ; GNU Emacs and other tools not checked. | |
1387 (defconst tramp-file-mode-type-map '((0 . "-") ; Normal file (SVID-v2 and XPG2) | |
1388 (1 . "p") ; fifo | |
1389 (2 . "c") ; character device | |
1390 (3 . "m") ; multiplexed character device (v7) | |
1391 (4 . "d") ; directory | |
1392 (5 . "?") ; Named special file (XENIX) | |
1393 (6 . "b") ; block device | |
1394 (7 . "?") ; multiplexed block device (v7) | |
1395 (8 . "-") ; regular file | |
1396 (9 . "n") ; network special file (HP-UX) | |
1397 (10 . "l") ; symlink | |
1398 (11 . "?") ; ACL shadow inode (Solaris, not userspace) | |
1399 (12 . "s") ; socket | |
1400 (13 . "D") ; door special (Solaris) | |
1401 (14 . "w")) ; whiteout (BSD) | |
1402 "A list of file types returned from the `stat' system call. | |
1403 This is used to map a mode number to a permission string.") | |
1404 | |
1405 (defvar tramp-dos-coding-system | |
1406 (if (and (fboundp 'coding-system-p) | |
1407 (funcall 'coding-system-p '(dos))) | |
1408 'dos | |
1409 'undecided-dos) | |
1410 "Some Emacsen know the `dos' coding system, others need `undecided-dos'.") | |
1411 | |
46752 | 1412 (defvar tramp-last-cmd-time nil |
1413 "Internal Tramp variable recording the time when the last cmd was sent. | |
1414 This variable is buffer-local in every buffer.") | |
1415 (make-variable-buffer-local 'tramp-last-cmd-time) | |
45861 | 1416 |
46992
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
1417 (defvar tramp-feature-write-region-fix |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
1418 (let ((file-coding-system-alist '(("test" emacs-mule)))) |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
1419 (find-operation-coding-system 'write-region 0 0 "" nil "test")) |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
1420 "Internal variable to say if `write-region' chooses the right coding. |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
1421 Older versions of Emacs chose the coding system for `write-region' based |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
1422 on the FILENAME argument, even if VISIT was a string.") |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
1423 |
45861 | 1424 ;; New handlers should be added here. The following operations can be |
1425 ;; handled using the normal primitives: file-name-as-directory, | |
1426 ;; file-name-directory, file-name-nondirectory, | |
1427 ;; file-name-sans-versions, get-file-buffer. | |
1428 (defconst tramp-file-name-handler-alist | |
1429 '( | |
1430 (load . tramp-handle-load) | |
1431 (make-symbolic-link . tramp-handle-make-symbolic-link) | |
1432 (file-name-directory . tramp-handle-file-name-directory) | |
1433 (file-name-nondirectory . tramp-handle-file-name-nondirectory) | |
1434 (file-truename . tramp-handle-file-truename) | |
1435 (file-exists-p . tramp-handle-file-exists-p) | |
1436 (file-directory-p . tramp-handle-file-directory-p) | |
1437 (file-executable-p . tramp-handle-file-executable-p) | |
1438 (file-accessible-directory-p . tramp-handle-file-accessible-directory-p) | |
1439 (file-readable-p . tramp-handle-file-readable-p) | |
1440 (file-regular-p . tramp-handle-file-regular-p) | |
1441 (file-symlink-p . tramp-handle-file-symlink-p) | |
1442 (file-writable-p . tramp-handle-file-writable-p) | |
1443 (file-ownership-preserved-p . tramp-handle-file-ownership-preserved-p) | |
1444 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) | |
1445 (file-attributes . tramp-handle-file-attributes) | |
1446 (file-modes . tramp-handle-file-modes) | |
1447 (file-directory-files . tramp-handle-file-directory-files) | |
1448 (directory-files . tramp-handle-directory-files) | |
1449 (file-name-all-completions . tramp-handle-file-name-all-completions) | |
1450 (file-name-completion . tramp-handle-file-name-completion) | |
1451 (add-name-to-file . tramp-handle-add-name-to-file) | |
1452 (copy-file . tramp-handle-copy-file) | |
1453 (rename-file . tramp-handle-rename-file) | |
1454 (set-file-modes . tramp-handle-set-file-modes) | |
1455 (make-directory . tramp-handle-make-directory) | |
1456 (delete-directory . tramp-handle-delete-directory) | |
1457 (delete-file . tramp-handle-delete-file) | |
1458 (directory-file-name . tramp-handle-directory-file-name) | |
1459 (shell-command . tramp-handle-shell-command) | |
1460 (insert-directory . tramp-handle-insert-directory) | |
1461 (expand-file-name . tramp-handle-expand-file-name) | |
1462 (file-local-copy . tramp-handle-file-local-copy) | |
1463 (insert-file-contents . tramp-handle-insert-file-contents) | |
1464 (write-region . tramp-handle-write-region) | |
1465 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory) | |
1466 (dired-call-process . tramp-handle-dired-call-process) | |
1467 (dired-recursive-delete-directory | |
1468 . tramp-handle-dired-recursive-delete-directory) | |
1469 (set-visited-file-modtime . tramp-handle-set-visited-file-modtime) | |
1470 (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)) | |
1471 "Alist of handler functions. | |
1472 Operations not mentioned here will be handled by the normal Emacs functions.") | |
1473 | |
1474 ;;; Internal functions which must come first. | |
1475 | |
1476 (defsubst tramp-message (level fmt-string &rest args) | |
1477 "Emit a message depending on verbosity level. | |
1478 First arg LEVEL says to be quiet if `tramp-verbose' is less than LEVEL. The | |
1479 message is emitted only if `tramp-verbose' is greater than or equal to LEVEL. | |
1480 Calls function `message' with FMT-STRING as control string and the remaining | |
1481 ARGS to actually emit the message (if applicable). | |
1482 | |
1483 This function expects to be called from the tramp buffer only!" | |
1484 (when (<= level tramp-verbose) | |
1485 (apply #'message (concat "tramp: " fmt-string) args) | |
1486 (when tramp-debug-buffer | |
1487 (save-excursion | |
1488 (set-buffer | |
1489 (tramp-get-debug-buffer | |
1490 tramp-current-multi-method tramp-current-method | |
1491 tramp-current-user tramp-current-host)) | |
1492 (goto-char (point-max)) | |
1493 (tramp-insert-with-face | |
1494 'italic | |
1495 (concat "# " (apply #'format fmt-string args) "\n")))))) | |
1496 | |
1497 (defun tramp-message-for-buffer | |
1498 (multi-method method user host level fmt-string &rest args) | |
1499 "Like `tramp-message' but temporarily switches to the tramp buffer. | |
1500 First three args METHOD, USER, and HOST identify the tramp buffer to use, | |
1501 remaining args passed to `tramp-message'." | |
1502 (save-excursion | |
1503 (set-buffer (tramp-get-buffer multi-method method user host)) | |
1504 (apply 'tramp-message level fmt-string args))) | |
1505 | |
1506 (defsubst tramp-line-end-position nil | |
1507 "Return point at end of line. | |
1508 Calls `line-end-position' or `point-at-eol' if defined, else | |
1509 own implementation." | |
1510 (cond | |
1511 ((fboundp 'line-end-position) (funcall 'line-end-position)) | |
1512 ((fboundp 'point-at-eol) (funcall 'point-at-eol)) | |
1513 (t (save-excursion (end-of-line) (point))))) | |
1514 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1515 (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
|
1516 "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
|
1517 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1518 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
|
1519 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
|
1520 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
|
1521 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
|
1522 `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
|
1523 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
|
1524 `foo-user', `foo-host', `foo-path'. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1525 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1526 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
|
1527 `progn'). |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1528 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1529 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
|
1530 `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
|
1531 `(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
|
1532 (,(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
|
1533 (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
|
1534 (,(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
|
1535 (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
|
1536 (,(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
|
1537 (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
|
1538 (,(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
|
1539 (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
|
1540 (,(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
|
1541 (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
|
1542 ,@body)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1543 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1544 (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
|
1545 |
45861 | 1546 ;;; File Name Handler Functions: |
1547 | |
1548 (defun tramp-handle-make-symbolic-link | |
1549 (filename linkname &optional ok-if-already-exists) | |
1550 "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
|
1551 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
|
1552 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
|
1553 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
|
1554 |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1555 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
|
1556 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
|
1557 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
|
1558 target of the symlink differ." |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1559 (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
|
1560 (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
|
1561 (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
|
1562 filename linkname ok-if-already-exists)) |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1563 (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
|
1564 (cwd (file-name-directory l-path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1565 (unless ln |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1566 (signal 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1567 (list "Making a symbolic link." |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1568 "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
|
1569 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1570 ;; 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
|
1571 (when (file-exists-p linkname) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1572 ;; What to do? |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1573 (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
|
1574 (and (numberp ok-if-already-exists) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1575 (not (yes-or-no-p |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1576 (format |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1577 "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
|
1578 l-path))))) |
46307
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1579 (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
|
1580 (delete-file linkname))) |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1581 |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1582 ;; 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
|
1583 (when (tramp-tramp-file-p filename) |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1584 (setq filename (tramp-file-name-path |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1585 (tramp-dissect-file-name |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1586 (expand-file-name filename))))) |
45861 | 1587 |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1588 ;; 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
|
1589 ;; 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
|
1590 ;; that FILENAME belongs to. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1591 (zerop |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1592 (tramp-send-command-and-check |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1593 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
|
1594 (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
|
1595 cwd ln |
46307
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1596 filename |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1597 l-path) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1598 t))))) |
45861 | 1599 |
1600 | |
1601 (defun tramp-handle-load (file &optional noerror nomessage nosuffix must-suffix) | |
1602 "Like `load' for tramp files. Not implemented!" | |
1603 (unless (file-name-absolute-p file) | |
1604 (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
|
1605 (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
|
1606 (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
|
1607 (tramp-invoke-ange-ftp 'load |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1608 file noerror nomessage nosuffix must-suffix)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1609 (unless nosuffix |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1610 (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
|
1611 (setq file (concat file ".elc"))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1612 ((file-exists-p (concat file ".el")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1613 (setq file (concat file ".el"))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1614 (when must-suffix |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1615 ;; 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
|
1616 ;; Included for safety's sake. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1617 (unless (or (file-name-directory file) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1618 (string-match "\\.elc?\\'" file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1619 (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
|
1620 file))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1621 (unless noerror |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1622 (when (not (file-exists-p file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1623 (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
|
1624 (if (not (file-exists-p file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1625 nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1626 (unless nomessage |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1627 (message "Loading %s..." file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1628 (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
|
1629 ;; 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
|
1630 (load local-copy noerror t t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1631 (delete-file local-copy)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1632 (unless nomessage |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1633 (message "Loading %s...done" file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1634 t))) |
45861 | 1635 |
1636 ;; Path manipulation functions that grok TRAMP paths... | |
1637 (defun tramp-handle-file-name-directory (file) | |
1638 "Like `file-name-directory' but aware of TRAMP files." | |
1639 ;; 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
|
1640 (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
|
1641 (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
|
1642 (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
|
1643 ;; 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
|
1644 ;; (1) (string= path "") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1645 ;; (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
|
1646 ;; 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
|
1647 ;; 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
|
1648 ;; "/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
|
1649 ;; We should do some investigation. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1650 (if (string= path "") |
45861 | 1651 ;; For a filename like "/[foo]", we return "/". The `else' |
1652 ;; case would return "/[foo]" unchanged. But if we do that, | |
1653 ;; then `file-expand-wildcards' ceases to work. It's not | |
1654 ;; quite clear to me what's the intuition that tells that this | |
1655 ;; behavior is the right behavior, but oh, well. | |
1656 "/" | |
1657 ;; run the command on the path portion only | |
1658 ;; CCC: This should take into account the remote machine type, no? | |
1659 ;; --daniel <daniel@danann.net> | |
1660 (tramp-make-tramp-file-name multi-method method user host | |
1661 ;; This will not recurse... | |
1662 (or (file-name-directory path) ""))))) | |
1663 | |
1664 (defun tramp-handle-file-name-nondirectory (file) | |
1665 "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
|
1666 (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
|
1667 (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
|
1668 (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
|
1669 (file-name-nondirectory path))) |
45861 | 1670 |
1671 (defun tramp-handle-file-truename (filename &optional counter prev-dirs) | |
1672 "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
|
1673 (with-parsed-tramp-file-name filename nil |
46790 | 1674 ;; Ange-FTP does not support truename processing, but for |
1675 ;; convenience we pretend it did and forward the call to Ange-FTP | |
1676 ;; anyway. Ange-FTP then just invokes `identity'. | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1677 (when (tramp-ange-ftp-file-name-p multi-method method) |
46790 | 1678 (tramp-invoke-ange-ftp 'file-truename filename)) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1679 (let* ((steps (tramp-split-string path "/")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1680 (pathdir (let ((directory-sep-char ?/)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1681 (file-name-as-directory path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1682 (is-dir (string= path pathdir)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1683 (thisstep nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1684 (numchase 0) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1685 ;; 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
|
1686 ;; 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
|
1687 ;; 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
|
1688 ;; 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
|
1689 (numchase-limit 20) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1690 (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
|
1691 (curstri "") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1692 symlink-target) |
45861 | 1693 (tramp-message-for-buffer |
1694 multi-method method user host | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1695 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
|
1696 (while (and steps (< numchase numchase-limit)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1697 (setq thisstep (pop steps)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1698 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1699 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1700 10 "Check %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1701 (mapconcat 'identity |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1702 (append '("") (reverse result) (list thisstep)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1703 "/")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1704 (setq symlink-target |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1705 (nth 0 (tramp-handle-file-attributes |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1706 (tramp-make-tramp-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1707 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1708 (mapconcat 'identity |
46790 | 1709 (append '("") |
1710 (reverse result) | |
1711 (list thisstep)) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1712 "/"))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1713 (cond ((string= "." thisstep) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1714 (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
|
1715 10 "Ignoring step `.'")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1716 ((string= ".." thisstep) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1717 (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
|
1718 10 "Processing step `..'") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1719 (pop result)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1720 ((stringp symlink-target) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1721 ;; It's a symlink, follow it. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1722 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1723 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1724 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
|
1725 (setq numchase (1+ numchase)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1726 (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
|
1727 (setq result nil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1728 (setq steps |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1729 (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
|
1730 (t |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1731 ;; It's a file. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1732 (setq result (cons thisstep result))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1733 (when (>= numchase numchase-limit) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1734 (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
|
1735 (setq result (reverse result)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1736 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1737 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1738 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
|
1739 filename (mapconcat 'identity (cons "" result) "/")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1740 (tramp-make-tramp-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1741 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1742 (concat (mapconcat 'identity (cons "" result) "/") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1743 (if is-dir "/" "")))))) |
45861 | 1744 |
1745 ;; Basic functions. | |
1746 | |
1747 (defun tramp-handle-file-exists-p (filename) | |
1748 "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
|
1749 (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
|
1750 (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
|
1751 (tramp-invoke-ange-ftp 'file-exists-p filename)) |
45861 | 1752 (save-excursion |
1753 (zerop (tramp-send-command-and-check | |
1754 multi-method method user host | |
1755 (format | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1756 (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
|
1757 (tramp-shell-quote-argument path))))))) |
45861 | 1758 |
1759 ;; CCC: This should check for an error condition and signal failure | |
1760 ;; when something goes wrong. | |
1761 ;; Daniel Pittman <daniel@danann.net> | |
1762 (defun tramp-handle-file-attributes (filename &optional nonnumeric) | |
1763 "Like `file-attributes' for tramp files. | |
1764 Optional argument NONNUMERIC means return user and group name | |
1765 rather than as numbers." | |
46752 | 1766 (let (result) |
1767 (with-parsed-tramp-file-name filename nil | |
1768 (when (tramp-ange-ftp-file-name-p multi-method method) | |
1769 (tramp-invoke-ange-ftp 'file-attributes filename)) | |
1770 (when (tramp-handle-file-exists-p filename) | |
1771 ;; file exists, find out stuff | |
1772 (save-excursion | |
45861 | 1773 (if (tramp-get-remote-perl multi-method method user host) |
46752 | 1774 (setq result |
1775 (tramp-handle-file-attributes-with-perl | |
1776 multi-method method user host path nonnumeric)) | |
1777 (setq result | |
1778 (tramp-handle-file-attributes-with-ls | |
1779 multi-method method user host path nonnumeric)))))) | |
1780 result)) | |
45861 | 1781 |
1782 | |
1783 (defun tramp-handle-file-attributes-with-ls | |
1784 (multi-method method user host path &optional nonnumeric) | |
1785 "Implement `file-attributes' for tramp files using the ls(1) command." | |
1786 (let (symlinkp dirp | |
1787 res-inode res-filemodes res-numlinks | |
1788 res-uid res-gid res-size res-symlink-target) | |
46752 | 1789 (tramp-message-for-buffer multi-method method user host 10 |
1790 "file attributes with ls: %s" | |
1791 (tramp-make-tramp-file-name | |
1792 multi-method method user host path)) | |
45861 | 1793 (tramp-send-command |
1794 multi-method method user host | |
1795 (format "%s %s %s" | |
1796 (tramp-get-ls-command multi-method method user host) | |
1797 (if nonnumeric "-ild" "-ildn") | |
1798 (tramp-shell-quote-argument path))) | |
1799 (tramp-wait-for-output) | |
1800 ;; parse `ls -l' output ... | |
1801 ;; ... inode | |
1802 (setq res-inode | |
1803 (condition-case err | |
1804 (read (current-buffer)) | |
1805 (invalid-read-syntax | |
1806 (when (and (equal (cadr err) | |
1807 "Integer constant overflow in reader") | |
1808 (string-match | |
1809 "^[0-9]+\\([0-9][0-9][0-9][0-9][0-9]\\)\\'" | |
1810 (caddr err))) | |
1811 (let* ((big (read (substring (caddr err) 0 | |
1812 (match-beginning 1)))) | |
1813 (small (read (match-string 1 (caddr err)))) | |
1814 (twiddle (/ small 65536))) | |
1815 (cons (+ big twiddle) | |
1816 (- small (* twiddle 65536)))))))) | |
1817 ;; ... file mode flags | |
1818 (setq res-filemodes (symbol-name (read (current-buffer)))) | |
1819 ;; ... number links | |
1820 (setq res-numlinks (read (current-buffer))) | |
1821 ;; ... uid and gid | |
1822 (setq res-uid (read (current-buffer))) | |
1823 (setq res-gid (read (current-buffer))) | |
1824 (unless nonnumeric | |
1825 (unless (numberp res-uid) (setq res-uid -1)) | |
1826 (unless (numberp res-gid) (setq res-gid -1))) | |
1827 ;; ... size | |
1828 (setq res-size (read (current-buffer))) | |
1829 ;; From the file modes, figure out other stuff. | |
1830 (setq symlinkp (eq ?l (aref res-filemodes 0))) | |
1831 (setq dirp (eq ?d (aref res-filemodes 0))) | |
1832 ;; if symlink, find out file name pointed to | |
1833 (when symlinkp | |
1834 (search-forward "-> ") | |
1835 (setq res-symlink-target | |
1836 (buffer-substring (point) | |
1837 (tramp-line-end-position)))) | |
1838 ;; return data gathered | |
1839 (list | |
1840 ;; 0. t for directory, string (name linked to) for symbolic | |
1841 ;; link, or nil. | |
1842 (or dirp res-symlink-target nil) | |
1843 ;; 1. Number of links to file. | |
1844 res-numlinks | |
1845 ;; 2. File uid. | |
1846 res-uid | |
1847 ;; 3. File gid. | |
1848 res-gid | |
1849 ;; 4. Last access time, as a list of two integers. First | |
1850 ;; integer has high-order 16 bits of time, second has low 16 | |
1851 ;; bits. | |
1852 ;; 5. Last modification time, likewise. | |
1853 ;; 6. Last status change time, likewise. | |
1854 '(0 0) '(0 0) '(0 0) ;CCC how to find out? | |
1855 ;; 7. Size in bytes (-1, if number is out of range). | |
1856 res-size | |
1857 ;; 8. File modes, as a string of ten letters or dashes as in ls -l. | |
1858 res-filemodes | |
1859 ;; 9. t iff file's gid would change if file were deleted and | |
1860 ;; recreated. | |
1861 nil ;hm? | |
1862 ;; 10. inode number. | |
1863 res-inode | |
1864 ;; 11. Device number. | |
1865 -1 ;hm? | |
1866 ))) | |
1867 | |
1868 (defun tramp-handle-file-attributes-with-perl | |
1869 (multi-method method user host path &optional nonnumeric) | |
1870 "Implement `file-attributes' for tramp files using a Perl script. | |
1871 | |
1872 The Perl command is sent to the remote machine when the connection | |
1873 is initially created and is kept cached by the remote shell." | |
46752 | 1874 (tramp-message-for-buffer multi-method method user host 10 |
1875 "file attributes with perl: %s" | |
1876 (tramp-make-tramp-file-name | |
1877 multi-method method user host path)) | |
45861 | 1878 (tramp-send-command |
1879 multi-method method user host | |
1880 (format "tramp_file_attributes %s" | |
1881 (tramp-shell-quote-argument path))) | |
1882 (tramp-wait-for-output) | |
1883 (let ((result (read (current-buffer)))) | |
1884 (setcar (nthcdr 8 result) | |
1885 (tramp-file-mode-from-int (nth 8 result))) | |
1886 result)) | |
1887 | |
1888 (defun tramp-handle-set-visited-file-modtime (&optional time-list) | |
1889 "Like `set-visited-file-modtime' for tramp files." | |
1890 (unless (buffer-file-name) | |
1891 (error "Can't set-visited-file-modtime: buffer `%s' not visiting a file" | |
1892 (buffer-name))) | |
1893 (when time-list | |
1894 (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
|
1895 (let ((f (buffer-file-name)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1896 (coding-system-used nil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1897 (with-parsed-tramp-file-name f nil |
46790 | 1898 ;; This operation is not handled by Ange-FTP! Compare this |
1899 ;; behavior with `file-truename' which Ange-FTP does not really | |
1900 ;; handle, either, but at least it pretends to. I wonder if | |
1901 ;; Ange-FTP should also pretend to grok | |
1902 ;; `set-visited-file-modtime', for consistency? | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1903 (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
|
1904 (throw 'tramp-forward-to-ange-ftp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1905 (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
|
1906 (list time-list)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1907 (let* ((attr (file-attributes f)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1908 (modtime (nth 5 attr))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1909 ;; 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
|
1910 ;; `tramp-handle-file-attributes-with-ls'. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1911 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1912 (setq coding-system-used last-coding-system-used)) |
45861 | 1913 (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
|
1914 (tramp-run-real-handler 'set-visited-file-modtime (list modtime)) |
45861 | 1915 (save-excursion |
1916 (tramp-send-command | |
1917 multi-method method user host | |
1918 (format "%s -ild %s" | |
1919 (tramp-get-ls-command multi-method method user host) | |
1920 (tramp-shell-quote-argument path))) | |
1921 (tramp-wait-for-output) | |
1922 (setq attr (buffer-substring (point) | |
1923 (progn (end-of-line) (point))))) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1924 (setq tramp-buffer-file-attributes attr)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1925 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1926 (setq last-coding-system-used coding-system-used)) |
45861 | 1927 nil)))) |
1928 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1929 ;; CCC continue here |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1930 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1931 ;; 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
|
1932 ;; `tramp-handle-set-visited-file-modtime'. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1933 (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
|
1934 "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
|
1935 (with-current-buffer buf |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1936 (let ((f (buffer-file-name))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1937 (with-parsed-tramp-file-name f nil |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1938 (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
|
1939 ;; 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
|
1940 ;; on the arg list. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1941 (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
|
1942 user host path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1943 (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
|
1944 (let* ((attr (file-attributes f)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1945 (modtime (nth 5 attr))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1946 (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
|
1947 ;; 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
|
1948 ;; 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
|
1949 ;; (HIGH . LOW)? |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1950 (let ((mt (visited-file-modtime))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1951 (< (abs (tramp-time-diff |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1952 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
|
1953 (attr |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1954 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1955 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1956 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1957 (format "%s -ild %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1958 (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
|
1959 user host) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1960 (tramp-shell-quote-argument path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1961 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1962 (setq attr (buffer-substring |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1963 (point) (progn (end-of-line) (point))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1964 (equal tramp-buffer-file-attributes attr)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1965 ;; 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
|
1966 (t nil))))))) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1967 |
45861 | 1968 (defadvice clear-visited-file-modtime (after tramp activate) |
1969 "Set `tramp-buffer-file-attributes' back to nil. | |
1970 Tramp uses this variable as an emulation for the actual modtime of the file, | |
1971 if the remote host can't provide the modtime." | |
1972 (setq tramp-buffer-file-attributes nil)) | |
1973 | |
1974 (defun tramp-handle-set-file-modes (filename mode) | |
1975 "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
|
1976 (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
|
1977 (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
|
1978 (tramp-invoke-ange-ftp 'set-file-modes filename mode)) |
45861 | 1979 (save-excursion |
1980 (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
|
1981 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1982 (format "chmod %s %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1983 (tramp-decimal-to-octal mode) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1984 (tramp-shell-quote-argument path)))) |
45861 | 1985 (signal 'file-error |
1986 (list "Doing chmod" | |
1987 ;; FIXME: extract the proper text from chmod's stderr. | |
1988 "error while changing file's mode" | |
1989 filename)))))) | |
1990 | |
1991 ;; Simple functions using the `test' command. | |
1992 | |
1993 (defun tramp-handle-file-executable-p (filename) | |
1994 "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
|
1995 (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
|
1996 (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
|
1997 (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
|
1998 (zerop (tramp-run-test "-x" filename)))) |
45861 | 1999 |
2000 (defun tramp-handle-file-readable-p (filename) | |
2001 "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
|
2002 (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
|
2003 (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
|
2004 (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
|
2005 (zerop (tramp-run-test "-r" filename)))) |
45861 | 2006 |
2007 (defun tramp-handle-file-accessible-directory-p (filename) | |
2008 "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
|
2009 (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
|
2010 (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
|
2011 (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
|
2012 (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
|
2013 (zerop (tramp-run-test "-r" filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2014 (zerop (tramp-run-test "-x" filename))))) |
45861 | 2015 |
2016 ;; When the remote shell is started, it looks for a shell which groks | |
2017 ;; tilde expansion. Here, we assume that all shells which grok tilde | |
2018 ;; expansion will also provide a `test' command which groks `-nt' (for | |
2019 ;; newer than). If this breaks, tell me about it and I'll try to do | |
2020 ;; something smarter about it. | |
2021 (defun tramp-handle-file-newer-than-file-p (file1 file2) | |
2022 "Like `file-newer-than-file-p' for tramp files." | |
2023 (cond ((not (file-exists-p file1)) | |
2024 nil) | |
2025 ((not (file-exists-p file2)) | |
2026 t) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2027 ;; 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
|
2028 ;; 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
|
2029 ;; message. Todo: make a better error message. |
45861 | 2030 (t |
2031 (save-excursion | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2032 (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
|
2033 (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
|
2034 (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
|
2035 (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
|
2036 (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
|
2037 file1 file2)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2038 (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
|
2039 (equal v1-method v2-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2040 (equal v1-user v2-user) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2041 (equal v1-host v2-host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2042 (signal 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2043 (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
|
2044 file1 file2))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2045 (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
|
2046 (tramp-tramp-file-p file2)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2047 (signal 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2048 (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
|
2049 file1 file2))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2050 (if (tramp-get-test-groks-nt |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2051 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
|
2052 (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
|
2053 (zerop (tramp-run-test2 "tramp_test_nt" file1 file2))))))))) |
45861 | 2054 |
2055 ;; Functions implemented using the basic functions above. | |
2056 | |
2057 (defun tramp-handle-file-modes (filename) | |
2058 "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
|
2059 (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
|
2060 (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
|
2061 (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
|
2062 (when (file-exists-p filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2063 (tramp-mode-string-to-int |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2064 (nth 8 (tramp-handle-file-attributes filename)))))) |
45861 | 2065 |
2066 (defun tramp-handle-file-directory-p (filename) | |
2067 "Like `file-directory-p' for tramp files." | |
2068 ;; Care must be taken that this function returns `t' for symlinks | |
2069 ;; pointing to directories. Surely the most obvious implementation | |
2070 ;; would be `test -d', but that returns false for such symlinks. | |
2071 ;; CCC: Stefan Monnier says that `test -d' follows symlinks. And | |
2072 ;; I now think he's right. So we could be using `test -d', couldn't | |
2073 ;; we? | |
2074 ;; | |
2075 ;; 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
|
2076 (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
|
2077 (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
|
2078 (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
|
2079 (save-excursion |
45861 | 2080 (zerop |
2081 (tramp-send-command-and-check | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2082 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2083 (format "test -d %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2084 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2085 t))))) ;run command in subshell |
45861 | 2086 |
2087 (defun tramp-handle-file-regular-p (filename) | |
2088 "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
|
2089 (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
|
2090 (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
|
2091 (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
|
2092 (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
|
2093 (eq ?- (aref (nth 8 (tramp-handle-file-attributes filename)) 0))))) |
45861 | 2094 |
2095 (defun tramp-handle-file-symlink-p (filename) | |
2096 "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
|
2097 (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
|
2098 (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
|
2099 (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
|
2100 (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
|
2101 (when (stringp x) x)))) |
45861 | 2102 |
2103 (defun tramp-handle-file-writable-p (filename) | |
2104 "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
|
2105 (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
|
2106 (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
|
2107 (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
|
2108 (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
|
2109 ;; Existing files must be writable. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2110 (zerop (tramp-run-test "-w" filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2111 ;; 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
|
2112 (and (zerop (tramp-run-test |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2113 "-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
|
2114 (zerop (tramp-run-test |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2115 "-w" (tramp-handle-file-name-directory filename))))))) |
45861 | 2116 |
2117 (defun tramp-handle-file-ownership-preserved-p (filename) | |
2118 "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
|
2119 (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
|
2120 (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
|
2121 (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
|
2122 (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
|
2123 ;; Existing files must be writable. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2124 (zerop (tramp-run-test "-O" filename))))) |
45861 | 2125 |
2126 ;; Other file name ops. | |
2127 | |
2128 ;; ;; Matthias Köppe <mkoeppe@mail.math.uni-magdeburg.de> | |
2129 ;; (defun tramp-handle-directory-file-name (directory) | |
2130 ;; "Like `directory-file-name' for tramp files." | |
2131 ;; (if (and (eq (aref directory (- (length directory) 1)) ?/) | |
2132 ;; (not (eq (aref directory (- (length directory) 2)) ?:))) | |
2133 ;; (substring directory 0 (- (length directory) 1)) | |
2134 ;; directory)) | |
2135 | |
2136 ;; Philippe Troin <phil@fifi.org> | |
2137 (defun tramp-handle-directory-file-name (directory) | |
2138 "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
|
2139 (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
|
2140 (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
|
2141 (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
|
2142 (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
|
2143 (save-match-data |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2144 (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
|
2145 (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
|
2146 (/= (match-end 0) directory-length-1)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2147 (substring directory 0 directory-length-1) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2148 directory))))) |
45861 | 2149 |
2150 ;; Directory listings. | |
2151 | |
46752 | 2152 (defun tramp-handle-directory-files (directory |
2153 &optional full match nosort files-only) | |
45861 | 2154 "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
|
2155 (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
|
2156 (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
|
2157 (tramp-invoke-ange-ftp 'directory-files |
46752 | 2158 directory full match nosort files-only)) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2159 (let (result x) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2160 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2161 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2162 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2163 (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
|
2164 nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2165 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2166 "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
|
2167 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2168 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2169 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2170 (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
|
2171 " -a | cat")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2172 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2173 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2174 (while (zerop (forward-line -1)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2175 (setq x (buffer-substring (point) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2176 (tramp-line-end-position))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2177 (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
|
2178 (if full |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2179 (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
|
2180 x) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2181 result) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2182 (push x result)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2183 (tramp-send-command multi-method method user host "cd") |
46752 | 2184 (tramp-wait-for-output) |
2185 ;; Remove non-files or non-directories if necessary. Using | |
2186 ;; the remote shell for this would probably be way faster. | |
2187 ;; Maybe something could be adapted from | |
2188 ;; tramp-handle-file-name-all-completions. | |
2189 (when files-only | |
2190 (let ((temp (nreverse result)) | |
2191 item) | |
2192 (setq result nil) | |
2193 (if (equal files-only t) | |
2194 ;; files only | |
2195 (while temp | |
2196 (setq item (pop temp)) | |
2197 (when (file-regular-p item) | |
2198 (push item result))) | |
2199 ;; directories only | |
2200 (while temp | |
2201 (setq item (pop temp)) | |
2202 (when (file-directory-p item) | |
2203 (push item result))))))) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2204 result))) |
45861 | 2205 |
2206 ;; This function should return "foo/" for directories and "bar" for | |
2207 ;; files. We use `ls -ad' to get a list of files (including | |
2208 ;; directories), and `find . -type d \! -name . -prune' to get a list | |
2209 ;; of directories. | |
2210 (defun tramp-handle-file-name-all-completions (filename directory) | |
2211 "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
|
2212 (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
|
2213 (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
|
2214 (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
|
2215 filename directory)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2216 (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
|
2217 (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
|
2218 result) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2219 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2220 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2221 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2222 (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
|
2223 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2224 "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
|
2225 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2226 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2227 ;; 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
|
2228 ;; 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
|
2229 ;; rock. --daniel@danann.net |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2230 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2231 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2232 (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
|
2233 "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
|
2234 "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
|
2235 (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
|
2236 (if (or nowild (zerop (length filename))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2237 "" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2238 (format "-d %s*" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2239 (tramp-shell-quote-argument filename))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2240 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2241 ;; Now grab the output. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2242 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2243 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2244 (while (zerop (forward-line -1)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2245 (push (buffer-substring (point) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2246 (tramp-line-end-position)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2247 result)) |
45861 | 2248 |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2249 (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
|
2250 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2251 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2252 ;; Return the list. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2253 (if nowild |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2254 (all-completions filename (mapcar 'list result)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2255 result)))))) |
45861 | 2256 |
2257 | |
2258 ;; The following isn't needed for Emacs 20 but for 19.34? | |
2259 (defun tramp-handle-file-name-completion (filename directory) | |
2260 "Like `file-name-completion' for tramp files." | |
2261 (unless (tramp-tramp-file-p directory) | |
2262 (error | |
2263 "tramp-handle-file-name-completion invoked on non-tramp directory `%s'" | |
2264 directory)) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2265 (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
|
2266 (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
|
2267 (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
|
2268 filename directory)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2269 (try-completion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2270 filename |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2271 (mapcar (lambda (x) (cons x nil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2272 (tramp-handle-file-name-all-completions filename directory))))) |
45861 | 2273 |
2274 ;; cp, mv and ln | |
2275 | |
2276 (defun tramp-handle-add-name-to-file | |
2277 (filename newname &optional ok-if-already-exists) | |
2278 "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
|
2279 (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
|
2280 (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
|
2281 (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
|
2282 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
|
2283 (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
|
2284 (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
|
2285 (equal v1-method v2-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2286 (equal v1-user v2-user) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2287 (equal v1-host v2-host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2288 (error "add-name-to-file: %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2289 "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
|
2290 (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
|
2291 (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
|
2292 (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
|
2293 filename newname ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2294 (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
|
2295 (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
|
2296 filename newname ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2297 (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
|
2298 (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
|
2299 filename newname ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2300 (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
|
2301 (file-exists-p newname) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2302 (not (numberp ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2303 (y-or-n-p |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2304 (format |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2305 "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
|
2306 newname))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2307 (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
|
2308 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2309 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
|
2310 (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
|
2311 (tramp-shell-quote-argument v2-path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2312 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2313 "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
|
2314 (buffer-name)))))) |
45861 | 2315 |
2316 (defun tramp-handle-copy-file | |
2317 (filename newname &optional ok-if-already-exists keep-date) | |
2318 "Like `copy-file' for tramp files." | |
2319 ;; Check if both files are local -- invoke normal copy-file. | |
2320 ;; Otherwise, use tramp from local system. | |
2321 (setq filename (expand-file-name filename)) | |
2322 (setq newname (expand-file-name newname)) | |
2323 ;; At least one file a tramp file? | |
2324 (if (or (tramp-tramp-file-p filename) | |
2325 (tramp-tramp-file-p newname)) | |
2326 (tramp-do-copy-or-rename-file | |
2327 'copy filename newname ok-if-already-exists keep-date) | |
2328 (tramp-run-real-handler | |
2329 'copy-file | |
2330 (list filename newname ok-if-already-exists keep-date)))) | |
2331 | |
2332 (defun tramp-handle-rename-file | |
2333 (filename newname &optional ok-if-already-exists) | |
2334 "Like `rename-file' for tramp files." | |
2335 ;; Check if both files are local -- invoke normal rename-file. | |
2336 ;; Otherwise, use tramp from local system. | |
2337 (setq filename (expand-file-name filename)) | |
2338 (setq newname (expand-file-name newname)) | |
2339 ;; At least one file a tramp file? | |
2340 (if (or (tramp-tramp-file-p filename) | |
2341 (tramp-tramp-file-p newname)) | |
2342 (tramp-do-copy-or-rename-file | |
2343 'rename filename newname ok-if-already-exists) | |
2344 (tramp-run-real-handler 'rename-file | |
2345 (list filename newname ok-if-already-exists)))) | |
2346 | |
2347 (defun tramp-do-copy-or-rename-file | |
2348 (op filename newname &optional ok-if-already-exists keep-date) | |
2349 "Copy or rename a remote file. | |
2350 OP must be `copy' or `rename' and indicates the operation to perform. | |
2351 FILENAME specifies the file to copy or rename, NEWNAME is the name of | |
2352 the new file (for copy) or the new name of the file (for rename). | |
2353 OK-IF-ALREADY-EXISTS means don't barf if NEWNAME exists already. | |
2354 KEEP-DATE means to make sure that NEWNAME has the same timestamp | |
2355 as FILENAME. | |
2356 | |
2357 This function is invoked by `tramp-handle-copy-file' and | |
2358 `tramp-handle-rename-file'. It is an error if OP is neither of `copy' | |
2359 and `rename'. FILENAME and NEWNAME must be absolute file names." | |
2360 (unless (memq op '(copy rename)) | |
2361 (error "Unknown operation `%s', must be `copy' or `rename'" op)) | |
2362 (unless ok-if-already-exists | |
2363 (when (file-exists-p newname) | |
2364 (signal 'file-already-exists | |
2365 (list newname)))) | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2366 (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
|
2367 (t2 (tramp-tramp-file-p newname))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2368 ;; 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
|
2369 (cond |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2370 ((and t1 t2) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2371 ;; Both are Tramp files. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2372 (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
|
2373 (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
|
2374 ;; Possibly invoke Ange-FTP. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2375 (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
|
2376 (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
|
2377 (tramp-invoke-ange-ftp |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2378 (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
|
2379 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
|
2380 ;; 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
|
2381 (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
|
2382 (equal v1-method v2-method) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2383 (equal v1-host v2-host) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2384 (equal v1-user v2-user)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2385 ;; 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
|
2386 ;; 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
|
2387 ;; directly. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2388 (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
|
2389 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
|
2390 v1-path v2-path keep-date) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2391 ;; 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
|
2392 ;; 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
|
2393 ;; 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
|
2394 ;; 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
|
2395 ;; 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
|
2396 ;; 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
|
2397 ;; 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
|
2398 ;; 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
|
2399 ;; source and target file. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2400 |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2401 ;; 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
|
2402 ;; 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
|
2403 ;; can invoke rcp directly. Note that |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2404 ;; 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
|
2405 ;; 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
|
2406 (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
|
2407 op filename newname keep-date))))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2408 ((or t1 t2) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2409 ;; 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
|
2410 (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
|
2411 (t |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2412 ;; 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
|
2413 (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
|
2414 |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2415 (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
|
2416 "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
|
2417 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
|
2418 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
|
2419 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
|
2420 (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
|
2421 (when keep-date |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2422 (tramp-message |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2423 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
|
2424 " with inline copying across machines"))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2425 (save-excursion |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2426 (set-buffer trampbuf) (erase-buffer) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2427 (insert-file-contents-literally filename) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2428 (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
|
2429 (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
|
2430 ;; 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
|
2431 (unless (eq op 'copy) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2432 (delete-file filename)))) |
45861 | 2433 |
2434 (defun tramp-do-copy-or-rename-file-directly | |
2435 (op multi-method method user host path1 path2 keep-date) | |
2436 "Invokes `cp' or `mv' on the remote system. | |
2437 OP must be one of `copy' or `rename', indicating `cp' or `mv', | |
2438 respectively. METHOD, USER, and HOST specify the connection. | |
2439 PATH1 and PATH2 specify the two arguments of `cp' or `mv'. | |
2440 If KEEP-DATE is non-nil, preserve the time stamp when copying." | |
2441 ;; CCC: What happens to the timestamp when renaming? | |
2442 (let ((cmd (cond ((and (eq op 'copy) keep-date) "cp -f -p") | |
2443 ((eq op 'copy) "cp -f") | |
2444 ((eq op 'rename) "mv -f") | |
2445 (t (error | |
2446 "Unknown operation `%s', must be `copy' or `rename'" | |
2447 op))))) | |
2448 (save-excursion | |
2449 (tramp-barf-unless-okay | |
2450 multi-method method user host | |
2451 (format "%s %s %s" | |
2452 cmd | |
2453 (tramp-shell-quote-argument path1) | |
2454 (tramp-shell-quote-argument path2)) | |
2455 nil 'file-error | |
2456 "Copying directly failed, see buffer `%s' for details." | |
2457 (buffer-name))))) | |
2458 | |
2459 ;; mkdir | |
2460 (defun tramp-handle-make-directory (dir &optional parents) | |
2461 "Like `make-directory' for tramp files." | |
46752 | 2462 (setq dir (expand-file-name dir)) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2463 (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
|
2464 (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
|
2465 (tramp-invoke-ange-ftp 'make-directory dir parents)) |
46790 | 2466 (save-excursion |
2467 (tramp-barf-unless-okay | |
2468 multi-method method user host | |
2469 (format " %s %s" | |
2470 (if parents "mkdir -p" "mkdir") | |
2471 (tramp-shell-quote-argument path)) | |
2472 nil 'file-error | |
2473 "Couldn't make directory %s" dir)))) | |
45861 | 2474 |
2475 ;; CCC error checking? | |
2476 (defun tramp-handle-delete-directory (directory) | |
2477 "Like `delete-directory' for tramp files." | |
46752 | 2478 (setq directory (expand-file-name directory)) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2479 (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
|
2480 (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
|
2481 (tramp-invoke-ange-ftp 'delete-directory directory)) |
45861 | 2482 (save-excursion |
2483 (tramp-send-command | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2484 multi-method method user host |
45861 | 2485 (format "rmdir %s ; echo ok" |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2486 (tramp-shell-quote-argument path))) |
45861 | 2487 (tramp-wait-for-output)))) |
2488 | |
2489 (defun tramp-handle-delete-file (filename) | |
2490 "Like `delete-file' for tramp files." | |
46752 | 2491 (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
|
2492 (with-parsed-tramp-file-name filename nil |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2493 (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
|
2494 (tramp-invoke-ange-ftp 'delete-file filename)) |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2495 (save-excursion |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2496 (unless (zerop (tramp-send-command-and-check |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2497 multi-method method user host |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2498 (format "rm -f %s" |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2499 (tramp-shell-quote-argument path)))) |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2500 (signal 'file-error "Couldn't delete Tramp file"))))) |
45861 | 2501 |
2502 ;; Dired. | |
2503 | |
2504 ;; CCC: This does not seem to be enough. Something dies when | |
2505 ;; we try and delete two directories under TRAMP :/ | |
2506 (defun tramp-handle-dired-recursive-delete-directory (filename) | |
2507 "Recursively delete the directory given. | |
2508 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
|
2509 (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
|
2510 (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
|
2511 (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
|
2512 filename)) |
45861 | 2513 ;; run a shell command 'rm -r <path>' |
2514 ;; Code shamelessly stolen for the dired implementation and, um, hacked :) | |
2515 (or (tramp-handle-file-exists-p filename) | |
2516 (signal | |
2517 'file-error | |
2518 (list "Removing old file name" "no such directory" filename))) | |
2519 ;; Which is better, -r or -R? (-r works for me <daniel@danann.net>) | |
2520 (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
|
2521 (format "rm -r %s" (tramp-shell-quote-argument path))) |
45861 | 2522 ;; Wait for the remote system to return to us... |
2523 ;; This might take a while, allow it plenty of time. | |
2524 (tramp-wait-for-output 120) | |
2525 ;; Make sure that it worked... | |
2526 (and (tramp-handle-file-exists-p filename) | |
2527 (error "Failed to recusively delete %s" filename)))) | |
2528 | |
2529 | |
2530 (defun tramp-handle-dired-call-process (program discard &rest arguments) | |
2531 "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
|
2532 (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
|
2533 (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
|
2534 (let ((default-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2535 (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
|
2536 (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
|
2537 program discard arguments))) |
45861 | 2538 (save-excursion |
2539 (tramp-barf-unless-okay | |
2540 multi-method method user host | |
2541 (format "cd %s" (tramp-shell-quote-argument path)) | |
2542 nil 'file-error | |
2543 "tramp-handle-dired-call-process: Couldn't `cd %s'" | |
2544 (tramp-shell-quote-argument path)) | |
2545 (tramp-send-command | |
2546 multi-method method user host | |
2547 (mapconcat #'tramp-shell-quote-argument (cons program arguments) " ")) | |
2548 (tramp-wait-for-output)) | |
2549 (unless discard | |
2550 (insert-buffer (tramp-get-buffer multi-method method user host))) | |
2551 (save-excursion | |
2552 (prog1 | |
2553 (tramp-send-command-and-check multi-method method user host nil) | |
2554 (tramp-send-command multi-method method user host "cd") | |
2555 (tramp-wait-for-output))))) | |
2556 | |
2557 ;; Pacify byte-compiler. The function is needed on XEmacs only. I'm | |
2558 ;; not sure at all that this is the right way to do it, but let's hope | |
2559 ;; it works for now, and wait for a guru to point out the Right Way to | |
2560 ;; achieve this. | |
2561 ;;(eval-when-compile | |
2562 ;; (unless (fboundp 'dired-insert-set-properties) | |
2563 ;; (fset 'dired-insert-set-properties 'ignore))) | |
2564 ;; Gerd suggests this: | |
2565 (eval-when-compile (require 'dired)) | |
2566 ;; Note that dired is required at run-time, too, when it is needed. | |
2567 ;; It is only needed on XEmacs for the function | |
2568 ;; `dired-insert-set-properties'. | |
2569 | |
2570 (defun tramp-handle-insert-directory | |
2571 (filename switches &optional wildcard full-directory-p) | |
2572 "Like `insert-directory' for tramp files." | |
46752 | 2573 (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
|
2574 (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
|
2575 (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
|
2576 (tramp-invoke-ange-ftp 'insert-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2577 filename switches wildcard full-directory-p)) |
45861 | 2578 (tramp-message-for-buffer |
2579 multi-method method user host 10 | |
2580 "Inserting directory `ls %s %s', wildcard %s, fulldir %s" | |
2581 switches filename (if wildcard "yes" "no") | |
2582 (if full-directory-p "yes" "no")) | |
2583 (when wildcard | |
2584 (setq wildcard (file-name-nondirectory path)) | |
2585 (setq path (file-name-directory path))) | |
2586 (when (listp switches) | |
2587 (setq switches (mapconcat 'identity switches " "))) | |
2588 (unless full-directory-p | |
2589 (setq switches (concat "-d " switches))) | |
2590 (when wildcard | |
2591 (setq switches (concat switches " " wildcard))) | |
2592 (save-excursion | |
2593 ;; If `full-directory-p', we just say `ls -l FILENAME'. | |
2594 ;; Else we chdir to the parent directory, then say `ls -ld BASENAME'. | |
2595 (if full-directory-p | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2596 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2597 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2598 (format "%s %s %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2599 (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
|
2600 switches |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2601 (if wildcard |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2602 path |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2603 (tramp-shell-quote-argument (concat path "."))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2604 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2605 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2606 (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
|
2607 (file-name-directory path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2608 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2609 "Couldn't `cd %s'" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2610 (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
|
2611 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2612 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2613 (format "%s %s %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2614 (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
|
2615 switches |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2616 (if full-directory-p |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2617 ;; 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
|
2618 ;; listing for symlinks, too. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2619 (concat (file-name-as-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2620 (file-name-nondirectory path)) ".") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2621 (file-name-nondirectory path))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2622 (sit-for 1) ;needed for rsh but not ssh? |
45861 | 2623 (tramp-wait-for-output)) |
2624 (insert-buffer (tramp-get-buffer multi-method method user host)) | |
2625 ;; On XEmacs, we want to call (exchange-point-and-mark t), but | |
2626 ;; that doesn't exist on Emacs, so we use this workaround instead. | |
2627 ;; Since zmacs-region-stays doesn't exist in Emacs, this ought to | |
2628 ;; be safe. Thanks to Daniel Pittman <daniel@danann.net>. | |
2629 (let ((zmacs-region-stays t)) | |
2630 (exchange-point-and-mark)) | |
2631 (save-excursion | |
2632 (tramp-send-command multi-method method user host "cd") | |
2633 (tramp-wait-for-output)) | |
2634 ;; Another XEmacs specialty follows. What's the right way to do | |
2635 ;; it? | |
2636 (when (and (featurep 'xemacs) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2637 (eq major-mode 'dired-mode)) |
45861 | 2638 (save-excursion |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2639 (require 'dired) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2640 (dired-insert-set-properties (point) (mark t)))))) |
45861 | 2641 |
2642 ;; Continuation of kluge to pacify byte-compiler. | |
2643 ;;(eval-when-compile | |
2644 ;; (when (eq (symbol-function 'dired-insert-set-properties) 'ignore) | |
2645 ;; (fmakunbound 'dired-insert-set-properties))) | |
2646 | |
2647 ;; CCC is this the right thing to do? | |
2648 (defun tramp-handle-unhandled-file-name-directory (filename) | |
2649 "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
|
2650 (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
|
2651 (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
|
2652 (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
|
2653 filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2654 (expand-file-name "~/"))) |
45861 | 2655 |
2656 ;; Canonicalization of file names. | |
2657 | |
2658 (defun tramp-drop-volume-letter (name) | |
2659 "Cut off unnecessary drive letter from file NAME. | |
2660 The function `tramp-handle-expand-file-name' calls `expand-file-name' | |
2661 locally on a remote file name. When the local system is a W32 system | |
2662 but the remote system is Unix, this introduces a superfluous drive | |
2663 letter into the file name. This function removes it. | |
2664 | |
2665 Doesn't do anything if the NAME does not start with a drive letter." | |
2666 (if (and (> (length name) 1) | |
2667 (char-equal (aref name 1) ?:) | |
2668 (let ((c1 (aref name 0))) | |
2669 (or (and (>= c1 ?A) (<= c1 ?Z)) | |
2670 (and (>= c1 ?a) (<= c1 ?z))))) | |
2671 (substring name 2) | |
2672 name)) | |
2673 | |
2674 (defun tramp-handle-expand-file-name (name &optional dir) | |
2675 "Like `expand-file-name' for tramp files." | |
2676 ;; If DIR is not given, use DEFAULT-DIRECTORY or "/". | |
2677 (setq dir (or dir default-directory "/")) | |
2678 ;; Unless NAME is absolute, concat DIR and NAME. | |
2679 (unless (file-name-absolute-p name) | |
2680 (setq name (concat (file-name-as-directory dir) name))) | |
2681 ;; If NAME is not a tramp file, run the real handler | |
2682 (if (not (tramp-tramp-file-p name)) | |
2683 (tramp-run-real-handler 'expand-file-name | |
2684 (list name nil)) | |
2685 ;; Dissect NAME. | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2686 (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
|
2687 (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
|
2688 (tramp-invoke-ange-ftp 'expand-file-name name nil)) |
45861 | 2689 (unless (file-name-absolute-p path) |
2690 (setq path (concat "~/" path))) | |
2691 (save-excursion | |
2692 ;; Tilde expansion if necessary. This needs a shell which | |
2693 ;; groks tilde expansion! The function `tramp-find-shell' is | |
2694 ;; supposed to find such a shell on the remote host. Please | |
2695 ;; tell me about it when this doesn't work on your system. | |
2696 (when (string-match "\\`\\(~[^/]*\\)\\(.*\\)\\'" path) | |
2697 (let ((uname (match-string 1 path)) | |
2698 (fname (match-string 2 path))) | |
2699 ;; CCC fanatic error checking? | |
2700 (set-buffer (tramp-get-buffer multi-method method user host)) | |
2701 (erase-buffer) | |
2702 (tramp-send-command | |
2703 multi-method method user host | |
2704 (format "cd %s; pwd" uname) | |
2705 t) | |
2706 (tramp-wait-for-output) | |
2707 (goto-char (point-min)) | |
2708 (setq uname (buffer-substring (point) (tramp-line-end-position))) | |
2709 (setq path (concat uname fname)) | |
2710 (erase-buffer))) | |
2711 ;; No tilde characters in file name, do normal | |
2712 ;; expand-file-name (this does "/./" and "/../"). We bind | |
2713 ;; directory-sep-char here for XEmacs on Windows, which would | |
2714 ;; otherwise use backslash. | |
2715 (let ((directory-sep-char ?/)) | |
2716 (tramp-make-tramp-file-name | |
2717 multi-method method user host | |
2718 (tramp-drop-volume-letter | |
2719 (tramp-run-real-handler 'expand-file-name (list path))))))))) | |
2720 | |
2721 ;; Remote commands. | |
2722 | |
2723 (defun tramp-handle-shell-command (command &optional output-buffer error-buffer) | |
2724 "Like `shell-command' for tramp files. | |
2725 This will break if COMMAND prints a newline, followed by the value of | |
2726 `tramp-end-of-output', followed by another newline." | |
46752 | 2727 (when (tramp-tramp-file-p default-directory) |
2728 (with-parsed-tramp-file-name default-directory nil | |
2729 (when (tramp-ange-ftp-file-name-p multi-method method) | |
2730 (let ((default-directory (tramp-make-ange-ftp-file-name | |
2731 user host path))) | |
2732 (tramp-invoke-ange-ftp 'shell-command | |
2733 command output-buffer error-buffer))) | |
2734 (let (status) | |
2735 (when (string-match "&[ \t]*\\'" command) | |
2736 (error "Tramp doesn't grok asynchronous shell commands, yet")) | |
2737 (when error-buffer | |
2738 (error "Tramp doesn't grok optional third arg ERROR-BUFFER, yet")) | |
2739 (save-excursion | |
2740 (tramp-barf-unless-okay | |
2741 multi-method method user host | |
2742 (format "cd %s" (tramp-shell-quote-argument path)) | |
2743 nil 'file-error | |
2744 "tramp-handle-shell-command: Couldn't `cd %s'" | |
2745 (tramp-shell-quote-argument path)) | |
2746 (tramp-send-command multi-method method user host | |
2747 (concat command "; tramp_old_status=$?")) | |
2748 ;; This will break if the shell command prints "/////" | |
2749 ;; somewhere. Let's just hope for the best... | |
2750 (tramp-wait-for-output)) | |
2751 (unless output-buffer | |
2752 (setq output-buffer (get-buffer-create "*Shell Command Output*")) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2753 (set-buffer output-buffer) |
46752 | 2754 (erase-buffer)) |
2755 (unless (bufferp output-buffer) | |
2756 (setq output-buffer (current-buffer))) | |
2757 (set-buffer output-buffer) | |
2758 (insert-buffer (tramp-get-buffer multi-method method user host)) | |
2759 (save-excursion | |
2760 (tramp-send-command multi-method method user host "cd") | |
2761 (tramp-wait-for-output) | |
2762 (tramp-send-command | |
2763 multi-method method user host | |
2764 (concat "tramp_set_exit_status $tramp_old_status;" | |
2765 " echo tramp_exit_status $?")) | |
2766 (tramp-wait-for-output) | |
2767 (goto-char (point-max)) | |
2768 (unless (search-backward "tramp_exit_status " nil t) | |
2769 (error "Couldn't find exit status of `%s'" command)) | |
2770 (skip-chars-forward "^ ") | |
2771 (setq status (read (current-buffer)))) | |
2772 (unless (zerop (buffer-size)) | |
2773 (pop-to-buffer output-buffer)) | |
2774 status))) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2775 ;; 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
|
2776 ;; 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
|
2777 (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
|
2778 default-directory) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2779 (tramp-run-real-handler 'shell-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2780 (list command output-buffer error-buffer))) |
45861 | 2781 |
2782 ;; File Editing. | |
2783 | |
2784 (defsubst tramp-make-temp-file () | |
2785 (funcall (if (fboundp 'make-temp-file) 'make-temp-file 'make-temp-name) | |
2786 (expand-file-name tramp-temp-name-prefix | |
2787 (tramp-temporary-file-directory)))) | |
2788 | |
2789 (defun tramp-handle-file-local-copy (filename) | |
2790 "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
|
2791 (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
|
2792 (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
|
2793 (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
|
2794 (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
|
2795 tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2796 (unless (file-exists-p filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2797 (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
|
2798 filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2799 (setq tmpfil (tramp-make-temp-file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2800 (cond ((tramp-get-rcp-program multi-method method) |
46752 | 2801 ;; Use rcp-like program for file transfer. |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2802 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2803 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2804 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
|
2805 (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
|
2806 (unless (equal |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2807 0 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2808 (apply #'call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2809 (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
|
2810 nil trampbuf nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2811 (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
|
2812 (list |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2813 (tramp-make-rcp-program-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2814 user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2815 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2816 tmpfil)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2817 (pop-to-buffer trampbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2818 (error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2819 (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
|
2820 "see buffer `%s' for details") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2821 (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
|
2822 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2823 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2824 5 "Fetching %s to tmp file %s...done" filename tmpfil)) |
46752 | 2825 ((and (tramp-get-encoding-command multi-method method user host) |
2826 (tramp-get-decoding-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
|
2827 ;; Use inline encoding for file transfer. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2828 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2829 ;; 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
|
2830 ;; tramp-current-user, tramp-current-host. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2831 (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
|
2832 (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
|
2833 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2834 multi-method method user host |
46752 | 2835 (concat (tramp-get-encoding-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
|
2836 " < " (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2837 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2838 "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
|
2839 (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
|
2840 ;; Remove trailing status code |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2841 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2842 (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
|
2843 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2844 (tramp-message 5 "Decoding remote file %s..." filename) |
46752 | 2845 (if (and (tramp-get-decoding-function multi-method method user host) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2846 (fboundp (tramp-get-decoding-function |
46752 | 2847 multi-method method user host))) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2848 ;; 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
|
2849 ;; method, we call it. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2850 (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
|
2851 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2852 (erase-buffer) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2853 (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
|
2854 user host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2855 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2856 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2857 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
|
2858 filename |
46752 | 2859 (tramp-get-decoding-function multi-method method user host)) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2860 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2861 (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
|
2862 (funcall (tramp-get-decoding-function |
46752 | 2863 multi-method method user host) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2864 (point-min) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2865 (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2866 (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
|
2867 (kill-buffer tmpbuf)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2868 ;; 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
|
2869 ;; 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
|
2870 (let ((tmpfil2 (tramp-make-temp-file))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2871 (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
|
2872 (tramp-message |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2873 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
|
2874 filename |
46752 | 2875 (tramp-get-decoding-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
|
2876 (call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2877 tramp-sh-program |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2878 tmpfil2 ;input |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2879 nil ;output |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2880 nil ;display |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2881 "-c" (concat (tramp-get-decoding-command |
46752 | 2882 multi-method method user host) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2883 " > " tmpfil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2884 (delete-file tmpfil2))) |
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 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
|
2888 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2889 (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
|
2890 tmpfil))) |
45861 | 2891 |
2892 | |
2893 (defun tramp-handle-insert-file-contents | |
2894 (filename &optional visit beg end replace) | |
2895 "Like `insert-file-contents' for tramp files." | |
2896 (barf-if-buffer-read-only) | |
2897 (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
|
2898 (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
|
2899 (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
|
2900 (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
|
2901 filename visit beg end replace)) |
45861 | 2902 (if (not (tramp-handle-file-exists-p filename)) |
2903 (progn | |
2904 (when visit | |
2905 (setq buffer-file-name filename) | |
2906 (set-visited-file-modtime) | |
2907 (set-buffer-modified-p nil)) | |
2908 (signal 'file-error | |
2909 (format "File `%s' not found on remote host" filename)) | |
2910 (list (tramp-handle-expand-file-name filename) 0)) | |
2911 (let ((local-copy (tramp-handle-file-local-copy filename)) | |
2912 (coding-system-used nil) | |
2913 (result nil)) | |
2914 (when visit | |
2915 (setq buffer-file-name filename) | |
2916 (set-visited-file-modtime) | |
2917 (set-buffer-modified-p nil)) | |
2918 (tramp-message-for-buffer | |
2919 multi-method method user host | |
2920 9 "Inserting local temp file `%s'..." local-copy) | |
2921 (setq result | |
2922 (tramp-run-real-handler 'insert-file-contents | |
2923 (list local-copy nil beg end replace))) | |
2924 ;; Now `last-coding-system-used' has right value. Remember it. | |
2925 (when (boundp 'last-coding-system-used) | |
2926 (setq coding-system-used last-coding-system-used)) | |
2927 (tramp-message 9 "Inserting local temp file `%s'...done" local-copy) | |
2928 (delete-file local-copy) | |
2929 (when (boundp 'last-coding-system-used) | |
2930 (setq last-coding-system-used coding-system-used)) | |
2931 (list (expand-file-name filename) | |
2932 (second result)))))) | |
2933 | |
2934 ;; CCC grok APPEND, LOCKNAME, CONFIRM | |
2935 (defun tramp-handle-write-region | |
2936 (start end filename &optional append visit lockname confirm) | |
2937 "Like `write-region' for tramp files." | |
2938 (unless (eq append nil) | |
2939 (error "Cannot append to file using tramp (`%s')" filename)) | |
2940 (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
|
2941 ;; 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
|
2942 ;; 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
|
2943 ;; Ange-ftp ignores it, too. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2944 ;; (when (and lockname (stringp lockname)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2945 ;; (setq lockname (expand-file-name lockname))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2946 ;; (unless (or (eq lockname nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2947 ;; (string= lockname filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2948 ;; (error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2949 ;; "tramp-handle-write-region: LOCKNAME must be nil or equal FILENAME")) |
45861 | 2950 ;; XEmacs takes a coding system as the sevent argument, not `confirm' |
2951 (when (and (not (featurep 'xemacs)) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2952 confirm (file-exists-p filename)) |
45861 | 2953 (unless (y-or-n-p (format "File %s exists; overwrite anyway? " |
2954 filename)) | |
2955 (error "File not overwritten"))) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2956 (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
|
2957 (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
|
2958 (tramp-invoke-ange-ftp 'write-region |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2959 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
|
2960 (let ((curbuf (current-buffer)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2961 (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
|
2962 (rcp-args (tramp-get-rcp-args multi-method method)) |
46752 | 2963 (encoding-command |
2964 (tramp-get-encoding-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
|
2965 (encoding-function |
46752 | 2966 (tramp-get-encoding-function multi-method method user host)) |
2967 (decoding-command | |
2968 (tramp-get-decoding-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
|
2969 (trampbuf (get-buffer-create "*tramp output*")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2970 ;; 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
|
2971 ;; 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
|
2972 ;; 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
|
2973 ;; 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
|
2974 ;; 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
|
2975 ;; 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
|
2976 coding-system-used |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2977 tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2978 ;; 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
|
2979 ;; 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
|
2980 ;; because this makes the logic simpler. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2981 (setq tmpfil (tramp-make-temp-file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2982 ;; 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
|
2983 ;; 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
|
2984 ;; `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
|
2985 (tramp-run-real-handler |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2986 'write-region |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2987 (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
|
2988 (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
|
2989 (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
|
2990 ;; 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
|
2991 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2992 (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
|
2993 ;; 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
|
2994 ;; 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
|
2995 ;; 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
|
2996 ;; 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
|
2997 ;; _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
|
2998 ;; 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
|
2999 (cond (rcp-program |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3000 ;; 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
|
3001 (let ((argl (append rcp-args |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3002 (list |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3003 tmpfil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3004 (tramp-make-rcp-program-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3005 user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3006 (tramp-shell-quote-argument path)))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3007 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3008 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3009 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
|
3010 (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
|
3011 (when tramp-debug-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3012 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3013 (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
|
3014 method user host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3015 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3016 (tramp-insert-with-face |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3017 '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
|
3018 (mapconcat 'identity argl " "))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3019 (unless (equal 0 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3020 (apply #'call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3021 rcp-program nil trampbuf nil argl)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3022 (pop-to-buffer trampbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3023 (error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3024 "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
|
3025 filename rcp-program)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3026 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3027 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3028 6 "Transferring file using `%s'...done" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3029 rcp-program))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3030 ((and encoding-command decoding-command) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3031 ;; Use inline file transfer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3032 (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
|
3033 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3034 ;; Encode tmpfil into tmpbuf |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3035 (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
|
3036 5 "Encoding region...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3037 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3038 (erase-buffer) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3039 ;; Use encoding function or command. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3040 (if (and encoding-function |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3041 (fboundp encoding-function)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3042 (progn |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3043 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3044 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3045 6 "Encoding region using function...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3046 (insert-file-contents-literally tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3047 ;; 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
|
3048 ;; 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
|
3049 ;; both of the following conditions are |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3050 ;; 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
|
3051 ;; 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
|
3052 ;; default-directory is remote. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3053 ;; (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
|
3054 ;; 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
|
3055 ;; tmp file anyway. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3056 (let ((default-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3057 (tramp-temporary-file-directory))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3058 (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
|
3059 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3060 (unless (bolp) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3061 (newline))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3062 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3063 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3064 6 "Encoding region using command...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3065 (unless (equal 0 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3066 (call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3067 tramp-sh-program |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3068 tmpfil ;input = local tmp file |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3069 t ;output is current buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3070 nil ;don't redisplay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3071 "-c" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3072 encoding-command)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3073 (pop-to-buffer trampbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3074 (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
|
3075 " command `%s' failed") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3076 filename encoding-command))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3077 ;; 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
|
3078 ;; 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
|
3079 ;; 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
|
3080 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3081 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3082 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
|
3083 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3084 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3085 (format "%s >%s <<'EOF'" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3086 decoding-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3087 (tramp-shell-quote-argument path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3088 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3089 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3090 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3091 6 "Sending data to remote host...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3092 (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
|
3093 (point-min) (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3094 ;; wait for remote decoding to complete |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3095 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3096 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3097 6 "Sending end of data token...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3098 (tramp-send-command |
46992
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
3099 multi-method method user host "EOF" nil t) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3100 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3101 multi-method method user host 6 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3102 "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
|
3103 (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
|
3104 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3105 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3106 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
|
3107 (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
|
3108 " decode using `%s' failed") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3109 filename decoding-command) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3110 (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
|
3111 filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3112 (kill-buffer tmpbuf)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3113 (t |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3114 (error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3115 (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
|
3116 "decoding command or an rcp program") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3117 method))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3118 (delete-file tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3119 (unless (equal curbuf (current-buffer)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3120 (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
|
3121 curbuf (current-buffer))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3122 (when (eq visit t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3123 (set-visited-file-modtime)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3124 ;; 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
|
3125 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3126 (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
|
3127 (when (or (eq visit t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3128 (eq visit nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3129 (stringp visit)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3130 (message "Wrote %s" filename))))) |
45861 | 3131 |
3132 ;; Call down to the real handler. | |
3133 ;; Because EFS does not play nicely with TRAMP (both systems match an | |
3134 ;; TRAMP path) it is needed to disable efs as well as tramp for the | |
3135 ;; operation. | |
3136 ;; | |
3137 ;; Other than that, this is the canon file-handler code that the doco | |
3138 ;; says should be used here. Which is nice. | |
3139 ;; | |
3140 ;; Under XEmacs current, EFS also hooks in as | |
3141 ;; efs-sifn-handler-function to handle any path with environment | |
3142 ;; variables. This has two implications: | |
3143 ;; 1) That EFS may not be completely dead (yet) for TRAMP paths | |
3144 ;; 2) That TRAMP might want to do the same thing. | |
3145 ;; Details as they come in. | |
3146 ;; | |
3147 ;; Daniel Pittman <daniel@danann.net> | |
3148 | |
3149 ;; (defun tramp-run-real-handler (operation args) | |
3150 ;; "Invoke normal file name handler for OPERATION. | |
3151 ;; This inhibits EFS and Ange-FTP, too, because they conflict with tramp. | |
3152 ;; First arg specifies the OPERATION, remaining ARGS are passed to the | |
3153 ;; OPERATION." | |
3154 ;; (let ((inhibit-file-name-handlers | |
3155 ;; (list 'tramp-file-name-handler | |
3156 ;; 'efs-file-handler-function | |
3157 ;; 'ange-ftp-hook-function | |
3158 ;; (and (eq inhibit-file-name-operation operation) | |
3159 ;; inhibit-file-name-handlers))) | |
3160 ;; (inhibit-file-name-operation operation)) | |
3161 ;; (apply operation args))) | |
3162 | |
3163 (defun tramp-run-real-handler (operation args) | |
3164 "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
|
3165 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
|
3166 pass to the OPERATION." |
46835
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
3167 (let* ((op (if (eq operation 'ange-ftp-hook-function) |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
3168 (car args) |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
3169 operation)) |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
3170 (inhibit-file-name-handlers |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
3171 (list 'tramp-file-name-handler |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
3172 (and (eq inhibit-file-name-operation op) |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
3173 inhibit-file-name-handlers))) |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
3174 (inhibit-file-name-operation op)) |
45861 | 3175 (apply operation args))) |
3176 | |
3177 ;; Main function. | |
3178 ;;;###autoload | |
3179 (defun tramp-file-name-handler (operation &rest args) | |
3180 "Invoke tramp file name handler. | |
3181 Falls back to normal file name handler if no tramp file name handler exists." | |
3182 (let ((fn (assoc operation tramp-file-name-handler-alist))) | |
3183 (if fn | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3184 (catch 'tramp-forward-to-ange-ftp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3185 (save-match-data (apply (cdr fn) args))) |
45861 | 3186 (tramp-run-real-handler operation args)))) |
3187 | |
3188 ;; Register in file name handler alist | |
3189 ;;;###autoload | |
3190 (add-to-list 'file-name-handler-alist | |
3191 (cons tramp-file-name-regexp 'tramp-file-name-handler)) | |
3192 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3193 ;; 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
|
3194 ;; |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3195 ;; * 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
|
3196 ;; * 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
|
3197 ;; 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
|
3198 ;; * 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
|
3199 ;; |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3200 ;; 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
|
3201 ;; 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
|
3202 (defun tramp-disable-ange-ftp () |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3203 "Turn Ange-FTP off. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3204 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
|
3205 `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
|
3206 `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
|
3207 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
|
3208 `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
|
3209 `tramp-default-method-alist'. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3210 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3211 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
|
3212 present for backward compatibility." |
46060
40298ba8e901
(tramp-handle-ange-ftp): Fix typo.
Andreas Schwab <schwab@suse.de>
parents:
46048
diff
changeset
|
3213 (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
|
3214 (a2 (rassq 'ange-ftp-completion-hook-function file-name-handler-alist))) |
45861 | 3215 (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
|
3216 (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
|
3217 (tramp-disable-ange-ftp) |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3218 |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3219 (defun tramp-repair-jka-compr () |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3220 "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
|
3221 `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
|
3222 necessary anymore." |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3223 (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
|
3224 (when jka |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3225 (setq file-name-handler-alist |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3226 (cons jka (delete jka file-name-handler-alist)))))) |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3227 (tramp-repair-jka-compr) |
45861 | 3228 |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3229 (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
|
3230 "Invoke the Ange-FTP handler function and throw." |
46808
cf225aed7a75
Version 2.0.11 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46802
diff
changeset
|
3231 (or (boundp 'ange-ftp-name-format) (require 'ange-ftp)) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3232 (let ((ange-ftp-name-format |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3233 (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
|
3234 (nth 3 tramp-file-name-structure) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3235 (nth 2 tramp-file-name-structure) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3236 (nth 4 tramp-file-name-structure)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3237 (throw 'tramp-forward-to-ange-ftp |
46808
cf225aed7a75
Version 2.0.11 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46802
diff
changeset
|
3238 (tramp-run-real-handler 'ange-ftp-hook-function |
cf225aed7a75
Version 2.0.11 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46802
diff
changeset
|
3239 (cons operation args))))) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3240 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3241 (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
|
3242 "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
|
3243 (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
|
3244 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3245 |
45861 | 3246 ;;; Interactions with other packages: |
3247 | |
3248 ;; -- complete.el -- | |
3249 | |
3250 ;; This function contributed by Ed Sabol | |
3251 (defun tramp-handle-expand-many-files (name) | |
3252 "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
|
3253 (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
|
3254 (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
|
3255 (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
|
3256 (save-match-data |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3257 (if (or (string-match "\\*" name) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3258 (string-match "\\?" name) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3259 (string-match "\\[.*\\]" name)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3260 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3261 (let (bufstr) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3262 ;; 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
|
3263 ;; 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
|
3264 ;; 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
|
3265 ;; don't bother. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3266 ;;-(let ((comint-file-name-quote-list |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3267 ;;- (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
|
3268 ;;- '(?\* ?\? ?[ ?])))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3269 ;;- (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3270 ;;- multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3271 ;;- (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
|
3272 ;;- (tramp-wait-for-output)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3273 (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
|
3274 (format "echo %s" path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3275 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3276 (setq bufstr (buffer-substring (point-min) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3277 (tramp-line-end-position))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3278 (goto-char (point-min)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3279 (if (string-equal path bufstr) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3280 nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3281 (insert "(\"") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3282 (while (search-forward " " nil t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3283 (delete-backward-char 1) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3284 (insert "\" \"")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3285 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3286 (delete-backward-char 1) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3287 (insert "\")") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3288 (goto-char (point-min)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3289 (mapcar |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3290 (function (lambda (x) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3291 (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
|
3292 user host x))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3293 (read (current-buffer)))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3294 (list (tramp-handle-expand-file-name name)))))) |
45861 | 3295 |
3296 ;; Check for complete.el and override PC-expand-many-files if appropriate. | |
3297 (eval-when-compile | |
3298 (defun tramp-save-PC-expand-many-files (name))); avoid compiler warning | |
3299 | |
3300 (defun tramp-setup-complete () | |
3301 (fset 'tramp-save-PC-expand-many-files | |
3302 (symbol-function 'PC-expand-many-files)) | |
3303 (defun PC-expand-many-files (name) | |
3304 (if (tramp-tramp-file-p name) | |
3305 (tramp-handle-expand-many-files name) | |
3306 (tramp-save-PC-expand-many-files name)))) | |
3307 | |
3308 ;; Why isn't eval-after-load sufficient? | |
3309 (if (fboundp 'PC-expand-many-files) | |
3310 (tramp-setup-complete) | |
3311 (eval-after-load "complete" '(tramp-setup-complete))) | |
3312 | |
3313 | |
3314 | |
3315 | |
3316 ;;; Internal Functions: | |
3317 | |
3318 (defun tramp-set-auto-save () | |
3319 (when (and (buffer-file-name) | |
3320 (tramp-tramp-file-p (buffer-file-name)) | |
3321 auto-save-default) | |
3322 (auto-save-mode 1))) | |
3323 (add-hook 'find-file-hooks 'tramp-set-auto-save t) | |
3324 | |
3325 (defun tramp-run-test (switch filename) | |
3326 "Run `test' on the remote system, given a SWITCH and a FILENAME. | |
3327 Returns the exit code of the `test' program." | |
3328 (let ((v (tramp-dissect-file-name filename))) | |
3329 (save-excursion | |
3330 (tramp-send-command-and-check | |
3331 (tramp-file-name-multi-method v) (tramp-file-name-method v) | |
3332 (tramp-file-name-user v) (tramp-file-name-host v) | |
3333 (format "test %s %s" switch | |
3334 (tramp-shell-quote-argument (tramp-file-name-path v))))))) | |
3335 | |
3336 (defun tramp-run-test2 (program file1 file2 &optional switch) | |
3337 "Run `test'-like PROGRAM on the remote system, given FILE1, FILE2. | |
3338 The optional SWITCH is inserted between the two files. | |
3339 Returns the exit code of the `test' PROGRAM. Barfs if the methods, | |
3340 hosts, or files, disagree." | |
3341 (let* ((v1 (tramp-dissect-file-name file1)) | |
3342 (v2 (tramp-dissect-file-name file2)) | |
3343 (mmethod1 (tramp-file-name-multi-method v1)) | |
3344 (mmethod2 (tramp-file-name-multi-method v2)) | |
3345 (method1 (tramp-file-name-method v1)) | |
3346 (method2 (tramp-file-name-method v2)) | |
3347 (user1 (tramp-file-name-user v1)) | |
3348 (user2 (tramp-file-name-user v2)) | |
3349 (host1 (tramp-file-name-host v1)) | |
3350 (host2 (tramp-file-name-host v2)) | |
3351 (path1 (tramp-file-name-path v1)) | |
3352 (path2 (tramp-file-name-path v2))) | |
3353 (unless (and method1 method2 host1 host2 | |
3354 (equal mmethod1 mmethod2) | |
3355 (equal method1 method2) | |
3356 (equal user1 user2) | |
3357 (equal host1 host2)) | |
3358 (error "tramp-run-test2: %s" | |
3359 "only implemented for same method, same user, same host")) | |
3360 (save-excursion | |
3361 (tramp-send-command-and-check | |
3362 mmethod1 method1 user1 host1 | |
3363 (format "%s %s %s %s" | |
3364 program | |
3365 (tramp-shell-quote-argument path1) | |
3366 (or switch "") | |
3367 (tramp-shell-quote-argument path2)))))) | |
3368 | |
3369 (defun tramp-buffer-name (multi-method method user host) | |
3370 "A name for the connection buffer for USER at HOST using METHOD." | |
3371 (cond (multi-method | |
3372 (tramp-buffer-name-multi-method "tramp" multi-method method user host)) | |
3373 (user | |
3374 (format "*tramp/%s %s@%s*" method user host)) | |
3375 (t | |
3376 (format "*tramp/%s %s*" method host)))) | |
3377 | |
3378 (defun tramp-buffer-name-multi-method (prefix multi-method method user host) | |
3379 "A name for the multi method connection buffer. | |
3380 MULTI-METHOD gives the multi method, METHOD the array of methods, | |
3381 USER the array of user names, HOST the array of host names." | |
3382 (unless (and (= (length method) (length user)) | |
3383 (= (length method) (length host))) | |
3384 (error "Syntax error in multi method (implementation error)")) | |
3385 (let ((len (length method)) | |
3386 (i 0) | |
3387 string-list) | |
3388 (while (< i len) | |
3389 (setq string-list | |
3390 (cons (if (aref user i) | |
3391 (format "%s#%s@%s:" (aref method i) | |
3392 (aref user i) (aref host i)) | |
3393 (format "%s@%s:" (aref method i) (aref host i))) | |
3394 string-list)) | |
3395 (incf i)) | |
3396 (format "*%s/%s %s*" | |
3397 prefix multi-method | |
3398 (apply 'concat (reverse string-list))))) | |
3399 | |
3400 (defun tramp-get-buffer (multi-method method user host) | |
3401 "Get the connection buffer to be used for USER at HOST using METHOD." | |
3402 (get-buffer-create (tramp-buffer-name multi-method method user host))) | |
3403 | |
3404 (defun tramp-debug-buffer-name (multi-method method user host) | |
3405 "A name for the debug buffer for USER at HOST using METHOD." | |
3406 (cond (multi-method | |
3407 (tramp-buffer-name-multi-method "debug tramp" | |
3408 multi-method method user host)) | |
3409 (user | |
3410 (format "*debug tramp/%s %s@%s*" method user host)) | |
3411 (t | |
3412 (format "*debug tramp/%s %s*" method host)))) | |
3413 | |
3414 (defun tramp-get-debug-buffer (multi-method method user host) | |
3415 "Get the debug buffer for USER at HOST using METHOD." | |
3416 (get-buffer-create (tramp-debug-buffer-name multi-method method user host))) | |
3417 | |
3418 (defun tramp-find-executable (multi-method method user host | |
3419 progname dirlist ignore-tilde) | |
3420 "Searches for PROGNAME in all directories mentioned in DIRLIST. | |
3421 First args METHOD, USER and HOST specify the connection, PROGNAME | |
3422 is the program to search for, and DIRLIST gives the list of directories | |
3423 to search. If IGNORE-TILDE is non-nil, directory names starting | |
3424 with `~' will be ignored. | |
3425 | |
3426 Returns the full path name of PROGNAME, if found, and nil otherwise. | |
3427 | |
3428 This function expects to be in the right *tramp* buffer." | |
3429 (let (result) | |
3430 (when ignore-tilde | |
3431 ;; Remove all ~/foo directories from dirlist. In Emacs 20, | |
3432 ;; `remove' is in CL, and we want to avoid CL dependencies. | |
3433 (let (newdl d) | |
3434 (while dirlist | |
3435 (setq d (car dirlist)) | |
3436 (setq dirlist (cdr dirlist)) | |
3437 (unless (char-equal ?~ (aref d 0)) | |
3438 (setq newdl (cons d newdl)))) | |
3439 (setq dirlist (nreverse newdl)))) | |
3440 (tramp-send-command | |
3441 multi-method method user host | |
3442 (format (concat "while read d; " | |
3443 "do if test -x $d/%s -a -f $d/%s; " | |
3444 "then echo tramp_executable $d/%s; " | |
3445 "break; fi; done <<'EOF'") | |
3446 progname progname progname)) | |
3447 (mapcar (lambda (d) | |
3448 (tramp-send-command multi-method method user host d)) | |
3449 dirlist) | |
3450 (tramp-send-command multi-method method user host "EOF") | |
3451 (tramp-wait-for-output) | |
3452 (goto-char (point-max)) | |
3453 (when (search-backward "tramp_executable " nil t) | |
3454 (skip-chars-forward "^ ") | |
3455 (skip-chars-forward " ") | |
3456 (buffer-substring (point) (tramp-line-end-position))))) | |
3457 | |
3458 (defun tramp-set-remote-path (multi-method method user host var dirlist) | |
3459 "Sets the remote environment VAR to existing directories from DIRLIST. | |
3460 I.e., for each directory in DIRLIST, it is tested whether it exists and if | |
3461 so, it is added to the environment variable VAR." | |
3462 (let ((existing-dirs | |
3463 (mapcar | |
3464 (lambda (x) | |
3465 (when (and | |
3466 (file-exists-p | |
3467 (tramp-make-tramp-file-name multi-method method user host x)) | |
3468 (file-directory-p | |
3469 (tramp-make-tramp-file-name multi-method method user host x))) | |
3470 x)) | |
3471 dirlist))) | |
3472 (tramp-send-command | |
3473 multi-method method user host | |
3474 (concat var "=" | |
3475 (mapconcat 'identity (delq nil existing-dirs) ":") | |
3476 "; export " var)) | |
3477 (tramp-wait-for-output))) | |
3478 | |
3479 ;; -- communication with external shell -- | |
3480 | |
3481 (defun tramp-find-file-exists-command (multi-method method user host) | |
3482 "Find a command on the remote host for checking if a file exists. | |
3483 Here, we are looking for a command which has zero exit status if the | |
3484 file exists and nonzero exit status otherwise." | |
3485 (make-local-variable 'tramp-file-exists-command) | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3486 (tramp-message 9 "Finding command to check if file exists") |
45861 | 3487 (let ((existing |
3488 (tramp-make-tramp-file-name | |
3489 multi-method method user host | |
3490 "/")) ;assume this file always exists | |
3491 (nonexisting | |
3492 (tramp-make-tramp-file-name | |
3493 multi-method method user host | |
3494 "/ this file does not exist "))) ;assume this never exists | |
3495 ;; The algorithm is as follows: we try a list of several commands. | |
3496 ;; For each command, we first run `$cmd /' -- this should return | |
3497 ;; true, as the root directory always exists. And then we run | |
3498 ;; `$cmd /this\ file\ does\ not\ exist', hoping that the file indeed | |
3499 ;; does not exist. This should return false. We use the first | |
3500 ;; command we find that seems to work. | |
3501 ;; The list of commands to try is as follows: | |
3502 ;; `ls -d' This works on most systems, but NetBSD 1.4 | |
3503 ;; has a bug: `ls' always returns zero exit | |
3504 ;; status, even for files which don't exist. | |
3505 ;; `test -e' Some Bourne shells have a `test' builtin | |
3506 ;; which does not know the `-e' option. | |
3507 ;; `/bin/test -e' For those, the `test' binary on disk normally | |
3508 ;; provides the option. Alas, the binary | |
3509 ;; is sometimes `/bin/test' and sometimes it's | |
3510 ;; `/usr/bin/test'. | |
3511 ;; `/usr/bin/test -e' In case `/bin/test' does not exist. | |
3512 (unless (or | |
3513 (and (setq tramp-file-exists-command "test -e %s") | |
3514 (tramp-handle-file-exists-p existing) | |
3515 (not (tramp-handle-file-exists-p nonexisting))) | |
3516 (and (setq tramp-file-exists-command "/bin/test -e %s") | |
3517 (tramp-handle-file-exists-p existing) | |
3518 (not (tramp-handle-file-exists-p nonexisting))) | |
3519 (and (setq tramp-file-exists-command "/usr/bin/test -e %s") | |
3520 (tramp-handle-file-exists-p existing) | |
46808
cf225aed7a75
Version 2.0.11 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46802
diff
changeset
|
3521 (not (tramp-handle-file-exists-p nonexisting))) |
cf225aed7a75
Version 2.0.11 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46802
diff
changeset
|
3522 (and (setq tramp-file-exists-command "ls -d %s") |
cf225aed7a75
Version 2.0.11 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46802
diff
changeset
|
3523 (tramp-handle-file-exists-p existing) |
45861 | 3524 (not (tramp-handle-file-exists-p nonexisting)))) |
3525 (error "Couldn't find command to check if file exists.")))) | |
3526 | |
3527 | |
3528 ;; CCC test ksh or bash found for tilde expansion? | |
3529 (defun tramp-find-shell (multi-method method user host) | |
3530 "Find a shell on the remote host which groks tilde expansion." | |
3531 (let ((shell nil)) | |
3532 (tramp-send-command multi-method method user host "echo ~root") | |
3533 (tramp-wait-for-output) | |
3534 (cond | |
3535 ((string-match "^~root$" (buffer-string)) | |
3536 (setq shell | |
3537 (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
|
3538 "bash" tramp-remote-path t) |
45861 | 3539 (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
|
3540 "ksh" tramp-remote-path t))) |
45861 | 3541 (unless shell |
3542 (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
|
3543 ;; Find arguments for this shell. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3544 (let ((alist tramp-sh-extra-args) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3545 item extra-args) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3546 (while (and alist (null extra-args)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3547 (setq item (pop alist)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3548 (when (string-match (car item) shell) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3549 (setq extra-args (cdr item)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3550 (when extra-args (setq shell (concat shell " " extra-args)))) |
45861 | 3551 (tramp-message |
3552 5 "Starting remote shell `%s' for tilde expansion..." shell) | |
3553 (tramp-send-command | |
3554 multi-method method user host | |
46801
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
3555 (concat "PS1='$ ' exec " shell)) ; |
45861 | 3556 (unless (tramp-wait-for-regexp |
3557 (get-buffer-process (current-buffer)) | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3558 60 (format "\\(\\(%s\\)\\|\\(%s\\)\\)\\'" |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3559 tramp-shell-prompt-pattern shell-prompt-pattern)) |
45861 | 3560 (pop-to-buffer (buffer-name)) |
3561 (error "Couldn't find remote `%s' prompt." shell)) | |
46801
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
3562 (tramp-message |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3563 9 "Setting remote shell prompt...") |
45861 | 3564 (process-send-string nil (format "PS1='%s%s%s'; PS2=''; PS3=''%s" |
3565 tramp-rsh-end-of-line | |
3566 tramp-end-of-output | |
3567 tramp-rsh-end-of-line | |
3568 tramp-rsh-end-of-line)) | |
3569 (tramp-wait-for-output) | |
46801
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
3570 (tramp-message |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3571 9 "Setting remote shell prompt...done") |
46835
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
3572 ;; (tramp-send-command multi-method method user host "echo hello") |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
3573 ;; (tramp-message 5 "Waiting for remote `%s' to start up..." shell) |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
3574 ;; (unless (tramp-wait-for-output 5) |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
3575 ;; (unless (tramp-wait-for-output 5) |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
3576 ;; (pop-to-buffer (buffer-name)) |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
3577 ;; (error "Couldn't start remote `%s', see buffer `%s' for details" |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
3578 ;; shell (buffer-name)))) |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
3579 ;; (tramp-message 5 "Waiting for remote `%s' to start up...done" shell) |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
3580 ) |
45861 | 3581 (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
|
3582 (tramp-get-remote-sh multi-method method)))))) |
45861 | 3583 |
3584 (defun tramp-check-ls-command (multi-method method user host cmd) | |
3585 "Checks whether the given `ls' executable groks `-n'. | |
3586 METHOD, USER and HOST specify the connection, CMD (the full path name of) | |
3587 the `ls' executable. Returns t if CMD supports the `-n' option, nil | |
3588 otherwise." | |
3589 (tramp-message 9 "Checking remote `%s' command for `-n' option" | |
3590 cmd) | |
3591 (when (tramp-handle-file-executable-p | |
3592 (tramp-make-tramp-file-name multi-method method user host cmd)) | |
3593 (let ((result nil)) | |
3594 (tramp-message 7 "Testing remote command `%s' for -n..." cmd) | |
3595 (setq result | |
3596 (tramp-send-command-and-check | |
3597 multi-method method user host | |
3598 (format "%s -lnd / >/dev/null" | |
3599 cmd))) | |
3600 (tramp-message 7 "Testing remote command `%s' for -n...%s" | |
3601 cmd | |
3602 (if (zerop result) "okay" "failed")) | |
3603 (zerop result)))) | |
3604 | |
3605 (defun tramp-check-ls-commands (multi-method method user host cmd dirlist) | |
3606 "Checks whether the given `ls' executable in one of the dirs groks `-n'. | |
3607 Returns nil if none was found, else the command is returned." | |
3608 (let ((dl dirlist) | |
46835
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
3609 (result nil) |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
3610 (directory-sep-char ?/)) ;for XEmacs |
45861 | 3611 ;; It would be better to use the CL function `find', but |
3612 ;; we don't want run-time dependencies on CL. | |
3613 (while (and dl (not result)) | |
3614 (let ((x (concat (file-name-as-directory (car dl)) cmd))) | |
3615 (when (tramp-check-ls-command multi-method method user host x) | |
3616 (setq result x))) | |
3617 (setq dl (cdr dl))) | |
3618 result)) | |
3619 | |
3620 (defun tramp-find-ls-command (multi-method method user host) | |
3621 "Finds an `ls' command which groks the `-n' option, returning nil if failed. | |
3622 \(This option prints numeric user and group ids in a long listing.)" | |
3623 (tramp-message 9 "Finding a suitable `ls' command") | |
3624 (or | |
3625 (tramp-check-ls-commands multi-method method user host "ls" tramp-remote-path) | |
3626 (tramp-check-ls-commands multi-method method user host "gnuls" tramp-remote-path) | |
3627 (tramp-check-ls-commands multi-method method user host "gls" tramp-remote-path))) | |
3628 | |
3629 ;; ------------------------------------------------------------ | |
3630 ;; -- Functions for establishing connection -- | |
3631 ;; ------------------------------------------------------------ | |
3632 | |
46752 | 3633 ;; The following functions are actions to be taken when seeing certain |
3634 ;; prompts from the remote host. See the variable | |
3635 ;; `tramp-actions-before-shell' for usage of these functions. | |
3636 | |
3637 (defun tramp-action-login (p multi-method method user host) | |
3638 "Send the login name." | |
3639 (tramp-message 9 "Sending login name `%s'" | |
3640 (or user (user-login-name))) | |
3641 (erase-buffer) | |
3642 (process-send-string nil (concat (or user (user-login-name)) | |
3643 tramp-rsh-end-of-line))) | |
3644 | |
3645 (defun tramp-action-password (p multi-method method user host) | |
3646 "Query the user for a password." | |
3647 (when (tramp-method-out-of-band-p multi-method method) | |
3648 (kill-process (get-buffer-process (current-buffer))) | |
3649 (error (concat "Out of band method `%s' not applicable " | |
3650 "for remote shell asking for a password") | |
3651 method)) | |
3652 (tramp-enter-password p (match-string 0))) | |
3653 | |
3654 (defun tramp-action-succeed (p multi-method method user host) | |
3655 "Signal success in finding shell prompt." | |
3656 (tramp-message 9 "Found remote shell prompt.") | |
3657 (erase-buffer) | |
3658 (throw 'tramp-action 'ok)) | |
3659 | |
3660 (defun tramp-action-permission-denied (p multi-method method user host) | |
3661 "Signal permission denied." | |
46790 | 3662 (pop-to-buffer (tramp-get-buffer multi-method method user host)) |
46752 | 3663 (tramp-message 9 "Permission denied by remote host.") |
3664 (kill-process p) | |
3665 (throw 'tramp-action 'permission-denied)) | |
3666 | |
3667 (defun tramp-action-yesno (p multi-method method user host) | |
46992
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
3668 "Ask the user for confirmation using `yes-or-no-p'. |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
3669 Send \"yes\" to remote process on confirmation, abort otherwise. |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
3670 See also `tramp-action-yn'." |
46752 | 3671 (save-window-excursion |
3672 (pop-to-buffer (tramp-get-buffer multi-method method user host)) | |
3673 (unless (yes-or-no-p (match-string 0)) | |
3674 (kill-process p) | |
3675 (erase-buffer) | |
3676 (throw 'tramp-action 'permission-denied)) | |
3677 (process-send-string p (concat "yes" tramp-rsh-end-of-line)) | |
3678 (erase-buffer))) | |
3679 | |
46992
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
3680 (defun tramp-action-yn (p multi-method method user host) |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
3681 "Ask the user for confirmation using `y-or-n-p'. |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
3682 Send \"y\" to remote process on confirmation, abort otherwise. |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
3683 See also `tramp-action-yesno'." |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
3684 (save-window-excursion |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
3685 (pop-to-buffer (tramp-get-buffer multi-method method user host)) |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
3686 (unless (y-or-n-p (match-string 0)) |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
3687 (kill-process p) |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
3688 (erase-buffer) |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
3689 (throw 'tramp-action 'permission-denied)) |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
3690 (process-send-string p (concat "y" tramp-rsh-end-of-line)))) |
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
3691 |
46752 | 3692 ;; The following functions are specifically for multi connections. |
3693 | |
3694 (defun tramp-multi-action-login (p method user host) | |
3695 "Send the login name." | |
3696 (tramp-message 9 "Sending login name `%s'" user) | |
3697 (erase-buffer) | |
3698 (process-send-string p (concat user tramp-rsh-end-of-line))) | |
3699 | |
3700 (defun tramp-multi-action-password (p method user host) | |
3701 "Query the user for a password." | |
3702 (tramp-enter-password p (match-string 0))) | |
3703 | |
3704 (defun tramp-multi-action-succeed (p method user host) | |
3705 "Signal success in finding shell prompt." | |
3706 (tramp-message 9 "Found shell prompt on `%s'" host) | |
3707 (erase-buffer) | |
3708 (throw 'tramp-action 'ok)) | |
3709 | |
3710 (defun tramp-multi-action-permission-denied (p method user host) | |
3711 "Signal permission denied." | |
3712 (tramp-message 9 "Permission denied by remote host `%s'" host) | |
3713 (kill-process p) | |
3714 (erase-buffer) | |
3715 (throw 'tramp-action 'permission-denied)) | |
3716 | |
3717 ;; Functions for processing the actions. | |
3718 | |
3719 (defun tramp-process-one-action (p multi-method method user host actions) | |
3720 "Wait for output from the shell and perform one action." | |
3721 (let (found item pattern action todo) | |
3722 (erase-buffer) | |
3723 (tramp-message 9 "Waiting 60s for prompt from remote shell") | |
3724 (with-timeout (60 (throw 'tramp-action 'timeout)) | |
3725 (while (not found) | |
3726 (accept-process-output p 1) | |
3727 (goto-char (point-min)) | |
3728 (setq todo actions) | |
3729 (while todo | |
3730 (goto-char (point-min)) | |
3731 (setq item (pop todo)) | |
3732 (setq pattern (symbol-value (nth 0 item))) | |
3733 (setq action (nth 1 item)) | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3734 (tramp-message 10 "Looking for regexp \"%s\" from remote shell" |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3735 pattern) |
46752 | 3736 (when (re-search-forward (concat pattern "\\'") nil t) |
3737 (setq found (funcall action p multi-method method user host))))) | |
3738 found))) | |
3739 | |
3740 (defun tramp-process-actions (p multi-method method user host actions) | |
3741 "Perform actions until success." | |
3742 (let (exit) | |
3743 (while (not exit) | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3744 (tramp-message 9 "Waiting for prompts from remote shell") |
46752 | 3745 (setq exit |
3746 (catch 'tramp-action | |
3747 (tramp-process-one-action | |
3748 p multi-method method user host actions) | |
3749 nil))) | |
3750 (unless (eq exit 'ok) | |
3751 (error "Login failed")))) | |
3752 | |
3753 ;; For multi-actions. | |
3754 | |
3755 (defun tramp-process-one-multi-action (p method user host actions) | |
3756 "Wait for output from the shell and perform one action." | |
3757 (let (found item pattern action todo) | |
3758 (erase-buffer) | |
3759 (tramp-message 9 "Waiting 60s for prompt from remote shell") | |
3760 (with-timeout (60 (throw 'tramp-action 'timeout)) | |
3761 (while (not found) | |
3762 (accept-process-output p 1) | |
3763 (setq todo actions) | |
3764 (goto-char (point-min)) | |
3765 (while todo | |
3766 (goto-char (point-min)) | |
3767 (setq item (pop todo)) | |
3768 (setq pattern (symbol-value (nth 0 item))) | |
3769 (setq action (nth 1 item)) | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3770 (tramp-message 10 "Looking for regexp \"%s\" from remote shell" |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3771 pattern) |
46752 | 3772 (when (re-search-forward (concat pattern "\\'") nil t) |
3773 (setq found (funcall action p method user host))))) | |
3774 found))) | |
3775 | |
3776 (defun tramp-process-multi-actions (p method user host actions) | |
3777 "Perform actions until success." | |
3778 (let (exit) | |
3779 (while (not exit) | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3780 (tramp-message 9 "Waiting for prompts from remote shell") |
46752 | 3781 (setq exit |
3782 (catch 'tramp-action | |
3783 (tramp-process-one-multi-action p method user host actions) | |
3784 nil))) | |
3785 (unless (eq exit 'ok) | |
3786 (error "Login failed")))) | |
3787 | |
3788 ;; The actual functions for opening connections. | |
45861 | 3789 |
3790 (defun tramp-open-connection-telnet (multi-method method user host) | |
3791 "Open a connection using a telnet METHOD. | |
3792 This starts the command `telnet HOST ARGS'[*], then waits for a remote | |
3793 login prompt, then sends the user name USER, then waits for a remote | |
3794 password prompt. It queries the user for the password, then sends the | |
3795 password to the remote host. | |
3796 | |
3797 If USER is nil, uses value returned by `(user-login-name)' instead. | |
3798 | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3799 Recognition of the remote shell prompt is based on the variables |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3800 `shell-prompt-pattern' and `tramp-shell-prompt-pattern' which must be |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3801 set up correctly. |
45861 | 3802 |
3803 Please note that it is NOT possible to use this connection method | |
3804 together with an out-of-band transfer method! You must use an inline | |
3805 transfer method. | |
3806 | |
3807 Maybe the different regular expressions need to be tuned. | |
3808 | |
3809 * Actually, the telnet program as well as the args to be used can be | |
3810 specified in the method parameters, see the variable `tramp-methods'." | |
3811 (save-match-data | |
3812 (when (tramp-method-out-of-band-p multi-method method) | |
3813 (error "Cannot use out-of-band method `%s' with telnet connection method" | |
3814 method)) | |
3815 (when multi-method | |
3816 (error "Cannot multi-connect using telnet connection method")) | |
3817 (tramp-pre-connection multi-method method user host) | |
3818 (tramp-message 7 "Opening connection for %s@%s using %s..." | |
3819 (or user (user-login-name)) host method) | |
3820 (let ((process-environment (copy-sequence process-environment))) | |
3821 (setenv "TERM" tramp-terminal-type) | |
3822 (let* ((default-directory (tramp-temporary-file-directory)) | |
3823 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
3824 (> emacs-major-version 20)) | |
3825 tramp-dos-coding-system)) | |
3826 (p (apply 'start-process | |
3827 (tramp-buffer-name multi-method method user host) | |
3828 (tramp-get-buffer multi-method method user host) | |
3829 (tramp-get-telnet-program multi-method method) | |
3830 host | |
3831 (tramp-get-telnet-args multi-method method))) | |
3832 (found nil) | |
3833 (pw nil)) | |
3834 (process-kill-without-query p) | |
46752 | 3835 (set-buffer (tramp-get-buffer multi-method method user host)) |
3836 (erase-buffer) | |
3837 (tramp-process-actions p multi-method method user host | |
3838 tramp-actions-before-shell) | |
3839 | |
3840 ;; (tramp-message 9 "Waiting for login prompt...") | |
3841 ;; (unless (tramp-wait-for-regexp p nil tramp-login-prompt-regexp) | |
3842 ;; (pop-to-buffer (buffer-name)) | |
3843 ;; (kill-process p) | |
3844 ;; (error "Couldn't find remote login prompt")) | |
3845 ;; (erase-buffer) | |
3846 ;; ;; Remote login defaults to local one. | |
3847 ;; (tramp-message 9 "Sending login name %s" (or user (user-login-name))) | |
3848 ;; (process-send-string p (concat (or user (user-login-name)) | |
3849 ;; tramp-rsh-end-of-line)) | |
3850 ;; (tramp-message 9 "Waiting for password prompt...") | |
3851 ;; (unless (setq found (tramp-wait-for-regexp | |
3852 ;; p nil tramp-password-prompt-regexp)) | |
3853 ;; (pop-to-buffer (buffer-name)) | |
3854 ;; (kill-process p) | |
3855 ;; (error "Couldn't find remote password prompt")) | |
3856 ;; (erase-buffer) | |
3857 ;; (setq pw (tramp-read-passwd (car found))) | |
3858 ;; (tramp-message 9 "Sending password") | |
3859 ;; (process-send-string p (concat pw tramp-rsh-end-of-line)) | |
3860 ;; (tramp-message 9 "Waiting 30s for remote shell to come up...") | |
3861 ;; (unless (setq found | |
3862 ;; (tramp-wait-for-regexp | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3863 ;; p 30 (format "\\(%s\\)\\|\\(%s\\)\\|\\(%s\\)\\'" |
46752 | 3864 ;; tramp-wrong-passwd-regexp |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3865 ;; shell-prompt-pattern |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3866 ;; tramp-shell-prompt-pattern))) |
46752 | 3867 ;; (pop-to-buffer (buffer-name)) |
3868 ;; (kill-process p) | |
3869 ;; (error "Couldn't find remote shell prompt")) | |
3870 ;; (when (nth 1 found) | |
3871 ;; (pop-to-buffer (buffer-name)) | |
3872 ;; (kill-process p) | |
3873 ;; (error "Login failed: %s" (nth 1 found))) | |
3874 | |
45861 | 3875 (tramp-open-connection-setup-interactive-shell |
3876 p multi-method method user host) | |
3877 (tramp-post-connection multi-method method user host))))) | |
3878 | |
46752 | 3879 |
45861 | 3880 (defun tramp-open-connection-rsh (multi-method method user host) |
3881 "Open a connection using an rsh METHOD. | |
3882 This starts the command `rsh HOST -l USER'[*], then waits for a remote | |
3883 password or shell prompt. If a password prompt is seen, the user is | |
3884 queried for a password, this function sends the password to the remote | |
3885 host and waits for a shell prompt. | |
3886 | |
3887 If USER is nil, start the command `rsh HOST'[*] instead | |
3888 | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3889 Recognition of the remote shell prompt is based on the variables |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3890 `shell-prompt-pattern' and `tramp-shell-prompt-pattern' which must be |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3891 set up correctly. |
45861 | 3892 |
3893 Please note that it is NOT possible to use this connection method with | |
3894 an out-of-band transfer method if this function asks the user for a | |
3895 password! You must use an inline transfer method in this case. | |
3896 Sadly, the transfer method cannot be switched on the fly, instead you | |
3897 must specify the right method in the file name. | |
3898 | |
46010
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3899 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
|
3900 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
|
3901 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
|
3902 |
45861 | 3903 * Actually, the rsh program to be used can be specified in the |
3904 method parameters, see the variable `tramp-methods'." | |
3905 (save-match-data | |
3906 (when multi-method | |
3907 (error "Cannot multi-connect using rsh connection method")) | |
3908 (tramp-pre-connection multi-method method user host) | |
3909 (if user | |
3910 (tramp-message 7 "Opening connection for %s@%s using %s..." | |
3911 user host method) | |
3912 (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
|
3913 (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
|
3914 (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
|
3915 (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
|
3916 (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
|
3917 (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
|
3918 ;; 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
|
3919 ;; 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
|
3920 (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
|
3921 (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
|
3922 (setq host (match-string 1 host))) |
45861 | 3923 (setenv "TERM" tramp-terminal-type) |
3924 (let* ((default-directory (tramp-temporary-file-directory)) | |
3925 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
3926 (> emacs-major-version 20)) | |
3927 tramp-dos-coding-system)) | |
3928 (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
|
3929 (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
|
3930 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
|
3931 (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
|
3932 host rsh-args))) |
45861 | 3933 (found nil)) |
3934 (process-kill-without-query p) | |
46752 | 3935 |
3936 (set-buffer buf) | |
3937 (tramp-process-actions p multi-method method user host | |
3938 tramp-actions-before-shell) | |
3939 | |
3940 ;; (tramp-message 9 "Waiting 60s for shell or passwd prompt from %s" host) | |
3941 ;; (setq found | |
3942 ;; (tramp-wait-for-regexp | |
3943 ;; p 60 | |
3944 ;; (format | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3945 ;; "\\(%s\\)\\|\\(%s\\)\\|\\(%s\\)\\'" |
46752 | 3946 ;; tramp-password-prompt-regexp |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3947 ;; shell-prompt-pattern tramp-shell-prompt-pattern))) |
46752 | 3948 ;; (unless found |
3949 ;; (pop-to-buffer (buffer-name)) | |
3950 ;; (kill-process p) | |
3951 ;; (error "Couldn't find remote shell or passwd prompt")) | |
3952 ;; (when (nth 1 found) | |
3953 ;; (when (tramp-method-out-of-band-p multi-method method) | |
3954 ;; (pop-to-buffer (buffer-name)) | |
3955 ;; (kill-process p) | |
3956 ;; (error (concat "Out of band method `%s' not applicable" | |
3957 ;; " for remote shell asking for a password") | |
3958 ;; method)) | |
3959 ;; (erase-buffer) | |
3960 ;; (tramp-message 9 "Sending password...") | |
3961 ;; (tramp-enter-password p (nth 1 found)) | |
3962 ;; (tramp-message 9 "Sent password, waiting 60s for remote shell prompt") | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3963 ;; (setq found (tramp-wait-for-regexp |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3964 ;; p 60 |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3965 ;; (format "\\(%s\\)\\|\\(%s\\)\\|\\(%s\\)\\'" |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3966 ;; tramp-wrong-passwd-regexp |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3967 ;; shell-prompt-pattern |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3968 ;; tramp-shell-prompt-pattern)))) |
46752 | 3969 ;; (unless found |
3970 ;; (pop-to-buffer (buffer-name)) | |
3971 ;; (kill-process p) | |
3972 ;; (error "Couldn't find remote shell prompt")) | |
3973 ;; (when (nth 1 found) | |
3974 ;; (pop-to-buffer (buffer-name)) | |
3975 ;; (kill-process p) | |
3976 ;; (error "Login failed: %s" (nth 1 found))) | |
3977 | |
45861 | 3978 (tramp-message 7 "Initializing remote shell") |
3979 (tramp-open-connection-setup-interactive-shell | |
3980 p multi-method method user host) | |
3981 (tramp-post-connection multi-method method user host))))) | |
3982 | |
3983 (defun tramp-open-connection-su (multi-method method user host) | |
3984 "Open a connection using the `su' program with METHOD. | |
3985 This starts `su - USER', then waits for a password prompt. The HOST | |
3986 name must be equal to the local host name or to `localhost'. | |
3987 | |
3988 If USER is nil, uses value returned by user-login-name instead. | |
3989 | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3990 Recognition of the remote shell prompt is based on the variables |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3991 `shell-prompt-pattern' and `tramp-shell-prompt-pattern' which must be |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3992 set up correctly. Note that the other user may have a different shell |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3993 prompt than you do, so it is not at all unlikely that the variable |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
3994 `shell-prompt-pattern' is set up wrongly!" |
45861 | 3995 (save-match-data |
3996 (when (tramp-method-out-of-band-p multi-method method) | |
3997 (error "Cannot use out-of-band method `%s' with `su' connection method" | |
3998 method)) | |
3999 (unless (or (string-match (concat "^" (regexp-quote host)) | |
4000 (system-name)) | |
4001 (string= "localhost" host)) | |
4002 (error | |
4003 "Cannot connect to different host `%s' with `su' connection method" | |
4004 host)) | |
4005 (when (not user) | |
4006 (error "Must give user name for `su' connection method")) | |
4007 (tramp-pre-connection multi-method method user host) | |
4008 (tramp-message 7 "Opening connection for `%s' using `%s'..." | |
4009 (or user (user-login-name)) method) | |
4010 (let ((process-environment (copy-sequence process-environment))) | |
4011 (setenv "TERM" tramp-terminal-type) | |
4012 (let* ((default-directory (tramp-temporary-file-directory)) | |
4013 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
4014 (> emacs-major-version 20)) | |
4015 tramp-dos-coding-system)) | |
4016 (p (apply 'start-process | |
46752 | 4017 (tramp-buffer-name multi-method method user host) |
4018 (tramp-get-buffer multi-method method user host) | |
45861 | 4019 (tramp-get-su-program multi-method method) |
4020 (mapcar | |
4021 '(lambda (x) | |
46752 | 4022 (format-spec x `((?u . ,user)))) |
45861 | 4023 (tramp-get-su-args multi-method method)))) |
4024 (found nil) | |
4025 (pw nil)) | |
4026 (process-kill-without-query p) | |
46752 | 4027 (set-buffer (tramp-get-buffer multi-method method user host)) |
4028 (tramp-process-actions p multi-method method user host | |
4029 tramp-actions-before-shell) | |
4030 | |
4031 ;; (tramp-message 9 "Waiting 30s for shell or password prompt...") | |
4032 ;; (unless (setq found (tramp-wait-for-regexp | |
4033 ;; p 30 | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4034 ;; (format "\\(%s\\)\\|\\(%s\\)\\|\\(%s\\)\\'" |
46752 | 4035 ;; tramp-password-prompt-regexp |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4036 ;; shell-prompt-pattern |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4037 ;; tramp-shell-prompt-pattern))) |
46752 | 4038 ;; (pop-to-buffer (buffer-name)) |
4039 ;; (kill-process p) | |
4040 ;; (error "Couldn't find shell or password prompt")) | |
4041 ;; (when (nth 1 found) | |
4042 ;; (erase-buffer) | |
4043 ;; (setq pw (tramp-read-passwd (car found))) | |
4044 ;; (tramp-message 9 "Sending password") | |
4045 ;; (process-send-string p (concat pw tramp-rsh-end-of-line)) | |
4046 ;; (tramp-message 9 "Waiting 30s for remote shell to come up...") | |
4047 ;; (unless (setq found | |
4048 ;; (tramp-wait-for-regexp | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4049 ;; p 30 (format "\\(%s\\)\\|\\(%s\\)\\|\\(%s\\)\\'" |
46752 | 4050 ;; tramp-wrong-passwd-regexp |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4051 ;; shell-prompt-pattern |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4052 ;; tramp-shell-prompt-pattern))) |
46752 | 4053 ;; (pop-to-buffer (buffer-name)) |
4054 ;; (kill-process p) | |
4055 ;; (error "Couldn't find remote shell prompt")) | |
4056 ;; (when (nth 1 found) | |
4057 ;; (pop-to-buffer (buffer-name)) | |
4058 ;; (kill-process p) | |
4059 ;; (error "`su' failed: %s" (nth 1 found)))) | |
4060 | |
45861 | 4061 (tramp-open-connection-setup-interactive-shell |
4062 p multi-method method user host) | |
4063 (tramp-post-connection multi-method method | |
4064 user host))))) | |
4065 | |
4066 ;; HHH: Not Changed. Multi method. It is not clear to me how this can | |
4067 ;; handle not giving a user name in the "file name". | |
4068 ;; | |
4069 ;; This is more difficult than for the single-hop method. In the | |
4070 ;; multi-hop-method, the desired behaviour should be that the | |
4071 ;; user must specify names for the telnet hops of which the user | |
4072 ;; name is different than the "original" name (or different from | |
4073 ;; the previous hop. | |
4074 (defun tramp-open-connection-multi (multi-method method user host) | |
4075 "Open a multi-hop connection using METHOD. | |
4076 This uses a slightly changed file name syntax. The idea is to say | |
4077 [multi/telnet:u1@h1/rsh:u2@h2]/path/to/file | |
4078 This will use telnet to log in as u1 to h1, then use rsh from there to | |
4079 log in as u2 to h2." | |
4080 (save-match-data | |
4081 (unless multi-method | |
4082 (error "Multi-hop open connection function called on non-multi method")) | |
4083 (when (tramp-method-out-of-band-p multi-method method) | |
4084 (error "No out of band multi-hop connections")) | |
4085 (unless (and (arrayp method) (not (stringp method))) | |
4086 (error "METHOD must be an array of strings for multi methods")) | |
4087 (unless (and (arrayp user) (not (stringp user))) | |
4088 (error "USER must be an array of strings for multi methods")) | |
4089 (unless (and (arrayp host) (not (stringp host))) | |
4090 (error "HOST must be an array of strings for multi methods")) | |
4091 (unless (and (= (length method) (length user)) | |
4092 (= (length method) (length host))) | |
4093 (error "Arrays METHOD, USER, HOST must have equal length")) | |
4094 (tramp-pre-connection multi-method method user host) | |
4095 (tramp-message 7 "Opening `%s' connection..." multi-method) | |
4096 (let ((process-environment (copy-sequence process-environment))) | |
4097 (setenv "TERM" tramp-terminal-type) | |
4098 (let* ((default-directory (tramp-temporary-file-directory)) | |
4099 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
4100 (> emacs-major-version 20)) | |
4101 tramp-dos-coding-system)) | |
4102 (p (start-process (tramp-buffer-name multi-method method user host) | |
4103 (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
|
4104 tramp-multi-sh-program)) |
45861 | 4105 (num-hops (length method)) |
4106 (i 0)) | |
4107 (process-kill-without-query p) | |
4108 (tramp-message 9 "Waiting 60s for local shell to come up...") | |
4109 (unless (tramp-wait-for-regexp | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4110 p 60 (format "\\(%s\\)\\'\\|\\(%s\\)\\'" |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4111 shell-prompt-pattern tramp-shell-prompt-pattern)) |
45861 | 4112 (pop-to-buffer (buffer-name)) |
4113 (kill-process p) | |
4114 (error "Couldn't find local shell prompt")) | |
4115 ;; Now do all the connections as specified. | |
4116 (while (< i num-hops) | |
4117 (let* ((m (aref method i)) | |
4118 (u (aref user i)) | |
4119 (h (aref host i)) | |
4120 (entry (assoc m tramp-multi-connection-function-alist)) | |
4121 (multi-func (nth 1 entry)) | |
4122 (command (nth 2 entry))) | |
4123 ;; The multi-funcs don't need to do save-match-data, as that | |
4124 ;; is done here. | |
4125 (funcall multi-func p m u h command) | |
4126 (erase-buffer) | |
4127 (incf i))) | |
4128 (tramp-open-connection-setup-interactive-shell | |
4129 p multi-method method user host) | |
4130 (tramp-post-connection multi-method method user host))))) | |
4131 | |
4132 ;; HHH: Changed. Multi method. Don't know how to handle this in the case | |
4133 ;; of no user name provided. Hack to make it work as it did before: | |
4134 ;; changed `user' to `(or user (user-login-name))' in the places where | |
4135 ;; the value is actually used. | |
4136 (defun tramp-multi-connect-telnet (p method user host command) | |
4137 "Issue `telnet' command. | |
4138 Uses shell COMMAND to issue a `telnet' command to log in as USER to | |
4139 HOST. You can use percent escapes in COMMAND: `%h' is replaced with | |
4140 the host name, and `%n' is replaced with an end of line character, as | |
4141 set in `tramp-rsh-end-of-line'. Use `%%' if you want a literal percent | |
4142 character. | |
4143 | |
4144 If USER is nil, uses the return value of (user-login-name) instead." | |
46752 | 4145 (let ((cmd (format-spec command |
4146 `((?h . ,host) (?n . ,tramp-rsh-end-of-line)))) | |
4147 (cmd1 (format-spec command `((?h . ,host) (?n . "")))) | |
45861 | 4148 found pw) |
4149 (erase-buffer) | |
4150 (tramp-message 9 "Sending telnet command `%s'" cmd1) | |
4151 (process-send-string p cmd) | |
46752 | 4152 (tramp-process-multi-actions p method user host |
4153 tramp-multi-actions) | |
4154 | |
4155 ;; (tramp-message 9 "Waiting 30s for login prompt from %s" host) | |
4156 ;; (unless (tramp-wait-for-regexp p 30 tramp-login-prompt-regexp) | |
4157 ;; (pop-to-buffer (buffer-name)) | |
4158 ;; (kill-process p) | |
4159 ;; (error "Couldn't find login prompt from host %s" host)) | |
4160 ;; (erase-buffer) | |
4161 ;; (tramp-message 9 "Sending login name %s" (or user (user-login-name))) | |
4162 ;; (process-send-string p (concat (or user (user-login-name)) tramp-rsh-end-of-line)) | |
4163 ;; (tramp-message 9 "Waiting for password prompt") | |
4164 ;; (unless (setq found (tramp-wait-for-regexp p nil tramp-password-prompt-regexp)) | |
4165 ;; (pop-to-buffer (buffer-name)) | |
4166 ;; (kill-process p) | |
4167 ;; (error "Couldn't find password prompt from host %s" host)) | |
4168 ;; (erase-buffer) | |
4169 ;; (setq pw (tramp-read-passwd | |
4170 ;; (format "Password for %s@%s, %s" (or user (user-login-name)) host found))) | |
4171 ;; (tramp-message 9 "Sending password") | |
4172 ;; (process-send-string p (concat pw tramp-rsh-end-of-line)) | |
4173 ;; (tramp-message 9 "Waiting 60s for remote shell to come up...") | |
4174 ;; (unless (setq found (tramp-wait-for-regexp | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4175 ;; p 60 (format "\\(%s\\)\\|\\(%s\\)\\|\\(%s\\)\\'" |
46752 | 4176 ;; tramp-wrong-passwd-regexp |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4177 ;; shell-prompt-pattern |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4178 ;; tramp-shell-prompt-pattern))) |
46752 | 4179 ;; (pop-to-buffer (buffer-name)) |
4180 ;; (kill-process p) | |
4181 ;; (error "Couldn't find shell prompt from host %s" host)) | |
4182 ;; (when (nth 1 found) | |
4183 ;; (pop-to-buffer (buffer-name)) | |
4184 ;; (kill-process p) | |
4185 ;; (error "Login to %s failed: %s" (nth 2 found))) | |
4186 )) | |
45861 | 4187 |
4188 ;; HHH: Changed. Multi method. Don't know how to handle this in the case | |
4189 ;; of no user name provided. Hack to make it work as it did before: | |
4190 ;; changed `user' to `(or user (user-login-name))' in the places where | |
4191 ;; the value is actually used. | |
4192 (defun tramp-multi-connect-rlogin (p method user host command) | |
4193 "Issue `rlogin' command. | |
4194 Uses shell COMMAND to issue an `rlogin' command to log in as USER to | |
4195 HOST. You can use percent escapes in COMMAND. `%u' will be replaced | |
4196 with the user name, `%h' will be replaced with the host name, and `%n' | |
4197 will be replaced with the value of `tramp-rsh-end-of-line'. You can use | |
4198 `%%' if you want to use a literal percent character. | |
4199 | |
4200 If USER is nil, uses the return value of (user-login-name) instead." | |
46752 | 4201 (let ((cmd (format-spec command `((?h . ,host) |
4202 (?u . ,(or user (user-login-name))) | |
4203 (?n . ,tramp-rsh-end-of-line)))) | |
4204 (cmd1 (format-spec command `((?h . ,host) | |
4205 (?u . ,(or user (user-login-name))) | |
4206 (?n . "")))) | |
45861 | 4207 found) |
4208 (erase-buffer) | |
4209 (tramp-message 9 "Sending rlogin command `%s'" cmd1) | |
4210 (process-send-string p cmd) | |
46752 | 4211 (tramp-process-multi-actions p method user host |
4212 tramp-multi-actions) | |
4213 ;; (tramp-message 9 "Waiting 60s for shell or passwd prompt from %s" host) | |
4214 ;; (unless (setq found | |
4215 ;; (tramp-wait-for-regexp p 60 | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4216 ;; (format "\\(%s\\)\\|\\(%s\\)\\|\\(%s\\)\\'" |
46752 | 4217 ;; tramp-password-prompt-regexp |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4218 ;; shell-prompt-pattern |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4219 ;; tramp-shell-prompt-pattern))) |
46752 | 4220 ;; (pop-to-buffer (buffer-name)) |
4221 ;; (kill-process p) | |
4222 ;; (error "Couldn't find remote shell or passwd prompt")) | |
4223 ;; (when (nth 1 found) | |
4224 ;; (erase-buffer) | |
4225 ;; (tramp-message 9 "Sending password...") | |
4226 ;; (tramp-enter-password p (nth 1 found)) | |
4227 ;; (tramp-message 9 "Sent password, waiting 60s for remote shell prompt") | |
4228 ;; (setq found (tramp-wait-for-regexp p 60 | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4229 ;; (format "\\(%s\\)\\|\\(%s\\)\\|\\(%s\\)\\'" |
46752 | 4230 ;; tramp-wrong-passwd-regexp |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4231 ;; shell-prompt-pattern |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4232 ;; tramp-shell-prompt-pattern)))) |
46752 | 4233 ;; (unless found |
4234 ;; (pop-to-buffer (buffer-name)) | |
4235 ;; (kill-process p) | |
4236 ;; (error "Couldn't find remote shell prompt")) | |
4237 ;; (when (nth 1 found) | |
4238 ;; (pop-to-buffer (buffer-name)) | |
4239 ;; (kill-process p) | |
4240 ;; (error "Login failed: %s" (nth 1 found))) | |
4241 )) | |
45861 | 4242 |
4243 ;; HHH: Changed. Multi method. Don't know how to handle this in the case | |
4244 ;; of no user name provided. Hack to make it work as it did before: | |
4245 ;; changed `user' to `(or user (user-login-name))' in the places where | |
4246 ;; the value is actually used. | |
4247 (defun tramp-multi-connect-su (p method user host command) | |
4248 "Issue `su' command. | |
4249 Uses shell COMMAND to issue a `su' command to log in as USER on | |
4250 HOST. The HOST name is ignored, this just changes the user id on the | |
4251 host currently logged in to. | |
4252 | |
4253 If USER is nil, uses the return value of (user-login-name) instead. | |
4254 | |
4255 You can use percent escapes in the COMMAND. `%u' is replaced with the | |
4256 user name, and `%n' is replaced with the value of | |
4257 `tramp-rsh-end-of-line'. Use `%%' if you want a literal percent | |
4258 character." | |
46752 | 4259 (let ((cmd (format-spec command `((?u . ,(or user (user-login-name))) |
4260 (?n . ,tramp-rsh-end-of-line)))) | |
4261 (cmd1 (format-spec command `((?u . ,(or user (user-login-name))) | |
4262 (?n . "")))) | |
45861 | 4263 found) |
4264 (erase-buffer) | |
4265 (tramp-message 9 "Sending su command `%s'" cmd1) | |
4266 (process-send-string p cmd) | |
46752 | 4267 (tramp-process-multi-actions p method user host |
4268 tramp-multi-actions) | |
4269 ;; (tramp-message 9 "Waiting 60s for shell or passwd prompt for %s" (or user (user-login-name))) | |
4270 ;; (unless (setq found (tramp-wait-for-regexp | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4271 ;; p 60 (format "\\(%s\\)\\|\\(%s\\)\\|\\(%s\\)\\'" |
46752 | 4272 ;; tramp-password-prompt-regexp |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4273 ;; shell-prompt-pattern |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4274 ;; tramp-shell-prompt-pattern))) |
46752 | 4275 ;; (pop-to-buffer (buffer-name)) |
4276 ;; (kill-process p) | |
4277 ;; (error "Couldn't find shell or passwd prompt for %s" | |
4278 ;; (or user (user-login-name)))) | |
4279 ;; (when (nth 1 found) | |
4280 ;; (tramp-message 9 "Sending password...") | |
4281 ;; (tramp-enter-password p (nth 1 found)) | |
4282 ;; (erase-buffer) | |
4283 ;; (tramp-message 9 "Sent password, waiting 60s for remote shell prompt") | |
4284 ;; (setq found (tramp-wait-for-regexp p 60 | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4285 ;; (format "\\(%s\\)\\|\\(%s\\)\\|\\(%s\\)\\'" |
46752 | 4286 ;; tramp-wrong-passwd-regexp |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4287 ;; shell-prompt-pattern |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4288 ;; tramp-shell-prompt-pattern)))) |
46752 | 4289 ;; (unless found |
4290 ;; (pop-to-buffer (buffer-name)) | |
4291 ;; (kill-process p) | |
4292 ;; (error "Couldn't find remote shell prompt")) | |
4293 ;; (when (nth 1 found) | |
4294 ;; (pop-to-buffer (buffer-name)) | |
4295 ;; (kill-process p) | |
4296 ;; (error "Login failed: %s" (nth 1 found))) | |
4297 )) | |
45861 | 4298 |
4299 ;; Utility functions. | |
4300 | |
4301 (defun tramp-wait-for-regexp (proc timeout regexp) | |
4302 "Wait for a REGEXP to appear from process PROC within TIMEOUT seconds. | |
4303 Expects the output of PROC to be sent to the current buffer. Returns | |
4304 the string that matched, or nil. Waits indefinitely if TIMEOUT is | |
4305 nil." | |
4306 (let ((found nil) | |
4307 (start-time (current-time))) | |
4308 (cond (timeout | |
4309 ;; Work around a bug in XEmacs 21, where the timeout | |
4310 ;; expires faster than it should. This degenerates | |
4311 ;; to polling for buggy XEmacsen, but oh, well. | |
4312 (while (and (not found) | |
4313 (< (tramp-time-diff (current-time) start-time) | |
4314 timeout)) | |
4315 (with-timeout (timeout) | |
4316 (while (not found) | |
4317 (accept-process-output proc 1) | |
4318 (goto-char (point-min)) | |
4319 (setq found (when (re-search-forward regexp nil t) | |
4320 (tramp-match-string-list))))))) | |
4321 (t | |
4322 (while (not found) | |
4323 (accept-process-output proc 1) | |
4324 (goto-char (point-min)) | |
4325 (setq found (when (re-search-forward regexp nil t) | |
4326 (tramp-match-string-list)))))) | |
4327 (when tramp-debug-buffer | |
4328 (append-to-buffer | |
4329 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4330 tramp-current-user tramp-current-host) | |
4331 (point-min) (point-max)) | |
4332 (when (not found) | |
4333 (save-excursion | |
4334 (set-buffer | |
4335 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4336 tramp-current-user tramp-current-host)) | |
4337 (goto-char (point-max)) | |
4338 (insert "[[Regexp `" regexp "' not found" | |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
4339 (if timeout (format " in %d secs" timeout) "") |
45861 | 4340 "]]")))) |
4341 found)) | |
4342 | |
4343 (defun tramp-enter-password (p prompt) | |
4344 "Prompt for a password and send it to the remote end. | |
4345 Uses PROMPT as a prompt and sends the password to process P." | |
4346 (let ((pw (tramp-read-passwd prompt))) | |
46752 | 4347 (erase-buffer) |
45861 | 4348 (process-send-string p (concat pw tramp-rsh-end-of-line)))) |
4349 | |
4350 ;; HHH: Not Changed. This might handle the case where USER is not | |
4351 ;; given in the "File name" very poorly. Then, the local | |
4352 ;; variable tramp-current user will be set to nil. | |
4353 (defun tramp-pre-connection (multi-method method user host) | |
4354 "Do some setup before actually logging in. | |
4355 METHOD, USER and HOST specify the connection." | |
4356 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4357 (set (make-local-variable 'tramp-current-multi-method) multi-method) | |
4358 (set (make-local-variable 'tramp-current-method) method) | |
4359 (set (make-local-variable 'tramp-current-user) user) | |
4360 (set (make-local-variable 'tramp-current-host) host) | |
4361 (set (make-local-variable 'inhibit-eol-conversion) nil) | |
4362 (erase-buffer)) | |
4363 | |
4364 (defun tramp-open-connection-setup-interactive-shell | |
4365 (p multi-method method user host) | |
4366 "Set up an interactive shell. | |
4367 Mainly sets the prompt and the echo correctly. P is the shell process | |
4368 to set up. METHOD, USER and HOST specify the connection." | |
4369 ;; Wait a bit in case the remote end feels like sending a little | |
4370 ;; junk first. It seems that fencepost.gnu.org does this when doing | |
4371 ;; a Kerberos login. | |
4372 (sit-for 1) | |
4373 (tramp-discard-garbage-erase-buffer p multi-method method user host) | |
4374 (process-send-string nil (format "exec %s%s" | |
4375 (tramp-get-remote-sh multi-method method) | |
4376 tramp-rsh-end-of-line)) | |
4377 (when tramp-debug-buffer | |
4378 (save-excursion | |
4379 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
4380 (goto-char (point-max)) | |
4381 (tramp-insert-with-face | |
4382 'bold (format "$ exec %s\n" (tramp-get-remote-sh multi-method method))))) | |
4383 (tramp-message 9 "Waiting 30s for remote `%s' to come up..." | |
4384 (tramp-get-remote-sh multi-method method)) | |
4385 (unless (tramp-wait-for-regexp | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4386 p 30 (format "\\(%s\\|%s\\)\\'" |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4387 shell-prompt-pattern tramp-shell-prompt-pattern)) |
45861 | 4388 (pop-to-buffer (buffer-name)) |
4389 (error "Remote `%s' didn't come up. See buffer `%s' for details" | |
4390 (tramp-get-remote-sh multi-method method) (buffer-name))) | |
4391 (tramp-message 9 "Setting up remote shell environment") | |
4392 (tramp-discard-garbage-erase-buffer p multi-method method user host) | |
4393 (process-send-string | |
4394 nil (format "stty -inlcr -echo kill '^U'%s" tramp-rsh-end-of-line)) | |
4395 (unless (tramp-wait-for-regexp | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4396 p 30 (format "\\(%s\\|%s\\)\\'" |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4397 shell-prompt-pattern tramp-shell-prompt-pattern)) |
45861 | 4398 (pop-to-buffer (buffer-name)) |
4399 (error "Couldn't `stty -echo', see buffer `%s'" (buffer-name))) | |
4400 (erase-buffer) | |
4401 (process-send-string nil (format "TERM=dumb; export TERM%s" | |
4402 tramp-rsh-end-of-line)) | |
4403 (unless (tramp-wait-for-regexp | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4404 p 30 (format "\\(%s\\|%s\\)\\'" |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4405 shell-prompt-pattern tramp-shell-prompt-pattern)) |
45861 | 4406 (pop-to-buffer (buffer-name)) |
4407 (error "Couldn't `TERM=dumb; export TERM', see buffer `%s'" (buffer-name))) | |
4408 ;; Try to set up the coding system correctly. | |
4409 ;; CCC this can't be the right way to do it. Hm. | |
4410 (save-excursion | |
4411 (erase-buffer) | |
4412 (tramp-message 9 "Determining coding system") | |
4413 (process-send-string nil (format "echo foo ; echo bar %s" | |
4414 tramp-rsh-end-of-line)) | |
4415 (unless (tramp-wait-for-regexp | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4416 p 30 (format "\\(%s\\|%s\\)\\'" |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4417 shell-prompt-pattern tramp-shell-prompt-pattern)) |
45861 | 4418 (pop-to-buffer (buffer-name)) |
4419 (error "Couldn't `echo foo; echo bar' to determine line endings'")) | |
4420 (goto-char (point-min)) | |
4421 (if (featurep 'mule) | |
4422 ;; Use MULE to select the right EOL convention for communicating | |
4423 ;; with the process. | |
4424 (let* ((cs (or (process-coding-system p) (cons 'undecided 'undecided))) | |
4425 cs-decode cs-encode) | |
4426 (when (symbolp cs) (setq cs (cons cs cs))) | |
4427 (setq cs-decode (car cs)) | |
4428 (setq cs-encode (cdr cs)) | |
4429 (unless cs-decode (setq cs-decode 'undecided)) | |
4430 (unless cs-encode (setq cs-encode 'undecided)) | |
4431 (setq cs-encode (tramp-coding-system-change-eol-conversion | |
4432 cs-encode 'unix)) | |
4433 (when (search-forward "\r" nil t) | |
4434 (setq cs-decode (tramp-coding-system-change-eol-conversion | |
4435 cs-decode 'dos))) | |
4436 (set-buffer-process-coding-system cs-decode cs-encode)) | |
4437 ;; Look for ^M and do something useful if found. | |
4438 (when (search-forward "\r" nil t) | |
4439 ;; We have found a ^M but cannot frob the process coding system | |
4440 ;; because we're running on a non-MULE Emacs. Let's try | |
4441 ;; stty, instead. | |
4442 (tramp-message 9 "Trying `stty -onlcr'") | |
4443 (process-send-string nil (format "stty -onlcr%s" tramp-rsh-end-of-line)) | |
4444 (unless (tramp-wait-for-regexp | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4445 p 30 (format "\\(%s\\|%s\\)\\'" |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4446 shell-prompt-pattern tramp-shell-prompt-pattern)) |
45861 | 4447 (pop-to-buffer (buffer-name)) |
4448 (error "Couldn't `stty -onlcr', see buffer `%s'" (buffer-name)))))) | |
4449 (erase-buffer) | |
4450 (tramp-message | |
4451 9 "Waiting 30s for `HISTFILE=$HOME/.tramp_history; HISTSIZE=1'") | |
4452 (process-send-string | |
4453 nil (format "HISTFILE=$HOME/.tramp_history; HISTSIZE=1%s" | |
4454 tramp-rsh-end-of-line)) | |
4455 (unless (tramp-wait-for-regexp | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4456 p 30 (format "\\(%s\\|%s\\)\\'" |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4457 shell-prompt-pattern tramp-shell-prompt-pattern)) |
45861 | 4458 (pop-to-buffer (buffer-name)) |
4459 (error (concat "Couldn't `HISTFILE=$HOME/.tramp_history; " | |
4460 "HISTSIZE=1', see buffer `%s'") | |
4461 (buffer-name))) | |
4462 (erase-buffer) | |
4463 (tramp-message 9 "Waiting 30s for `set +o vi +o emacs'") | |
4464 (process-send-string | |
4465 nil (format "set +o vi +o emacs%s" ;mustn't `>/dev/null' with AIX? | |
4466 tramp-rsh-end-of-line)) | |
4467 (unless (tramp-wait-for-regexp | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4468 p 30 (format "\\(%s\\|%s\\)\\'" |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4469 shell-prompt-pattern tramp-shell-prompt-pattern)) |
45861 | 4470 (pop-to-buffer (buffer-name)) |
4471 (error "Couldn't `set +o vi +o emacs', see buffer `%s'" | |
4472 (buffer-name))) | |
4473 (erase-buffer) | |
4474 (tramp-message 9 "Waiting 30s for `unset MAIL MAILCHECK MAILPATH'") | |
4475 (process-send-string | |
4476 nil (format "unset MAIL MAILCHECK MAILPATH 1>/dev/null 2>/dev/null%s" | |
4477 tramp-rsh-end-of-line)) | |
4478 (unless (tramp-wait-for-regexp | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4479 p 30 (format "\\(%s\\|%s\\)\\'" |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4480 shell-prompt-pattern tramp-shell-prompt-pattern)) |
45861 | 4481 (pop-to-buffer (buffer-name)) |
4482 (error "Couldn't `unset MAIL MAILCHECK MAILPATH', see buffer `%s'" | |
4483 (buffer-name))) | |
4484 (erase-buffer) | |
4485 (tramp-message 9 "Waiting 30s for `unset CDPATH'") | |
4486 (process-send-string | |
4487 nil (format "unset CDPATH%s" tramp-rsh-end-of-line)) | |
4488 (unless (tramp-wait-for-regexp | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4489 p 30 (format "\\(%s\\|%s\\)\\'" |
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4490 shell-prompt-pattern tramp-shell-prompt-pattern)) |
45861 | 4491 (pop-to-buffer (buffer-name)) |
4492 (error "Couldn't `unset CDPATH', see buffer `%s'" | |
4493 (buffer-name))) | |
4494 (erase-buffer) | |
4495 (tramp-message 9 "Setting shell prompt") | |
4496 (tramp-send-command | |
4497 multi-method method user host | |
4498 (format "PS1='%s%s%s'; PS2=''; PS3=''" | |
4499 tramp-rsh-end-of-line | |
4500 tramp-end-of-output | |
4501 tramp-rsh-end-of-line)) | |
4502 (tramp-wait-for-output) | |
46835
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4503 ;; (tramp-send-command multi-method method user host "echo hello") |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4504 ;; (tramp-message 9 "Waiting for remote `%s' to come up..." |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4505 ;; (tramp-get-remote-sh multi-method method)) |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4506 ;; (unless (tramp-wait-for-output 5) |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4507 ;; (unless (tramp-wait-for-output 5) |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4508 ;; (pop-to-buffer (buffer-name)) |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4509 ;; (error "Couldn't set remote shell prompt. See buffer `%s' for details" |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4510 ;; (buffer-name)))) |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4511 ;; (tramp-message 7 "Waiting for remote `%s' to come up...done" |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4512 ;; (tramp-get-remote-sh multi-method method)) |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4513 ) |
45861 | 4514 |
4515 (defun tramp-post-connection (multi-method method user host) | |
4516 "Prepare a remote shell before being able to work on it. | |
4517 METHOD, USER and HOST specify the connection. | |
4518 Among other things, this finds a shell which groks tilde expansion, | |
4519 tries to find an `ls' command which groks the `-n' option, sets the | |
4520 locale to C and sets up the remote shell search path." | |
4521 ;; Search for a good shell before searching for a command which | |
4522 ;; checks if a file exists. This is done because Tramp wants to use | |
4523 ;; "test foo; echo $?" to check if various conditions hold, and | |
4524 ;; there are buggy /bin/sh implementations which don't execute the | |
4525 ;; "echo $?" part if the "test" part has an error. In particular, | |
4526 ;; the Solaris /bin/sh is a problem. I'm betting that all systems | |
4527 ;; with buggy /bin/sh implementations will have a working bash or | |
4528 ;; ksh. Whee... | |
4529 (tramp-find-shell multi-method method user host) | |
4530 ;; Without (sit-for 0.1) at least, my machine will almost always blow | |
4531 ;; up on 'not numberp /root' - a race that causes the 'echo ~root' | |
4532 ;; output of (tramp-find-shell) to show up along with the output of | |
4533 ;; (tramp-find-ls-command) testing. | |
4534 ;; | |
4535 ;; I can't work out why this is a problem though. The (tramp-wait-for-output) | |
4536 ;; call in (tramp-find-shell) *should* make this not happen, I thought. | |
4537 ;; | |
4538 ;; After much debugging I couldn't find any problem with the implementation | |
4539 ;; of that function though. The workaround stays for me at least. :/ | |
4540 ;; | |
4541 ;; Daniel Pittman <daniel@danann.net> | |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4542 (sleep-for 1) |
46808
cf225aed7a75
Version 2.0.11 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46802
diff
changeset
|
4543 (erase-buffer) |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4544 (tramp-find-file-exists-command multi-method method user host) |
45861 | 4545 (make-local-variable 'tramp-ls-command) |
4546 (setq tramp-ls-command (tramp-find-ls-command multi-method method user host)) | |
4547 (unless tramp-ls-command | |
4548 (tramp-message | |
4549 1 | |
4550 "Danger! Couldn't find ls which groks -n. Muddling through anyway") | |
4551 (setq tramp-ls-command | |
4552 (tramp-find-executable multi-method method user host | |
4553 "ls" tramp-remote-path nil))) | |
4554 (unless tramp-ls-command | |
4555 (error "Fatal error: Couldn't find remote executable `ls'")) | |
4556 (tramp-message 5 "Using remote command `%s' for getting directory listings" | |
4557 tramp-ls-command) | |
4558 (tramp-send-command multi-method method user host | |
4559 (concat "tramp_set_exit_status () {" tramp-rsh-end-of-line | |
4560 "return $1" tramp-rsh-end-of-line | |
4561 "}")) | |
4562 (tramp-wait-for-output) | |
4563 ;; Set remote PATH variable. | |
4564 (tramp-set-remote-path multi-method method user host "PATH" tramp-remote-path) | |
4565 ;; Tell remote shell to use standard time format, needed for | |
4566 ;; parsing `ls -l' output. | |
4567 (tramp-send-command multi-method method user host | |
4568 "LC_TIME=C; export LC_TIME; echo huhu") | |
4569 (tramp-wait-for-output) | |
4570 (tramp-send-command multi-method method user host | |
4571 "mesg n; echo huhu") | |
4572 (tramp-wait-for-output) | |
4573 (tramp-send-command multi-method method user host | |
4574 "biff n ; echo huhu") | |
4575 (tramp-wait-for-output) | |
4576 ;; Unalias ls(1) to work around issues with those silly people who make it | |
4577 ;; spit out ANSI escapes or whatever. | |
4578 (tramp-send-command multi-method method user host | |
4579 "unalias ls; echo huhu") | |
4580 (tramp-wait-for-output) | |
4581 ;; Does `test A -nt B' work? Use abominable `find' construct if it | |
4582 ;; doesn't. BSD/OS 4.0 wants the parentheses around the command, | |
4583 ;; for otherwise the shell crashes. | |
4584 (erase-buffer) | |
4585 (make-local-variable 'tramp-test-groks-nt) | |
4586 (tramp-send-command multi-method method user host | |
4587 "( test / -nt / )") | |
4588 (tramp-wait-for-output) | |
4589 (goto-char (point-min)) | |
4590 (setq tramp-test-groks-nt | |
4591 (looking-at (format "\n%s\n" (regexp-quote tramp-end-of-output)))) | |
4592 (unless tramp-test-groks-nt | |
4593 (tramp-send-command | |
4594 multi-method method user host | |
4595 (concat "tramp_test_nt () {" tramp-rsh-end-of-line | |
4596 "test -n \"`find $1 -prune -newer $2 -print`\"" tramp-rsh-end-of-line | |
4597 "}"))) | |
4598 (tramp-wait-for-output) | |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4599 ;; Send the fallback `uudecode' script. |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4600 (erase-buffer) |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4601 (tramp-send-linewise multi-method method user host tramp-uudecode) |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4602 (tramp-wait-for-output) |
45861 | 4603 ;; Find a `perl'. |
4604 (erase-buffer) | |
4605 (let ((tramp-remote-perl | |
4606 (or (tramp-find-executable multi-method method user host | |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4607 "perl5" tramp-remote-path nil) |
45861 | 4608 (tramp-find-executable multi-method method user host |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4609 "perl" tramp-remote-path nil)))) |
45861 | 4610 (when tramp-remote-perl |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4611 (tramp-set-connection-property "perl" tramp-remote-perl |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4612 multi-method method user host) |
45861 | 4613 ;; Set up stat in Perl if we can. |
4614 (when tramp-remote-perl | |
4615 (tramp-message 5 "Sending the Perl `file-attributes' implementation.") | |
4616 (tramp-send-linewise | |
4617 multi-method method user host | |
4618 (concat "tramp_file_attributes () {\n" | |
4619 tramp-remote-perl | |
4620 " -e '" tramp-perl-file-attributes "' $1 2>/dev/null\n" | |
4621 "}")) | |
4622 (tramp-wait-for-output) | |
46790 | 4623 (tramp-message 5 "Sending the Perl `mime-encode' implementations.") |
46752 | 4624 (tramp-send-linewise |
4625 multi-method method user host | |
4626 (concat "tramp_encode () {\n" | |
4627 (format tramp-perl-encode tramp-remote-perl) | |
4628 " 2>/dev/null" | |
4629 "\n}")) | |
4630 (tramp-wait-for-output) | |
46790 | 4631 (tramp-send-linewise |
4632 multi-method method user host | |
4633 (concat "tramp_encode_with_module () {\n" | |
4634 (format tramp-perl-encode-with-module tramp-remote-perl) | |
4635 " 2>/dev/null" | |
4636 "\n}")) | |
4637 (tramp-wait-for-output) | |
4638 (tramp-message 5 "Sending the Perl `mime-decode' implementations.") | |
46752 | 4639 (tramp-send-linewise |
4640 multi-method method user host | |
4641 (concat "tramp_decode () {\n" | |
4642 (format tramp-perl-decode tramp-remote-perl) | |
4643 " 2>/dev/null" | |
4644 "\n}")) | |
46790 | 4645 (tramp-wait-for-output) |
4646 (tramp-send-linewise | |
4647 multi-method method user host | |
4648 (concat "tramp_decode_with_module () {\n" | |
4649 (format tramp-perl-decode-with-module tramp-remote-perl) | |
4650 " 2>/dev/null" | |
4651 "\n}")) | |
46752 | 4652 (tramp-wait-for-output)))) |
45861 | 4653 ;; Find ln(1) |
4654 (erase-buffer) | |
4655 (let ((ln (tramp-find-executable multi-method method user host | |
4656 "ln" tramp-remote-path nil))) | |
4657 (when ln | |
4658 (tramp-set-connection-property "ln" ln multi-method method user host))) | |
4659 (erase-buffer) | |
46752 | 4660 ;; Find the right encoding/decoding commands to use. |
4661 (unless (tramp-get-rcp-program multi-method method) | |
4662 (tramp-find-inline-encoding multi-method method user host)) | |
45861 | 4663 ;; If encoding/decoding command are given, test to see if they work. |
4664 ;; CCC: Maybe it would be useful to run the encoder both locally and | |
4665 ;; remotely to see if they produce the same result. | |
46752 | 4666 (let ((decoding (tramp-get-decoding-command multi-method method user host)) |
4667 (encoding (tramp-get-encoding-command multi-method method user host)) | |
45861 | 4668 (magic-string "xyzzy")) |
4669 (when (and (or decoding encoding) (not (and decoding encoding))) | |
4670 (tramp-kill-process multi-method method user host) | |
4671 (error | |
4672 "Must give both decoding and encoding command in method definition")) | |
4673 (when (and decoding encoding) | |
4674 (tramp-message | |
4675 5 | |
4676 "Checking to see if encoding/decoding commands work on remote host...") | |
4677 (tramp-send-command | |
4678 multi-method method user host | |
4679 (format "echo %s | %s | %s" | |
4680 (tramp-shell-quote-argument magic-string) encoding decoding)) | |
4681 (tramp-wait-for-output) | |
4682 (unless (looking-at (regexp-quote magic-string)) | |
4683 (tramp-kill-process multi-method method user host) | |
4684 (error "Remote host cannot execute de/encoding commands. See buffer `%s' for details" | |
4685 (buffer-name))) | |
4686 (erase-buffer) | |
4687 (tramp-message | |
4688 5 "Checking to see if encoding/decoding commands work on remote host...done")))) | |
4689 | |
46752 | 4690 ;; CCC: We should either implement a Perl version of base64 encoding |
4691 ;; and decoding. Then we just use that in the last item. The other | |
4692 ;; alternative is to use the Perl version of UU encoding. But then | |
4693 ;; we need a Lisp version of uuencode. | |
4694 (defvar tramp-coding-commands | |
4695 '(("mimencode -b" "mimencode -u -b" | |
4696 base64-encode-region base64-decode-region) | |
4697 ("mmencode -b" "mmencode -u -b" | |
4698 base64-encode-region base64-decode-region) | |
4699 ("recode data..base64" "recode base64..data" | |
4700 base64-encode-region base64-decode-region) | |
4701 ("uuencode xxx" "uudecode -o -" | |
4702 nil uudecode-decode-region) | |
4703 ("uuencode xxx" "uudecode -p" | |
4704 nil uudecode-decode-region) | |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4705 ("uuencode xxx" "tramp_uudecode" |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4706 nil uudecode-decode-region) |
46790 | 4707 ("tramp_encode_with_module" "tramp_decode_with_module" |
4708 base64-encode-region base64-decode-region) | |
46752 | 4709 ("tramp_encode" "tramp_decode" |
4710 base64-encode-region base64-decode-region)) | |
4711 "List of coding commands for inline transfer. | |
4712 Each item is a list (ENCODING-COMMAND DECODING-COMMAND | |
4713 ENCODING-FUNCTION DECODING-FUNCTION). | |
4714 | |
4715 Each item can be a string, giving a command, or a symbol, giving | |
4716 a function. | |
4717 | |
4718 The ENCODING-COMMAND should be a command accepting a plain file on | |
4719 standard input and writing the encoded file to standard output. The | |
4720 DECODING-COMMAND should be a command accepting an encoded file on | |
4721 standard input and writing the decoded file to standard output. | |
4722 | |
4723 The ENCODING-FUNCTION and DECODING-FUNCTION functions will be called | |
4724 with two arguments, start and end of region, and are expected to | |
4725 replace the region contents with the encoded or decoded results, | |
4726 respectively.") | |
4727 | |
4728 (defun tramp-find-inline-encoding (multi-method method user host) | |
4729 "Find an inline transfer encoding that works. | |
4730 Goes through the list `tramp-coding-commands'." | |
4731 (let ((commands tramp-coding-commands) | |
4732 item found) | |
4733 (while (and commands (null found)) | |
4734 (setq item (pop commands)) | |
4735 (catch 'wont-work | |
4736 (let ((ec (nth 0 item)) | |
4737 (dc (nth 1 item)) | |
4738 (ef (nth 2 item)) | |
4739 (df (nth 3 item))) | |
4740 ;; Check if encoding and decoding commands can be called | |
4741 ;; remotely with null input and output. This makes sure there | |
4742 ;; are no syntax errors and the command is really found. | |
4743 (tramp-message-for-buffer | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4744 multi-method method user host 9 |
46752 | 4745 "Checking remote encoding command `%s' for sanity" ec) |
4746 (unless (zerop (tramp-send-command-and-check | |
4747 multi-method method user host | |
4748 (format "%s </dev/null >/dev/null" ec) t)) | |
4749 (throw 'wont-work nil)) | |
4750 (tramp-message-for-buffer | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4751 multi-method method user host 9 |
46752 | 4752 "Checking remote decoding command `%s' for sanity" dc) |
4753 (unless (zerop (tramp-send-command-and-check | |
4754 multi-method method user host | |
46801
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
4755 (format "echo xyzzy | %s | %s >/dev/null" ec dc) t)) |
46752 | 4756 (throw 'wont-work nil)) |
4757 ;; If no encoding/decoding function is given, the | |
4758 ;; corresponding encoding/decoding command also has to work | |
4759 ;; locally. | |
4760 (when (not (fboundp ef)) | |
4761 (tramp-message-for-buffer | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4762 multi-method method user host 9 |
46752 | 4763 "Checking local encoding command `%s' for sanity" ec) |
4764 (unless (zerop (call-process | |
4765 tramp-sh-program ;program | |
4766 nil ;input | |
4767 nil ;output buffer | |
4768 nil ;redisplay | |
4769 "-c" | |
4770 (format "%s </dev/null >/dev/null" ec))) | |
4771 (throw 'wont-work nil))) | |
4772 (when (not (fboundp df)) | |
4773 (tramp-message-for-buffer | |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
4774 multi-method method user host 9 |
46752 | 4775 "Checking local decoding command `%s' for sanity" dc) |
4776 (unless (zerop (call-process | |
4777 tramp-sh-program ;program | |
4778 nil ;input file | |
4779 nil ;output buffer | |
4780 nil ;redisplay | |
4781 "-c" | |
4782 (format "%s </dev/null >/dev/null" dc))) | |
4783 (throw 'wont-work nil))) | |
4784 ;; CCC: At this point, maybe we should check that the output | |
4785 ;; of the commands is correct. But for the moment we will | |
4786 ;; assume that commands working on empty input will also | |
4787 ;; work in practice. | |
4788 (setq found item)))) | |
4789 ;; Did we find something? If not, issue error. If so, | |
4790 ;; set connection properties. | |
4791 (unless found | |
4792 (error "Couldn't find an inline transfer encoding")) | |
4793 (let ((ec (nth 0 found)) | |
4794 (dc (nth 1 found)) | |
4795 (ef (nth 2 found)) | |
4796 (df (nth 3 found))) | |
4797 (tramp-set-encoding-command multi-method method user host ec) | |
4798 (tramp-set-decoding-command multi-method method user host dc) | |
4799 (tramp-set-encoding-function multi-method method user host ef) | |
4800 (tramp-set-decoding-function multi-method method user host df)))) | |
4801 | |
45861 | 4802 |
4803 (defun tramp-maybe-open-connection (multi-method method user host) | |
4804 "Maybe open a connection to HOST, logging in as USER, using METHOD. | |
4805 Does not do anything if a connection is already open, but re-opens the | |
4806 connection if a previous connection has died for some reason." | |
46752 | 4807 (let ((p (get-buffer-process (tramp-get-buffer multi-method method user host))) |
4808 last-cmd-time) | |
4809 ;; If too much time has passed since last command was sent, look | |
4810 ;; whether process is still alive. If it isn't, kill it. When | |
4811 ;; using ssh, it can sometimes happen that the remote end has hung | |
4812 ;; up but the local ssh client doesn't recognize this until it | |
4813 ;; tries to send some data to the remote end. So that's why we | |
4814 ;; try to send a command from time to time, then look again | |
4815 ;; whether the process is really alive. | |
4816 (save-excursion | |
4817 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4818 (when (and tramp-last-cmd-time | |
46992
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
4819 (> (tramp-time-diff (current-time) tramp-last-cmd-time) 60)) |
46835
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4820 (tramp-send-command |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4821 multi-method method user host "echo are you awake" nil t) |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4822 (unless (tramp-wait-for-output 10) |
46752 | 4823 (delete-process p) |
4824 (setq p nil)) | |
4825 (erase-buffer))) | |
4826 (unless (and p (processp p) (memq (process-status p) '(run open))) | |
45861 | 4827 (when (and p (processp p)) |
4828 (delete-process p)) | |
4829 (funcall (tramp-get-connection-function multi-method method) | |
4830 multi-method method user host)))) | |
4831 | |
4832 (defun tramp-send-command | |
46835
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4833 (multi-method method user host command &optional noerase neveropen) |
45861 | 4834 "Send the COMMAND to USER at HOST (logged in using METHOD). |
4835 Erases temporary buffer before sending the command (unless NOERASE | |
46835
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4836 is true). |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4837 If optional seventh arg NEVEROPEN is non-nil, never try to open the |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4838 connection. This is meant to be used from |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4839 `tramp-maybe-open-connection' only." |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4840 (or neveropen |
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
4841 (tramp-maybe-open-connection multi-method method user host)) |
46752 | 4842 (setq tramp-last-cmd-time (current-time)) |
45861 | 4843 (when tramp-debug-buffer |
4844 (save-excursion | |
4845 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
4846 (goto-char (point-max)) | |
4847 (tramp-insert-with-face 'bold (format "$ %s\n" command)))) | |
4848 (let ((proc nil)) | |
4849 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4850 (unless noerase (erase-buffer)) | |
4851 (setq proc (get-buffer-process (current-buffer))) | |
4852 (process-send-string proc | |
4853 (concat command tramp-rsh-end-of-line)))) | |
4854 | |
4855 ;; It seems that Tru64 Unix does not like it if long strings are sent | |
4856 ;; to it in one go. (This happens when sending the Perl | |
4857 ;; `file-attributes' implementation, for instance.) Therefore, we | |
4858 ;; have this function which waits a bit at each line. | |
4859 (defun tramp-send-linewise | |
4860 (multi-method method user host string &optional noerase) | |
4861 "Send the STRING to USER at HOST linewise. | |
4862 Erases temporary buffer before sending the STRING (unless NOERASE | |
4863 is true). | |
4864 | |
4865 The STRING is expected to use Unix line-endings, but the lines sent to | |
4866 the remote host use line-endings as defined in the variable | |
4867 `tramp-rsh-end-of-line'." | |
4868 (tramp-maybe-open-connection multi-method method user host) | |
4869 (when tramp-debug-buffer | |
4870 (save-excursion | |
4871 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
4872 (goto-char (point-max)) | |
4873 (tramp-insert-with-face 'bold (format "$ %s\n" string)))) | |
4874 (let ((proc nil) | |
4875 (lines (split-string string "\n"))) | |
4876 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4877 (unless noerase (erase-buffer)) | |
4878 (setq proc (get-buffer-process (current-buffer))) | |
4879 (mapcar (lambda (x) | |
4880 (sleep-for 0.1) | |
4881 (process-send-string proc | |
4882 (concat x tramp-rsh-end-of-line))) | |
4883 lines))) | |
4884 | |
4885 (defun tramp-wait-for-output (&optional timeout) | |
4886 "Wait for output from remote rsh command." | |
4887 (let ((proc (get-buffer-process (current-buffer))) | |
4888 (found nil) | |
4889 (start-time (current-time)) | |
4890 (end-of-output (concat "^" | |
4891 (regexp-quote tramp-end-of-output) | |
4892 "$"))) | |
4893 ;; Algorithm: get waiting output. See if last line contains | |
4894 ;; end-of-output sentinel. If not, wait a bit and again get | |
4895 ;; waiting output. Repeat until timeout expires or end-of-output | |
4896 ;; sentinel is seen. Will hang if timeout is nil and | |
4897 ;; end-of-output sentinel never appears. | |
4898 (save-match-data | |
4899 (cond (timeout | |
4900 ;; Work around an XEmacs bug, where the timeout expires | |
4901 ;; faster than it should. This degenerates into polling | |
4902 ;; for buggy XEmacsen, but oh, well. | |
4903 (while (and (not found) | |
4904 (< (tramp-time-diff (current-time) start-time) | |
4905 timeout)) | |
4906 (with-timeout (timeout) | |
4907 (while (not found) | |
4908 (accept-process-output proc 1) | |
4909 (goto-char (point-max)) | |
4910 (forward-line -1) | |
4911 (setq found (looking-at end-of-output)))))) | |
4912 (t | |
4913 (while (not found) | |
4914 (accept-process-output proc 1) | |
4915 (goto-char (point-max)) | |
4916 (forward-line -1) | |
4917 (setq found (looking-at end-of-output)))))) | |
4918 ;; At this point, either the timeout has expired or we have found | |
4919 ;; the end-of-output sentinel. | |
4920 (when found | |
4921 (goto-char (point-max)) | |
4922 (forward-line -2) | |
4923 (delete-region (point) (point-max))) | |
4924 ;; Add output to debug buffer if appropriate. | |
4925 (when tramp-debug-buffer | |
4926 (append-to-buffer | |
4927 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4928 tramp-current-user tramp-current-host) | |
4929 (point-min) (point-max)) | |
4930 (when (not found) | |
4931 (save-excursion | |
4932 (set-buffer | |
4933 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4934 tramp-current-user tramp-current-host)) | |
4935 (goto-char (point-max)) | |
4936 (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
|
4937 (if timeout (format " in %d secs" timeout) "") |
45861 | 4938 "]]")))) |
4939 (goto-char (point-min)) | |
4940 ;; Return value is whether end-of-output sentinel was found. | |
4941 found)) | |
4942 | |
4943 (defun tramp-match-string-list (&optional string) | |
4944 "Returns list of all match strings. | |
4945 That is, (list (match-string 0) (match-string 1) ...), according to the | |
4946 number of matches." | |
4947 (let* ((nmatches (/ (length (match-data)) 2)) | |
4948 (i (- nmatches 1)) | |
4949 (res nil)) | |
4950 (while (>= i 0) | |
4951 (setq res (cons (match-string i string) res)) | |
4952 (setq i (- i 1))) | |
4953 res)) | |
4954 | |
4955 (defun tramp-send-command-and-check (multi-method method user host command | |
4956 &optional subshell) | |
4957 "Run COMMAND and check its exit status. | |
4958 MULTI-METHOD and METHOD specify how to log in (as USER) to the remote HOST. | |
4959 Sends `echo $?' along with the COMMAND for checking the exit status. If | |
4960 COMMAND is nil, just sends `echo $?'. Returns the exit status found. | |
4961 | |
4962 If the optional argument SUBSHELL is non-nil, the command is executed in | |
4963 a subshell, ie surrounded by parentheses." | |
4964 (tramp-send-command multi-method method user host | |
4965 (concat (if subshell "( " "") | |
4966 command | |
4967 (if command " 2>/dev/null; " "") | |
4968 "echo tramp_exit_status $?" | |
4969 (if subshell " )" " "))) | |
4970 (tramp-wait-for-output) | |
4971 (goto-char (point-max)) | |
4972 (unless (search-backward "tramp_exit_status " nil t) | |
4973 (error "Couldn't find exit status of `%s'" command)) | |
4974 (skip-chars-forward "^ ") | |
4975 (read (current-buffer))) | |
4976 | |
4977 (defun tramp-barf-unless-okay (multi-method method user host command subshell | |
4978 signal fmt &rest args) | |
4979 "Run COMMAND, check exit status, throw error if exit status not okay. | |
4980 Similar to `tramp-send-command-and-check' but accepts two more arguments | |
4981 FMT and ARGS which are passed to `error'." | |
4982 (unless (zerop (tramp-send-command-and-check | |
4983 multi-method method user host command subshell)) | |
4984 ;; CCC: really pop-to-buffer? Maybe it's appropriate to be more | |
4985 ;; silent. | |
4986 (pop-to-buffer (current-buffer)) | |
4987 (funcall 'signal signal (apply 'format fmt args)))) | |
4988 | |
4989 (defun tramp-send-region (multi-method method user host start end) | |
4990 "Send the region from START to END to remote command | |
4991 running as USER on HOST using METHOD." | |
4992 (let ((proc (get-buffer-process | |
4993 (tramp-get-buffer multi-method method user host)))) | |
4994 (unless proc | |
4995 (error "Can't send region to remote host -- not logged in")) | |
4996 (process-send-region proc start end) | |
4997 (when tramp-debug-buffer | |
4998 (append-to-buffer | |
4999 (tramp-get-debug-buffer multi-method method user host) | |
5000 start end)))) | |
5001 | |
5002 (defun tramp-send-eof (multi-method method user host) | |
5003 "Send EOF to the remote end. | |
46151
eff75835ac2e
(tramp-send-eof): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
46060
diff
changeset
|
5004 METHOD, HOST and USER specify the connection." |
45861 | 5005 (let ((proc (get-buffer-process |
5006 (tramp-get-buffer multi-method method user host)))) | |
5007 (unless proc | |
5008 (error "Can't send EOF to remote host -- not logged in")) | |
5009 (process-send-eof proc))) | |
5010 ; (process-send-string proc "\^D"))) | |
5011 | |
5012 (defun tramp-kill-process (multi-method method user host) | |
5013 "Kill the connection process used by Tramp. | |
46151
eff75835ac2e
(tramp-send-eof): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
46060
diff
changeset
|
5014 MULTI-METHOD, METHOD, USER, and HOST specify the connection." |
45861 | 5015 (let ((proc (get-buffer-process |
5016 (tramp-get-buffer multi-method method user host)))) | |
5017 (kill-process proc))) | |
5018 | |
5019 (defun tramp-discard-garbage-erase-buffer (p multi-method method user host) | |
5020 "Erase buffer, then discard subsequent garbage. | |
5021 If `tramp-discard-garbage' is nil, just erase buffer." | |
5022 (if (not tramp-discard-garbage) | |
5023 (erase-buffer) | |
5024 (while (prog1 (erase-buffer) (accept-process-output p 0.25)) | |
5025 (when tramp-debug-buffer | |
5026 (save-excursion | |
5027 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
5028 (goto-char (point-max)) | |
5029 (tramp-insert-with-face | |
5030 'bold (format "Additional characters detected\n"))))))) | |
5031 | |
5032 (defun tramp-mode-string-to-int (mode-string) | |
5033 "Converts a ten-letter `drwxrwxrwx'-style mode string into mode bits." | |
5034 (let* ((mode-chars (string-to-vector mode-string)) | |
5035 (owner-read (aref mode-chars 1)) | |
5036 (owner-write (aref mode-chars 2)) | |
5037 (owner-execute-or-setid (aref mode-chars 3)) | |
5038 (group-read (aref mode-chars 4)) | |
5039 (group-write (aref mode-chars 5)) | |
5040 (group-execute-or-setid (aref mode-chars 6)) | |
5041 (other-read (aref mode-chars 7)) | |
5042 (other-write (aref mode-chars 8)) | |
5043 (other-execute-or-sticky (aref mode-chars 9))) | |
5044 (save-match-data | |
5045 (logior | |
5046 (case owner-read | |
5047 (?r (tramp-octal-to-decimal "00400")) (?- 0) | |
5048 (t (error "Second char `%c' must be one of `r-'" owner-read))) | |
5049 (case owner-write | |
5050 (?w (tramp-octal-to-decimal "00200")) (?- 0) | |
5051 (t (error "Third char `%c' must be one of `w-'" owner-write))) | |
5052 (case owner-execute-or-setid | |
5053 (?x (tramp-octal-to-decimal "00100")) | |
5054 (?S (tramp-octal-to-decimal "04000")) | |
5055 (?s (tramp-octal-to-decimal "04100")) | |
5056 (?- 0) | |
5057 (t (error "Fourth char `%c' must be one of `xsS-'" | |
5058 owner-execute-or-setid))) | |
5059 (case group-read | |
5060 (?r (tramp-octal-to-decimal "00040")) (?- 0) | |
5061 (t (error "Fifth char `%c' must be one of `r-'" group-read))) | |
5062 (case group-write | |
5063 (?w (tramp-octal-to-decimal "00020")) (?- 0) | |
5064 (t (error "Sixth char `%c' must be one of `w-'" group-write))) | |
5065 (case group-execute-or-setid | |
5066 (?x (tramp-octal-to-decimal "00010")) | |
5067 (?S (tramp-octal-to-decimal "02000")) | |
5068 (?s (tramp-octal-to-decimal "02010")) | |
5069 (?- 0) | |
5070 (t (error "Seventh char `%c' must be one of `xsS-'" | |
5071 group-execute-or-setid))) | |
5072 (case other-read | |
5073 (?r (tramp-octal-to-decimal "00004")) (?- 0) | |
5074 (t (error "Eighth char `%c' must be one of `r-'" other-read))) | |
5075 (case other-write | |
5076 (?w (tramp-octal-to-decimal "00002")) (?- 0) | |
5077 (t (error "Nineth char `%c' must be one of `w-'" other-write))) | |
5078 (case other-execute-or-sticky | |
5079 (?x (tramp-octal-to-decimal "00001")) | |
5080 (?T (tramp-octal-to-decimal "01000")) | |
5081 (?t (tramp-octal-to-decimal "01001")) | |
5082 (?- 0) | |
5083 (t (error "Tenth char `%c' must be one of `xtT-'" | |
5084 other-execute-or-sticky))))))) | |
5085 | |
5086 | |
5087 (defun tramp-file-mode-from-int (mode) | |
5088 "Turn an integer representing a file mode into an ls(1)-like string." | |
5089 (let ((type (cdr (assoc (logand (lsh mode -12) 15) tramp-file-mode-type-map))) | |
5090 (user (logand (lsh mode -6) 7)) | |
5091 (group (logand (lsh mode -3) 7)) | |
5092 (other (logand (lsh mode -0) 7)) | |
5093 (suid (> (logand (lsh mode -9) 4) 0)) | |
5094 (sgid (> (logand (lsh mode -9) 2) 0)) | |
5095 (sticky (> (logand (lsh mode -9) 1) 0))) | |
5096 (setq user (tramp-file-mode-permissions user suid "s")) | |
5097 (setq group (tramp-file-mode-permissions group sgid "s")) | |
5098 (setq other (tramp-file-mode-permissions other sticky "t")) | |
5099 (concat type user group other))) | |
5100 | |
5101 | |
5102 (defun tramp-file-mode-permissions (perm suid suid-text) | |
5103 "Convert a permission bitset into a string. | |
5104 This is used internally by `tramp-file-mode-from-int'." | |
5105 (let ((r (> (logand perm 4) 0)) | |
5106 (w (> (logand perm 2) 0)) | |
5107 (x (> (logand perm 1) 0))) | |
5108 (concat (or (and r "r") "-") | |
5109 (or (and w "w") "-") | |
5110 (or (and suid x suid-text) ; suid, execute | |
5111 (and suid (upcase suid-text)) ; suid, !execute | |
5112 (and x "x") "-")))) ; !suid | |
5113 | |
5114 | |
5115 (defun tramp-decimal-to-octal (i) | |
5116 "Return a string consisting of the octal digits of I. | |
5117 Not actually used. Use `(format \"%o\" i)' instead?" | |
5118 (cond ((< i 0) (error "Cannot convert negative number to octal")) | |
5119 ((not (integerp i)) (error "Cannot convert non-integer to octal")) | |
5120 ((zerop i) "0") | |
5121 (t (concat (tramp-decimal-to-octal (/ i 8)) | |
5122 (number-to-string (% i 8)))))) | |
5123 | |
5124 | |
5125 ;;(defun tramp-octal-to-decimal (ostr) | |
5126 ;; "Given a string of octal digits, return a decimal number." | |
5127 ;; (cond ((null ostr) 0) | |
5128 ;; ((string= "" ostr) 0) | |
5129 ;; (t (let ((last (aref ostr (1- (length ostr)))) | |
5130 ;; (rest (substring ostr 0 (1- (length ostr))))) | |
5131 ;; (unless (and (>= last ?0) | |
5132 ;; (<= last ?7)) | |
5133 ;; (error "Not an octal digit: %c" last)) | |
5134 ;; (+ (- last ?0) (* 8 (tramp-octal-to-decimal rest))))))) | |
5135 ;; Kudos to Gerd Moellmann for this suggestion. | |
5136 (defun tramp-octal-to-decimal (ostr) | |
5137 "Given a string of octal digits, return a decimal number." | |
5138 (let ((x (or ostr ""))) | |
5139 ;; `save-match' is in `tramp-mode-string-to-int' which calls this. | |
5140 (unless (string-match "\\`[0-7]*\\'" x) | |
5141 (error "Non-octal junk in string `%s'" x)) | |
5142 (string-to-number ostr 8))) | |
5143 | |
5144 (defun tramp-shell-case-fold (string) | |
5145 "Converts STRING to shell glob pattern which ignores case." | |
5146 (mapconcat | |
5147 (lambda (c) | |
5148 (if (equal (downcase c) (upcase c)) | |
5149 (vector c) | |
5150 (format "[%c%c]" (downcase c) (upcase c)))) | |
5151 string | |
5152 "")) | |
5153 | |
5154 | |
5155 ;; ------------------------------------------------------------ | |
5156 ;; -- TRAMP file names -- | |
5157 ;; ------------------------------------------------------------ | |
5158 ;; Conversion functions between external representation and | |
5159 ;; internal data structure. Convenience functions for internal | |
5160 ;; data structure. | |
5161 | |
5162 (defstruct tramp-file-name multi-method method user host path) | |
5163 | |
5164 (defun tramp-tramp-file-p (name) | |
5165 "Return t iff NAME is a tramp file." | |
5166 (save-match-data | |
5167 (string-match tramp-file-name-regexp name))) | |
5168 | |
5169 ;; HHH: Changed. Used to assign the return value of (user-login-name) | |
5170 ;; to the `user' part of the structure if a user name was not | |
5171 ;; provided, now it assigns nil. | |
5172 (defun tramp-dissect-file-name (name) | |
5173 "Return an `tramp-file-name' structure. | |
5174 The structure consists of remote method, remote user, remote host and | |
5175 remote path name." | |
5176 (let (method) | |
5177 (save-match-data | |
5178 (unless (string-match (nth 0 tramp-file-name-structure) name) | |
5179 (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
|
5180 (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
|
5181 (if (and method (member method tramp-multi-methods)) |
45861 | 5182 ;; If it's a multi method, the file name structure contains |
5183 ;; arrays of method, user and host. | |
5184 (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
|
5185 ;; 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
|
5186 (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
|
5187 (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
|
5188 (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
|
5189 (when (not method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5190 (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
|
5191 (make-tramp-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5192 :multi-method nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5193 :method method |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5194 :user (or user nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5195 :host host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5196 :path path)))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5197 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5198 (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
|
5199 "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
|
5200 (let ((choices tramp-default-method-alist) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5201 (method tramp-default-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5202 item) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5203 (while choices |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5204 (setq item (pop choices)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5205 (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
|
5206 (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
|
5207 (setq method (nth 2 item)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5208 (setq choices nil))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5209 method)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5210 |
45861 | 5211 ;; HHH: Not Changed. Multi method. Will probably not handle the case where |
5212 ;; a user name is not provided in the "file name" very well. | |
5213 (defun tramp-dissect-multi-file-name (name) | |
5214 "Not implemented yet." | |
5215 (let ((regexp (nth 0 tramp-multi-file-name-structure)) | |
5216 (method-index (nth 1 tramp-multi-file-name-structure)) | |
5217 (hops-index (nth 2 tramp-multi-file-name-structure)) | |
5218 (path-index (nth 3 tramp-multi-file-name-structure)) | |
5219 (hop-regexp (nth 0 tramp-multi-file-name-hop-structure)) | |
5220 (hop-method-index (nth 1 tramp-multi-file-name-hop-structure)) | |
5221 (hop-user-index (nth 2 tramp-multi-file-name-hop-structure)) | |
5222 (hop-host-index (nth 3 tramp-multi-file-name-hop-structure)) | |
5223 method hops len hop-methods hop-users hop-hosts path) | |
5224 (unless (string-match (format regexp hop-regexp) name) | |
5225 (error "Not a multi tramp file name: %s" name)) | |
5226 (setq method (match-string method-index name)) | |
5227 (setq hops (match-string hops-index name)) | |
5228 (setq len (/ (length (match-data t)) 2)) | |
5229 (when (< path-index 0) (incf path-index len)) | |
5230 (setq path (match-string path-index name)) | |
5231 (let ((index 0)) | |
5232 (while (string-match hop-regexp hops index) | |
5233 (setq index (match-end 0)) | |
5234 (setq hop-methods | |
5235 (cons (match-string hop-method-index hops) hop-methods)) | |
5236 (setq hop-users | |
5237 (cons (match-string hop-user-index hops) hop-users)) | |
5238 (setq hop-hosts | |
5239 (cons (match-string hop-host-index hops) hop-hosts)))) | |
5240 (make-tramp-file-name | |
5241 :multi-method method | |
5242 :method (apply 'vector (reverse hop-methods)) | |
5243 :user (apply 'vector (reverse hop-users)) | |
5244 :host (apply 'vector (reverse hop-hosts)) | |
5245 :path path))) | |
5246 | |
5247 (defun tramp-make-tramp-file-name (multi-method method user host path) | |
5248 "Constructs a tramp file name from METHOD, USER, HOST and PATH." | |
5249 (unless tramp-make-tramp-file-format | |
5250 (error "`tramp-make-tramp-file-format' is nil")) | |
5251 (if multi-method | |
5252 (tramp-make-tramp-multi-file-name multi-method method user host path) | |
5253 (if user | |
5254 (format-spec tramp-make-tramp-file-format | |
46752 | 5255 `((?m . ,method) (?u . ,user) (?h . ,host) (?p . ,path))) |
45861 | 5256 (format-spec tramp-make-tramp-file-user-nil-format |
46752 | 5257 `((?m . ,method) (?h . ,host) (?p . ,path)))))) |
45861 | 5258 |
5259 ;; CCC: Henrik Holm: Not Changed. Multi Method. What should be done | |
5260 ;; with this when USER is nil? | |
5261 (defun tramp-make-tramp-multi-file-name (multi-method method user host path) | |
5262 "Constructs a tramp file name for a multi-hop method." | |
5263 (unless tramp-make-multi-tramp-file-format | |
5264 (error "`tramp-make-multi-tramp-file-format' is nil")) | |
5265 (let* ((prefix-format (nth 0 tramp-make-multi-tramp-file-format)) | |
5266 (hop-format (nth 1 tramp-make-multi-tramp-file-format)) | |
5267 (path-format (nth 2 tramp-make-multi-tramp-file-format)) | |
46752 | 5268 (prefix (format-spec prefix-format `((?m . ,multi-method)))) |
45861 | 5269 (hops "") |
46752 | 5270 (path (format-spec path-format `((?p . ,path)))) |
45861 | 5271 (i 0) |
5272 (len (length method))) | |
5273 (while (< i len) | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
5274 (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
|
5275 (setq hops (concat hops (format-spec hop-format |
46752 | 5276 `((?m . ,m) (?u . ,u) (?h . ,h))))) |
45861 | 5277 (incf i))) |
5278 (concat prefix hops path))) | |
5279 | |
5280 (defun tramp-make-rcp-program-file-name (user host path) | |
5281 "Create a file name suitable to be passed to `rcp'." | |
5282 (if user | |
5283 (format "%s@%s:%s" user host path) | |
5284 (format "%s:%s" host path))) | |
5285 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5286 (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
|
5287 "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
|
5288 (if user |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5289 (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
|
5290 (format "/%s:%s" host path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5291 |
45861 | 5292 (defun tramp-method-out-of-band-p (multi-method method) |
5293 "Return t if this is an out-of-band method, nil otherwise. | |
5294 It is important to check for this condition, since it is not possible | |
5295 to enter a password for the `tramp-rcp-program'." | |
5296 (tramp-get-rcp-program multi-method method)) | |
5297 | |
5298 ;; Variables local to connection. | |
5299 | |
5300 (defun tramp-get-ls-command (multi-method method user host) | |
5301 (save-excursion | |
5302 (tramp-maybe-open-connection multi-method method user host) | |
5303 (set-buffer (tramp-get-buffer multi-method method user host)) | |
5304 tramp-ls-command)) | |
5305 | |
5306 (defun tramp-get-test-groks-nt (multi-method method user host) | |
5307 (save-excursion | |
5308 (tramp-maybe-open-connection multi-method method user host) | |
5309 (set-buffer (tramp-get-buffer multi-method method user host)) | |
5310 tramp-test-groks-nt)) | |
5311 | |
5312 (defun tramp-get-file-exists-command (multi-method method user host) | |
5313 (save-excursion | |
5314 (tramp-maybe-open-connection multi-method method user host) | |
5315 (set-buffer (tramp-get-buffer multi-method method user host)) | |
5316 tramp-file-exists-command)) | |
5317 | |
5318 (defun tramp-get-remote-perl (multi-method method user host) | |
5319 (tramp-get-connection-property "perl" nil multi-method method user host)) | |
5320 | |
5321 (defun tramp-get-remote-ln (multi-method method user host) | |
5322 (tramp-get-connection-property "ln" nil multi-method method user host)) | |
5323 | |
5324 ;; Get a property of a TRAMP connection. | |
46752 | 5325 (defun tramp-get-connection-property |
5326 (property default multi-method method user host) | |
45861 | 5327 "Get the named property for the connection. |
5328 If the value is not set for the connection, return `default'" | |
5329 (tramp-maybe-open-connection multi-method method user host) | |
5330 (with-current-buffer (tramp-get-buffer multi-method method user host) | |
5331 (let (error) | |
5332 (condition-case nil | |
5333 (symbol-value (intern (concat "tramp-connection-property-" property))) | |
5334 (error default))))) | |
5335 | |
5336 ;; Set a property of a TRAMP connection. | |
46752 | 5337 (defun tramp-set-connection-property |
5338 (property value multi-method method user host) | |
45861 | 5339 "Set the named property of a TRAMP connection." |
5340 (tramp-maybe-open-connection multi-method method user host) | |
5341 (with-current-buffer (tramp-get-buffer multi-method method user host) | |
5342 (set (make-local-variable | |
5343 (intern (concat "tramp-connection-property-" property))) | |
5344 value))) | |
5345 | |
46752 | 5346 ;; Some predefined connection properties. |
5347 (defun tramp-get-encoding-command (multi-method method user host) | |
5348 (tramp-get-connection-property "encoding-command" nil | |
5349 multi-method method user host)) | |
5350 (defun tramp-set-encoding-command (multi-method method user host command) | |
5351 (tramp-set-connection-property "encoding-command" command | |
5352 multi-method method user host)) | |
5353 (defun tramp-get-decoding-command (multi-method method user host) | |
5354 (tramp-get-connection-property "decoding-command" nil | |
5355 multi-method method user host)) | |
5356 (defun tramp-set-decoding-command (multi-method method user host command) | |
5357 (tramp-set-connection-property "decoding-command" command | |
5358 multi-method method user host)) | |
5359 (defun tramp-get-encoding-function (multi-method method user host) | |
5360 (tramp-get-connection-property "encoding-function" nil | |
5361 multi-method method user host)) | |
5362 (defun tramp-set-encoding-function (multi-method method user host func) | |
5363 (tramp-set-connection-property "encoding-function" func | |
5364 multi-method method user host)) | |
5365 (defun tramp-get-decoding-function (multi-method method user host) | |
5366 (tramp-get-connection-property "decoding-function" nil | |
5367 multi-method method user host)) | |
5368 (defun tramp-set-decoding-function (multi-method method user host func) | |
5369 (tramp-set-connection-property "decoding-function" func | |
5370 multi-method method user host)) | |
45861 | 5371 |
5372 | |
5373 (defun tramp-get-connection-function (multi-method method) | |
5374 (second (or (assoc 'tramp-connection-function | |
5375 (assoc (or multi-method method tramp-default-method) | |
5376 tramp-methods)) | |
5377 (error "Method `%s' didn't specify a connection function" | |
5378 (or multi-method method))))) | |
5379 | |
5380 (defun tramp-get-remote-sh (multi-method method) | |
5381 (second (or (assoc 'tramp-remote-sh | |
5382 (assoc (or multi-method method tramp-default-method) | |
5383 tramp-methods)) | |
5384 (error "Method `%s' didn't specify a remote shell" | |
5385 (or multi-method method))))) | |
5386 | |
5387 (defun tramp-get-rsh-program (multi-method method) | |
5388 (second (or (assoc 'tramp-rsh-program | |
5389 (assoc (or multi-method method tramp-default-method) | |
5390 tramp-methods)) | |
5391 (error "Method `%s' didn't specify an rsh program" | |
5392 (or multi-method method))))) | |
5393 | |
5394 (defun tramp-get-rsh-args (multi-method method) | |
5395 (second (or (assoc 'tramp-rsh-args | |
5396 (assoc (or multi-method method tramp-default-method) | |
5397 tramp-methods)) | |
5398 (error "Method `%s' didn't specify rsh args" | |
5399 (or multi-method method))))) | |
5400 | |
5401 (defun tramp-get-rcp-program (multi-method method) | |
5402 (second (or (assoc 'tramp-rcp-program | |
5403 (assoc (or multi-method method tramp-default-method) | |
5404 tramp-methods)) | |
5405 (error "Method `%s' didn't specify an rcp program" | |
5406 (or multi-method method))))) | |
5407 | |
5408 (defun tramp-get-rcp-args (multi-method method) | |
5409 (second (or (assoc 'tramp-rcp-args | |
5410 (assoc (or multi-method method tramp-default-method) | |
5411 tramp-methods)) | |
5412 (error "Method `%s' didn't specify rcp args" | |
5413 (or multi-method method))))) | |
5414 | |
5415 (defun tramp-get-rcp-keep-date-arg (multi-method method) | |
5416 (second (or (assoc 'tramp-rcp-keep-date-arg | |
5417 (assoc (or multi-method method tramp-default-method) | |
5418 tramp-methods)) | |
5419 (error "Method `%s' didn't specify `keep-date' arg for tramp" | |
5420 (or multi-method method))))) | |
5421 | |
5422 (defun tramp-get-su-program (multi-method method) | |
5423 (second (or (assoc 'tramp-su-program | |
5424 (assoc (or multi-method method tramp-default-method) | |
5425 tramp-methods)) | |
5426 (error "Method `%s' didn't specify a su program" | |
5427 (or multi-method method))))) | |
5428 | |
5429 (defun tramp-get-su-args (multi-method method) | |
5430 (second (or (assoc 'tramp-su-args | |
5431 (assoc (or multi-method method tramp-default-method) | |
5432 tramp-methods)) | |
5433 (error "Method `%s' didn't specify su args" | |
5434 (or multi-method method))))) | |
5435 | |
5436 (defun tramp-get-telnet-program (multi-method method) | |
5437 (second (or (assoc 'tramp-telnet-program | |
5438 (assoc (or multi-method method tramp-default-method) | |
5439 tramp-methods)) | |
5440 (error "Method `%s' didn't specify a telnet program" | |
5441 (or multi-method method))))) | |
5442 | |
5443 (defun tramp-get-telnet-args (multi-method method) | |
5444 (second (or (assoc 'tramp-telnet-args | |
5445 (assoc (or multi-method method tramp-default-method) | |
5446 tramp-methods)) | |
5447 (error "Method `%s' didn't specify telnet args" | |
5448 (or multi-method method))))) | |
5449 | |
46752 | 5450 ;; (defun tramp-get-encoding-command (multi-method method) |
5451 ;; (second (or (assoc 'tramp-encoding-command | |
5452 ;; (assoc (or multi-method method tramp-default-method) | |
5453 ;; tramp-methods)) | |
5454 ;; (error "Method `%s' didn't specify an encoding command" | |
5455 ;; (or multi-method method))))) | |
5456 | |
5457 ;; (defun tramp-get-decoding-command (multi-method method) | |
5458 ;; (second (or (assoc 'tramp-decoding-command | |
5459 ;; (assoc (or multi-method method tramp-default-method) | |
5460 ;; tramp-methods)) | |
5461 ;; (error "Method `%s' didn't specify a decoding command" | |
5462 ;; (or multi-method method))))) | |
5463 | |
5464 ;; (defun tramp-get-encoding-function (multi-method method) | |
5465 ;; (second (or (assoc 'tramp-encoding-function | |
5466 ;; (assoc (or multi-method method tramp-default-method) | |
5467 ;; tramp-methods)) | |
5468 ;; (error "Method `%s' didn't specify an encoding function" | |
5469 ;; (or multi-method method))))) | |
5470 | |
5471 ;; (defun tramp-get-decoding-function (multi-method method) | |
5472 ;; (second (or (assoc 'tramp-decoding-function | |
5473 ;; (assoc (or multi-method method tramp-default-method) | |
5474 ;; tramp-methods)) | |
5475 ;; (error "Method `%s' didn't specify a decoding function" | |
5476 ;; (or multi-method method))))) | |
5477 | |
45861 | 5478 ;; Auto saving to a special directory. |
5479 | |
5480 (defun tramp-make-auto-save-file-name (fn) | |
5481 "Returns a file name in `tramp-auto-save-directory' for autosaving this file." | |
5482 (when tramp-auto-save-directory | |
5483 (unless (file-exists-p tramp-auto-save-directory) | |
5484 (make-directory tramp-auto-save-directory t))) | |
5485 ;; jka-compr doesn't like auto-saving, so by appending "~" to the | |
5486 ;; file name we make sure that jka-compr isn't used for the | |
5487 ;; auto-save file. | |
5488 (let ((buffer-file-name (expand-file-name | |
5489 (tramp-subst-strs-in-string '(("_" . "|") | |
5490 ("/" . "_a") | |
5491 (":" . "_b") | |
5492 ("|" . "__") | |
5493 ("[" . "_l") | |
5494 ("]" . "_r")) | |
5495 fn) | |
5496 tramp-auto-save-directory))) | |
5497 (make-auto-save-file-name))) | |
5498 | |
5499 (defadvice make-auto-save-file-name | |
5500 (around tramp-advice-make-auto-save-file-name () activate) | |
5501 "Invoke `tramp-make-auto-save-file-name' for tramp files." | |
5502 (if (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)) | |
5503 tramp-auto-save-directory) | |
5504 (setq ad-return-value | |
5505 (tramp-make-auto-save-file-name (buffer-file-name))) | |
5506 ad-do-it)) | |
5507 | |
5508 (defun tramp-subst-strs-in-string (alist string) | |
5509 "Replace all occurrences of the string FROM with TO in STRING. | |
5510 ALIST is of the form ((FROM . TO) ...)." | |
5511 (save-match-data | |
5512 (while alist | |
5513 (let* ((pr (car alist)) | |
5514 (from (car pr)) | |
5515 (to (cdr pr))) | |
5516 (while (string-match (regexp-quote from) string) | |
5517 (setq string (replace-match to t t string))) | |
5518 (setq alist (cdr alist)))) | |
5519 string)) | |
5520 | |
5521 (defun tramp-insert-with-face (face string) | |
5522 "Insert text with a specific face." | |
5523 (let ((start (point))) | |
5524 (insert string) | |
5525 (add-text-properties start (point) (list 'face face)))) | |
5526 | |
5527 ;; ------------------------------------------------------------ | |
5528 ;; -- Compatibility functions section -- | |
5529 ;; ------------------------------------------------------------ | |
5530 | |
5531 (defun tramp-temporary-file-directory () | |
5532 "Return name of directory for temporary files (compat function). | |
5533 For Emacs, this is the variable `temporary-file-directory', for XEmacs | |
5534 this is the function `temp-directory'." | |
5535 (cond ((boundp 'temporary-file-directory) | |
5536 (symbol-value 'temporary-file-directory)) | |
5537 ((fboundp 'temp-directory) | |
5538 (funcall (symbol-function 'temp-directory))) ;pacify byte-compiler | |
5539 ((let ((d (getenv "TEMP"))) (and d (file-directory-p d))) | |
5540 (file-name-as-directory (getenv "TEMP"))) | |
5541 ((let ((d (getenv "TMP"))) (and d (file-directory-p d))) | |
5542 (file-name-as-directory (getenv "TMP"))) | |
5543 ((let ((d (getenv "TMPDIR"))) (and d (file-directory-p d))) | |
5544 (file-name-as-directory (getenv "TMPDIR"))) | |
5545 ((file-exists-p "c:/temp") (file-name-as-directory "c:/temp")) | |
5546 (t (message (concat "Neither `temporary-file-directory' nor " | |
5547 "`temp-directory' is defined -- using /tmp.")) | |
5548 (file-name-as-directory "/tmp")))) | |
5549 | |
5550 (defun tramp-read-passwd (prompt) | |
5551 "Read a password from user (compat function). | |
5552 Invokes `read-passwd' if that is defined, else `ange-ftp-read-passwd'." | |
5553 (apply | |
5554 (if (fboundp 'read-passwd) #'read-passwd #'ange-ftp-read-passwd) | |
5555 (list prompt))) | |
5556 | |
5557 (defun tramp-time-diff (t1 t2) | |
5558 "Return the difference between the two times, in seconds. | |
5559 T1 and T2 are time values (as returned by `current-time' for example). | |
5560 | |
5561 NOTE: This function will fail if the time difference is too large to | |
5562 fit in an integer." | |
5563 ;; Pacify byte-compiler with `symbol-function'. | |
5564 (cond ((fboundp 'subtract-time) | |
5565 (cadr (funcall (symbol-function 'subtract-time) t1 t2))) | |
5566 ((fboundp 'itimer-time-difference) | |
5567 (floor (funcall | |
5568 (symbol-function 'itimer-time-difference) | |
5569 (if (< (length t1) 3) (append t1 '(0)) t1) | |
5570 (if (< (length t2) 3) (append t2 '(0)) t2)))) | |
5571 (t | |
5572 ;; snarfed from Emacs 21 time-date.el | |
5573 (cadr (let ((borrow (< (cadr t1) (cadr t2)))) | |
5574 (list (- (car t1) (car t2) (if borrow 1 0)) | |
5575 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))))) | |
5576 | |
5577 (defun tramp-coding-system-change-eol-conversion (coding-system eol-type) | |
5578 "Return a coding system like CODING-SYSTEM but with given EOL-TYPE. | |
5579 EOL-TYPE can be one of `dos', `unix', or `mac'." | |
5580 (cond ((fboundp 'coding-system-change-eol-conversion) | |
5581 (apply #'coding-system-change-eol-conversion | |
5582 (list coding-system eol-type))) | |
5583 ((fboundp 'subsidiary-coding-system) | |
5584 (apply | |
5585 #'subsidiary-coding-system | |
5586 (list coding-system | |
5587 (cond ((eq eol-type 'dos) 'crlf) | |
5588 ((eq eol-type 'unix) 'lf) | |
5589 ((eq eol-type 'mac) 'cr) | |
5590 (t | |
5591 (error "Unknown EOL-TYPE `%s', must be %s" | |
5592 eol-type | |
5593 "`dos', `unix', or `mac'")))))) | |
5594 (t (error "Can't change EOL conversion -- is MULE missing?")))) | |
5595 | |
5596 (defun tramp-split-string (string pattern) | |
5597 "Like `split-string' but omit empty strings. | |
5598 In Emacs, (split-string \"/foo/bar\" \"/\") returns (\"foo\" \"bar\"). | |
5599 This is, the first, empty, element is omitted. In XEmacs, the first | |
5600 element is not omitted. | |
5601 | |
5602 Note: this function has been written for `tramp-handle-file-truename'. | |
5603 If you want to use it for something else, you'll have to check whether | |
5604 it does the right thing." | |
5605 (delete "" (split-string string pattern))) | |
5606 | |
5607 ;; ------------------------------------------------------------ | |
5608 ;; -- Kludges section -- | |
5609 ;; ------------------------------------------------------------ | |
5610 | |
5611 ;; Currently (as of Emacs 20.5), the function `shell-quote-argument' | |
5612 ;; does not deal well with newline characters. Newline is replaced by | |
5613 ;; backslash newline. But if, say, the string `a backslash newline b' | |
5614 ;; is passed to a shell, the shell will expand this into "ab", | |
5615 ;; completely omitting the newline. This is not what was intended. | |
5616 ;; It does not appear to be possible to make the function | |
5617 ;; `shell-quote-argument' work with newlines without making it | |
5618 ;; dependent on the shell used. But within this package, we know that | |
5619 ;; we will always use a Bourne-like shell, so we use an approach which | |
5620 ;; groks newlines. | |
5621 ;; | |
5622 ;; The approach is simple: we call `shell-quote-argument', then | |
5623 ;; massage the newline part of the result. | |
5624 ;; | |
5625 ;; This function should produce a string which is grokked by a Unix | |
5626 ;; shell, even if the Emacs is running on Windows. Since this is the | |
5627 ;; kludges section, we bind `system-type' in such a way that | |
5628 ;; `shell-quote-arguments' behaves as if on Unix. | |
5629 ;; | |
5630 ;; Thanks to Mario DeWeerd for the hint that it is sufficient for this | |
5631 ;; function to work with Bourne-like shells. | |
5632 ;; | |
5633 ;; CCC: This function should be rewritten so that | |
5634 ;; `shell-quote-argument' is not used. This way, we are safe from | |
5635 ;; changes in `shell-quote-argument'. | |
5636 (defun tramp-shell-quote-argument (s) | |
5637 "Similar to `shell-quote-argument', but groks newlines. | |
5638 Only works for Bourne-like shells." | |
5639 (let ((system-type 'not-windows)) | |
5640 (save-match-data | |
5641 (let ((result (shell-quote-argument s)) | |
5642 (nl (regexp-quote (format "\\%s" tramp-rsh-end-of-line)))) | |
5643 (when (and (>= (length result) 2) | |
5644 (string= (substring result 0 2) "\\~")) | |
5645 (setq result (substring result 1))) | |
5646 (while (string-match nl result) | |
5647 (setq result (replace-match (format "'%s'" tramp-rsh-end-of-line) | |
5648 t t result))) | |
5649 result)))) | |
5650 | |
5651 ;; ;; EFS hooks itself into the file name handling stuff in more places | |
5652 ;; ;; than just `file-name-handler-alist'. The following tells EFS to stay | |
5653 ;; ;; away from tramp.el paths. | |
5654 ;; ;; | |
5655 ;; ;; This is needed because EFS installs (efs-dired-before-readin) into | |
5656 ;; ;; 'dired-before-readin-hook'. This prevents EFS from opening an FTP | |
5657 ;; ;; connection to help it's dired process. Not that I have any real | |
5658 ;; ;; idea *why* this is helpful to dired. | |
5659 ;; ;; | |
5660 ;; ;; Anyway, this advice fixes the problem (with a sledgehammer :) | |
5661 ;; ;; | |
5662 ;; ;; Daniel Pittman <daniel@danann.net> | |
5663 ;; ;; | |
5664 ;; ;; CCC: when the other defadvice calls have disappeared, make sure | |
5665 ;; ;; not to call defadvice unless it's necessary. How do we find out whether | |
5666 ;; ;; it is necessary? (featurep 'efs) is surely the wrong way -- | |
5667 ;; ;; EFS might nicht be loaded yet. | |
5668 ;; (defadvice efs-ftp-path (around dont-match-tramp-path activate protect) | |
5669 ;; "Cause efs-ftp-path to fail when the path is a TRAMP path." | |
5670 ;; (if (tramp-tramp-file-p (ad-get-arg 0)) | |
5671 ;; nil | |
5672 ;; ad-do-it)) | |
5673 | |
5674 ;; We currently use "[" and "]" in the filename format. In Emacs | |
5675 ;; 20.x, this means that Emacs wants to expand wildcards if | |
5676 ;; `find-file-wildcards' is non-nil, and then barfs because no | |
5677 ;; expansion could be found. We detect this situation and do | |
5678 ;; something really awful: we have `file-expand-wildcards' return the | |
5679 ;; original filename if it can't expand anything. Let's just hope | |
5680 ;; that this doesn't break anything else. | |
5681 ;; | |
5682 ;; Another problem is that the check is done by Emacs version, which | |
5683 ;; is really not what we want to do. Oh, well. | |
5684 | |
5685 ;;(when (and (not (featurep 'xemacs)) | |
5686 ;; (= emacs-major-version 20)) | |
5687 ;; It seems that this advice is needed in Emacs 21, too. | |
5688 (defadvice file-expand-wildcards (around tramp-fix activate) | |
5689 (let ((name (ad-get-arg 0))) | |
5690 (if (tramp-tramp-file-p name) | |
5691 ;; If it's a Tramp file, dissect it and look if wildcards | |
5692 ;; need to be expanded at all. | |
5693 (let ((v (tramp-dissect-file-name name))) | |
5694 (if (string-match "[[*?]" (tramp-file-name-path v)) | |
5695 (let ((res ad-do-it)) | |
5696 (setq ad-return-value (or res (list name)))) | |
5697 (setq ad-return-value (list name)))) | |
5698 ;; If it is not a Tramp file, just run the original function. | |
5699 (let ((res ad-do-it)) | |
5700 (setq ad-return-value (or res (list name))))))) | |
5701 ;; ) | |
5702 | |
46752 | 5703 ;; Tramp version is useful in a number of situations. |
5704 | |
5705 (defun tramp-version (arg) | |
5706 "Print version number of tramp.el in minibuffer or current buffer." | |
5707 (interactive "P") | |
5708 (if arg (insert tramp-version) (message tramp-version))) | |
5709 | |
45861 | 5710 ;; Make the `reporter` functionality available for making bug reports about |
5711 ;; the package. A most useful piece of code. | |
5712 | |
5713 (unless (fboundp 'reporter-submit-bug-report) | |
5714 (autoload 'reporter-submit-bug-report "reporter")) | |
5715 | |
5716 (defun tramp-bug () | |
5717 "Submit a bug report to the TRAMP developers." | |
5718 (interactive) | |
5719 (require 'reporter) | |
5720 (let ((reporter-prompt-for-summary-p t)) | |
5721 (reporter-submit-bug-report | |
5722 tramp-bug-report-address ; to-address | |
5723 (format "tramp (%s)" tramp-version) ; package name and version | |
5724 `(;; Current state | |
5725 tramp-ls-command | |
5726 tramp-test-groks-nt | |
5727 tramp-file-exists-command | |
5728 tramp-current-multi-method | |
5729 tramp-current-method | |
5730 tramp-current-user | |
5731 tramp-current-host | |
5732 | |
5733 ;; System defaults | |
5734 tramp-auto-save-directory ; vars to dump | |
5735 tramp-default-method | |
5736 tramp-rsh-end-of-line | |
5737 tramp-remote-path | |
5738 tramp-login-prompt-regexp | |
5739 tramp-password-prompt-regexp | |
5740 tramp-wrong-passwd-regexp | |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
5741 tramp-yesno-prompt-regexp |
46992
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
5742 tramp-yn-prompt-regexp |
45861 | 5743 tramp-temp-name-prefix |
5744 tramp-file-name-structure | |
5745 tramp-file-name-regexp | |
5746 tramp-multi-file-name-structure | |
5747 tramp-multi-file-name-hop-structure | |
5748 tramp-multi-methods | |
5749 tramp-multi-connection-function-alist | |
5750 tramp-make-tramp-file-format | |
5751 tramp-end-of-output | |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
5752 tramp-coding-commands |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
5753 tramp-actions-before-shell |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
5754 tramp-multi-actions |
46835
df25ef3d3237
Version 2.0.12 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46808
diff
changeset
|
5755 tramp-terminal-type |
46998
9d6aef07c793
Version 2.0.14 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46992
diff
changeset
|
5756 tramp-shell-prompt-pattern |
45861 | 5757 |
5758 ;; Non-tramp variables of interest | |
5759 shell-prompt-pattern | |
5760 backup-by-copying | |
5761 backup-by-copying-when-linked | |
5762 backup-by-copying-when-mismatch | |
5763 ,(when (boundp 'backup-by-copying-when-privileged-mismatch) | |
5764 'backup-by-copying-when-privileged-mismatch) | |
5765 file-name-handler-alist) | |
5766 nil ; pre-hook | |
5767 nil ; post-hook | |
5768 "\ | |
5769 Enter your bug report in this message, including as much detail as you | |
5770 possibly can about the problem, what you did to cause it and what the | |
5771 local and remote machines are. | |
5772 | |
5773 If you can give a simple set of instructions to make this bug happen | |
5774 reliably, please include those. Thank you for helping kill bugs in | |
5775 TRAMP. | |
46801
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
5776 |
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
5777 Another useful thing to do is to put (setq tramp-debug-buffer t) in |
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
5778 the ~/.emacs file and to repeat the bug. Then, include the contents |
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
5779 of the *tramp/foo* buffer and the *debug tramp/foo* buffer in your bug |
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
5780 report. |
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
5781 |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
5782 --bug report follows this line-- |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
5783 "))) |
45861 | 5784 |
5785 (defalias 'tramp-submit-bug 'tramp-bug) | |
5786 | |
5787 (provide 'tramp) | |
5788 | |
5789 ;; Make sure that we get integration with the VC package. | |
5790 ;; When it is loaded, we need to pull in the integration module. | |
5791 ;; This must come after (provide 'tramp) because tramp-vc.el | |
5792 ;; requires tramp. | |
5793 (eval-after-load "vc" | |
5794 '(require 'tramp-vc)) | |
5795 | |
5796 ;;; TODO: | |
5797 | |
46790 | 5798 ;; * Add fallback for inline encodings. This should be used |
5799 ;; if the remote end doesn't support mimencode or a similar program. | |
5800 ;; For reading files from the remote host, we can just parse the output | |
5801 ;; of `od -b'. For writing files to the remote host, we construct | |
5802 ;; a shell program which contains only "safe" ascii characters | |
5803 ;; and which writes the right bytes to the file. We can use printf(1) | |
5804 ;; or "echo -e" or the printf function in awk and use octal escapes | |
5805 ;; for the "dangerous" characters. The null byte might be a problem. | |
5806 ;; On some systems, the octal escape doesn't work. So we try the following | |
5807 ;; two commands to write a null byte: | |
5808 ;; dd if=/dev/zero bs=1 count=1 | |
5809 ;; echo | tr '\n' '\000' | |
45861 | 5810 ;; * Cooperate with PCL-CVS. It uses start-process, which doesn't |
5811 ;; work for remote files. | |
5812 ;; * Rewrite `tramp-shell-quote-argument' to abstain from using | |
46790 | 5813 ;; `shell-quote-argument'. |
45861 | 5814 ;; * Completion gets confused when you leave out the method name. |
5815 ;; * Support `dired-compress-file' filename handler. | |
5816 ;; * In Emacs 21, `insert-directory' shows total number of bytes used | |
5817 ;; by the files in that directory. Add this here. | |
5818 ;; * Avoid screen blanking when hitting `g' in dired. (Eli Tziperman) | |
5819 ;; * Make ffap.el grok Tramp filenames. (Eli Tziperman) | |
5820 ;; * When logging in, keep looking for questions according to an alist | |
5821 ;; and then invoke the right function. | |
5822 ;; * Case-insensitive filename completion. (Norbert Goevert.) | |
5823 ;; * Running CVS remotely doesn't appear to work right. It thinks | |
5824 ;; files are locked by somebody else even if I'm the locking user. | |
5825 ;; Sometimes, one gets `No CVSROOT specified' errors from CVS. | |
5826 ;; (Skip Montanaro) | |
5827 ;; * Don't use globbing for directories with many files, as this is | |
5828 ;; likely to produce long command lines, and some shells choke on | |
5829 ;; long command lines. | |
5830 ;; * Find out about the new auto-save mechanism in Emacs 21 and | |
5831 ;; do the right thing. | |
5832 ;; * `vc-directory' does not work. It never displays any files, even | |
5833 ;; if it does show files when run locally. | |
5834 ;; * Allow correction of passwords, if the remote end allows this. | |
5835 ;; (Mark Hershberger) | |
5836 ;; * Make sure permissions of tmp file are good. | |
5837 ;; (Nelson Minar <nelson@media.mit.edu>) | |
5838 ;; * Grok passwd prompts with scp? (David Winter | |
5839 ;; <winter@nevis1.nevis.columbia.edu>). Maybe just do `ssh -l user | |
5840 ;; host', then wait a while for the passwd or passphrase prompt. If | |
5841 ;; there is one, remember the passwd/phrase. | |
5842 ;; * How to deal with MULE in `insert-file-contents' and `write-region'? | |
5843 ;; * Do asynchronous `shell-command's. | |
5844 ;; * Grok `append' parameter for `write-region'. | |
5845 ;; * Test remote ksh or bash for tilde expansion in `tramp-find-shell'? | |
5846 ;; * abbreviate-file-name | |
5847 ;; * grok ~ in tramp-remote-path (Henrik Holm <henrikh@tele.ntnu.no>) | |
5848 ;; * `C' in dired gives error `not tramp file name'. | |
5849 ;; * Also allow to omit user names when doing multi-hop. Not sure yet | |
5850 ;; what the user names should default to, though. | |
5851 ;; * better error checking. At least whenever we see something | |
5852 ;; strange when doing zerop, we should kill the process and start | |
5853 ;; again. (Greg Stark) | |
5854 ;; * Add caching for filename completion. (Greg Stark) | |
5855 ;; Of course, this has issues with usability (stale cache bites) | |
5856 ;; -- <daniel@danann.net> | |
5857 ;; * Provide a local cache of old versions of remote files for the rsync | |
5858 ;; transfer method to use. (Greg Stark) | |
5859 ;; * Remove unneeded parameters from methods. | |
5860 ;; * Invoke rsync once for copying a whole directory hierarchy. | |
5861 ;; (Francesco Potort́) | |
5862 ;; * Should we set PATH ourselves or should we rely on the remote end | |
5863 ;; to do it? | |
5864 ;; * Do the autoconf thing. | |
5865 ;; * Make it work for XEmacs 20, which is missing `with-timeout'. | |
5866 ;; * Allow non-Unix remote systems. (More a long-term thing.) | |
5867 ;; * Make it work for different encodings, and for different file name | |
5868 ;; encodings, too. (Daniel Pittman) | |
5869 ;; * Change applicable functions to pass a struct tramp-file-name rather | |
5870 ;; than the individual items MULTI-METHOD, METHOD, USER, HOST, PATH. | |
5871 ;; * Implement asynchronous shell commands. | |
5872 ;; * Clean up unused *tramp/foo* buffers after a while. (Pete Forman) | |
5873 ;; * Progress reports while copying files. (Michael Kifer) | |
5874 ;; * `Smart' connection method that uses inline for small and out of | |
5875 ;; band for large files. (Michael Kifer) | |
5876 ;; * Don't search for perl5 and perl. Instead, only search for perl and | |
5877 ;; then look if it's the right version (with `perl -v'). | |
5878 ;; * When editing a remote CVS controlled file as a different user, VC | |
5879 ;; gets confused about the file locking status. Try to find out why | |
5880 ;; the workaround doesn't work. | |
5881 ;; * When user is running ssh-agent, it would be useful to add the | |
5882 ;; passwords typed by the user to that agent. This way, the next time | |
5883 ;; round, the users don't have to type all this in again. | |
5884 ;; This would be especially useful for start-process, I think. | |
5885 ;; An easy way to implement start-process is to open a second shell | |
5886 ;; connection which is inconvenient if the user has to reenter | |
5887 ;; passwords. | |
5888 ;; * Change `copy-file' to grok the case where the filename handler | |
5889 ;; for the source and the target file are different. Right now, | |
5890 ;; it looks at the source file and then calls that handler, if | |
5891 ;; there is one. But since ange-ftp, for instance, does not know | |
5892 ;; about Tramp, it does not do the right thing if the target file | |
5893 ;; name is a Tramp name. | |
46992
6529728ddf05
Version 2.0.13 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46835
diff
changeset
|
5894 ;; * Username and hostname completion. |
45861 | 5895 |
5896 ;; Functions for file-name-handler-alist: | |
5897 ;; diff-latest-backup-file -- in diff.el | |
5898 ;; dired-compress-file | |
5899 ;; dired-uncache -- this will be needed when we do insert-directory caching | |
5900 ;; file-name-as-directory -- use primitive? | |
5901 ;; file-name-directory -- use primitive? | |
5902 ;; file-name-nondirectory -- use primitive? | |
5903 ;; file-name-sans-versions -- use primitive? | |
5904 ;; file-newer-than-file-p | |
5905 ;; find-backup-file-name | |
5906 ;; get-file-buffer -- use primitive | |
5907 ;; load | |
5908 ;; unhandled-file-name-directory | |
5909 ;; vc-registered | |
5910 | |
5911 ;;; tramp.el ends here |