Mercurial > emacs
annotate lisp/net/tramp.el @ 46822:341d8797885c
(ediff-copy-list): Use `defalias' instead of
`fset' and `symbol-function'.
author | John Paul Wallington <jpw@pobox.com> |
---|---|
date | Mon, 05 Aug 2002 22:37:25 +0000 |
parents | cf225aed7a75 |
children | df25ef3d3237 |
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. | |
46808
cf225aed7a75
Version 2.0.11 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46802
diff
changeset
|
75 (defconst tramp-version "2.0.11" |
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 | |
107 (defcustom tramp-verbose 10 | |
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 | |
702 (defcustom tramp-password-prompt-regexp | |
46752 | 703 "^.*\\([pP]assword\\|passphrase.*\\):\^@? *" |
45861 | 704 "*Regexp matching password-like prompts. |
46752 | 705 The regexp should match at end of buffer. |
45861 | 706 |
707 The `sudo' program appears to insert a `^@' character into the prompt." | |
708 :group 'tramp | |
709 :type 'regexp) | |
710 | |
711 (defcustom tramp-wrong-passwd-regexp | |
46790 | 712 (concat "^.*" |
713 ;; These strings should be on the last line | |
714 (regexp-opt '("Permission denied." | |
715 "Login incorrect" | |
716 "Login Incorrect" | |
717 "Connection refused" | |
718 "Connection closed" | |
719 "Sorry, try again." | |
720 "Name or service not known" | |
721 "Host key verification failed.") t) | |
722 ".*" | |
723 "\\|" | |
724 "^.*\\(" | |
725 ;; Here comes a list of regexes, separated by \\| | |
726 "Received signal [0-9]+" | |
727 "\\).*") | |
45861 | 728 "*Regexp matching a `login failed' message. |
46752 | 729 The regexp should match at end of buffer." |
730 :group 'tramp | |
731 :type 'regexp) | |
732 | |
733 (defcustom tramp-yesno-prompt-regexp | |
734 "Are you sure you want to continue connecting (yes/no)\\? *" | |
735 "Regular expression matching all queries which need to be confirmed. | |
736 The confirmation should be done with yes or no. | |
737 The regexp should match at end of buffer." | |
45861 | 738 :group 'tramp |
739 :type 'regexp) | |
740 | |
741 (defcustom tramp-temp-name-prefix "tramp." | |
742 "*Prefix to use for temporary files. | |
743 If this is a relative file name (such as \"tramp.\"), it is considered | |
744 relative to the directory name returned by the function | |
745 `tramp-temporary-file-directory' (which see). It may also be an | |
746 absolute file name; don't forget to include a prefix for the filename | |
747 part, though." | |
748 :group 'tramp | |
749 :type 'string) | |
750 | |
751 (defcustom tramp-discard-garbage nil | |
752 "*If non-nil, try to discard garbage sent by remote shell. | |
753 Some shells send such garbage upon connection setup." | |
754 :group 'tramp | |
755 :type 'boolean) | |
756 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
757 (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
|
758 "*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
|
759 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
|
760 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
|
761 arguments. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
762 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
763 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
|
764 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
|
765 shell from reading its init file." |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
766 :group 'tramp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
767 :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
|
768 |
45861 | 769 ;; File name format. |
770 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
771 (defconst tramp-file-name-structure-unified |
46752 | 772 (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
|
773 "\\(\\([^:@/]+\\)@\\)?" ;user |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
774 "\\([^:/]+\\):" ;host |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
775 "\\(.*\\)\\'") ;path |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
776 2 4 5 6) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
777 "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
|
778 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
|
779 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
|
780 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
781 (defconst tramp-file-name-structure-separate |
46752 | 782 (list (concat "\\`/\\[\\(\\([a-zA-Z0-9-]+\\)/\\)?" ;method |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
783 "\\(\\([-a-zA-Z0-9_#/:]+\\)@\\)?" ;user |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
784 "\\([-a-zA-Z0-9_#/:@.]+\\)\\]" ;host |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
785 "\\(.*\\)\\'") ;path |
45861 | 786 2 4 5 6) |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
787 "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
|
788 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
|
789 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
|
790 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
|
791 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
792 (defcustom tramp-file-name-structure |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
793 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
794 tramp-file-name-structure-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
795 tramp-file-name-structure-unified) |
45861 | 796 "*List of five elements (REGEXP METHOD USER HOST FILE), detailing \ |
797 the tramp file name structure. | |
798 | |
799 The first element REGEXP is a regular expression matching a tramp file | |
800 name. The regex should contain parentheses around the method name, | |
801 the user name, the host name, and the file name parts. | |
802 | |
803 The second element METHOD is a number, saying which pair of | |
804 parentheses matches the method name. The third element USER is | |
805 similar, but for the user name. The fourth element HOST is similar, | |
806 but for the host name. The fifth element FILE is for the file name. | |
807 These numbers are passed directly to `match-string', which see. That | |
808 means the opening parentheses are counted to identify the pair. | |
809 | |
810 See also `tramp-file-name-regexp' and `tramp-make-tramp-file-format'." | |
811 :group 'tramp | |
812 :type '(list (regexp :tag "File name regexp") | |
813 (integer :tag "Paren pair for method name") | |
814 (integer :tag "Paren pair for user name ") | |
815 (integer :tag "Paren pair for host name ") | |
816 (integer :tag "Paren pair for file name "))) | |
817 | |
818 ;;;###autoload | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
819 (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
|
820 "\\`/[^/:]+:" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
821 "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
|
822 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
|
823 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
|
824 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
825 ;;;###autoload |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
826 (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
|
827 "\\`/\\[.*\\]" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
828 "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
|
829 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
|
830 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
|
831 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
832 ;;;###autoload |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
833 (defcustom tramp-file-name-regexp |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
834 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
835 tramp-file-name-regexp-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
836 tramp-file-name-regexp-unified) |
45861 | 837 "*Regular expression matching file names handled by tramp. |
838 This regexp should match tramp file names but no other file names. | |
839 \(When tramp.el is loaded, this regular expression is prepended to | |
840 `file-name-handler-alist', and that is searched sequentially. Thus, | |
841 if the tramp entry appears rather early in the `file-name-handler-alist' | |
842 and is a bit too general, then some files might be considered tramp | |
843 files which are not really tramp files. | |
844 | |
845 Please note that the entry in `file-name-handler-alist' is made when | |
846 this file (tramp.el) is loaded. This means that this variable must be set | |
847 before loading tramp.el. Alternatively, `file-name-handler-alist' can be | |
848 updated after changing this variable. | |
849 | |
850 Also see `tramp-file-name-structure' and `tramp-make-tramp-file-format'." | |
851 :group 'tramp | |
852 :type 'regexp) | |
853 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
854 (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
|
855 "/%m:%u@%h:%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
856 "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
|
857 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
|
858 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
|
859 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
860 (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
|
861 "/[%m/%u@%h]%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
862 "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
|
863 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
|
864 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
|
865 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
866 (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
|
867 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
868 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
|
869 tramp-make-tramp-file-format-unified) |
45861 | 870 "*Format string saying how to construct tramp file name. |
871 `%m' is replaced by the method name. | |
872 `%u' is replaced by the user name. | |
873 `%h' is replaced by the host name. | |
874 `%p' is replaced by the file name. | |
875 `%%' is replaced by %. | |
876 | |
877 Also see `tramp-file-name-structure' and `tramp-file-name-regexp'." | |
878 :group 'tramp | |
879 :type 'string) | |
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-user-nil-format-unified |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
882 "/%m:%h:%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
883 "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
|
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 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-user-nil-format-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
888 "/[%m/%h]%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
889 "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
|
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 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-user-nil-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-user-nil-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-user-nil-format-unified) |
45861 | 897 "*Format string saying how to construct tramp file name when the user name is not known. |
898 `%m' is replaced by the method name. | |
899 `%h' is replaced by the host name. | |
900 `%p' is replaced by the file name. | |
901 `%%' is replaced by %. | |
902 | |
903 Also see `tramp-make-tramp-file-format', `tramp-file-name-structure', and `tramp-file-name-regexp'." | |
904 :group 'tramp | |
905 :type 'string) | |
906 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
907 (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
|
908 (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
|
909 "\\(\\(%s\\)+\\)" ;hops |
46347
3996ea20e5e3
(tramp-multi-file-name-structure-unified): Add
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46307
diff
changeset
|
910 "\\(.*\\)\\'") ;path |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
911 2 3 -1) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
912 "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
|
913 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
|
914 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
|
915 |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
916 (defconst tramp-multi-file-name-structure-separate |
45861 | 917 (list (concat |
918 ;; prefix | |
46347
3996ea20e5e3
(tramp-multi-file-name-structure-unified): Add
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46307
diff
changeset
|
919 "\\`/\\[\\(\\([a-z0-9]+\\)?\\)" |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
920 ;; regexp specifying the hops |
45861 | 921 "\\(\\(%s\\)+\\)" |
922 ;; path name | |
923 "\\]\\(.*\\)\\'") | |
924 2 ;number of pair to match method | |
925 3 ;number of pair to match hops | |
926 -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
|
927 "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
|
928 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
|
929 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
|
930 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
931 (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
|
932 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
933 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
|
934 tramp-multi-file-name-structure-unified) |
45861 | 935 "*Describes the file name structure of `multi' files. |
936 Multi files allow you to contact a remote host in several hops. | |
937 This is a list of four elements (REGEXP METHOD HOP PATH). | |
938 | |
939 The first element, REGEXP, gives a regular expression to match against | |
940 the file name. In this regular expression, `%s' is replaced with the | |
941 value of `tramp-multi-file-name-hop-structure'. (Note: in order to | |
942 allow multiple hops, you normally want to use something like | |
943 \"\\\\(\\\\(%s\\\\)+\\\\)\" in the regular expression. The outer pair | |
944 of parentheses is used for the HOP element, see below.) | |
945 | |
946 All remaining elements are numbers. METHOD gives the number of the | |
947 paren pair which matches the method name. HOP gives the number of the | |
948 paren pair which matches the hop sequence. PATH gives the number of | |
949 the paren pair which matches the path name on the remote host. | |
950 | |
951 PATH can also be negative, which means to count from the end. Ie, a | |
952 value of -1 means the last paren pair. | |
953 | |
954 I think it would be good if the regexp matches the whole of the | |
955 string, but I haven't actually tried what happens if it doesn't..." | |
956 :group 'tramp | |
957 :type '(list (regexp :tag "File name regexp") | |
958 (integer :tag "Paren pair for method name") | |
959 (integer :tag "Paren pair for hops") | |
960 (integer :tag "Paren pair to match path"))) | |
961 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
962 (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
|
963 (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
|
964 "\\([^@:/]+\\)@" ;user |
46347
3996ea20e5e3
(tramp-multi-file-name-structure-unified): Add
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46307
diff
changeset
|
965 "\\([^:/]+\\):") ;host |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
966 1 2 3) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
967 "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
|
968 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
|
969 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
|
970 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
971 (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
|
972 (list (concat "/\\([a-z0-9_]+\\):" ;hop method |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
973 "\\([a-z0-9_]+\\)@" ;user |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
974 "\\([a-z0-9.-]+\\)") ;host |
45861 | 975 1 2 3) |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
976 "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
|
977 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
|
978 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
|
979 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
980 (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
|
981 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
982 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
|
983 tramp-multi-file-name-hop-structure-unified) |
45861 | 984 "*Describes the structure of a hop in multi files. |
985 This is a list of four elements (REGEXP METHOD USER HOST). First | |
986 element REGEXP is used to match against the hop. Pair number METHOD | |
987 matches the method of one hop, pair number USER matches the user of | |
988 one hop, pair number HOST matches the host of one hop. | |
989 | |
990 This regular expression should match exactly all of one hop." | |
991 :group 'tramp | |
992 :type '(list (regexp :tag "Hop regexp") | |
993 (integer :tag "Paren pair for method name") | |
994 (integer :tag "Paren pair for user name") | |
995 (integer :tag "Paren pair for host name"))) | |
996 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
997 (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
|
998 (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
|
999 "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
|
1000 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
|
1001 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
|
1002 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1003 (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
|
1004 (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
|
1005 "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
|
1006 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
|
1007 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
|
1008 |
45861 | 1009 (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
|
1010 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1011 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
|
1012 tramp-make-multi-tramp-file-format-unified) |
45861 | 1013 "*Describes how to construct a `multi' file name. |
1014 This is a list of three elements PREFIX, HOP and PATH. | |
1015 | |
1016 The first element PREFIX says how to construct the prefix, the second | |
1017 element HOP specifies what each hop looks like, and the final element | |
1018 PATH says how to construct the path name. | |
1019 | |
1020 In PREFIX, `%%' means `%' and `%m' means the method name. | |
1021 | |
1022 In HOP, `%%' means `%' and `%m', `%u', `%h' mean the hop method, hop | |
1023 user and hop host, respectively. | |
1024 | |
1025 In PATH, `%%' means `%' and `%p' means the path name. | |
1026 | |
1027 The resulting file name always contains one copy of PREFIX and one | |
1028 copy of PATH, but there is one copy of HOP for each hop in the file | |
1029 name. | |
1030 | |
1031 Note: the current implementation requires the prefix to contain the | |
1032 method name, followed by all the hops, and the path name must come | |
1033 last." | |
1034 :group 'tramp | |
1035 :type '(list string string string)) | |
1036 | |
1037 (defcustom tramp-terminal-type "dumb" | |
1038 "*Value of TERM environment variable for logging in to remote host. | |
1039 Because Tramp wants to parse the output of the remote shell, it is easily | |
1040 confused by ANSI color escape sequences and suchlike. Often, shell init | |
1041 files conditionalize this setup based on the TERM environment variable." | |
1042 :group 'tramp | |
1043 :type 'string) | |
1044 | |
1045 (defcustom tramp-completion-without-shell-p nil | |
1046 "*If nil, use shell wildcards for completion, else rely on Lisp only. | |
1047 Using shell wildcards for completions has the advantage that it can be | |
1048 fast even in large directories, but completion is always | |
1049 case-sensitive. Relying on Lisp only means that case-insensitive | |
1050 completion is possible (subject to the variable `completion-ignore-case'), | |
1051 but it might be slow on large directories." | |
1052 :group 'tramp | |
1053 :type 'boolean) | |
1054 | |
46752 | 1055 (defcustom tramp-actions-before-shell |
1056 '((tramp-password-prompt-regexp tramp-action-password) | |
1057 (tramp-login-prompt-regexp tramp-action-login) | |
1058 (shell-prompt-pattern tramp-action-succeed) | |
1059 (tramp-wrong-passwd-regexp tramp-action-permission-denied) | |
1060 (tramp-yesno-prompt-regexp tramp-action-yesno)) | |
1061 "List of pattern/action pairs. | |
1062 Whenever a pattern matches, the corresponding action is performed. | |
1063 Each item looks like (PATTERN ACTION). | |
1064 | |
1065 The PATTERN should be a symbol, a variable. The value of this | |
1066 variable gives the regular expression to search for. Note that the | |
1067 regexp must match at the end of the buffer, \"\\'\" is implicitly | |
1068 appended to it. | |
1069 | |
1070 The ACTION should also be a symbol, but a function. When the | |
1071 corresponding PATTERN matches, the ACTION function is called." | |
1072 :group 'tramp | |
1073 :type '(repeat (list variable function))) | |
1074 | |
1075 (defcustom tramp-multi-actions | |
1076 '((tramp-password-prompt-regexp tramp-multi-action-password) | |
1077 (tramp-login-prompt-regexp tramp-multi-action-login) | |
1078 (shell-prompt-pattern tramp-multi-action-succeed) | |
1079 (tramp-wrong-passwd-regexp tramp-multi-action-permission-denied)) | |
1080 "List of pattern/action pairs. | |
1081 This list is used for each hop in multi-hop connections. | |
1082 See `tramp-actions-before-shell' for more info." | |
1083 :group 'tramp | |
1084 :type '(repeat (list variable function))) | |
1085 | |
45861 | 1086 ;;; Internal Variables: |
1087 | |
1088 (defvar tramp-buffer-file-attributes nil | |
1089 "Holds the `ls -ild' output for the current buffer. | |
1090 This variable is local to each buffer. It is not used if the remote | |
1091 machine groks Perl. If it is used, it's used as an emulation for | |
1092 the visited file modtime.") | |
1093 (make-variable-buffer-local 'tramp-buffer-file-attributes) | |
1094 | |
1095 (defvar tramp-end-of-output "/////" | |
1096 "String used to recognize end of output.") | |
1097 | |
1098 (defvar tramp-connection-function nil | |
1099 "This internal variable holds a parameter for `tramp-methods'. | |
1100 In the connection buffer, this variable has the value of the like-named | |
1101 method parameter, as specified in `tramp-methods' (which see).") | |
1102 | |
1103 (defvar tramp-remote-sh nil | |
1104 "This internal variable holds a parameter for `tramp-methods'. | |
1105 In the connection buffer, this variable has the value of the like-named | |
1106 method parameter, as specified in `tramp-methods' (which see).") | |
1107 | |
1108 (defvar tramp-rsh-program nil | |
1109 "This internal variable holds a parameter for `tramp-methods'. | |
1110 In the connection buffer, this variable has the value of the like-named | |
1111 method parameter, as specified in `tramp-methods' (which see).") | |
1112 | |
1113 (defvar tramp-rsh-args nil | |
1114 "This internal variable holds a parameter for `tramp-methods'. | |
1115 In the connection buffer, this variable has the value of the like-named | |
1116 method parameter, as specified in `tramp-methods' (which see).") | |
1117 | |
1118 (defvar tramp-rcp-program nil | |
1119 "This internal variable holds a parameter for `tramp-methods'. | |
1120 In the connection buffer, this variable has the value of the like-named | |
1121 method parameter, as specified in `tramp-methods' (which see).") | |
1122 | |
1123 (defvar tramp-rcp-args nil | |
1124 "This internal variable holds a parameter for `tramp-methods'. | |
1125 In the connection buffer, this variable has the value of the like-named | |
1126 method parameter, as specified in `tramp-methods' (which see).") | |
1127 | |
1128 (defvar tramp-rcp-keep-date-arg 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-encoding-command 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-decoding-command 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-encoding-function 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-decoding-function 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-telnet-program 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-telnet-args 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 | |
46790 | 1163 (defvar tramp-su-program 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 | |
45861 | 1168 ;; CCC `local in each buffer'? |
1169 (defvar tramp-ls-command nil | |
1170 "This command is used to get a long listing with numeric user and group ids. | |
1171 This variable is automatically made buffer-local to each rsh process buffer | |
1172 upon opening the connection.") | |
1173 | |
1174 (defvar tramp-current-multi-method nil | |
1175 "Name of `multi' connection method for this *tramp* buffer, or nil if not multi. | |
1176 This variable is automatically made buffer-local to each rsh process buffer | |
1177 upon opening the connection.") | |
1178 | |
1179 (defvar tramp-current-method nil | |
1180 "Connection method for this *tramp* buffer. | |
1181 This variable is automatically made buffer-local to each rsh process buffer | |
1182 upon opening the connection.") | |
1183 | |
1184 (defvar tramp-current-user nil | |
1185 "Remote login name for this *tramp* buffer. | |
1186 This variable is automatically made buffer-local to each rsh process buffer | |
1187 upon opening the connection.") | |
1188 | |
1189 (defvar tramp-current-host nil | |
1190 "Remote host for this *tramp* buffer. | |
1191 This variable is automatically made buffer-local to each rsh process buffer | |
1192 upon opening the connection.") | |
1193 | |
1194 (defvar tramp-test-groks-nt nil | |
1195 "Whether the `test' command groks the `-nt' switch. | |
1196 \(`test A -nt B' tests if file A is newer than file B.) | |
1197 This variable is automatically made buffer-local to each rsh process buffer | |
1198 upon opening the connection.") | |
1199 | |
1200 (defvar tramp-file-exists-command nil | |
1201 "Command to use for checking if a file exists. | |
1202 This variable is automatically made buffer-local to each rsh process buffer | |
1203 upon opening the connection.") | |
1204 | |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1205 (defconst tramp-uudecode "\ |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1206 tramp_uudecode () { |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1207 \(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
|
1208 cat /tmp/tramp.$$ |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1209 rm -f /tmp/tramp.$$ |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1210 }" |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1211 "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
|
1212 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
|
1213 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
|
1214 |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
1215 ;; 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
|
1216 ;; 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
|
1217 ;; 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
|
1218 ;; end. |
46808
cf225aed7a75
Version 2.0.11 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46802
diff
changeset
|
1219 (defconst tramp-perl-file-attributes "\ |
cf225aed7a75
Version 2.0.11 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46802
diff
changeset
|
1220 $f = $ARGV[0]; |
45861 | 1221 @s = lstat($f); |
1222 if (($s[2] & 0170000) == 0120000) { $l = readlink($f); $l = \"\\\"$l\\\"\"; } | |
1223 elsif (($s[2] & 0170000) == 040000) { $l = \"t\"; } | |
1224 else { $l = \"nil\" }; | |
46808
cf225aed7a75
Version 2.0.11 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46802
diff
changeset
|
1225 printf(\"(%s %u %d %d (%u %u) (%u %u) (%u %u) %u %u t (%u . %u) (%u %u))\\n\", |
45861 | 1226 $l, $s[3], $s[4], $s[5], $s[8] >> 16 & 0xffff, $s[8] & 0xffff, |
1227 $s[9] >> 16 & 0xffff, $s[9] & 0xffff, $s[10] >> 16 & 0xffff, $s[10] & 0xffff, | |
1228 $s[7], $s[2], $s[1] >> 16 & 0xffff, $s[1] & 0xffff, $s[0] >> 16 & 0xffff, $s[0] & 0xffff);" | |
1229 "Perl script to produce output suitable for use with `file-attributes' | |
1230 on the remote file system.") | |
1231 | |
46752 | 1232 ;; ;; These two use uu encoding. |
1233 ;; (defvar tramp-perl-encode "%s -e'\ | |
1234 ;; print qq(begin 644 xxx\n); | |
1235 ;; my $s = q(); | |
1236 ;; my $res = q(); | |
1237 ;; while (read(STDIN, $s, 45)) { | |
1238 ;; print pack(q(u), $s); | |
1239 ;; } | |
1240 ;; print qq(`\n); | |
1241 ;; print qq(end\n); | |
1242 ;; '" | |
1243 ;; "Perl program to use for encoding a file. | |
1244 ;; Escape sequence %s is replaced with name of Perl binary.") | |
1245 | |
1246 ;; (defvar tramp-perl-decode "%s -ne ' | |
1247 ;; print unpack q(u), $_; | |
1248 ;; '" | |
1249 ;; "Perl program to use for decoding a file. | |
1250 ;; Escape sequence %s is replaced with name of Perl binary.") | |
1251 | |
1252 ;; These two use base64 encoding. | |
46790 | 1253 (defvar tramp-perl-encode-with-module |
1254 "perl -MMIME::Base64 -0777 -ne 'print encode_base64($_)'" | |
1255 "Perl program to use for encoding a file. | |
1256 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
|
1257 This string is passed to `format', so percent characters need to be doubled. |
46790 | 1258 This implementation requires the MIME::Base64 Perl module to be installed |
1259 on the remote host.") | |
1260 | |
1261 (defvar tramp-perl-decode-with-module | |
1262 "perl -MMIME::Base64 -0777 -ne 'print decode_base64($_)'" | |
1263 "Perl program to use for decoding a file. | |
1264 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
|
1265 This string is passed to `format', so percent characters need to be doubled. |
46790 | 1266 This implementation requires the MIME::Base64 Perl module to be installed |
1267 on the remote host.") | |
1268 | |
46752 | 1269 (defvar tramp-perl-encode |
46790 | 1270 "%s -e ' |
1271 # This script contributed by Juanma Barranquero <lektu@terra.es>. | |
1272 # Copyright (C) 2002 Free Software Foundation, Inc. | |
1273 use strict; | |
1274 | |
46795 | 1275 my %%trans = do { |
46790 | 1276 my $i = 0; |
1277 map {(substr(unpack(q(B8), chr $i++), 2, 6), $_)} | |
1278 split //, q(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/); | |
1279 }; | |
1280 | |
46797 | 1281 binmode(\\*STDIN); |
46790 | 1282 |
1283 # We read in chunks of 54 bytes, to generate output lines | |
1284 # of 72 chars (plus end of line) | |
46797 | 1285 $/ = \\54; |
46790 | 1286 |
1287 while (my $data = <STDIN>) { | |
1288 my $pad = q(); | |
1289 | |
1290 # Only for the last chunk, and only if did not fill the last three-byte packet | |
1291 if (eof) { | |
46795 | 1292 my $mod = length($data) %% 3; |
46790 | 1293 $pad = q(=) x (3 - $mod) if $mod; |
1294 } | |
1295 | |
1296 # Not the fastest method, but it is simple: unpack to binary string, split | |
1297 # by groups of 6 bits and convert back from binary to byte; then map into | |
1298 # the translation table | |
1299 print | |
1300 join q(), | |
1301 map($trans{$_}, | |
1302 (substr(unpack(q(B*), $data) . q(00000), 0, 432) =~ /....../g)), | |
1303 $pad, | |
46797 | 1304 qq(\\n); |
46790 | 1305 } |
1306 '" | |
46752 | 1307 "Perl program to use for encoding a file. |
46795 | 1308 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
|
1309 This string is passed to `format', so percent characters need to be doubled.") |
46752 | 1310 |
1311 (defvar tramp-perl-decode | |
46790 | 1312 "%s -e ' |
1313 # This script contributed by Juanma Barranquero <lektu@terra.es>. | |
1314 # Copyright (C) 2002 Free Software Foundation, Inc. | |
1315 use strict; | |
1316 | |
46795 | 1317 my %%trans = do { |
46790 | 1318 my $i = 0; |
46795 | 1319 map {($_, sprintf(q(%%06b), $i++))} |
46790 | 1320 split //, q(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/) |
1321 }; | |
1322 | |
46795 | 1323 my %%bytes = map {(unpack(q(B8), chr $_), chr $_)} 0 .. 255; |
46790 | 1324 |
46797 | 1325 binmode(\\*STDOUT); |
46790 | 1326 |
1327 # We are going to accumulate into $pending to accept any line length | |
1328 # (we do not check they are <= 76 chars as the RFC says) | |
1329 my $pending = q(); | |
1330 | |
1331 while (my $data = <STDIN>) { | |
1332 chomp $data; | |
1333 | |
1334 # If we find one or two =, we have reached the end and | |
1335 # any following data is to be discarded | |
1336 my $finished = $data =~ s/(==?).*/$1/; | |
1337 $pending .= $data; | |
1338 | |
1339 my $len = length($pending); | |
1340 my $chunk = substr($pending, 0, $len & ~3, q()); | |
1341 | |
1342 # Easy method: translate from chars to (pregenerated) six-bit packets, join, | |
1343 # split in 8-bit chunks and convert back to char. | |
1344 print join q(), | |
1345 map $bytes{$_}, | |
1346 ((join q(), map {$trans{$_} || q()} split //, $chunk) =~ /......../g); | |
1347 | |
1348 last if $finished; | |
1349 } | |
1350 '" | |
46752 | 1351 "Perl program to use for decoding a file. |
46795 | 1352 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
|
1353 This string is passed to `format', so percent characters need to be doubled.") |
45861 | 1354 |
1355 ; These values conform to `file-attributes' from XEmacs 21.2. | |
1356 ; GNU Emacs and other tools not checked. | |
1357 (defconst tramp-file-mode-type-map '((0 . "-") ; Normal file (SVID-v2 and XPG2) | |
1358 (1 . "p") ; fifo | |
1359 (2 . "c") ; character device | |
1360 (3 . "m") ; multiplexed character device (v7) | |
1361 (4 . "d") ; directory | |
1362 (5 . "?") ; Named special file (XENIX) | |
1363 (6 . "b") ; block device | |
1364 (7 . "?") ; multiplexed block device (v7) | |
1365 (8 . "-") ; regular file | |
1366 (9 . "n") ; network special file (HP-UX) | |
1367 (10 . "l") ; symlink | |
1368 (11 . "?") ; ACL shadow inode (Solaris, not userspace) | |
1369 (12 . "s") ; socket | |
1370 (13 . "D") ; door special (Solaris) | |
1371 (14 . "w")) ; whiteout (BSD) | |
1372 "A list of file types returned from the `stat' system call. | |
1373 This is used to map a mode number to a permission string.") | |
1374 | |
1375 (defvar tramp-dos-coding-system | |
1376 (if (and (fboundp 'coding-system-p) | |
1377 (funcall 'coding-system-p '(dos))) | |
1378 'dos | |
1379 'undecided-dos) | |
1380 "Some Emacsen know the `dos' coding system, others need `undecided-dos'.") | |
1381 | |
46752 | 1382 (defvar tramp-last-cmd-time nil |
1383 "Internal Tramp variable recording the time when the last cmd was sent. | |
1384 This variable is buffer-local in every buffer.") | |
1385 (make-variable-buffer-local 'tramp-last-cmd-time) | |
45861 | 1386 |
1387 ;; New handlers should be added here. The following operations can be | |
1388 ;; handled using the normal primitives: file-name-as-directory, | |
1389 ;; file-name-directory, file-name-nondirectory, | |
1390 ;; file-name-sans-versions, get-file-buffer. | |
1391 (defconst tramp-file-name-handler-alist | |
1392 '( | |
1393 (load . tramp-handle-load) | |
1394 (make-symbolic-link . tramp-handle-make-symbolic-link) | |
1395 (file-name-directory . tramp-handle-file-name-directory) | |
1396 (file-name-nondirectory . tramp-handle-file-name-nondirectory) | |
1397 (file-truename . tramp-handle-file-truename) | |
1398 (file-exists-p . tramp-handle-file-exists-p) | |
1399 (file-directory-p . tramp-handle-file-directory-p) | |
1400 (file-executable-p . tramp-handle-file-executable-p) | |
1401 (file-accessible-directory-p . tramp-handle-file-accessible-directory-p) | |
1402 (file-readable-p . tramp-handle-file-readable-p) | |
1403 (file-regular-p . tramp-handle-file-regular-p) | |
1404 (file-symlink-p . tramp-handle-file-symlink-p) | |
1405 (file-writable-p . tramp-handle-file-writable-p) | |
1406 (file-ownership-preserved-p . tramp-handle-file-ownership-preserved-p) | |
1407 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) | |
1408 (file-attributes . tramp-handle-file-attributes) | |
1409 (file-modes . tramp-handle-file-modes) | |
1410 (file-directory-files . tramp-handle-file-directory-files) | |
1411 (directory-files . tramp-handle-directory-files) | |
1412 (file-name-all-completions . tramp-handle-file-name-all-completions) | |
1413 (file-name-completion . tramp-handle-file-name-completion) | |
1414 (add-name-to-file . tramp-handle-add-name-to-file) | |
1415 (copy-file . tramp-handle-copy-file) | |
1416 (rename-file . tramp-handle-rename-file) | |
1417 (set-file-modes . tramp-handle-set-file-modes) | |
1418 (make-directory . tramp-handle-make-directory) | |
1419 (delete-directory . tramp-handle-delete-directory) | |
1420 (delete-file . tramp-handle-delete-file) | |
1421 (directory-file-name . tramp-handle-directory-file-name) | |
1422 (shell-command . tramp-handle-shell-command) | |
1423 (insert-directory . tramp-handle-insert-directory) | |
1424 (expand-file-name . tramp-handle-expand-file-name) | |
1425 (file-local-copy . tramp-handle-file-local-copy) | |
1426 (insert-file-contents . tramp-handle-insert-file-contents) | |
1427 (write-region . tramp-handle-write-region) | |
1428 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory) | |
1429 (dired-call-process . tramp-handle-dired-call-process) | |
1430 (dired-recursive-delete-directory | |
1431 . tramp-handle-dired-recursive-delete-directory) | |
1432 (set-visited-file-modtime . tramp-handle-set-visited-file-modtime) | |
1433 (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)) | |
1434 "Alist of handler functions. | |
1435 Operations not mentioned here will be handled by the normal Emacs functions.") | |
1436 | |
1437 ;;; Internal functions which must come first. | |
1438 | |
1439 (defsubst tramp-message (level fmt-string &rest args) | |
1440 "Emit a message depending on verbosity level. | |
1441 First arg LEVEL says to be quiet if `tramp-verbose' is less than LEVEL. The | |
1442 message is emitted only if `tramp-verbose' is greater than or equal to LEVEL. | |
1443 Calls function `message' with FMT-STRING as control string and the remaining | |
1444 ARGS to actually emit the message (if applicable). | |
1445 | |
1446 This function expects to be called from the tramp buffer only!" | |
1447 (when (<= level tramp-verbose) | |
1448 (apply #'message (concat "tramp: " fmt-string) args) | |
1449 (when tramp-debug-buffer | |
1450 (save-excursion | |
1451 (set-buffer | |
1452 (tramp-get-debug-buffer | |
1453 tramp-current-multi-method tramp-current-method | |
1454 tramp-current-user tramp-current-host)) | |
1455 (goto-char (point-max)) | |
1456 (tramp-insert-with-face | |
1457 'italic | |
1458 (concat "# " (apply #'format fmt-string args) "\n")))))) | |
1459 | |
1460 (defun tramp-message-for-buffer | |
1461 (multi-method method user host level fmt-string &rest args) | |
1462 "Like `tramp-message' but temporarily switches to the tramp buffer. | |
1463 First three args METHOD, USER, and HOST identify the tramp buffer to use, | |
1464 remaining args passed to `tramp-message'." | |
1465 (save-excursion | |
1466 (set-buffer (tramp-get-buffer multi-method method user host)) | |
1467 (apply 'tramp-message level fmt-string args))) | |
1468 | |
1469 (defsubst tramp-line-end-position nil | |
1470 "Return point at end of line. | |
1471 Calls `line-end-position' or `point-at-eol' if defined, else | |
1472 own implementation." | |
1473 (cond | |
1474 ((fboundp 'line-end-position) (funcall 'line-end-position)) | |
1475 ((fboundp 'point-at-eol) (funcall 'point-at-eol)) | |
1476 (t (save-excursion (end-of-line) (point))))) | |
1477 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1478 (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
|
1479 "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
|
1480 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1481 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
|
1482 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
|
1483 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
|
1484 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
|
1485 `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
|
1486 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
|
1487 `foo-user', `foo-host', `foo-path'. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1488 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1489 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
|
1490 `progn'). |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1491 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1492 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
|
1493 `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
|
1494 `(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
|
1495 (,(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
|
1496 (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
|
1497 (,(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
|
1498 (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
|
1499 (,(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
|
1500 (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
|
1501 (,(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
|
1502 (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
|
1503 (,(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
|
1504 (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
|
1505 ,@body)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1506 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1507 (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
|
1508 |
45861 | 1509 ;;; File Name Handler Functions: |
1510 | |
1511 (defun tramp-handle-make-symbolic-link | |
1512 (filename linkname &optional ok-if-already-exists) | |
1513 "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
|
1514 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
|
1515 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
|
1516 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
|
1517 |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1518 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
|
1519 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
|
1520 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
|
1521 target of the symlink differ." |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1522 (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
|
1523 (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
|
1524 (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
|
1525 filename linkname ok-if-already-exists)) |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1526 (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
|
1527 (cwd (file-name-directory l-path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1528 (unless ln |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1529 (signal 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1530 (list "Making a symbolic link." |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1531 "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
|
1532 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1533 ;; 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
|
1534 (when (file-exists-p linkname) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1535 ;; What to do? |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1536 (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
|
1537 (and (numberp ok-if-already-exists) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1538 (not (yes-or-no-p |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1539 (format |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1540 "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
|
1541 l-path))))) |
46307
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1542 (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
|
1543 (delete-file linkname))) |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1544 |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1545 ;; 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
|
1546 (when (tramp-tramp-file-p filename) |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1547 (setq filename (tramp-file-name-path |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1548 (tramp-dissect-file-name |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1549 (expand-file-name filename))))) |
45861 | 1550 |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1551 ;; 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
|
1552 ;; 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
|
1553 ;; that FILENAME belongs to. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1554 (zerop |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1555 (tramp-send-command-and-check |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1556 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
|
1557 (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
|
1558 cwd ln |
46307
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1559 filename |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1560 l-path) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1561 t))))) |
45861 | 1562 |
1563 | |
1564 (defun tramp-handle-load (file &optional noerror nomessage nosuffix must-suffix) | |
1565 "Like `load' for tramp files. Not implemented!" | |
1566 (unless (file-name-absolute-p file) | |
1567 (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
|
1568 (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
|
1569 (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
|
1570 (tramp-invoke-ange-ftp 'load |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1571 file noerror nomessage nosuffix must-suffix)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1572 (unless nosuffix |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1573 (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
|
1574 (setq file (concat file ".elc"))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1575 ((file-exists-p (concat file ".el")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1576 (setq file (concat file ".el"))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1577 (when must-suffix |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1578 ;; 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
|
1579 ;; Included for safety's sake. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1580 (unless (or (file-name-directory file) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1581 (string-match "\\.elc?\\'" file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1582 (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
|
1583 file))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1584 (unless noerror |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1585 (when (not (file-exists-p file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1586 (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
|
1587 (if (not (file-exists-p file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1588 nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1589 (unless nomessage |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1590 (message "Loading %s..." file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1591 (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
|
1592 ;; 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
|
1593 (load local-copy noerror t t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1594 (delete-file local-copy)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1595 (unless nomessage |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1596 (message "Loading %s...done" file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1597 t))) |
45861 | 1598 |
1599 ;; Path manipulation functions that grok TRAMP paths... | |
1600 (defun tramp-handle-file-name-directory (file) | |
1601 "Like `file-name-directory' but aware of TRAMP files." | |
1602 ;; 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
|
1603 (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
|
1604 (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
|
1605 (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
|
1606 ;; 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
|
1607 ;; (1) (string= path "") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1608 ;; (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
|
1609 ;; 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
|
1610 ;; 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
|
1611 ;; "/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
|
1612 ;; We should do some investigation. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1613 (if (string= path "") |
45861 | 1614 ;; For a filename like "/[foo]", we return "/". The `else' |
1615 ;; case would return "/[foo]" unchanged. But if we do that, | |
1616 ;; then `file-expand-wildcards' ceases to work. It's not | |
1617 ;; quite clear to me what's the intuition that tells that this | |
1618 ;; behavior is the right behavior, but oh, well. | |
1619 "/" | |
1620 ;; run the command on the path portion only | |
1621 ;; CCC: This should take into account the remote machine type, no? | |
1622 ;; --daniel <daniel@danann.net> | |
1623 (tramp-make-tramp-file-name multi-method method user host | |
1624 ;; This will not recurse... | |
1625 (or (file-name-directory path) ""))))) | |
1626 | |
1627 (defun tramp-handle-file-name-nondirectory (file) | |
1628 "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
|
1629 (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
|
1630 (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
|
1631 (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
|
1632 (file-name-nondirectory path))) |
45861 | 1633 |
1634 (defun tramp-handle-file-truename (filename &optional counter prev-dirs) | |
1635 "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
|
1636 (with-parsed-tramp-file-name filename nil |
46790 | 1637 ;; Ange-FTP does not support truename processing, but for |
1638 ;; convenience we pretend it did and forward the call to Ange-FTP | |
1639 ;; 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
|
1640 (when (tramp-ange-ftp-file-name-p multi-method method) |
46790 | 1641 (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
|
1642 (let* ((steps (tramp-split-string path "/")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1643 (pathdir (let ((directory-sep-char ?/)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1644 (file-name-as-directory path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1645 (is-dir (string= path pathdir)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1646 (thisstep nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1647 (numchase 0) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1648 ;; 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
|
1649 ;; 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
|
1650 ;; 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
|
1651 ;; 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
|
1652 (numchase-limit 20) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1653 (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
|
1654 (curstri "") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1655 symlink-target) |
45861 | 1656 (tramp-message-for-buffer |
1657 multi-method method user host | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1658 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
|
1659 (while (and steps (< numchase numchase-limit)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1660 (setq thisstep (pop steps)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1661 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1662 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1663 10 "Check %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1664 (mapconcat 'identity |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1665 (append '("") (reverse result) (list thisstep)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1666 "/")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1667 (setq symlink-target |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1668 (nth 0 (tramp-handle-file-attributes |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1669 (tramp-make-tramp-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1670 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1671 (mapconcat 'identity |
46790 | 1672 (append '("") |
1673 (reverse result) | |
1674 (list thisstep)) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1675 "/"))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1676 (cond ((string= "." thisstep) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1677 (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
|
1678 10 "Ignoring step `.'")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1679 ((string= ".." thisstep) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1680 (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
|
1681 10 "Processing step `..'") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1682 (pop result)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1683 ((stringp symlink-target) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1684 ;; It's a symlink, follow it. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1685 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1686 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1687 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
|
1688 (setq numchase (1+ numchase)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1689 (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
|
1690 (setq result nil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1691 (setq steps |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1692 (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
|
1693 (t |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1694 ;; It's a file. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1695 (setq result (cons thisstep result))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1696 (when (>= numchase numchase-limit) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1697 (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
|
1698 (setq result (reverse result)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1699 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1700 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1701 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
|
1702 filename (mapconcat 'identity (cons "" result) "/")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1703 (tramp-make-tramp-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1704 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1705 (concat (mapconcat 'identity (cons "" result) "/") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1706 (if is-dir "/" "")))))) |
45861 | 1707 |
1708 ;; Basic functions. | |
1709 | |
1710 (defun tramp-handle-file-exists-p (filename) | |
1711 "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
|
1712 (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
|
1713 (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
|
1714 (tramp-invoke-ange-ftp 'file-exists-p filename)) |
45861 | 1715 (save-excursion |
1716 (zerop (tramp-send-command-and-check | |
1717 multi-method method user host | |
1718 (format | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1719 (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
|
1720 (tramp-shell-quote-argument path))))))) |
45861 | 1721 |
1722 ;; CCC: This should check for an error condition and signal failure | |
1723 ;; when something goes wrong. | |
1724 ;; Daniel Pittman <daniel@danann.net> | |
1725 (defun tramp-handle-file-attributes (filename &optional nonnumeric) | |
1726 "Like `file-attributes' for tramp files. | |
1727 Optional argument NONNUMERIC means return user and group name | |
1728 rather than as numbers." | |
46752 | 1729 (let (result) |
1730 (with-parsed-tramp-file-name filename nil | |
1731 (when (tramp-ange-ftp-file-name-p multi-method method) | |
1732 (tramp-invoke-ange-ftp 'file-attributes filename)) | |
1733 (when (tramp-handle-file-exists-p filename) | |
1734 ;; file exists, find out stuff | |
1735 (save-excursion | |
45861 | 1736 (if (tramp-get-remote-perl multi-method method user host) |
46752 | 1737 (setq result |
1738 (tramp-handle-file-attributes-with-perl | |
1739 multi-method method user host path nonnumeric)) | |
1740 (setq result | |
1741 (tramp-handle-file-attributes-with-ls | |
1742 multi-method method user host path nonnumeric)))))) | |
1743 result)) | |
45861 | 1744 |
1745 | |
1746 (defun tramp-handle-file-attributes-with-ls | |
1747 (multi-method method user host path &optional nonnumeric) | |
1748 "Implement `file-attributes' for tramp files using the ls(1) command." | |
1749 (let (symlinkp dirp | |
1750 res-inode res-filemodes res-numlinks | |
1751 res-uid res-gid res-size res-symlink-target) | |
46752 | 1752 (tramp-message-for-buffer multi-method method user host 10 |
1753 "file attributes with ls: %s" | |
1754 (tramp-make-tramp-file-name | |
1755 multi-method method user host path)) | |
45861 | 1756 (tramp-send-command |
1757 multi-method method user host | |
1758 (format "%s %s %s" | |
1759 (tramp-get-ls-command multi-method method user host) | |
1760 (if nonnumeric "-ild" "-ildn") | |
1761 (tramp-shell-quote-argument path))) | |
1762 (tramp-wait-for-output) | |
1763 ;; parse `ls -l' output ... | |
1764 ;; ... inode | |
1765 (setq res-inode | |
1766 (condition-case err | |
1767 (read (current-buffer)) | |
1768 (invalid-read-syntax | |
1769 (when (and (equal (cadr err) | |
1770 "Integer constant overflow in reader") | |
1771 (string-match | |
1772 "^[0-9]+\\([0-9][0-9][0-9][0-9][0-9]\\)\\'" | |
1773 (caddr err))) | |
1774 (let* ((big (read (substring (caddr err) 0 | |
1775 (match-beginning 1)))) | |
1776 (small (read (match-string 1 (caddr err)))) | |
1777 (twiddle (/ small 65536))) | |
1778 (cons (+ big twiddle) | |
1779 (- small (* twiddle 65536)))))))) | |
1780 ;; ... file mode flags | |
1781 (setq res-filemodes (symbol-name (read (current-buffer)))) | |
1782 ;; ... number links | |
1783 (setq res-numlinks (read (current-buffer))) | |
1784 ;; ... uid and gid | |
1785 (setq res-uid (read (current-buffer))) | |
1786 (setq res-gid (read (current-buffer))) | |
1787 (unless nonnumeric | |
1788 (unless (numberp res-uid) (setq res-uid -1)) | |
1789 (unless (numberp res-gid) (setq res-gid -1))) | |
1790 ;; ... size | |
1791 (setq res-size (read (current-buffer))) | |
1792 ;; From the file modes, figure out other stuff. | |
1793 (setq symlinkp (eq ?l (aref res-filemodes 0))) | |
1794 (setq dirp (eq ?d (aref res-filemodes 0))) | |
1795 ;; if symlink, find out file name pointed to | |
1796 (when symlinkp | |
1797 (search-forward "-> ") | |
1798 (setq res-symlink-target | |
1799 (buffer-substring (point) | |
1800 (tramp-line-end-position)))) | |
1801 ;; return data gathered | |
1802 (list | |
1803 ;; 0. t for directory, string (name linked to) for symbolic | |
1804 ;; link, or nil. | |
1805 (or dirp res-symlink-target nil) | |
1806 ;; 1. Number of links to file. | |
1807 res-numlinks | |
1808 ;; 2. File uid. | |
1809 res-uid | |
1810 ;; 3. File gid. | |
1811 res-gid | |
1812 ;; 4. Last access time, as a list of two integers. First | |
1813 ;; integer has high-order 16 bits of time, second has low 16 | |
1814 ;; bits. | |
1815 ;; 5. Last modification time, likewise. | |
1816 ;; 6. Last status change time, likewise. | |
1817 '(0 0) '(0 0) '(0 0) ;CCC how to find out? | |
1818 ;; 7. Size in bytes (-1, if number is out of range). | |
1819 res-size | |
1820 ;; 8. File modes, as a string of ten letters or dashes as in ls -l. | |
1821 res-filemodes | |
1822 ;; 9. t iff file's gid would change if file were deleted and | |
1823 ;; recreated. | |
1824 nil ;hm? | |
1825 ;; 10. inode number. | |
1826 res-inode | |
1827 ;; 11. Device number. | |
1828 -1 ;hm? | |
1829 ))) | |
1830 | |
1831 (defun tramp-handle-file-attributes-with-perl | |
1832 (multi-method method user host path &optional nonnumeric) | |
1833 "Implement `file-attributes' for tramp files using a Perl script. | |
1834 | |
1835 The Perl command is sent to the remote machine when the connection | |
1836 is initially created and is kept cached by the remote shell." | |
46752 | 1837 (tramp-message-for-buffer multi-method method user host 10 |
1838 "file attributes with perl: %s" | |
1839 (tramp-make-tramp-file-name | |
1840 multi-method method user host path)) | |
45861 | 1841 (tramp-send-command |
1842 multi-method method user host | |
1843 (format "tramp_file_attributes %s" | |
1844 (tramp-shell-quote-argument path))) | |
1845 (tramp-wait-for-output) | |
1846 (let ((result (read (current-buffer)))) | |
1847 (setcar (nthcdr 8 result) | |
1848 (tramp-file-mode-from-int (nth 8 result))) | |
1849 result)) | |
1850 | |
1851 (defun tramp-handle-set-visited-file-modtime (&optional time-list) | |
1852 "Like `set-visited-file-modtime' for tramp files." | |
1853 (unless (buffer-file-name) | |
1854 (error "Can't set-visited-file-modtime: buffer `%s' not visiting a file" | |
1855 (buffer-name))) | |
1856 (when time-list | |
1857 (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
|
1858 (let ((f (buffer-file-name)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1859 (coding-system-used nil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1860 (with-parsed-tramp-file-name f nil |
46790 | 1861 ;; This operation is not handled by Ange-FTP! Compare this |
1862 ;; behavior with `file-truename' which Ange-FTP does not really | |
1863 ;; handle, either, but at least it pretends to. I wonder if | |
1864 ;; Ange-FTP should also pretend to grok | |
1865 ;; `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
|
1866 (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
|
1867 (throw 'tramp-forward-to-ange-ftp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1868 (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
|
1869 (list time-list)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1870 (let* ((attr (file-attributes f)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1871 (modtime (nth 5 attr))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1872 ;; 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
|
1873 ;; `tramp-handle-file-attributes-with-ls'. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1874 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1875 (setq coding-system-used last-coding-system-used)) |
45861 | 1876 (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
|
1877 (tramp-run-real-handler 'set-visited-file-modtime (list modtime)) |
45861 | 1878 (save-excursion |
1879 (tramp-send-command | |
1880 multi-method method user host | |
1881 (format "%s -ild %s" | |
1882 (tramp-get-ls-command multi-method method user host) | |
1883 (tramp-shell-quote-argument path))) | |
1884 (tramp-wait-for-output) | |
1885 (setq attr (buffer-substring (point) | |
1886 (progn (end-of-line) (point))))) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1887 (setq tramp-buffer-file-attributes attr)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1888 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1889 (setq last-coding-system-used coding-system-used)) |
45861 | 1890 nil)))) |
1891 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1892 ;; CCC continue here |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1893 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1894 ;; 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
|
1895 ;; `tramp-handle-set-visited-file-modtime'. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1896 (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
|
1897 "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
|
1898 (with-current-buffer buf |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1899 (let ((f (buffer-file-name))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1900 (with-parsed-tramp-file-name f nil |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1901 (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
|
1902 ;; 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
|
1903 ;; on the arg list. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1904 (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
|
1905 user host path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1906 (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
|
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 (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
|
1910 ;; 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
|
1911 ;; 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
|
1912 ;; (HIGH . LOW)? |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1913 (let ((mt (visited-file-modtime))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1914 (< (abs (tramp-time-diff |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1915 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
|
1916 (attr |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1917 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1918 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1919 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1920 (format "%s -ild %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1921 (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
|
1922 user host) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1923 (tramp-shell-quote-argument path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1924 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1925 (setq attr (buffer-substring |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1926 (point) (progn (end-of-line) (point))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1927 (equal tramp-buffer-file-attributes attr)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1928 ;; 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
|
1929 (t nil))))))) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1930 |
45861 | 1931 (defadvice clear-visited-file-modtime (after tramp activate) |
1932 "Set `tramp-buffer-file-attributes' back to nil. | |
1933 Tramp uses this variable as an emulation for the actual modtime of the file, | |
1934 if the remote host can't provide the modtime." | |
1935 (setq tramp-buffer-file-attributes nil)) | |
1936 | |
1937 (defun tramp-handle-set-file-modes (filename mode) | |
1938 "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
|
1939 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1940 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1941 (tramp-invoke-ange-ftp 'set-file-modes filename mode)) |
45861 | 1942 (save-excursion |
1943 (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
|
1944 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1945 (format "chmod %s %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1946 (tramp-decimal-to-octal mode) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1947 (tramp-shell-quote-argument path)))) |
45861 | 1948 (signal 'file-error |
1949 (list "Doing chmod" | |
1950 ;; FIXME: extract the proper text from chmod's stderr. | |
1951 "error while changing file's mode" | |
1952 filename)))))) | |
1953 | |
1954 ;; Simple functions using the `test' command. | |
1955 | |
1956 (defun tramp-handle-file-executable-p (filename) | |
1957 "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
|
1958 (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
|
1959 (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
|
1960 (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
|
1961 (zerop (tramp-run-test "-x" filename)))) |
45861 | 1962 |
1963 (defun tramp-handle-file-readable-p (filename) | |
1964 "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
|
1965 (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
|
1966 (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
|
1967 (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
|
1968 (zerop (tramp-run-test "-r" filename)))) |
45861 | 1969 |
1970 (defun tramp-handle-file-accessible-directory-p (filename) | |
1971 "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
|
1972 (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
|
1973 (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
|
1974 (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
|
1975 (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
|
1976 (zerop (tramp-run-test "-r" filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1977 (zerop (tramp-run-test "-x" filename))))) |
45861 | 1978 |
1979 ;; When the remote shell is started, it looks for a shell which groks | |
1980 ;; tilde expansion. Here, we assume that all shells which grok tilde | |
1981 ;; expansion will also provide a `test' command which groks `-nt' (for | |
1982 ;; newer than). If this breaks, tell me about it and I'll try to do | |
1983 ;; something smarter about it. | |
1984 (defun tramp-handle-file-newer-than-file-p (file1 file2) | |
1985 "Like `file-newer-than-file-p' for tramp files." | |
1986 (cond ((not (file-exists-p file1)) | |
1987 nil) | |
1988 ((not (file-exists-p file2)) | |
1989 t) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1990 ;; 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
|
1991 ;; 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
|
1992 ;; message. Todo: make a better error message. |
45861 | 1993 (t |
1994 (save-excursion | |
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 file1 v1 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1996 (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
|
1997 (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
|
1998 (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
|
1999 (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
|
2000 file1 file2)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2001 (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
|
2002 (equal v1-method v2-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2003 (equal v1-user v2-user) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2004 (equal v1-host v2-host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2005 (signal 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2006 (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
|
2007 file1 file2))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2008 (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
|
2009 (tramp-tramp-file-p file2)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2010 (signal 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2011 (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
|
2012 file1 file2))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2013 (if (tramp-get-test-groks-nt |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2014 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
|
2015 (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
|
2016 (zerop (tramp-run-test2 "tramp_test_nt" file1 file2))))))))) |
45861 | 2017 |
2018 ;; Functions implemented using the basic functions above. | |
2019 | |
2020 (defun tramp-handle-file-modes (filename) | |
2021 "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
|
2022 (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
|
2023 (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
|
2024 (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
|
2025 (when (file-exists-p filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2026 (tramp-mode-string-to-int |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2027 (nth 8 (tramp-handle-file-attributes filename)))))) |
45861 | 2028 |
2029 (defun tramp-handle-file-directory-p (filename) | |
2030 "Like `file-directory-p' for tramp files." | |
2031 ;; Care must be taken that this function returns `t' for symlinks | |
2032 ;; pointing to directories. Surely the most obvious implementation | |
2033 ;; would be `test -d', but that returns false for such symlinks. | |
2034 ;; CCC: Stefan Monnier says that `test -d' follows symlinks. And | |
2035 ;; I now think he's right. So we could be using `test -d', couldn't | |
2036 ;; we? | |
2037 ;; | |
2038 ;; 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
|
2039 (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
|
2040 (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
|
2041 (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
|
2042 (save-excursion |
45861 | 2043 (zerop |
2044 (tramp-send-command-and-check | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2045 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2046 (format "test -d %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2047 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2048 t))))) ;run command in subshell |
45861 | 2049 |
2050 (defun tramp-handle-file-regular-p (filename) | |
2051 "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
|
2052 (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
|
2053 (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
|
2054 (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
|
2055 (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
|
2056 (eq ?- (aref (nth 8 (tramp-handle-file-attributes filename)) 0))))) |
45861 | 2057 |
2058 (defun tramp-handle-file-symlink-p (filename) | |
2059 "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
|
2060 (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
|
2061 (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
|
2062 (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
|
2063 (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
|
2064 (when (stringp x) x)))) |
45861 | 2065 |
2066 (defun tramp-handle-file-writable-p (filename) | |
2067 "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
|
2068 (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
|
2069 (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
|
2070 (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
|
2071 (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
|
2072 ;; Existing files must be writable. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2073 (zerop (tramp-run-test "-w" filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2074 ;; 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
|
2075 (and (zerop (tramp-run-test |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2076 "-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
|
2077 (zerop (tramp-run-test |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2078 "-w" (tramp-handle-file-name-directory filename))))))) |
45861 | 2079 |
2080 (defun tramp-handle-file-ownership-preserved-p (filename) | |
2081 "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
|
2082 (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
|
2083 (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
|
2084 (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
|
2085 (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
|
2086 ;; Existing files must be writable. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2087 (zerop (tramp-run-test "-O" filename))))) |
45861 | 2088 |
2089 ;; Other file name ops. | |
2090 | |
2091 ;; ;; Matthias Köppe <mkoeppe@mail.math.uni-magdeburg.de> | |
2092 ;; (defun tramp-handle-directory-file-name (directory) | |
2093 ;; "Like `directory-file-name' for tramp files." | |
2094 ;; (if (and (eq (aref directory (- (length directory) 1)) ?/) | |
2095 ;; (not (eq (aref directory (- (length directory) 2)) ?:))) | |
2096 ;; (substring directory 0 (- (length directory) 1)) | |
2097 ;; directory)) | |
2098 | |
2099 ;; Philippe Troin <phil@fifi.org> | |
2100 (defun tramp-handle-directory-file-name (directory) | |
2101 "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
|
2102 (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
|
2103 (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
|
2104 (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
|
2105 (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
|
2106 (save-match-data |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2107 (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
|
2108 (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
|
2109 (/= (match-end 0) directory-length-1)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2110 (substring directory 0 directory-length-1) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2111 directory))))) |
45861 | 2112 |
2113 ;; Directory listings. | |
2114 | |
46752 | 2115 (defun tramp-handle-directory-files (directory |
2116 &optional full match nosort files-only) | |
45861 | 2117 "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
|
2118 (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
|
2119 (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
|
2120 (tramp-invoke-ange-ftp 'directory-files |
46752 | 2121 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
|
2122 (let (result x) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2123 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2124 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2125 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2126 (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
|
2127 nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2128 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2129 "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
|
2130 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2131 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2132 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2133 (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
|
2134 " -a | cat")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2135 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2136 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2137 (while (zerop (forward-line -1)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2138 (setq x (buffer-substring (point) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2139 (tramp-line-end-position))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2140 (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
|
2141 (if full |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2142 (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
|
2143 x) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2144 result) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2145 (push x result)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2146 (tramp-send-command multi-method method user host "cd") |
46752 | 2147 (tramp-wait-for-output) |
2148 ;; Remove non-files or non-directories if necessary. Using | |
2149 ;; the remote shell for this would probably be way faster. | |
2150 ;; Maybe something could be adapted from | |
2151 ;; tramp-handle-file-name-all-completions. | |
2152 (when files-only | |
2153 (let ((temp (nreverse result)) | |
2154 item) | |
2155 (setq result nil) | |
2156 (if (equal files-only t) | |
2157 ;; files only | |
2158 (while temp | |
2159 (setq item (pop temp)) | |
2160 (when (file-regular-p item) | |
2161 (push item result))) | |
2162 ;; directories only | |
2163 (while temp | |
2164 (setq item (pop temp)) | |
2165 (when (file-directory-p item) | |
2166 (push item result))))))) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2167 result))) |
45861 | 2168 |
2169 ;; This function should return "foo/" for directories and "bar" for | |
2170 ;; files. We use `ls -ad' to get a list of files (including | |
2171 ;; directories), and `find . -type d \! -name . -prune' to get a list | |
2172 ;; of directories. | |
2173 (defun tramp-handle-file-name-all-completions (filename directory) | |
2174 "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
|
2175 (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
|
2176 (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
|
2177 (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
|
2178 filename directory)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2179 (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
|
2180 (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
|
2181 result) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2182 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2183 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2184 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2185 (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
|
2186 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2187 "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
|
2188 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2189 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2190 ;; 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
|
2191 ;; 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
|
2192 ;; rock. --daniel@danann.net |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2193 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2194 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2195 (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
|
2196 "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
|
2197 "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
|
2198 (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
|
2199 (if (or nowild (zerop (length filename))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2200 "" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2201 (format "-d %s*" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2202 (tramp-shell-quote-argument filename))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2203 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2204 ;; Now grab the output. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2205 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2206 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2207 (while (zerop (forward-line -1)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2208 (push (buffer-substring (point) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2209 (tramp-line-end-position)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2210 result)) |
45861 | 2211 |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2212 (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
|
2213 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2214 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2215 ;; Return the list. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2216 (if nowild |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2217 (all-completions filename (mapcar 'list result)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2218 result)))))) |
45861 | 2219 |
2220 | |
2221 ;; The following isn't needed for Emacs 20 but for 19.34? | |
2222 (defun tramp-handle-file-name-completion (filename directory) | |
2223 "Like `file-name-completion' for tramp files." | |
2224 (unless (tramp-tramp-file-p directory) | |
2225 (error | |
2226 "tramp-handle-file-name-completion invoked on non-tramp directory `%s'" | |
2227 directory)) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2228 (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
|
2229 (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
|
2230 (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
|
2231 filename directory)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2232 (try-completion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2233 filename |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2234 (mapcar (lambda (x) (cons x nil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2235 (tramp-handle-file-name-all-completions filename directory))))) |
45861 | 2236 |
2237 ;; cp, mv and ln | |
2238 | |
2239 (defun tramp-handle-add-name-to-file | |
2240 (filename newname &optional ok-if-already-exists) | |
2241 "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
|
2242 (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
|
2243 (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
|
2244 (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
|
2245 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
|
2246 (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
|
2247 (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
|
2248 (equal v1-method v2-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2249 (equal v1-user v2-user) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2250 (equal v1-host v2-host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2251 (error "add-name-to-file: %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2252 "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
|
2253 (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
|
2254 (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
|
2255 (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
|
2256 filename newname ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2257 (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
|
2258 (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
|
2259 filename newname ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2260 (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
|
2261 (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
|
2262 filename newname ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2263 (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
|
2264 (file-exists-p newname) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2265 (not (numberp ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2266 (y-or-n-p |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2267 (format |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2268 "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
|
2269 newname))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2270 (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
|
2271 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2272 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
|
2273 (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
|
2274 (tramp-shell-quote-argument v2-path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2275 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2276 "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
|
2277 (buffer-name)))))) |
45861 | 2278 |
2279 (defun tramp-handle-copy-file | |
2280 (filename newname &optional ok-if-already-exists keep-date) | |
2281 "Like `copy-file' for tramp files." | |
2282 ;; Check if both files are local -- invoke normal copy-file. | |
2283 ;; Otherwise, use tramp from local system. | |
2284 (setq filename (expand-file-name filename)) | |
2285 (setq newname (expand-file-name newname)) | |
2286 ;; At least one file a tramp file? | |
2287 (if (or (tramp-tramp-file-p filename) | |
2288 (tramp-tramp-file-p newname)) | |
2289 (tramp-do-copy-or-rename-file | |
2290 'copy filename newname ok-if-already-exists keep-date) | |
2291 (tramp-run-real-handler | |
2292 'copy-file | |
2293 (list filename newname ok-if-already-exists keep-date)))) | |
2294 | |
2295 (defun tramp-handle-rename-file | |
2296 (filename newname &optional ok-if-already-exists) | |
2297 "Like `rename-file' for tramp files." | |
2298 ;; Check if both files are local -- invoke normal rename-file. | |
2299 ;; Otherwise, use tramp from local system. | |
2300 (setq filename (expand-file-name filename)) | |
2301 (setq newname (expand-file-name newname)) | |
2302 ;; At least one file a tramp file? | |
2303 (if (or (tramp-tramp-file-p filename) | |
2304 (tramp-tramp-file-p newname)) | |
2305 (tramp-do-copy-or-rename-file | |
2306 'rename filename newname ok-if-already-exists) | |
2307 (tramp-run-real-handler 'rename-file | |
2308 (list filename newname ok-if-already-exists)))) | |
2309 | |
2310 (defun tramp-do-copy-or-rename-file | |
2311 (op filename newname &optional ok-if-already-exists keep-date) | |
2312 "Copy or rename a remote file. | |
2313 OP must be `copy' or `rename' and indicates the operation to perform. | |
2314 FILENAME specifies the file to copy or rename, NEWNAME is the name of | |
2315 the new file (for copy) or the new name of the file (for rename). | |
2316 OK-IF-ALREADY-EXISTS means don't barf if NEWNAME exists already. | |
2317 KEEP-DATE means to make sure that NEWNAME has the same timestamp | |
2318 as FILENAME. | |
2319 | |
2320 This function is invoked by `tramp-handle-copy-file' and | |
2321 `tramp-handle-rename-file'. It is an error if OP is neither of `copy' | |
2322 and `rename'. FILENAME and NEWNAME must be absolute file names." | |
2323 (unless (memq op '(copy rename)) | |
2324 (error "Unknown operation `%s', must be `copy' or `rename'" op)) | |
2325 (unless ok-if-already-exists | |
2326 (when (file-exists-p newname) | |
2327 (signal 'file-already-exists | |
2328 (list newname)))) | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2329 (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
|
2330 (t2 (tramp-tramp-file-p newname))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2331 ;; 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
|
2332 (cond |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2333 ((and t1 t2) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2334 ;; Both are Tramp files. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2335 (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
|
2336 (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
|
2337 ;; Possibly invoke Ange-FTP. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2338 (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
|
2339 (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
|
2340 (tramp-invoke-ange-ftp |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2341 (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
|
2342 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
|
2343 ;; 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
|
2344 (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
|
2345 (equal v1-method v2-method) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2346 (equal v1-host v2-host) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2347 (equal v1-user v2-user)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2348 ;; 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
|
2349 ;; 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
|
2350 ;; directly. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2351 (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
|
2352 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
|
2353 v1-path v2-path keep-date) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2354 ;; 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
|
2355 ;; 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
|
2356 ;; 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
|
2357 ;; 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
|
2358 ;; 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
|
2359 ;; 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
|
2360 ;; 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
|
2361 ;; 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
|
2362 ;; source and target file. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2363 |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2364 ;; 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
|
2365 ;; 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
|
2366 ;; can invoke rcp directly. Note that |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2367 ;; 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
|
2368 ;; 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
|
2369 (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
|
2370 op filename newname keep-date))))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2371 ((or t1 t2) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2372 ;; 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
|
2373 (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
|
2374 (t |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2375 ;; 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
|
2376 (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
|
2377 |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2378 (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
|
2379 "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
|
2380 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
|
2381 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
|
2382 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
|
2383 (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
|
2384 (when keep-date |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2385 (tramp-message |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2386 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
|
2387 " with inline copying across machines"))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2388 (save-excursion |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2389 (set-buffer trampbuf) (erase-buffer) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2390 (insert-file-contents-literally filename) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2391 (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
|
2392 (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
|
2393 ;; 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
|
2394 (unless (eq op 'copy) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2395 (delete-file filename)))) |
45861 | 2396 |
2397 (defun tramp-do-copy-or-rename-file-directly | |
2398 (op multi-method method user host path1 path2 keep-date) | |
2399 "Invokes `cp' or `mv' on the remote system. | |
2400 OP must be one of `copy' or `rename', indicating `cp' or `mv', | |
2401 respectively. METHOD, USER, and HOST specify the connection. | |
2402 PATH1 and PATH2 specify the two arguments of `cp' or `mv'. | |
2403 If KEEP-DATE is non-nil, preserve the time stamp when copying." | |
2404 ;; CCC: What happens to the timestamp when renaming? | |
2405 (let ((cmd (cond ((and (eq op 'copy) keep-date) "cp -f -p") | |
2406 ((eq op 'copy) "cp -f") | |
2407 ((eq op 'rename) "mv -f") | |
2408 (t (error | |
2409 "Unknown operation `%s', must be `copy' or `rename'" | |
2410 op))))) | |
2411 (save-excursion | |
2412 (tramp-barf-unless-okay | |
2413 multi-method method user host | |
2414 (format "%s %s %s" | |
2415 cmd | |
2416 (tramp-shell-quote-argument path1) | |
2417 (tramp-shell-quote-argument path2)) | |
2418 nil 'file-error | |
2419 "Copying directly failed, see buffer `%s' for details." | |
2420 (buffer-name))))) | |
2421 | |
2422 ;; mkdir | |
2423 (defun tramp-handle-make-directory (dir &optional parents) | |
2424 "Like `make-directory' for tramp files." | |
46752 | 2425 (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
|
2426 (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
|
2427 (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
|
2428 (tramp-invoke-ange-ftp 'make-directory dir parents)) |
46790 | 2429 (save-excursion |
2430 (tramp-barf-unless-okay | |
2431 multi-method method user host | |
2432 (format " %s %s" | |
2433 (if parents "mkdir -p" "mkdir") | |
2434 (tramp-shell-quote-argument path)) | |
2435 nil 'file-error | |
2436 "Couldn't make directory %s" dir)))) | |
45861 | 2437 |
2438 ;; CCC error checking? | |
2439 (defun tramp-handle-delete-directory (directory) | |
2440 "Like `delete-directory' for tramp files." | |
46752 | 2441 (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
|
2442 (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
|
2443 (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
|
2444 (tramp-invoke-ange-ftp 'delete-directory directory)) |
45861 | 2445 (save-excursion |
2446 (tramp-send-command | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2447 multi-method method user host |
45861 | 2448 (format "rmdir %s ; echo ok" |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2449 (tramp-shell-quote-argument path))) |
45861 | 2450 (tramp-wait-for-output)))) |
2451 | |
2452 (defun tramp-handle-delete-file (filename) | |
2453 "Like `delete-file' for tramp files." | |
46752 | 2454 (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
|
2455 (with-parsed-tramp-file-name filename nil |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2456 (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
|
2457 (tramp-invoke-ange-ftp 'delete-file filename)) |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2458 (save-excursion |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2459 (unless (zerop (tramp-send-command-and-check |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2460 multi-method method user host |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2461 (format "rm -f %s" |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2462 (tramp-shell-quote-argument path)))) |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2463 (signal 'file-error "Couldn't delete Tramp file"))))) |
45861 | 2464 |
2465 ;; Dired. | |
2466 | |
2467 ;; CCC: This does not seem to be enough. Something dies when | |
2468 ;; we try and delete two directories under TRAMP :/ | |
2469 (defun tramp-handle-dired-recursive-delete-directory (filename) | |
2470 "Recursively delete the directory given. | |
2471 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
|
2472 (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
|
2473 (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
|
2474 (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
|
2475 filename)) |
45861 | 2476 ;; run a shell command 'rm -r <path>' |
2477 ;; Code shamelessly stolen for the dired implementation and, um, hacked :) | |
2478 (or (tramp-handle-file-exists-p filename) | |
2479 (signal | |
2480 'file-error | |
2481 (list "Removing old file name" "no such directory" filename))) | |
2482 ;; Which is better, -r or -R? (-r works for me <daniel@danann.net>) | |
2483 (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
|
2484 (format "rm -r %s" (tramp-shell-quote-argument path))) |
45861 | 2485 ;; Wait for the remote system to return to us... |
2486 ;; This might take a while, allow it plenty of time. | |
2487 (tramp-wait-for-output 120) | |
2488 ;; Make sure that it worked... | |
2489 (and (tramp-handle-file-exists-p filename) | |
2490 (error "Failed to recusively delete %s" filename)))) | |
2491 | |
2492 | |
2493 (defun tramp-handle-dired-call-process (program discard &rest arguments) | |
2494 "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
|
2495 (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
|
2496 (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
|
2497 (let ((default-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2498 (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
|
2499 (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
|
2500 program discard arguments))) |
45861 | 2501 (save-excursion |
2502 (tramp-barf-unless-okay | |
2503 multi-method method user host | |
2504 (format "cd %s" (tramp-shell-quote-argument path)) | |
2505 nil 'file-error | |
2506 "tramp-handle-dired-call-process: Couldn't `cd %s'" | |
2507 (tramp-shell-quote-argument path)) | |
2508 (tramp-send-command | |
2509 multi-method method user host | |
2510 (mapconcat #'tramp-shell-quote-argument (cons program arguments) " ")) | |
2511 (tramp-wait-for-output)) | |
2512 (unless discard | |
2513 (insert-buffer (tramp-get-buffer multi-method method user host))) | |
2514 (save-excursion | |
2515 (prog1 | |
2516 (tramp-send-command-and-check multi-method method user host nil) | |
2517 (tramp-send-command multi-method method user host "cd") | |
2518 (tramp-wait-for-output))))) | |
2519 | |
2520 ;; Pacify byte-compiler. The function is needed on XEmacs only. I'm | |
2521 ;; not sure at all that this is the right way to do it, but let's hope | |
2522 ;; it works for now, and wait for a guru to point out the Right Way to | |
2523 ;; achieve this. | |
2524 ;;(eval-when-compile | |
2525 ;; (unless (fboundp 'dired-insert-set-properties) | |
2526 ;; (fset 'dired-insert-set-properties 'ignore))) | |
2527 ;; Gerd suggests this: | |
2528 (eval-when-compile (require 'dired)) | |
2529 ;; Note that dired is required at run-time, too, when it is needed. | |
2530 ;; It is only needed on XEmacs for the function | |
2531 ;; `dired-insert-set-properties'. | |
2532 | |
2533 (defun tramp-handle-insert-directory | |
2534 (filename switches &optional wildcard full-directory-p) | |
2535 "Like `insert-directory' for tramp files." | |
46752 | 2536 (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
|
2537 (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
|
2538 (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
|
2539 (tramp-invoke-ange-ftp 'insert-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2540 filename switches wildcard full-directory-p)) |
45861 | 2541 (tramp-message-for-buffer |
2542 multi-method method user host 10 | |
2543 "Inserting directory `ls %s %s', wildcard %s, fulldir %s" | |
2544 switches filename (if wildcard "yes" "no") | |
2545 (if full-directory-p "yes" "no")) | |
2546 (when wildcard | |
2547 (setq wildcard (file-name-nondirectory path)) | |
2548 (setq path (file-name-directory path))) | |
2549 (when (listp switches) | |
2550 (setq switches (mapconcat 'identity switches " "))) | |
2551 (unless full-directory-p | |
2552 (setq switches (concat "-d " switches))) | |
2553 (when wildcard | |
2554 (setq switches (concat switches " " wildcard))) | |
2555 (save-excursion | |
2556 ;; If `full-directory-p', we just say `ls -l FILENAME'. | |
2557 ;; Else we chdir to the parent directory, then say `ls -ld BASENAME'. | |
2558 (if full-directory-p | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2559 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2560 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2561 (format "%s %s %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2562 (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
|
2563 switches |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2564 (if wildcard |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2565 path |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2566 (tramp-shell-quote-argument (concat path "."))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2567 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2568 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2569 (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
|
2570 (file-name-directory path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2571 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2572 "Couldn't `cd %s'" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2573 (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
|
2574 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2575 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2576 (format "%s %s %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2577 (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
|
2578 switches |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2579 (if full-directory-p |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2580 ;; 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
|
2581 ;; listing for symlinks, too. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2582 (concat (file-name-as-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2583 (file-name-nondirectory path)) ".") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2584 (file-name-nondirectory path))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2585 (sit-for 1) ;needed for rsh but not ssh? |
45861 | 2586 (tramp-wait-for-output)) |
2587 (insert-buffer (tramp-get-buffer multi-method method user host)) | |
2588 ;; On XEmacs, we want to call (exchange-point-and-mark t), but | |
2589 ;; that doesn't exist on Emacs, so we use this workaround instead. | |
2590 ;; Since zmacs-region-stays doesn't exist in Emacs, this ought to | |
2591 ;; be safe. Thanks to Daniel Pittman <daniel@danann.net>. | |
2592 (let ((zmacs-region-stays t)) | |
2593 (exchange-point-and-mark)) | |
2594 (save-excursion | |
2595 (tramp-send-command multi-method method user host "cd") | |
2596 (tramp-wait-for-output)) | |
2597 ;; Another XEmacs specialty follows. What's the right way to do | |
2598 ;; it? | |
2599 (when (and (featurep 'xemacs) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2600 (eq major-mode 'dired-mode)) |
45861 | 2601 (save-excursion |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2602 (require 'dired) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2603 (dired-insert-set-properties (point) (mark t)))))) |
45861 | 2604 |
2605 ;; Continuation of kluge to pacify byte-compiler. | |
2606 ;;(eval-when-compile | |
2607 ;; (when (eq (symbol-function 'dired-insert-set-properties) 'ignore) | |
2608 ;; (fmakunbound 'dired-insert-set-properties))) | |
2609 | |
2610 ;; CCC is this the right thing to do? | |
2611 (defun tramp-handle-unhandled-file-name-directory (filename) | |
2612 "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
|
2613 (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
|
2614 (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
|
2615 (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
|
2616 filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2617 (expand-file-name "~/"))) |
45861 | 2618 |
2619 ;; Canonicalization of file names. | |
2620 | |
2621 (defun tramp-drop-volume-letter (name) | |
2622 "Cut off unnecessary drive letter from file NAME. | |
2623 The function `tramp-handle-expand-file-name' calls `expand-file-name' | |
2624 locally on a remote file name. When the local system is a W32 system | |
2625 but the remote system is Unix, this introduces a superfluous drive | |
2626 letter into the file name. This function removes it. | |
2627 | |
2628 Doesn't do anything if the NAME does not start with a drive letter." | |
2629 (if (and (> (length name) 1) | |
2630 (char-equal (aref name 1) ?:) | |
2631 (let ((c1 (aref name 0))) | |
2632 (or (and (>= c1 ?A) (<= c1 ?Z)) | |
2633 (and (>= c1 ?a) (<= c1 ?z))))) | |
2634 (substring name 2) | |
2635 name)) | |
2636 | |
2637 (defun tramp-handle-expand-file-name (name &optional dir) | |
2638 "Like `expand-file-name' for tramp files." | |
2639 ;; If DIR is not given, use DEFAULT-DIRECTORY or "/". | |
2640 (setq dir (or dir default-directory "/")) | |
2641 ;; Unless NAME is absolute, concat DIR and NAME. | |
2642 (unless (file-name-absolute-p name) | |
2643 (setq name (concat (file-name-as-directory dir) name))) | |
2644 ;; If NAME is not a tramp file, run the real handler | |
2645 (if (not (tramp-tramp-file-p name)) | |
2646 (tramp-run-real-handler 'expand-file-name | |
2647 (list name nil)) | |
2648 ;; Dissect NAME. | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2649 (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
|
2650 (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
|
2651 (tramp-invoke-ange-ftp 'expand-file-name name nil)) |
45861 | 2652 (unless (file-name-absolute-p path) |
2653 (setq path (concat "~/" path))) | |
2654 (save-excursion | |
2655 ;; Tilde expansion if necessary. This needs a shell which | |
2656 ;; groks tilde expansion! The function `tramp-find-shell' is | |
2657 ;; supposed to find such a shell on the remote host. Please | |
2658 ;; tell me about it when this doesn't work on your system. | |
2659 (when (string-match "\\`\\(~[^/]*\\)\\(.*\\)\\'" path) | |
2660 (let ((uname (match-string 1 path)) | |
2661 (fname (match-string 2 path))) | |
2662 ;; CCC fanatic error checking? | |
2663 (set-buffer (tramp-get-buffer multi-method method user host)) | |
2664 (erase-buffer) | |
2665 (tramp-send-command | |
2666 multi-method method user host | |
2667 (format "cd %s; pwd" uname) | |
2668 t) | |
2669 (tramp-wait-for-output) | |
2670 (goto-char (point-min)) | |
2671 (setq uname (buffer-substring (point) (tramp-line-end-position))) | |
2672 (setq path (concat uname fname)) | |
2673 (erase-buffer))) | |
2674 ;; No tilde characters in file name, do normal | |
2675 ;; expand-file-name (this does "/./" and "/../"). We bind | |
2676 ;; directory-sep-char here for XEmacs on Windows, which would | |
2677 ;; otherwise use backslash. | |
2678 (let ((directory-sep-char ?/)) | |
2679 (tramp-make-tramp-file-name | |
2680 multi-method method user host | |
2681 (tramp-drop-volume-letter | |
2682 (tramp-run-real-handler 'expand-file-name (list path))))))))) | |
2683 | |
2684 ;; Remote commands. | |
2685 | |
2686 (defun tramp-handle-shell-command (command &optional output-buffer error-buffer) | |
2687 "Like `shell-command' for tramp files. | |
2688 This will break if COMMAND prints a newline, followed by the value of | |
2689 `tramp-end-of-output', followed by another newline." | |
46752 | 2690 (when (tramp-tramp-file-p default-directory) |
2691 (with-parsed-tramp-file-name default-directory nil | |
2692 (when (tramp-ange-ftp-file-name-p multi-method method) | |
2693 (let ((default-directory (tramp-make-ange-ftp-file-name | |
2694 user host path))) | |
2695 (tramp-invoke-ange-ftp 'shell-command | |
2696 command output-buffer error-buffer))) | |
2697 (let (status) | |
2698 (when (string-match "&[ \t]*\\'" command) | |
2699 (error "Tramp doesn't grok asynchronous shell commands, yet")) | |
2700 (when error-buffer | |
2701 (error "Tramp doesn't grok optional third arg ERROR-BUFFER, yet")) | |
2702 (save-excursion | |
2703 (tramp-barf-unless-okay | |
2704 multi-method method user host | |
2705 (format "cd %s" (tramp-shell-quote-argument path)) | |
2706 nil 'file-error | |
2707 "tramp-handle-shell-command: Couldn't `cd %s'" | |
2708 (tramp-shell-quote-argument path)) | |
2709 (tramp-send-command multi-method method user host | |
2710 (concat command "; tramp_old_status=$?")) | |
2711 ;; This will break if the shell command prints "/////" | |
2712 ;; somewhere. Let's just hope for the best... | |
2713 (tramp-wait-for-output)) | |
2714 (unless output-buffer | |
2715 (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
|
2716 (set-buffer output-buffer) |
46752 | 2717 (erase-buffer)) |
2718 (unless (bufferp output-buffer) | |
2719 (setq output-buffer (current-buffer))) | |
2720 (set-buffer output-buffer) | |
2721 (insert-buffer (tramp-get-buffer multi-method method user host)) | |
2722 (save-excursion | |
2723 (tramp-send-command multi-method method user host "cd") | |
2724 (tramp-wait-for-output) | |
2725 (tramp-send-command | |
2726 multi-method method user host | |
2727 (concat "tramp_set_exit_status $tramp_old_status;" | |
2728 " echo tramp_exit_status $?")) | |
2729 (tramp-wait-for-output) | |
2730 (goto-char (point-max)) | |
2731 (unless (search-backward "tramp_exit_status " nil t) | |
2732 (error "Couldn't find exit status of `%s'" command)) | |
2733 (skip-chars-forward "^ ") | |
2734 (setq status (read (current-buffer)))) | |
2735 (unless (zerop (buffer-size)) | |
2736 (pop-to-buffer output-buffer)) | |
2737 status))) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2738 ;; 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
|
2739 ;; 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
|
2740 (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
|
2741 default-directory) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2742 (tramp-run-real-handler 'shell-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2743 (list command output-buffer error-buffer))) |
45861 | 2744 |
2745 ;; File Editing. | |
2746 | |
2747 (defsubst tramp-make-temp-file () | |
2748 (funcall (if (fboundp 'make-temp-file) 'make-temp-file 'make-temp-name) | |
2749 (expand-file-name tramp-temp-name-prefix | |
2750 (tramp-temporary-file-directory)))) | |
2751 | |
2752 (defun tramp-handle-file-local-copy (filename) | |
2753 "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
|
2754 (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
|
2755 (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
|
2756 (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
|
2757 (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
|
2758 tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2759 (unless (file-exists-p filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2760 (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
|
2761 filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2762 (setq tmpfil (tramp-make-temp-file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2763 (cond ((tramp-get-rcp-program multi-method method) |
46752 | 2764 ;; 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
|
2765 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2766 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2767 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
|
2768 (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
|
2769 (unless (equal |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2770 0 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2771 (apply #'call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2772 (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
|
2773 nil trampbuf nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2774 (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
|
2775 (list |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2776 (tramp-make-rcp-program-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2777 user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2778 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2779 tmpfil)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2780 (pop-to-buffer trampbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2781 (error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2782 (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
|
2783 "see buffer `%s' for details") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2784 (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
|
2785 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2786 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2787 5 "Fetching %s to tmp file %s...done" filename tmpfil)) |
46752 | 2788 ((and (tramp-get-encoding-command multi-method method user host) |
2789 (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
|
2790 ;; Use inline encoding for file transfer. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2791 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2792 ;; 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
|
2793 ;; tramp-current-user, tramp-current-host. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2794 (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
|
2795 (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
|
2796 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2797 multi-method method user host |
46752 | 2798 (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
|
2799 " < " (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2800 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2801 "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
|
2802 (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
|
2803 ;; Remove trailing status code |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2804 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2805 (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
|
2806 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2807 (tramp-message 5 "Decoding remote file %s..." filename) |
46752 | 2808 (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
|
2809 (fboundp (tramp-get-decoding-function |
46752 | 2810 multi-method method user host))) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2811 ;; 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
|
2812 ;; method, we call it. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2813 (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
|
2814 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2815 (erase-buffer) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2816 (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
|
2817 user host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2818 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2819 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2820 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
|
2821 filename |
46752 | 2822 (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
|
2823 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2824 (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
|
2825 (funcall (tramp-get-decoding-function |
46752 | 2826 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 (point-min) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2828 (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2829 (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
|
2830 (kill-buffer tmpbuf)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2831 ;; 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
|
2832 ;; 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
|
2833 (let ((tmpfil2 (tramp-make-temp-file))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2834 (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
|
2835 (tramp-message |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2836 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
|
2837 filename |
46752 | 2838 (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
|
2839 (call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2840 tramp-sh-program |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2841 tmpfil2 ;input |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2842 nil ;output |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2843 nil ;display |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2844 "-c" (concat (tramp-get-decoding-command |
46752 | 2845 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 " > " tmpfil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2847 (delete-file tmpfil2))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2848 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2849 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2850 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
|
2851 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2852 (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
|
2853 tmpfil))) |
45861 | 2854 |
2855 | |
2856 (defun tramp-handle-insert-file-contents | |
2857 (filename &optional visit beg end replace) | |
2858 "Like `insert-file-contents' for tramp files." | |
2859 (barf-if-buffer-read-only) | |
2860 (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
|
2861 (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
|
2862 (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
|
2863 (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
|
2864 filename visit beg end replace)) |
45861 | 2865 (if (not (tramp-handle-file-exists-p filename)) |
2866 (progn | |
2867 (when visit | |
2868 (setq buffer-file-name filename) | |
2869 (set-visited-file-modtime) | |
2870 (set-buffer-modified-p nil)) | |
2871 (signal 'file-error | |
2872 (format "File `%s' not found on remote host" filename)) | |
2873 (list (tramp-handle-expand-file-name filename) 0)) | |
2874 (let ((local-copy (tramp-handle-file-local-copy filename)) | |
2875 (coding-system-used nil) | |
2876 (result nil)) | |
2877 (when visit | |
2878 (setq buffer-file-name filename) | |
2879 (set-visited-file-modtime) | |
2880 (set-buffer-modified-p nil)) | |
2881 (tramp-message-for-buffer | |
2882 multi-method method user host | |
2883 9 "Inserting local temp file `%s'..." local-copy) | |
2884 (setq result | |
2885 (tramp-run-real-handler 'insert-file-contents | |
2886 (list local-copy nil beg end replace))) | |
2887 ;; Now `last-coding-system-used' has right value. Remember it. | |
2888 (when (boundp 'last-coding-system-used) | |
2889 (setq coding-system-used last-coding-system-used)) | |
2890 (tramp-message 9 "Inserting local temp file `%s'...done" local-copy) | |
2891 (delete-file local-copy) | |
2892 (when (boundp 'last-coding-system-used) | |
2893 (setq last-coding-system-used coding-system-used)) | |
2894 (list (expand-file-name filename) | |
2895 (second result)))))) | |
2896 | |
2897 ;; CCC grok APPEND, LOCKNAME, CONFIRM | |
2898 (defun tramp-handle-write-region | |
2899 (start end filename &optional append visit lockname confirm) | |
2900 "Like `write-region' for tramp files." | |
2901 (unless (eq append nil) | |
2902 (error "Cannot append to file using tramp (`%s')" filename)) | |
2903 (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
|
2904 ;; 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
|
2905 ;; 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
|
2906 ;; Ange-ftp ignores it, too. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2907 ;; (when (and lockname (stringp lockname)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2908 ;; (setq lockname (expand-file-name lockname))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2909 ;; (unless (or (eq lockname nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2910 ;; (string= lockname filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2911 ;; (error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2912 ;; "tramp-handle-write-region: LOCKNAME must be nil or equal FILENAME")) |
45861 | 2913 ;; XEmacs takes a coding system as the sevent argument, not `confirm' |
2914 (when (and (not (featurep 'xemacs)) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2915 confirm (file-exists-p filename)) |
45861 | 2916 (unless (y-or-n-p (format "File %s exists; overwrite anyway? " |
2917 filename)) | |
2918 (error "File not overwritten"))) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2919 (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
|
2920 (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
|
2921 (tramp-invoke-ange-ftp 'write-region |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2922 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
|
2923 (let ((curbuf (current-buffer)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2924 (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
|
2925 (rcp-args (tramp-get-rcp-args multi-method method)) |
46752 | 2926 (encoding-command |
2927 (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
|
2928 (encoding-function |
46752 | 2929 (tramp-get-encoding-function multi-method method user host)) |
2930 (decoding-command | |
2931 (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
|
2932 (trampbuf (get-buffer-create "*tramp output*")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2933 ;; 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
|
2934 ;; 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
|
2935 ;; 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
|
2936 ;; 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
|
2937 ;; 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
|
2938 ;; 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
|
2939 coding-system-used |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2940 tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2941 ;; 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
|
2942 ;; 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
|
2943 ;; because this makes the logic simpler. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2944 (setq tmpfil (tramp-make-temp-file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2945 ;; 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
|
2946 ;; 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
|
2947 ;; `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
|
2948 (tramp-run-real-handler |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2949 'write-region |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2950 (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
|
2951 (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
|
2952 (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
|
2953 ;; 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
|
2954 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2955 (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
|
2956 ;; 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
|
2957 ;; 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
|
2958 ;; 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
|
2959 ;; 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
|
2960 ;; _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
|
2961 ;; 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
|
2962 (cond (rcp-program |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2963 ;; 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
|
2964 (let ((argl (append rcp-args |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2965 (list |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2966 tmpfil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2967 (tramp-make-rcp-program-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2968 user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2969 (tramp-shell-quote-argument path)))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2970 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2971 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2972 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
|
2973 (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
|
2974 (when tramp-debug-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2975 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2976 (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
|
2977 method user host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2978 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2979 (tramp-insert-with-face |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2980 '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
|
2981 (mapconcat 'identity argl " "))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2982 (unless (equal 0 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2983 (apply #'call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2984 rcp-program nil trampbuf nil argl)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2985 (pop-to-buffer trampbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2986 (error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2987 "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
|
2988 filename rcp-program)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2989 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2990 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2991 6 "Transferring file using `%s'...done" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2992 rcp-program))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2993 ((and encoding-command decoding-command) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2994 ;; Use inline file transfer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2995 (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
|
2996 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2997 ;; Encode tmpfil into tmpbuf |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2998 (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
|
2999 5 "Encoding region...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3000 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3001 (erase-buffer) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3002 ;; Use encoding function or command. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3003 (if (and encoding-function |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3004 (fboundp encoding-function)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3005 (progn |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3006 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3007 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3008 6 "Encoding region using function...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3009 (insert-file-contents-literally tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3010 ;; 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
|
3011 ;; 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
|
3012 ;; both of the following conditions are |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3013 ;; 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
|
3014 ;; 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
|
3015 ;; default-directory is remote. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3016 ;; (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
|
3017 ;; 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
|
3018 ;; tmp file anyway. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3019 (let ((default-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3020 (tramp-temporary-file-directory))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3021 (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
|
3022 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3023 (unless (bolp) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3024 (newline))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3025 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3026 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3027 6 "Encoding region using command...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3028 (unless (equal 0 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3029 (call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3030 tramp-sh-program |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3031 tmpfil ;input = local tmp file |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3032 t ;output is current buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3033 nil ;don't redisplay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3034 "-c" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3035 encoding-command)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3036 (pop-to-buffer trampbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3037 (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
|
3038 " command `%s' failed") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3039 filename encoding-command))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3040 ;; 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
|
3041 ;; 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
|
3042 ;; 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
|
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 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
|
3046 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3047 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3048 (format "%s >%s <<'EOF'" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3049 decoding-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3050 (tramp-shell-quote-argument path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3051 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3052 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3053 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3054 6 "Sending data to remote host...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3055 (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
|
3056 (point-min) (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3057 ;; wait for remote decoding to complete |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3058 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3059 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3060 6 "Sending end of data token...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3061 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3062 multi-method method user host "EOF") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3063 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3064 multi-method method user host 6 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3065 "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
|
3066 (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
|
3067 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3068 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3069 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
|
3070 (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
|
3071 " decode using `%s' failed") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3072 filename decoding-command) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3073 (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
|
3074 filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3075 (kill-buffer tmpbuf)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3076 (t |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3077 (error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3078 (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
|
3079 "decoding command or an rcp program") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3080 method))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3081 (delete-file tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3082 (unless (equal curbuf (current-buffer)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3083 (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
|
3084 curbuf (current-buffer))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3085 (when (eq visit t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3086 (set-visited-file-modtime)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3087 ;; 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
|
3088 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3089 (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
|
3090 (when (or (eq visit t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3091 (eq visit nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3092 (stringp visit)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3093 (message "Wrote %s" filename))))) |
45861 | 3094 |
3095 ;; Call down to the real handler. | |
3096 ;; Because EFS does not play nicely with TRAMP (both systems match an | |
3097 ;; TRAMP path) it is needed to disable efs as well as tramp for the | |
3098 ;; operation. | |
3099 ;; | |
3100 ;; Other than that, this is the canon file-handler code that the doco | |
3101 ;; says should be used here. Which is nice. | |
3102 ;; | |
3103 ;; Under XEmacs current, EFS also hooks in as | |
3104 ;; efs-sifn-handler-function to handle any path with environment | |
3105 ;; variables. This has two implications: | |
3106 ;; 1) That EFS may not be completely dead (yet) for TRAMP paths | |
3107 ;; 2) That TRAMP might want to do the same thing. | |
3108 ;; Details as they come in. | |
3109 ;; | |
3110 ;; Daniel Pittman <daniel@danann.net> | |
3111 | |
3112 ;; (defun tramp-run-real-handler (operation args) | |
3113 ;; "Invoke normal file name handler for OPERATION. | |
3114 ;; This inhibits EFS and Ange-FTP, too, because they conflict with tramp. | |
3115 ;; First arg specifies the OPERATION, remaining ARGS are passed to the | |
3116 ;; OPERATION." | |
3117 ;; (let ((inhibit-file-name-handlers | |
3118 ;; (list 'tramp-file-name-handler | |
3119 ;; 'efs-file-handler-function | |
3120 ;; 'ange-ftp-hook-function | |
3121 ;; (and (eq inhibit-file-name-operation operation) | |
3122 ;; inhibit-file-name-handlers))) | |
3123 ;; (inhibit-file-name-operation operation)) | |
3124 ;; (apply operation args))) | |
3125 | |
3126 (defun tramp-run-real-handler (operation args) | |
3127 "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
|
3128 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
|
3129 pass to the OPERATION." |
45861 | 3130 (let ((inhibit-file-name-handlers |
3131 (list 'tramp-file-name-handler | |
3132 (and (eq inhibit-file-name-operation operation) | |
3133 inhibit-file-name-handlers))) | |
3134 (inhibit-file-name-operation operation)) | |
3135 (apply operation args))) | |
3136 | |
3137 ;; Main function. | |
3138 ;;;###autoload | |
3139 (defun tramp-file-name-handler (operation &rest args) | |
3140 "Invoke tramp file name handler. | |
3141 Falls back to normal file name handler if no tramp file name handler exists." | |
3142 (let ((fn (assoc operation tramp-file-name-handler-alist))) | |
3143 (if fn | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3144 (catch 'tramp-forward-to-ange-ftp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3145 (save-match-data (apply (cdr fn) args))) |
45861 | 3146 (tramp-run-real-handler operation args)))) |
3147 | |
3148 ;; Register in file name handler alist | |
3149 ;;;###autoload | |
3150 (add-to-list 'file-name-handler-alist | |
3151 (cons tramp-file-name-regexp 'tramp-file-name-handler)) | |
3152 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3153 ;; 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
|
3154 ;; |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3155 ;; * 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
|
3156 ;; * 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
|
3157 ;; 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
|
3158 ;; * 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
|
3159 ;; |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3160 ;; 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
|
3161 ;; 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
|
3162 (defun tramp-disable-ange-ftp () |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3163 "Turn Ange-FTP off. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3164 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
|
3165 `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
|
3166 `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
|
3167 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
|
3168 `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
|
3169 `tramp-default-method-alist'. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3170 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3171 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
|
3172 present for backward compatibility." |
46060
40298ba8e901
(tramp-handle-ange-ftp): Fix typo.
Andreas Schwab <schwab@suse.de>
parents:
46048
diff
changeset
|
3173 (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
|
3174 (a2 (rassq 'ange-ftp-completion-hook-function file-name-handler-alist))) |
45861 | 3175 (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
|
3176 (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
|
3177 (tramp-disable-ange-ftp) |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3178 |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3179 (defun tramp-repair-jka-compr () |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3180 "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
|
3181 `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
|
3182 necessary anymore." |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3183 (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
|
3184 (when jka |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3185 (setq file-name-handler-alist |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3186 (cons jka (delete jka file-name-handler-alist)))))) |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3187 (tramp-repair-jka-compr) |
45861 | 3188 |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3189 (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
|
3190 "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
|
3191 (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
|
3192 (let ((ange-ftp-name-format |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3193 (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
|
3194 (nth 3 tramp-file-name-structure) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3195 (nth 2 tramp-file-name-structure) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3196 (nth 4 tramp-file-name-structure)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3197 (throw 'tramp-forward-to-ange-ftp |
46808
cf225aed7a75
Version 2.0.11 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46802
diff
changeset
|
3198 (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
|
3199 (cons operation args))))) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3200 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3201 (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
|
3202 "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
|
3203 (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
|
3204 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3205 |
45861 | 3206 ;;; Interactions with other packages: |
3207 | |
3208 ;; -- complete.el -- | |
3209 | |
3210 ;; This function contributed by Ed Sabol | |
3211 (defun tramp-handle-expand-many-files (name) | |
3212 "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
|
3213 (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
|
3214 (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
|
3215 (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
|
3216 (save-match-data |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3217 (if (or (string-match "\\*" name) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3218 (string-match "\\?" name) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3219 (string-match "\\[.*\\]" name)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3220 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3221 (let (bufstr) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3222 ;; 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
|
3223 ;; 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
|
3224 ;; 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
|
3225 ;; don't bother. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3226 ;;-(let ((comint-file-name-quote-list |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3227 ;;- (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
|
3228 ;;- '(?\* ?\? ?[ ?])))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3229 ;;- (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3230 ;;- multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3231 ;;- (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
|
3232 ;;- (tramp-wait-for-output)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3233 (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
|
3234 (format "echo %s" path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3235 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3236 (setq bufstr (buffer-substring (point-min) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3237 (tramp-line-end-position))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3238 (goto-char (point-min)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3239 (if (string-equal path bufstr) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3240 nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3241 (insert "(\"") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3242 (while (search-forward " " nil t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3243 (delete-backward-char 1) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3244 (insert "\" \"")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3245 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3246 (delete-backward-char 1) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3247 (insert "\")") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3248 (goto-char (point-min)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3249 (mapcar |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3250 (function (lambda (x) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3251 (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
|
3252 user host x))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3253 (read (current-buffer)))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3254 (list (tramp-handle-expand-file-name name)))))) |
45861 | 3255 |
3256 ;; Check for complete.el and override PC-expand-many-files if appropriate. | |
3257 (eval-when-compile | |
3258 (defun tramp-save-PC-expand-many-files (name))); avoid compiler warning | |
3259 | |
3260 (defun tramp-setup-complete () | |
3261 (fset 'tramp-save-PC-expand-many-files | |
3262 (symbol-function 'PC-expand-many-files)) | |
3263 (defun PC-expand-many-files (name) | |
3264 (if (tramp-tramp-file-p name) | |
3265 (tramp-handle-expand-many-files name) | |
3266 (tramp-save-PC-expand-many-files name)))) | |
3267 | |
3268 ;; Why isn't eval-after-load sufficient? | |
3269 (if (fboundp 'PC-expand-many-files) | |
3270 (tramp-setup-complete) | |
3271 (eval-after-load "complete" '(tramp-setup-complete))) | |
3272 | |
3273 | |
3274 | |
3275 | |
3276 ;;; Internal Functions: | |
3277 | |
3278 (defun tramp-set-auto-save () | |
3279 (when (and (buffer-file-name) | |
3280 (tramp-tramp-file-p (buffer-file-name)) | |
3281 auto-save-default) | |
3282 (auto-save-mode 1))) | |
3283 (add-hook 'find-file-hooks 'tramp-set-auto-save t) | |
3284 | |
3285 (defun tramp-run-test (switch filename) | |
3286 "Run `test' on the remote system, given a SWITCH and a FILENAME. | |
3287 Returns the exit code of the `test' program." | |
3288 (let ((v (tramp-dissect-file-name filename))) | |
3289 (save-excursion | |
3290 (tramp-send-command-and-check | |
3291 (tramp-file-name-multi-method v) (tramp-file-name-method v) | |
3292 (tramp-file-name-user v) (tramp-file-name-host v) | |
3293 (format "test %s %s" switch | |
3294 (tramp-shell-quote-argument (tramp-file-name-path v))))))) | |
3295 | |
3296 (defun tramp-run-test2 (program file1 file2 &optional switch) | |
3297 "Run `test'-like PROGRAM on the remote system, given FILE1, FILE2. | |
3298 The optional SWITCH is inserted between the two files. | |
3299 Returns the exit code of the `test' PROGRAM. Barfs if the methods, | |
3300 hosts, or files, disagree." | |
3301 (let* ((v1 (tramp-dissect-file-name file1)) | |
3302 (v2 (tramp-dissect-file-name file2)) | |
3303 (mmethod1 (tramp-file-name-multi-method v1)) | |
3304 (mmethod2 (tramp-file-name-multi-method v2)) | |
3305 (method1 (tramp-file-name-method v1)) | |
3306 (method2 (tramp-file-name-method v2)) | |
3307 (user1 (tramp-file-name-user v1)) | |
3308 (user2 (tramp-file-name-user v2)) | |
3309 (host1 (tramp-file-name-host v1)) | |
3310 (host2 (tramp-file-name-host v2)) | |
3311 (path1 (tramp-file-name-path v1)) | |
3312 (path2 (tramp-file-name-path v2))) | |
3313 (unless (and method1 method2 host1 host2 | |
3314 (equal mmethod1 mmethod2) | |
3315 (equal method1 method2) | |
3316 (equal user1 user2) | |
3317 (equal host1 host2)) | |
3318 (error "tramp-run-test2: %s" | |
3319 "only implemented for same method, same user, same host")) | |
3320 (save-excursion | |
3321 (tramp-send-command-and-check | |
3322 mmethod1 method1 user1 host1 | |
3323 (format "%s %s %s %s" | |
3324 program | |
3325 (tramp-shell-quote-argument path1) | |
3326 (or switch "") | |
3327 (tramp-shell-quote-argument path2)))))) | |
3328 | |
3329 (defun tramp-buffer-name (multi-method method user host) | |
3330 "A name for the connection buffer for USER at HOST using METHOD." | |
3331 (cond (multi-method | |
3332 (tramp-buffer-name-multi-method "tramp" multi-method method user host)) | |
3333 (user | |
3334 (format "*tramp/%s %s@%s*" method user host)) | |
3335 (t | |
3336 (format "*tramp/%s %s*" method host)))) | |
3337 | |
3338 (defun tramp-buffer-name-multi-method (prefix multi-method method user host) | |
3339 "A name for the multi method connection buffer. | |
3340 MULTI-METHOD gives the multi method, METHOD the array of methods, | |
3341 USER the array of user names, HOST the array of host names." | |
3342 (unless (and (= (length method) (length user)) | |
3343 (= (length method) (length host))) | |
3344 (error "Syntax error in multi method (implementation error)")) | |
3345 (let ((len (length method)) | |
3346 (i 0) | |
3347 string-list) | |
3348 (while (< i len) | |
3349 (setq string-list | |
3350 (cons (if (aref user i) | |
3351 (format "%s#%s@%s:" (aref method i) | |
3352 (aref user i) (aref host i)) | |
3353 (format "%s@%s:" (aref method i) (aref host i))) | |
3354 string-list)) | |
3355 (incf i)) | |
3356 (format "*%s/%s %s*" | |
3357 prefix multi-method | |
3358 (apply 'concat (reverse string-list))))) | |
3359 | |
3360 (defun tramp-get-buffer (multi-method method user host) | |
3361 "Get the connection buffer to be used for USER at HOST using METHOD." | |
3362 (get-buffer-create (tramp-buffer-name multi-method method user host))) | |
3363 | |
3364 (defun tramp-debug-buffer-name (multi-method method user host) | |
3365 "A name for the debug buffer for USER at HOST using METHOD." | |
3366 (cond (multi-method | |
3367 (tramp-buffer-name-multi-method "debug tramp" | |
3368 multi-method method user host)) | |
3369 (user | |
3370 (format "*debug tramp/%s %s@%s*" method user host)) | |
3371 (t | |
3372 (format "*debug tramp/%s %s*" method host)))) | |
3373 | |
3374 (defun tramp-get-debug-buffer (multi-method method user host) | |
3375 "Get the debug buffer for USER at HOST using METHOD." | |
3376 (get-buffer-create (tramp-debug-buffer-name multi-method method user host))) | |
3377 | |
3378 (defun tramp-find-executable (multi-method method user host | |
3379 progname dirlist ignore-tilde) | |
3380 "Searches for PROGNAME in all directories mentioned in DIRLIST. | |
3381 First args METHOD, USER and HOST specify the connection, PROGNAME | |
3382 is the program to search for, and DIRLIST gives the list of directories | |
3383 to search. If IGNORE-TILDE is non-nil, directory names starting | |
3384 with `~' will be ignored. | |
3385 | |
3386 Returns the full path name of PROGNAME, if found, and nil otherwise. | |
3387 | |
3388 This function expects to be in the right *tramp* buffer." | |
3389 (let (result) | |
3390 (when ignore-tilde | |
3391 ;; Remove all ~/foo directories from dirlist. In Emacs 20, | |
3392 ;; `remove' is in CL, and we want to avoid CL dependencies. | |
3393 (let (newdl d) | |
3394 (while dirlist | |
3395 (setq d (car dirlist)) | |
3396 (setq dirlist (cdr dirlist)) | |
3397 (unless (char-equal ?~ (aref d 0)) | |
3398 (setq newdl (cons d newdl)))) | |
3399 (setq dirlist (nreverse newdl)))) | |
3400 (tramp-send-command | |
3401 multi-method method user host | |
3402 (format (concat "while read d; " | |
3403 "do if test -x $d/%s -a -f $d/%s; " | |
3404 "then echo tramp_executable $d/%s; " | |
3405 "break; fi; done <<'EOF'") | |
3406 progname progname progname)) | |
3407 (mapcar (lambda (d) | |
3408 (tramp-send-command multi-method method user host d)) | |
3409 dirlist) | |
3410 (tramp-send-command multi-method method user host "EOF") | |
3411 (tramp-wait-for-output) | |
3412 (goto-char (point-max)) | |
3413 (when (search-backward "tramp_executable " nil t) | |
3414 (skip-chars-forward "^ ") | |
3415 (skip-chars-forward " ") | |
3416 (buffer-substring (point) (tramp-line-end-position))))) | |
3417 | |
3418 (defun tramp-set-remote-path (multi-method method user host var dirlist) | |
3419 "Sets the remote environment VAR to existing directories from DIRLIST. | |
3420 I.e., for each directory in DIRLIST, it is tested whether it exists and if | |
3421 so, it is added to the environment variable VAR." | |
3422 (let ((existing-dirs | |
3423 (mapcar | |
3424 (lambda (x) | |
3425 (when (and | |
3426 (file-exists-p | |
3427 (tramp-make-tramp-file-name multi-method method user host x)) | |
3428 (file-directory-p | |
3429 (tramp-make-tramp-file-name multi-method method user host x))) | |
3430 x)) | |
3431 dirlist))) | |
3432 (tramp-send-command | |
3433 multi-method method user host | |
3434 (concat var "=" | |
3435 (mapconcat 'identity (delq nil existing-dirs) ":") | |
3436 "; export " var)) | |
3437 (tramp-wait-for-output))) | |
3438 | |
3439 ;; -- communication with external shell -- | |
3440 | |
3441 (defun tramp-find-file-exists-command (multi-method method user host) | |
3442 "Find a command on the remote host for checking if a file exists. | |
3443 Here, we are looking for a command which has zero exit status if the | |
3444 file exists and nonzero exit status otherwise." | |
3445 (make-local-variable 'tramp-file-exists-command) | |
3446 (tramp-message 10 "Finding command to check if file exists") | |
3447 (let ((existing | |
3448 (tramp-make-tramp-file-name | |
3449 multi-method method user host | |
3450 "/")) ;assume this file always exists | |
3451 (nonexisting | |
3452 (tramp-make-tramp-file-name | |
3453 multi-method method user host | |
3454 "/ this file does not exist "))) ;assume this never exists | |
3455 ;; The algorithm is as follows: we try a list of several commands. | |
3456 ;; For each command, we first run `$cmd /' -- this should return | |
3457 ;; true, as the root directory always exists. And then we run | |
3458 ;; `$cmd /this\ file\ does\ not\ exist', hoping that the file indeed | |
3459 ;; does not exist. This should return false. We use the first | |
3460 ;; command we find that seems to work. | |
3461 ;; The list of commands to try is as follows: | |
3462 ;; `ls -d' This works on most systems, but NetBSD 1.4 | |
3463 ;; has a bug: `ls' always returns zero exit | |
3464 ;; status, even for files which don't exist. | |
3465 ;; `test -e' Some Bourne shells have a `test' builtin | |
3466 ;; which does not know the `-e' option. | |
3467 ;; `/bin/test -e' For those, the `test' binary on disk normally | |
3468 ;; provides the option. Alas, the binary | |
3469 ;; is sometimes `/bin/test' and sometimes it's | |
3470 ;; `/usr/bin/test'. | |
3471 ;; `/usr/bin/test -e' In case `/bin/test' does not exist. | |
3472 (unless (or | |
3473 (and (setq tramp-file-exists-command "test -e %s") | |
3474 (tramp-handle-file-exists-p existing) | |
3475 (not (tramp-handle-file-exists-p nonexisting))) | |
3476 (and (setq tramp-file-exists-command "/bin/test -e %s") | |
3477 (tramp-handle-file-exists-p existing) | |
3478 (not (tramp-handle-file-exists-p nonexisting))) | |
3479 (and (setq tramp-file-exists-command "/usr/bin/test -e %s") | |
3480 (tramp-handle-file-exists-p existing) | |
46808
cf225aed7a75
Version 2.0.11 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46802
diff
changeset
|
3481 (not (tramp-handle-file-exists-p nonexisting))) |
cf225aed7a75
Version 2.0.11 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46802
diff
changeset
|
3482 (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
|
3483 (tramp-handle-file-exists-p existing) |
45861 | 3484 (not (tramp-handle-file-exists-p nonexisting)))) |
3485 (error "Couldn't find command to check if file exists.")))) | |
3486 | |
3487 | |
3488 ;; CCC test ksh or bash found for tilde expansion? | |
3489 (defun tramp-find-shell (multi-method method user host) | |
3490 "Find a shell on the remote host which groks tilde expansion." | |
3491 (let ((shell nil)) | |
3492 (tramp-send-command multi-method method user host "echo ~root") | |
3493 (tramp-wait-for-output) | |
3494 (cond | |
3495 ((string-match "^~root$" (buffer-string)) | |
3496 (setq shell | |
3497 (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
|
3498 "bash" tramp-remote-path t) |
45861 | 3499 (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
|
3500 "ksh" tramp-remote-path t))) |
45861 | 3501 (unless shell |
3502 (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
|
3503 ;; Find arguments for this shell. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3504 (let ((alist tramp-sh-extra-args) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3505 item extra-args) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3506 (while (and alist (null extra-args)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3507 (setq item (pop alist)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3508 (when (string-match (car item) shell) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3509 (setq extra-args (cdr item)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3510 (when extra-args (setq shell (concat shell " " extra-args)))) |
45861 | 3511 (tramp-message |
3512 5 "Starting remote shell `%s' for tilde expansion..." shell) | |
3513 (tramp-send-command | |
3514 multi-method method user host | |
46801
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
3515 (concat "PS1='$ ' exec " shell)) ; |
45861 | 3516 (unless (tramp-wait-for-regexp |
3517 (get-buffer-process (current-buffer)) | |
46801
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
3518 60 (format "\\(\\$ *\\|\\(%s\\)\\)\\'" shell-prompt-pattern)) |
45861 | 3519 (pop-to-buffer (buffer-name)) |
3520 (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
|
3521 (tramp-message |
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
3522 10 "Setting remote shell prompt...") |
45861 | 3523 (process-send-string nil (format "PS1='%s%s%s'; PS2=''; PS3=''%s" |
3524 tramp-rsh-end-of-line | |
3525 tramp-end-of-output | |
3526 tramp-rsh-end-of-line | |
3527 tramp-rsh-end-of-line)) | |
3528 (tramp-wait-for-output) | |
46801
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
3529 (tramp-message |
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
3530 10 "Setting remote shell prompt...done") |
45861 | 3531 (tramp-send-command multi-method method user host "echo hello") |
3532 (tramp-message 5 "Waiting for remote `%s' to start up..." shell) | |
3533 (unless (tramp-wait-for-output 5) | |
3534 (unless (tramp-wait-for-output 5) | |
3535 (pop-to-buffer (buffer-name)) | |
3536 (error "Couldn't start remote `%s', see buffer `%s' for details" | |
3537 shell (buffer-name)))) | |
3538 (tramp-message 5 "Waiting for remote `%s' to start up...done" shell)) | |
3539 (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
|
3540 (tramp-get-remote-sh multi-method method)))))) |
45861 | 3541 |
3542 (defun tramp-check-ls-command (multi-method method user host cmd) | |
3543 "Checks whether the given `ls' executable groks `-n'. | |
3544 METHOD, USER and HOST specify the connection, CMD (the full path name of) | |
3545 the `ls' executable. Returns t if CMD supports the `-n' option, nil | |
3546 otherwise." | |
3547 (tramp-message 9 "Checking remote `%s' command for `-n' option" | |
3548 cmd) | |
3549 (when (tramp-handle-file-executable-p | |
3550 (tramp-make-tramp-file-name multi-method method user host cmd)) | |
3551 (let ((result nil)) | |
3552 (tramp-message 7 "Testing remote command `%s' for -n..." cmd) | |
3553 (setq result | |
3554 (tramp-send-command-and-check | |
3555 multi-method method user host | |
3556 (format "%s -lnd / >/dev/null" | |
3557 cmd))) | |
3558 (tramp-message 7 "Testing remote command `%s' for -n...%s" | |
3559 cmd | |
3560 (if (zerop result) "okay" "failed")) | |
3561 (zerop result)))) | |
3562 | |
3563 (defun tramp-check-ls-commands (multi-method method user host cmd dirlist) | |
3564 "Checks whether the given `ls' executable in one of the dirs groks `-n'. | |
3565 Returns nil if none was found, else the command is returned." | |
3566 (let ((dl dirlist) | |
3567 (result nil)) | |
3568 ;; It would be better to use the CL function `find', but | |
3569 ;; we don't want run-time dependencies on CL. | |
3570 (while (and dl (not result)) | |
3571 (let ((x (concat (file-name-as-directory (car dl)) cmd))) | |
3572 (when (tramp-check-ls-command multi-method method user host x) | |
3573 (setq result x))) | |
3574 (setq dl (cdr dl))) | |
3575 result)) | |
3576 | |
3577 (defun tramp-find-ls-command (multi-method method user host) | |
3578 "Finds an `ls' command which groks the `-n' option, returning nil if failed. | |
3579 \(This option prints numeric user and group ids in a long listing.)" | |
3580 (tramp-message 9 "Finding a suitable `ls' command") | |
3581 (or | |
3582 (tramp-check-ls-commands multi-method method user host "ls" tramp-remote-path) | |
3583 (tramp-check-ls-commands multi-method method user host "gnuls" tramp-remote-path) | |
3584 (tramp-check-ls-commands multi-method method user host "gls" tramp-remote-path))) | |
3585 | |
3586 ;; ------------------------------------------------------------ | |
3587 ;; -- Functions for establishing connection -- | |
3588 ;; ------------------------------------------------------------ | |
3589 | |
46752 | 3590 ;; The following functions are actions to be taken when seeing certain |
3591 ;; prompts from the remote host. See the variable | |
3592 ;; `tramp-actions-before-shell' for usage of these functions. | |
3593 | |
3594 (defun tramp-action-login (p multi-method method user host) | |
3595 "Send the login name." | |
3596 (tramp-message 9 "Sending login name `%s'" | |
3597 (or user (user-login-name))) | |
3598 (erase-buffer) | |
3599 (process-send-string nil (concat (or user (user-login-name)) | |
3600 tramp-rsh-end-of-line))) | |
3601 | |
3602 (defun tramp-action-password (p multi-method method user host) | |
3603 "Query the user for a password." | |
3604 (when (tramp-method-out-of-band-p multi-method method) | |
3605 (kill-process (get-buffer-process (current-buffer))) | |
3606 (error (concat "Out of band method `%s' not applicable " | |
3607 "for remote shell asking for a password") | |
3608 method)) | |
3609 (tramp-enter-password p (match-string 0))) | |
3610 | |
3611 (defun tramp-action-succeed (p multi-method method user host) | |
3612 "Signal success in finding shell prompt." | |
3613 (tramp-message 9 "Found remote shell prompt.") | |
3614 (erase-buffer) | |
3615 (throw 'tramp-action 'ok)) | |
3616 | |
3617 (defun tramp-action-permission-denied (p multi-method method user host) | |
3618 "Signal permission denied." | |
46790 | 3619 (pop-to-buffer (tramp-get-buffer multi-method method user host)) |
46752 | 3620 (tramp-message 9 "Permission denied by remote host.") |
3621 (kill-process p) | |
3622 (throw 'tramp-action 'permission-denied)) | |
3623 | |
3624 (defun tramp-action-yesno (p multi-method method user host) | |
3625 "Ask the user if he is sure." | |
3626 (save-window-excursion | |
3627 (pop-to-buffer (tramp-get-buffer multi-method method user host)) | |
3628 (unless (yes-or-no-p (match-string 0)) | |
3629 (kill-process p) | |
3630 (erase-buffer) | |
3631 (throw 'tramp-action 'permission-denied)) | |
3632 (process-send-string p (concat "yes" tramp-rsh-end-of-line)) | |
3633 (erase-buffer))) | |
3634 | |
3635 ;; The following functions are specifically for multi connections. | |
3636 | |
3637 (defun tramp-multi-action-login (p method user host) | |
3638 "Send the login name." | |
3639 (tramp-message 9 "Sending login name `%s'" user) | |
3640 (erase-buffer) | |
3641 (process-send-string p (concat user tramp-rsh-end-of-line))) | |
3642 | |
3643 (defun tramp-multi-action-password (p method user host) | |
3644 "Query the user for a password." | |
3645 (tramp-enter-password p (match-string 0))) | |
3646 | |
3647 (defun tramp-multi-action-succeed (p method user host) | |
3648 "Signal success in finding shell prompt." | |
3649 (tramp-message 9 "Found shell prompt on `%s'" host) | |
3650 (erase-buffer) | |
3651 (throw 'tramp-action 'ok)) | |
3652 | |
3653 (defun tramp-multi-action-permission-denied (p method user host) | |
3654 "Signal permission denied." | |
3655 (tramp-message 9 "Permission denied by remote host `%s'" host) | |
3656 (kill-process p) | |
3657 (erase-buffer) | |
3658 (throw 'tramp-action 'permission-denied)) | |
3659 | |
3660 ;; Functions for processing the actions. | |
3661 | |
3662 (defun tramp-process-one-action (p multi-method method user host actions) | |
3663 "Wait for output from the shell and perform one action." | |
3664 (let (found item pattern action todo) | |
3665 (erase-buffer) | |
3666 (tramp-message 9 "Waiting 60s for prompt from remote shell") | |
3667 (with-timeout (60 (throw 'tramp-action 'timeout)) | |
3668 (while (not found) | |
3669 (accept-process-output p 1) | |
3670 (goto-char (point-min)) | |
3671 (setq todo actions) | |
3672 (while todo | |
3673 (goto-char (point-min)) | |
3674 (setq item (pop todo)) | |
3675 (setq pattern (symbol-value (nth 0 item))) | |
3676 (setq action (nth 1 item)) | |
3677 (tramp-message 10 "Looking for pattern %s" pattern) | |
3678 (when (re-search-forward (concat pattern "\\'") nil t) | |
3679 (setq found (funcall action p multi-method method user host))))) | |
3680 found))) | |
3681 | |
3682 (defun tramp-process-actions (p multi-method method user host actions) | |
3683 "Perform actions until success." | |
3684 (let (exit) | |
3685 (while (not exit) | |
3686 (tramp-message 10 "Processing actions") | |
3687 (setq exit | |
3688 (catch 'tramp-action | |
3689 (tramp-process-one-action | |
3690 p multi-method method user host actions) | |
3691 nil))) | |
3692 (unless (eq exit 'ok) | |
3693 (error "Login failed")))) | |
3694 | |
3695 ;; For multi-actions. | |
3696 | |
3697 (defun tramp-process-one-multi-action (p method user host actions) | |
3698 "Wait for output from the shell and perform one action." | |
3699 (let (found item pattern action todo) | |
3700 (erase-buffer) | |
3701 (tramp-message 9 "Waiting 60s for prompt from remote shell") | |
3702 (with-timeout (60 (throw 'tramp-action 'timeout)) | |
3703 (while (not found) | |
3704 (accept-process-output p 1) | |
3705 (setq todo actions) | |
3706 (goto-char (point-min)) | |
3707 (while todo | |
3708 (goto-char (point-min)) | |
3709 (setq item (pop todo)) | |
3710 (setq pattern (symbol-value (nth 0 item))) | |
3711 (setq action (nth 1 item)) | |
3712 (tramp-message 10 "Looking for pattern %s" pattern) | |
3713 (when (re-search-forward (concat pattern "\\'") nil t) | |
3714 (setq found (funcall action p method user host))))) | |
3715 found))) | |
3716 | |
3717 (defun tramp-process-multi-actions (p method user host actions) | |
3718 "Perform actions until success." | |
3719 (let (exit) | |
3720 (while (not exit) | |
3721 (setq exit | |
3722 (catch 'tramp-action | |
3723 (tramp-process-one-multi-action p method user host actions) | |
3724 nil))) | |
3725 (unless (eq exit 'ok) | |
3726 (error "Login failed")))) | |
3727 | |
3728 ;; The actual functions for opening connections. | |
45861 | 3729 |
3730 (defun tramp-open-connection-telnet (multi-method method user host) | |
3731 "Open a connection using a telnet METHOD. | |
3732 This starts the command `telnet HOST ARGS'[*], then waits for a remote | |
3733 login prompt, then sends the user name USER, then waits for a remote | |
3734 password prompt. It queries the user for the password, then sends the | |
3735 password to the remote host. | |
3736 | |
3737 If USER is nil, uses value returned by `(user-login-name)' instead. | |
3738 | |
3739 Recognition of the remote shell prompt is based on the variable | |
3740 `shell-prompt-pattern' which must be set up correctly. | |
3741 | |
3742 Please note that it is NOT possible to use this connection method | |
3743 together with an out-of-band transfer method! You must use an inline | |
3744 transfer method. | |
3745 | |
3746 Maybe the different regular expressions need to be tuned. | |
3747 | |
3748 * Actually, the telnet program as well as the args to be used can be | |
3749 specified in the method parameters, see the variable `tramp-methods'." | |
3750 (save-match-data | |
3751 (when (tramp-method-out-of-band-p multi-method method) | |
3752 (error "Cannot use out-of-band method `%s' with telnet connection method" | |
3753 method)) | |
3754 (when multi-method | |
3755 (error "Cannot multi-connect using telnet connection method")) | |
3756 (tramp-pre-connection multi-method method user host) | |
3757 (tramp-message 7 "Opening connection for %s@%s using %s..." | |
3758 (or user (user-login-name)) host method) | |
3759 (let ((process-environment (copy-sequence process-environment))) | |
3760 (setenv "TERM" tramp-terminal-type) | |
3761 (let* ((default-directory (tramp-temporary-file-directory)) | |
3762 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
3763 (> emacs-major-version 20)) | |
3764 tramp-dos-coding-system)) | |
3765 (p (apply 'start-process | |
3766 (tramp-buffer-name multi-method method user host) | |
3767 (tramp-get-buffer multi-method method user host) | |
3768 (tramp-get-telnet-program multi-method method) | |
3769 host | |
3770 (tramp-get-telnet-args multi-method method))) | |
3771 (found nil) | |
3772 (pw nil)) | |
3773 (process-kill-without-query p) | |
46752 | 3774 (set-buffer (tramp-get-buffer multi-method method user host)) |
3775 (erase-buffer) | |
3776 (tramp-process-actions p multi-method method user host | |
3777 tramp-actions-before-shell) | |
3778 | |
3779 ;; (tramp-message 9 "Waiting for login prompt...") | |
3780 ;; (unless (tramp-wait-for-regexp p nil tramp-login-prompt-regexp) | |
3781 ;; (pop-to-buffer (buffer-name)) | |
3782 ;; (kill-process p) | |
3783 ;; (error "Couldn't find remote login prompt")) | |
3784 ;; (erase-buffer) | |
3785 ;; ;; Remote login defaults to local one. | |
3786 ;; (tramp-message 9 "Sending login name %s" (or user (user-login-name))) | |
3787 ;; (process-send-string p (concat (or user (user-login-name)) | |
3788 ;; tramp-rsh-end-of-line)) | |
3789 ;; (tramp-message 9 "Waiting for password prompt...") | |
3790 ;; (unless (setq found (tramp-wait-for-regexp | |
3791 ;; p nil tramp-password-prompt-regexp)) | |
3792 ;; (pop-to-buffer (buffer-name)) | |
3793 ;; (kill-process p) | |
3794 ;; (error "Couldn't find remote password prompt")) | |
3795 ;; (erase-buffer) | |
3796 ;; (setq pw (tramp-read-passwd (car found))) | |
3797 ;; (tramp-message 9 "Sending password") | |
3798 ;; (process-send-string p (concat pw tramp-rsh-end-of-line)) | |
3799 ;; (tramp-message 9 "Waiting 30s for remote shell to come up...") | |
3800 ;; (unless (setq found | |
3801 ;; (tramp-wait-for-regexp | |
3802 ;; p 30 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3803 ;; tramp-wrong-passwd-regexp | |
3804 ;; shell-prompt-pattern))) | |
3805 ;; (pop-to-buffer (buffer-name)) | |
3806 ;; (kill-process p) | |
3807 ;; (error "Couldn't find remote shell prompt")) | |
3808 ;; (when (nth 1 found) | |
3809 ;; (pop-to-buffer (buffer-name)) | |
3810 ;; (kill-process p) | |
3811 ;; (error "Login failed: %s" (nth 1 found))) | |
3812 | |
45861 | 3813 (tramp-open-connection-setup-interactive-shell |
3814 p multi-method method user host) | |
3815 (tramp-post-connection multi-method method user host))))) | |
3816 | |
46752 | 3817 |
45861 | 3818 (defun tramp-open-connection-rsh (multi-method method user host) |
3819 "Open a connection using an rsh METHOD. | |
3820 This starts the command `rsh HOST -l USER'[*], then waits for a remote | |
3821 password or shell prompt. If a password prompt is seen, the user is | |
3822 queried for a password, this function sends the password to the remote | |
3823 host and waits for a shell prompt. | |
3824 | |
3825 If USER is nil, start the command `rsh HOST'[*] instead | |
3826 | |
3827 Recognition of the remote shell prompt is based on the variable | |
3828 `shell-prompt-pattern' which must be set up correctly. | |
3829 | |
3830 Please note that it is NOT possible to use this connection method with | |
3831 an out-of-band transfer method if this function asks the user for a | |
3832 password! You must use an inline transfer method in this case. | |
3833 Sadly, the transfer method cannot be switched on the fly, instead you | |
3834 must specify the right method in the file name. | |
3835 | |
46010
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3836 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
|
3837 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
|
3838 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
|
3839 |
45861 | 3840 * Actually, the rsh program to be used can be specified in the |
3841 method parameters, see the variable `tramp-methods'." | |
3842 (save-match-data | |
3843 (when multi-method | |
3844 (error "Cannot multi-connect using rsh connection method")) | |
3845 (tramp-pre-connection multi-method method user host) | |
3846 (if user | |
3847 (tramp-message 7 "Opening connection for %s@%s using %s..." | |
3848 user host method) | |
3849 (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
|
3850 (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
|
3851 (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
|
3852 (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
|
3853 (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
|
3854 (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
|
3855 ;; 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
|
3856 ;; 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
|
3857 (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
|
3858 (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
|
3859 (setq host (match-string 1 host))) |
45861 | 3860 (setenv "TERM" tramp-terminal-type) |
3861 (let* ((default-directory (tramp-temporary-file-directory)) | |
3862 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
3863 (> emacs-major-version 20)) | |
3864 tramp-dos-coding-system)) | |
3865 (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
|
3866 (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
|
3867 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
|
3868 (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
|
3869 host rsh-args))) |
45861 | 3870 (found nil)) |
3871 (process-kill-without-query p) | |
46752 | 3872 |
3873 (set-buffer buf) | |
3874 (tramp-process-actions p multi-method method user host | |
3875 tramp-actions-before-shell) | |
3876 | |
3877 ;; (tramp-message 9 "Waiting 60s for shell or passwd prompt from %s" host) | |
3878 ;; (setq found | |
3879 ;; (tramp-wait-for-regexp | |
3880 ;; p 60 | |
3881 ;; (format | |
3882 ;; "\\(%s\\)\\|\\(%s\\)\\'" | |
3883 ;; tramp-password-prompt-regexp | |
3884 ;; shell-prompt-pattern))) | |
3885 ;; (unless found | |
3886 ;; (pop-to-buffer (buffer-name)) | |
3887 ;; (kill-process p) | |
3888 ;; (error "Couldn't find remote shell or passwd prompt")) | |
3889 ;; (when (nth 1 found) | |
3890 ;; (when (tramp-method-out-of-band-p multi-method method) | |
3891 ;; (pop-to-buffer (buffer-name)) | |
3892 ;; (kill-process p) | |
3893 ;; (error (concat "Out of band method `%s' not applicable" | |
3894 ;; " for remote shell asking for a password") | |
3895 ;; method)) | |
3896 ;; (erase-buffer) | |
3897 ;; (tramp-message 9 "Sending password...") | |
3898 ;; (tramp-enter-password p (nth 1 found)) | |
3899 ;; (tramp-message 9 "Sent password, waiting 60s for remote shell prompt") | |
3900 ;; (setq found (tramp-wait-for-regexp p 60 | |
3901 ;; (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3902 ;; tramp-wrong-passwd-regexp | |
3903 ;; shell-prompt-pattern)))) | |
3904 ;; (unless found | |
3905 ;; (pop-to-buffer (buffer-name)) | |
3906 ;; (kill-process p) | |
3907 ;; (error "Couldn't find remote shell prompt")) | |
3908 ;; (when (nth 1 found) | |
3909 ;; (pop-to-buffer (buffer-name)) | |
3910 ;; (kill-process p) | |
3911 ;; (error "Login failed: %s" (nth 1 found))) | |
3912 | |
45861 | 3913 (tramp-message 7 "Initializing remote shell") |
3914 (tramp-open-connection-setup-interactive-shell | |
3915 p multi-method method user host) | |
3916 (tramp-post-connection multi-method method user host))))) | |
3917 | |
3918 (defun tramp-open-connection-su (multi-method method user host) | |
3919 "Open a connection using the `su' program with METHOD. | |
3920 This starts `su - USER', then waits for a password prompt. The HOST | |
3921 name must be equal to the local host name or to `localhost'. | |
3922 | |
3923 If USER is nil, uses value returned by user-login-name instead. | |
3924 | |
3925 Recognition of the remote shell prompt is based on the variable | |
3926 `shell-prompt-pattern' which must be set up correctly. Note that the | |
3927 other user may have a different shell prompt than you do, so it is not | |
3928 at all unlikely that this variable is set up wrongly!" | |
3929 (save-match-data | |
3930 (when (tramp-method-out-of-band-p multi-method method) | |
3931 (error "Cannot use out-of-band method `%s' with `su' connection method" | |
3932 method)) | |
3933 (unless (or (string-match (concat "^" (regexp-quote host)) | |
3934 (system-name)) | |
3935 (string= "localhost" host)) | |
3936 (error | |
3937 "Cannot connect to different host `%s' with `su' connection method" | |
3938 host)) | |
3939 (when (not user) | |
3940 (error "Must give user name for `su' connection method")) | |
3941 (tramp-pre-connection multi-method method user host) | |
3942 (tramp-message 7 "Opening connection for `%s' using `%s'..." | |
3943 (or user (user-login-name)) method) | |
3944 (let ((process-environment (copy-sequence process-environment))) | |
3945 (setenv "TERM" tramp-terminal-type) | |
3946 (let* ((default-directory (tramp-temporary-file-directory)) | |
3947 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
3948 (> emacs-major-version 20)) | |
3949 tramp-dos-coding-system)) | |
3950 (p (apply 'start-process | |
46752 | 3951 (tramp-buffer-name multi-method method user host) |
3952 (tramp-get-buffer multi-method method user host) | |
45861 | 3953 (tramp-get-su-program multi-method method) |
3954 (mapcar | |
3955 '(lambda (x) | |
46752 | 3956 (format-spec x `((?u . ,user)))) |
45861 | 3957 (tramp-get-su-args multi-method method)))) |
3958 (found nil) | |
3959 (pw nil)) | |
3960 (process-kill-without-query p) | |
46752 | 3961 (set-buffer (tramp-get-buffer multi-method method user host)) |
3962 (tramp-process-actions p multi-method method user host | |
3963 tramp-actions-before-shell) | |
3964 | |
3965 ;; (tramp-message 9 "Waiting 30s for shell or password prompt...") | |
3966 ;; (unless (setq found (tramp-wait-for-regexp | |
3967 ;; p 30 | |
3968 ;; (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3969 ;; tramp-password-prompt-regexp | |
3970 ;; shell-prompt-pattern))) | |
3971 ;; (pop-to-buffer (buffer-name)) | |
3972 ;; (kill-process p) | |
3973 ;; (error "Couldn't find shell or password prompt")) | |
3974 ;; (when (nth 1 found) | |
3975 ;; (erase-buffer) | |
3976 ;; (setq pw (tramp-read-passwd (car found))) | |
3977 ;; (tramp-message 9 "Sending password") | |
3978 ;; (process-send-string p (concat pw tramp-rsh-end-of-line)) | |
3979 ;; (tramp-message 9 "Waiting 30s for remote shell to come up...") | |
3980 ;; (unless (setq found | |
3981 ;; (tramp-wait-for-regexp | |
3982 ;; p 30 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3983 ;; tramp-wrong-passwd-regexp | |
3984 ;; shell-prompt-pattern))) | |
3985 ;; (pop-to-buffer (buffer-name)) | |
3986 ;; (kill-process p) | |
3987 ;; (error "Couldn't find remote shell prompt")) | |
3988 ;; (when (nth 1 found) | |
3989 ;; (pop-to-buffer (buffer-name)) | |
3990 ;; (kill-process p) | |
3991 ;; (error "`su' failed: %s" (nth 1 found)))) | |
3992 | |
45861 | 3993 (tramp-open-connection-setup-interactive-shell |
3994 p multi-method method user host) | |
3995 (tramp-post-connection multi-method method | |
3996 user host))))) | |
3997 | |
3998 ;; HHH: Not Changed. Multi method. It is not clear to me how this can | |
3999 ;; handle not giving a user name in the "file name". | |
4000 ;; | |
4001 ;; This is more difficult than for the single-hop method. In the | |
4002 ;; multi-hop-method, the desired behaviour should be that the | |
4003 ;; user must specify names for the telnet hops of which the user | |
4004 ;; name is different than the "original" name (or different from | |
4005 ;; the previous hop. | |
4006 (defun tramp-open-connection-multi (multi-method method user host) | |
4007 "Open a multi-hop connection using METHOD. | |
4008 This uses a slightly changed file name syntax. The idea is to say | |
4009 [multi/telnet:u1@h1/rsh:u2@h2]/path/to/file | |
4010 This will use telnet to log in as u1 to h1, then use rsh from there to | |
4011 log in as u2 to h2." | |
4012 (save-match-data | |
4013 (unless multi-method | |
4014 (error "Multi-hop open connection function called on non-multi method")) | |
4015 (when (tramp-method-out-of-band-p multi-method method) | |
4016 (error "No out of band multi-hop connections")) | |
4017 (unless (and (arrayp method) (not (stringp method))) | |
4018 (error "METHOD must be an array of strings for multi methods")) | |
4019 (unless (and (arrayp user) (not (stringp user))) | |
4020 (error "USER must be an array of strings for multi methods")) | |
4021 (unless (and (arrayp host) (not (stringp host))) | |
4022 (error "HOST must be an array of strings for multi methods")) | |
4023 (unless (and (= (length method) (length user)) | |
4024 (= (length method) (length host))) | |
4025 (error "Arrays METHOD, USER, HOST must have equal length")) | |
4026 (tramp-pre-connection multi-method method user host) | |
4027 (tramp-message 7 "Opening `%s' connection..." multi-method) | |
4028 (let ((process-environment (copy-sequence process-environment))) | |
4029 (setenv "TERM" tramp-terminal-type) | |
4030 (let* ((default-directory (tramp-temporary-file-directory)) | |
4031 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
4032 (> emacs-major-version 20)) | |
4033 tramp-dos-coding-system)) | |
4034 (p (start-process (tramp-buffer-name multi-method method user host) | |
4035 (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
|
4036 tramp-multi-sh-program)) |
45861 | 4037 (num-hops (length method)) |
4038 (i 0)) | |
4039 (process-kill-without-query p) | |
4040 (tramp-message 9 "Waiting 60s for local shell to come up...") | |
4041 (unless (tramp-wait-for-regexp | |
4042 p 60 (format "%s\\'" shell-prompt-pattern)) | |
4043 (pop-to-buffer (buffer-name)) | |
4044 (kill-process p) | |
4045 (error "Couldn't find local shell prompt")) | |
4046 ;; Now do all the connections as specified. | |
4047 (while (< i num-hops) | |
4048 (let* ((m (aref method i)) | |
4049 (u (aref user i)) | |
4050 (h (aref host i)) | |
4051 (entry (assoc m tramp-multi-connection-function-alist)) | |
4052 (multi-func (nth 1 entry)) | |
4053 (command (nth 2 entry))) | |
4054 ;; The multi-funcs don't need to do save-match-data, as that | |
4055 ;; is done here. | |
4056 (funcall multi-func p m u h command) | |
4057 (erase-buffer) | |
4058 (incf i))) | |
4059 (tramp-open-connection-setup-interactive-shell | |
4060 p multi-method method user host) | |
4061 (tramp-post-connection multi-method method user host))))) | |
4062 | |
4063 ;; HHH: Changed. Multi method. Don't know how to handle this in the case | |
4064 ;; of no user name provided. Hack to make it work as it did before: | |
4065 ;; changed `user' to `(or user (user-login-name))' in the places where | |
4066 ;; the value is actually used. | |
4067 (defun tramp-multi-connect-telnet (p method user host command) | |
4068 "Issue `telnet' command. | |
4069 Uses shell COMMAND to issue a `telnet' command to log in as USER to | |
4070 HOST. You can use percent escapes in COMMAND: `%h' is replaced with | |
4071 the host name, and `%n' is replaced with an end of line character, as | |
4072 set in `tramp-rsh-end-of-line'. Use `%%' if you want a literal percent | |
4073 character. | |
4074 | |
4075 If USER is nil, uses the return value of (user-login-name) instead." | |
46752 | 4076 (let ((cmd (format-spec command |
4077 `((?h . ,host) (?n . ,tramp-rsh-end-of-line)))) | |
4078 (cmd1 (format-spec command `((?h . ,host) (?n . "")))) | |
45861 | 4079 found pw) |
4080 (erase-buffer) | |
4081 (tramp-message 9 "Sending telnet command `%s'" cmd1) | |
4082 (process-send-string p cmd) | |
46752 | 4083 (tramp-process-multi-actions p method user host |
4084 tramp-multi-actions) | |
4085 | |
4086 ;; (tramp-message 9 "Waiting 30s for login prompt from %s" host) | |
4087 ;; (unless (tramp-wait-for-regexp p 30 tramp-login-prompt-regexp) | |
4088 ;; (pop-to-buffer (buffer-name)) | |
4089 ;; (kill-process p) | |
4090 ;; (error "Couldn't find login prompt from host %s" host)) | |
4091 ;; (erase-buffer) | |
4092 ;; (tramp-message 9 "Sending login name %s" (or user (user-login-name))) | |
4093 ;; (process-send-string p (concat (or user (user-login-name)) tramp-rsh-end-of-line)) | |
4094 ;; (tramp-message 9 "Waiting for password prompt") | |
4095 ;; (unless (setq found (tramp-wait-for-regexp p nil tramp-password-prompt-regexp)) | |
4096 ;; (pop-to-buffer (buffer-name)) | |
4097 ;; (kill-process p) | |
4098 ;; (error "Couldn't find password prompt from host %s" host)) | |
4099 ;; (erase-buffer) | |
4100 ;; (setq pw (tramp-read-passwd | |
4101 ;; (format "Password for %s@%s, %s" (or user (user-login-name)) host found))) | |
4102 ;; (tramp-message 9 "Sending password") | |
4103 ;; (process-send-string p (concat pw tramp-rsh-end-of-line)) | |
4104 ;; (tramp-message 9 "Waiting 60s for remote shell to come up...") | |
4105 ;; (unless (setq found (tramp-wait-for-regexp | |
4106 ;; p 60 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
4107 ;; tramp-wrong-passwd-regexp | |
4108 ;; shell-prompt-pattern))) | |
4109 ;; (pop-to-buffer (buffer-name)) | |
4110 ;; (kill-process p) | |
4111 ;; (error "Couldn't find shell prompt from host %s" host)) | |
4112 ;; (when (nth 1 found) | |
4113 ;; (pop-to-buffer (buffer-name)) | |
4114 ;; (kill-process p) | |
4115 ;; (error "Login to %s failed: %s" (nth 2 found))) | |
4116 )) | |
45861 | 4117 |
4118 ;; HHH: Changed. Multi method. Don't know how to handle this in the case | |
4119 ;; of no user name provided. Hack to make it work as it did before: | |
4120 ;; changed `user' to `(or user (user-login-name))' in the places where | |
4121 ;; the value is actually used. | |
4122 (defun tramp-multi-connect-rlogin (p method user host command) | |
4123 "Issue `rlogin' command. | |
4124 Uses shell COMMAND to issue an `rlogin' command to log in as USER to | |
4125 HOST. You can use percent escapes in COMMAND. `%u' will be replaced | |
4126 with the user name, `%h' will be replaced with the host name, and `%n' | |
4127 will be replaced with the value of `tramp-rsh-end-of-line'. You can use | |
4128 `%%' if you want to use a literal percent character. | |
4129 | |
4130 If USER is nil, uses the return value of (user-login-name) instead." | |
46752 | 4131 (let ((cmd (format-spec command `((?h . ,host) |
4132 (?u . ,(or user (user-login-name))) | |
4133 (?n . ,tramp-rsh-end-of-line)))) | |
4134 (cmd1 (format-spec command `((?h . ,host) | |
4135 (?u . ,(or user (user-login-name))) | |
4136 (?n . "")))) | |
45861 | 4137 found) |
4138 (erase-buffer) | |
4139 (tramp-message 9 "Sending rlogin command `%s'" cmd1) | |
4140 (process-send-string p cmd) | |
46752 | 4141 (tramp-process-multi-actions p method user host |
4142 tramp-multi-actions) | |
4143 ;; (tramp-message 9 "Waiting 60s for shell or passwd prompt from %s" host) | |
4144 ;; (unless (setq found | |
4145 ;; (tramp-wait-for-regexp p 60 | |
4146 ;; (format "\\(%s\\)\\|\\(%s\\)\\'" | |
4147 ;; tramp-password-prompt-regexp | |
4148 ;; shell-prompt-pattern))) | |
4149 ;; (pop-to-buffer (buffer-name)) | |
4150 ;; (kill-process p) | |
4151 ;; (error "Couldn't find remote shell or passwd prompt")) | |
4152 ;; (when (nth 1 found) | |
4153 ;; (erase-buffer) | |
4154 ;; (tramp-message 9 "Sending password...") | |
4155 ;; (tramp-enter-password p (nth 1 found)) | |
4156 ;; (tramp-message 9 "Sent password, waiting 60s for remote shell prompt") | |
4157 ;; (setq found (tramp-wait-for-regexp p 60 | |
4158 ;; (format "\\(%s\\)\\|\\(%s\\)\\'" | |
4159 ;; tramp-wrong-passwd-regexp | |
4160 ;; shell-prompt-pattern)))) | |
4161 ;; (unless found | |
4162 ;; (pop-to-buffer (buffer-name)) | |
4163 ;; (kill-process p) | |
4164 ;; (error "Couldn't find remote shell prompt")) | |
4165 ;; (when (nth 1 found) | |
4166 ;; (pop-to-buffer (buffer-name)) | |
4167 ;; (kill-process p) | |
4168 ;; (error "Login failed: %s" (nth 1 found))) | |
4169 )) | |
45861 | 4170 |
4171 ;; HHH: Changed. Multi method. Don't know how to handle this in the case | |
4172 ;; of no user name provided. Hack to make it work as it did before: | |
4173 ;; changed `user' to `(or user (user-login-name))' in the places where | |
4174 ;; the value is actually used. | |
4175 (defun tramp-multi-connect-su (p method user host command) | |
4176 "Issue `su' command. | |
4177 Uses shell COMMAND to issue a `su' command to log in as USER on | |
4178 HOST. The HOST name is ignored, this just changes the user id on the | |
4179 host currently logged in to. | |
4180 | |
4181 If USER is nil, uses the return value of (user-login-name) instead. | |
4182 | |
4183 You can use percent escapes in the COMMAND. `%u' is replaced with the | |
4184 user name, and `%n' is replaced with the value of | |
4185 `tramp-rsh-end-of-line'. Use `%%' if you want a literal percent | |
4186 character." | |
46752 | 4187 (let ((cmd (format-spec command `((?u . ,(or user (user-login-name))) |
4188 (?n . ,tramp-rsh-end-of-line)))) | |
4189 (cmd1 (format-spec command `((?u . ,(or user (user-login-name))) | |
4190 (?n . "")))) | |
45861 | 4191 found) |
4192 (erase-buffer) | |
4193 (tramp-message 9 "Sending su command `%s'" cmd1) | |
4194 (process-send-string p cmd) | |
46752 | 4195 (tramp-process-multi-actions p method user host |
4196 tramp-multi-actions) | |
4197 ;; (tramp-message 9 "Waiting 60s for shell or passwd prompt for %s" (or user (user-login-name))) | |
4198 ;; (unless (setq found (tramp-wait-for-regexp | |
4199 ;; p 60 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
4200 ;; tramp-password-prompt-regexp | |
4201 ;; shell-prompt-pattern))) | |
4202 ;; (pop-to-buffer (buffer-name)) | |
4203 ;; (kill-process p) | |
4204 ;; (error "Couldn't find shell or passwd prompt for %s" | |
4205 ;; (or user (user-login-name)))) | |
4206 ;; (when (nth 1 found) | |
4207 ;; (tramp-message 9 "Sending password...") | |
4208 ;; (tramp-enter-password p (nth 1 found)) | |
4209 ;; (erase-buffer) | |
4210 ;; (tramp-message 9 "Sent password, waiting 60s for remote shell prompt") | |
4211 ;; (setq found (tramp-wait-for-regexp p 60 | |
4212 ;; (format "\\(%s\\)\\|\\(%s\\)\\'" | |
4213 ;; tramp-wrong-passwd-regexp | |
4214 ;; shell-prompt-pattern)))) | |
4215 ;; (unless found | |
4216 ;; (pop-to-buffer (buffer-name)) | |
4217 ;; (kill-process p) | |
4218 ;; (error "Couldn't find remote shell prompt")) | |
4219 ;; (when (nth 1 found) | |
4220 ;; (pop-to-buffer (buffer-name)) | |
4221 ;; (kill-process p) | |
4222 ;; (error "Login failed: %s" (nth 1 found))) | |
4223 )) | |
45861 | 4224 |
4225 ;; Utility functions. | |
4226 | |
4227 (defun tramp-wait-for-regexp (proc timeout regexp) | |
4228 "Wait for a REGEXP to appear from process PROC within TIMEOUT seconds. | |
4229 Expects the output of PROC to be sent to the current buffer. Returns | |
4230 the string that matched, or nil. Waits indefinitely if TIMEOUT is | |
4231 nil." | |
4232 (let ((found nil) | |
4233 (start-time (current-time))) | |
4234 (cond (timeout | |
4235 ;; Work around a bug in XEmacs 21, where the timeout | |
4236 ;; expires faster than it should. This degenerates | |
4237 ;; to polling for buggy XEmacsen, but oh, well. | |
4238 (while (and (not found) | |
4239 (< (tramp-time-diff (current-time) start-time) | |
4240 timeout)) | |
4241 (with-timeout (timeout) | |
4242 (while (not found) | |
4243 (accept-process-output proc 1) | |
4244 (goto-char (point-min)) | |
4245 (setq found (when (re-search-forward regexp nil t) | |
4246 (tramp-match-string-list))))))) | |
4247 (t | |
4248 (while (not found) | |
4249 (accept-process-output proc 1) | |
4250 (goto-char (point-min)) | |
4251 (setq found (when (re-search-forward regexp nil t) | |
4252 (tramp-match-string-list)))))) | |
4253 (when tramp-debug-buffer | |
4254 (append-to-buffer | |
4255 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4256 tramp-current-user tramp-current-host) | |
4257 (point-min) (point-max)) | |
4258 (when (not found) | |
4259 (save-excursion | |
4260 (set-buffer | |
4261 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4262 tramp-current-user tramp-current-host)) | |
4263 (goto-char (point-max)) | |
4264 (insert "[[Regexp `" regexp "' not found" | |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
4265 (if timeout (format " in %d secs" timeout) "") |
45861 | 4266 "]]")))) |
4267 found)) | |
4268 | |
4269 (defun tramp-enter-password (p prompt) | |
4270 "Prompt for a password and send it to the remote end. | |
4271 Uses PROMPT as a prompt and sends the password to process P." | |
4272 (let ((pw (tramp-read-passwd prompt))) | |
46752 | 4273 (erase-buffer) |
45861 | 4274 (process-send-string p (concat pw tramp-rsh-end-of-line)))) |
4275 | |
4276 ;; HHH: Not Changed. This might handle the case where USER is not | |
4277 ;; given in the "File name" very poorly. Then, the local | |
4278 ;; variable tramp-current user will be set to nil. | |
4279 (defun tramp-pre-connection (multi-method method user host) | |
4280 "Do some setup before actually logging in. | |
4281 METHOD, USER and HOST specify the connection." | |
4282 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4283 (set (make-local-variable 'tramp-current-multi-method) multi-method) | |
4284 (set (make-local-variable 'tramp-current-method) method) | |
4285 (set (make-local-variable 'tramp-current-user) user) | |
4286 (set (make-local-variable 'tramp-current-host) host) | |
4287 (set (make-local-variable 'inhibit-eol-conversion) nil) | |
4288 (erase-buffer)) | |
4289 | |
4290 (defun tramp-open-connection-setup-interactive-shell | |
4291 (p multi-method method user host) | |
4292 "Set up an interactive shell. | |
4293 Mainly sets the prompt and the echo correctly. P is the shell process | |
4294 to set up. METHOD, USER and HOST specify the connection." | |
4295 ;; Wait a bit in case the remote end feels like sending a little | |
4296 ;; junk first. It seems that fencepost.gnu.org does this when doing | |
4297 ;; a Kerberos login. | |
4298 (sit-for 1) | |
4299 (tramp-discard-garbage-erase-buffer p multi-method method user host) | |
4300 (process-send-string nil (format "exec %s%s" | |
4301 (tramp-get-remote-sh multi-method method) | |
4302 tramp-rsh-end-of-line)) | |
4303 (when tramp-debug-buffer | |
4304 (save-excursion | |
4305 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
4306 (goto-char (point-max)) | |
4307 (tramp-insert-with-face | |
4308 'bold (format "$ exec %s\n" (tramp-get-remote-sh multi-method method))))) | |
4309 (tramp-message 9 "Waiting 30s for remote `%s' to come up..." | |
4310 (tramp-get-remote-sh multi-method method)) | |
4311 (unless (tramp-wait-for-regexp | |
4312 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4313 (pop-to-buffer (buffer-name)) | |
4314 (error "Remote `%s' didn't come up. See buffer `%s' for details" | |
4315 (tramp-get-remote-sh multi-method method) (buffer-name))) | |
4316 (tramp-message 9 "Setting up remote shell environment") | |
4317 (tramp-discard-garbage-erase-buffer p multi-method method user host) | |
4318 (process-send-string | |
4319 nil (format "stty -inlcr -echo kill '^U'%s" tramp-rsh-end-of-line)) | |
4320 (unless (tramp-wait-for-regexp | |
4321 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4322 (pop-to-buffer (buffer-name)) | |
4323 (error "Couldn't `stty -echo', see buffer `%s'" (buffer-name))) | |
4324 (erase-buffer) | |
4325 (process-send-string nil (format "TERM=dumb; export TERM%s" | |
4326 tramp-rsh-end-of-line)) | |
4327 (unless (tramp-wait-for-regexp | |
4328 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4329 (pop-to-buffer (buffer-name)) | |
4330 (error "Couldn't `TERM=dumb; export TERM', see buffer `%s'" (buffer-name))) | |
4331 ;; Try to set up the coding system correctly. | |
4332 ;; CCC this can't be the right way to do it. Hm. | |
4333 (save-excursion | |
4334 (erase-buffer) | |
4335 (tramp-message 9 "Determining coding system") | |
4336 (process-send-string nil (format "echo foo ; echo bar %s" | |
4337 tramp-rsh-end-of-line)) | |
4338 (unless (tramp-wait-for-regexp | |
4339 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4340 (pop-to-buffer (buffer-name)) | |
4341 (error "Couldn't `echo foo; echo bar' to determine line endings'")) | |
4342 (goto-char (point-min)) | |
4343 (if (featurep 'mule) | |
4344 ;; Use MULE to select the right EOL convention for communicating | |
4345 ;; with the process. | |
4346 (let* ((cs (or (process-coding-system p) (cons 'undecided 'undecided))) | |
4347 cs-decode cs-encode) | |
4348 (when (symbolp cs) (setq cs (cons cs cs))) | |
4349 (setq cs-decode (car cs)) | |
4350 (setq cs-encode (cdr cs)) | |
4351 (unless cs-decode (setq cs-decode 'undecided)) | |
4352 (unless cs-encode (setq cs-encode 'undecided)) | |
4353 (setq cs-encode (tramp-coding-system-change-eol-conversion | |
4354 cs-encode 'unix)) | |
4355 (when (search-forward "\r" nil t) | |
4356 (setq cs-decode (tramp-coding-system-change-eol-conversion | |
4357 cs-decode 'dos))) | |
4358 (set-buffer-process-coding-system cs-decode cs-encode)) | |
4359 ;; Look for ^M and do something useful if found. | |
4360 (when (search-forward "\r" nil t) | |
4361 ;; We have found a ^M but cannot frob the process coding system | |
4362 ;; because we're running on a non-MULE Emacs. Let's try | |
4363 ;; stty, instead. | |
4364 (tramp-message 9 "Trying `stty -onlcr'") | |
4365 (process-send-string nil (format "stty -onlcr%s" tramp-rsh-end-of-line)) | |
4366 (unless (tramp-wait-for-regexp | |
4367 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4368 (pop-to-buffer (buffer-name)) | |
4369 (error "Couldn't `stty -onlcr', see buffer `%s'" (buffer-name)))))) | |
4370 (erase-buffer) | |
4371 (tramp-message | |
4372 9 "Waiting 30s for `HISTFILE=$HOME/.tramp_history; HISTSIZE=1'") | |
4373 (process-send-string | |
4374 nil (format "HISTFILE=$HOME/.tramp_history; HISTSIZE=1%s" | |
4375 tramp-rsh-end-of-line)) | |
4376 (unless (tramp-wait-for-regexp | |
4377 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4378 (pop-to-buffer (buffer-name)) | |
4379 (error (concat "Couldn't `HISTFILE=$HOME/.tramp_history; " | |
4380 "HISTSIZE=1', see buffer `%s'") | |
4381 (buffer-name))) | |
4382 (erase-buffer) | |
4383 (tramp-message 9 "Waiting 30s for `set +o vi +o emacs'") | |
4384 (process-send-string | |
4385 nil (format "set +o vi +o emacs%s" ;mustn't `>/dev/null' with AIX? | |
4386 tramp-rsh-end-of-line)) | |
4387 (unless (tramp-wait-for-regexp | |
4388 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4389 (pop-to-buffer (buffer-name)) | |
4390 (error "Couldn't `set +o vi +o emacs', see buffer `%s'" | |
4391 (buffer-name))) | |
4392 (erase-buffer) | |
4393 (tramp-message 9 "Waiting 30s for `unset MAIL MAILCHECK MAILPATH'") | |
4394 (process-send-string | |
4395 nil (format "unset MAIL MAILCHECK MAILPATH 1>/dev/null 2>/dev/null%s" | |
4396 tramp-rsh-end-of-line)) | |
4397 (unless (tramp-wait-for-regexp | |
4398 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4399 (pop-to-buffer (buffer-name)) | |
4400 (error "Couldn't `unset MAIL MAILCHECK MAILPATH', see buffer `%s'" | |
4401 (buffer-name))) | |
4402 (erase-buffer) | |
4403 (tramp-message 9 "Waiting 30s for `unset CDPATH'") | |
4404 (process-send-string | |
4405 nil (format "unset CDPATH%s" tramp-rsh-end-of-line)) | |
4406 (unless (tramp-wait-for-regexp | |
4407 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4408 (pop-to-buffer (buffer-name)) | |
4409 (error "Couldn't `unset CDPATH', see buffer `%s'" | |
4410 (buffer-name))) | |
4411 (erase-buffer) | |
4412 (tramp-message 9 "Setting shell prompt") | |
4413 (tramp-send-command | |
4414 multi-method method user host | |
4415 (format "PS1='%s%s%s'; PS2=''; PS3=''" | |
4416 tramp-rsh-end-of-line | |
4417 tramp-end-of-output | |
4418 tramp-rsh-end-of-line)) | |
4419 (tramp-wait-for-output) | |
4420 (tramp-send-command multi-method method user host "echo hello") | |
4421 (tramp-message 9 "Waiting for remote `%s' to come up..." | |
4422 (tramp-get-remote-sh multi-method method)) | |
4423 (unless (tramp-wait-for-output 5) | |
4424 (unless (tramp-wait-for-output 5) | |
4425 (pop-to-buffer (buffer-name)) | |
4426 (error "Couldn't set remote shell prompt. See buffer `%s' for details" | |
4427 (buffer-name)))) | |
4428 (tramp-message 7 "Waiting for remote `%s' to come up...done" | |
4429 (tramp-get-remote-sh multi-method method))) | |
4430 | |
4431 (defun tramp-post-connection (multi-method method user host) | |
4432 "Prepare a remote shell before being able to work on it. | |
4433 METHOD, USER and HOST specify the connection. | |
4434 Among other things, this finds a shell which groks tilde expansion, | |
4435 tries to find an `ls' command which groks the `-n' option, sets the | |
4436 locale to C and sets up the remote shell search path." | |
4437 ;; Search for a good shell before searching for a command which | |
4438 ;; checks if a file exists. This is done because Tramp wants to use | |
4439 ;; "test foo; echo $?" to check if various conditions hold, and | |
4440 ;; there are buggy /bin/sh implementations which don't execute the | |
4441 ;; "echo $?" part if the "test" part has an error. In particular, | |
4442 ;; the Solaris /bin/sh is a problem. I'm betting that all systems | |
4443 ;; with buggy /bin/sh implementations will have a working bash or | |
4444 ;; ksh. Whee... | |
4445 (tramp-find-shell multi-method method user host) | |
4446 ;; Without (sit-for 0.1) at least, my machine will almost always blow | |
4447 ;; up on 'not numberp /root' - a race that causes the 'echo ~root' | |
4448 ;; output of (tramp-find-shell) to show up along with the output of | |
4449 ;; (tramp-find-ls-command) testing. | |
4450 ;; | |
4451 ;; I can't work out why this is a problem though. The (tramp-wait-for-output) | |
4452 ;; call in (tramp-find-shell) *should* make this not happen, I thought. | |
4453 ;; | |
4454 ;; After much debugging I couldn't find any problem with the implementation | |
4455 ;; of that function though. The workaround stays for me at least. :/ | |
4456 ;; | |
4457 ;; Daniel Pittman <daniel@danann.net> | |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4458 (sleep-for 1) |
46808
cf225aed7a75
Version 2.0.11 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46802
diff
changeset
|
4459 (erase-buffer) |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4460 (tramp-find-file-exists-command multi-method method user host) |
45861 | 4461 (make-local-variable 'tramp-ls-command) |
4462 (setq tramp-ls-command (tramp-find-ls-command multi-method method user host)) | |
4463 (unless tramp-ls-command | |
4464 (tramp-message | |
4465 1 | |
4466 "Danger! Couldn't find ls which groks -n. Muddling through anyway") | |
4467 (setq tramp-ls-command | |
4468 (tramp-find-executable multi-method method user host | |
4469 "ls" tramp-remote-path nil))) | |
4470 (unless tramp-ls-command | |
4471 (error "Fatal error: Couldn't find remote executable `ls'")) | |
4472 (tramp-message 5 "Using remote command `%s' for getting directory listings" | |
4473 tramp-ls-command) | |
4474 (tramp-send-command multi-method method user host | |
4475 (concat "tramp_set_exit_status () {" tramp-rsh-end-of-line | |
4476 "return $1" tramp-rsh-end-of-line | |
4477 "}")) | |
4478 (tramp-wait-for-output) | |
4479 ;; Set remote PATH variable. | |
4480 (tramp-set-remote-path multi-method method user host "PATH" tramp-remote-path) | |
4481 ;; Tell remote shell to use standard time format, needed for | |
4482 ;; parsing `ls -l' output. | |
4483 (tramp-send-command multi-method method user host | |
4484 "LC_TIME=C; export LC_TIME; echo huhu") | |
4485 (tramp-wait-for-output) | |
4486 (tramp-send-command multi-method method user host | |
4487 "mesg n; echo huhu") | |
4488 (tramp-wait-for-output) | |
4489 (tramp-send-command multi-method method user host | |
4490 "biff n ; echo huhu") | |
4491 (tramp-wait-for-output) | |
4492 ;; Unalias ls(1) to work around issues with those silly people who make it | |
4493 ;; spit out ANSI escapes or whatever. | |
4494 (tramp-send-command multi-method method user host | |
4495 "unalias ls; echo huhu") | |
4496 (tramp-wait-for-output) | |
4497 ;; Does `test A -nt B' work? Use abominable `find' construct if it | |
4498 ;; doesn't. BSD/OS 4.0 wants the parentheses around the command, | |
4499 ;; for otherwise the shell crashes. | |
4500 (erase-buffer) | |
4501 (make-local-variable 'tramp-test-groks-nt) | |
4502 (tramp-send-command multi-method method user host | |
4503 "( test / -nt / )") | |
4504 (tramp-wait-for-output) | |
4505 (goto-char (point-min)) | |
4506 (setq tramp-test-groks-nt | |
4507 (looking-at (format "\n%s\n" (regexp-quote tramp-end-of-output)))) | |
4508 (unless tramp-test-groks-nt | |
4509 (tramp-send-command | |
4510 multi-method method user host | |
4511 (concat "tramp_test_nt () {" tramp-rsh-end-of-line | |
4512 "test -n \"`find $1 -prune -newer $2 -print`\"" tramp-rsh-end-of-line | |
4513 "}"))) | |
4514 (tramp-wait-for-output) | |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4515 ;; Send the fallback `uudecode' script. |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4516 (erase-buffer) |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4517 (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
|
4518 (tramp-wait-for-output) |
45861 | 4519 ;; Find a `perl'. |
4520 (erase-buffer) | |
4521 (let ((tramp-remote-perl | |
4522 (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
|
4523 "perl5" tramp-remote-path nil) |
45861 | 4524 (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
|
4525 "perl" tramp-remote-path nil)))) |
45861 | 4526 (when tramp-remote-perl |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4527 (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
|
4528 multi-method method user host) |
45861 | 4529 ;; Set up stat in Perl if we can. |
4530 (when tramp-remote-perl | |
4531 (tramp-message 5 "Sending the Perl `file-attributes' implementation.") | |
4532 (tramp-send-linewise | |
4533 multi-method method user host | |
4534 (concat "tramp_file_attributes () {\n" | |
4535 tramp-remote-perl | |
4536 " -e '" tramp-perl-file-attributes "' $1 2>/dev/null\n" | |
4537 "}")) | |
4538 (tramp-wait-for-output) | |
46790 | 4539 (tramp-message 5 "Sending the Perl `mime-encode' implementations.") |
46752 | 4540 (tramp-send-linewise |
4541 multi-method method user host | |
4542 (concat "tramp_encode () {\n" | |
4543 (format tramp-perl-encode tramp-remote-perl) | |
4544 " 2>/dev/null" | |
4545 "\n}")) | |
4546 (tramp-wait-for-output) | |
46790 | 4547 (tramp-send-linewise |
4548 multi-method method user host | |
4549 (concat "tramp_encode_with_module () {\n" | |
4550 (format tramp-perl-encode-with-module tramp-remote-perl) | |
4551 " 2>/dev/null" | |
4552 "\n}")) | |
4553 (tramp-wait-for-output) | |
4554 (tramp-message 5 "Sending the Perl `mime-decode' implementations.") | |
46752 | 4555 (tramp-send-linewise |
4556 multi-method method user host | |
4557 (concat "tramp_decode () {\n" | |
4558 (format tramp-perl-decode tramp-remote-perl) | |
4559 " 2>/dev/null" | |
4560 "\n}")) | |
46790 | 4561 (tramp-wait-for-output) |
4562 (tramp-send-linewise | |
4563 multi-method method user host | |
4564 (concat "tramp_decode_with_module () {\n" | |
4565 (format tramp-perl-decode-with-module tramp-remote-perl) | |
4566 " 2>/dev/null" | |
4567 "\n}")) | |
46752 | 4568 (tramp-wait-for-output)))) |
45861 | 4569 ;; Find ln(1) |
4570 (erase-buffer) | |
4571 (let ((ln (tramp-find-executable multi-method method user host | |
4572 "ln" tramp-remote-path nil))) | |
4573 (when ln | |
4574 (tramp-set-connection-property "ln" ln multi-method method user host))) | |
4575 (erase-buffer) | |
46752 | 4576 ;; Find the right encoding/decoding commands to use. |
4577 (unless (tramp-get-rcp-program multi-method method) | |
4578 (tramp-find-inline-encoding multi-method method user host)) | |
45861 | 4579 ;; If encoding/decoding command are given, test to see if they work. |
4580 ;; CCC: Maybe it would be useful to run the encoder both locally and | |
4581 ;; remotely to see if they produce the same result. | |
46752 | 4582 (let ((decoding (tramp-get-decoding-command multi-method method user host)) |
4583 (encoding (tramp-get-encoding-command multi-method method user host)) | |
45861 | 4584 (magic-string "xyzzy")) |
4585 (when (and (or decoding encoding) (not (and decoding encoding))) | |
4586 (tramp-kill-process multi-method method user host) | |
4587 (error | |
4588 "Must give both decoding and encoding command in method definition")) | |
4589 (when (and decoding encoding) | |
4590 (tramp-message | |
4591 5 | |
4592 "Checking to see if encoding/decoding commands work on remote host...") | |
4593 (tramp-send-command | |
4594 multi-method method user host | |
4595 (format "echo %s | %s | %s" | |
4596 (tramp-shell-quote-argument magic-string) encoding decoding)) | |
4597 (tramp-wait-for-output) | |
4598 (unless (looking-at (regexp-quote magic-string)) | |
4599 (tramp-kill-process multi-method method user host) | |
4600 (error "Remote host cannot execute de/encoding commands. See buffer `%s' for details" | |
4601 (buffer-name))) | |
4602 (erase-buffer) | |
4603 (tramp-message | |
4604 5 "Checking to see if encoding/decoding commands work on remote host...done")))) | |
4605 | |
46752 | 4606 ;; CCC: We should either implement a Perl version of base64 encoding |
4607 ;; and decoding. Then we just use that in the last item. The other | |
4608 ;; alternative is to use the Perl version of UU encoding. But then | |
4609 ;; we need a Lisp version of uuencode. | |
4610 (defvar tramp-coding-commands | |
4611 '(("mimencode -b" "mimencode -u -b" | |
4612 base64-encode-region base64-decode-region) | |
4613 ("mmencode -b" "mmencode -u -b" | |
4614 base64-encode-region base64-decode-region) | |
4615 ("recode data..base64" "recode base64..data" | |
4616 base64-encode-region base64-decode-region) | |
4617 ("uuencode xxx" "uudecode -o -" | |
4618 nil uudecode-decode-region) | |
4619 ("uuencode xxx" "uudecode -p" | |
4620 nil uudecode-decode-region) | |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4621 ("uuencode xxx" "tramp_uudecode" |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
4622 nil uudecode-decode-region) |
46790 | 4623 ("tramp_encode_with_module" "tramp_decode_with_module" |
4624 base64-encode-region base64-decode-region) | |
46752 | 4625 ("tramp_encode" "tramp_decode" |
4626 base64-encode-region base64-decode-region)) | |
4627 "List of coding commands for inline transfer. | |
4628 Each item is a list (ENCODING-COMMAND DECODING-COMMAND | |
4629 ENCODING-FUNCTION DECODING-FUNCTION). | |
4630 | |
4631 Each item can be a string, giving a command, or a symbol, giving | |
4632 a function. | |
4633 | |
4634 The ENCODING-COMMAND should be a command accepting a plain file on | |
4635 standard input and writing the encoded file to standard output. The | |
4636 DECODING-COMMAND should be a command accepting an encoded file on | |
4637 standard input and writing the decoded file to standard output. | |
4638 | |
4639 The ENCODING-FUNCTION and DECODING-FUNCTION functions will be called | |
4640 with two arguments, start and end of region, and are expected to | |
4641 replace the region contents with the encoded or decoded results, | |
4642 respectively.") | |
4643 | |
4644 (defun tramp-find-inline-encoding (multi-method method user host) | |
4645 "Find an inline transfer encoding that works. | |
4646 Goes through the list `tramp-coding-commands'." | |
4647 (let ((commands tramp-coding-commands) | |
4648 item found) | |
4649 (while (and commands (null found)) | |
4650 (setq item (pop commands)) | |
4651 (catch 'wont-work | |
4652 (let ((ec (nth 0 item)) | |
4653 (dc (nth 1 item)) | |
4654 (ef (nth 2 item)) | |
4655 (df (nth 3 item))) | |
4656 ;; Check if encoding and decoding commands can be called | |
4657 ;; remotely with null input and output. This makes sure there | |
4658 ;; are no syntax errors and the command is really found. | |
4659 (tramp-message-for-buffer | |
4660 multi-method method user host 10 | |
4661 "Checking remote encoding command `%s' for sanity" ec) | |
4662 (unless (zerop (tramp-send-command-and-check | |
4663 multi-method method user host | |
4664 (format "%s </dev/null >/dev/null" ec) t)) | |
4665 (throw 'wont-work nil)) | |
4666 (tramp-message-for-buffer | |
4667 multi-method method user host 10 | |
4668 "Checking remote decoding command `%s' for sanity" dc) | |
4669 (unless (zerop (tramp-send-command-and-check | |
4670 multi-method method user host | |
46801
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
4671 (format "echo xyzzy | %s | %s >/dev/null" ec dc) t)) |
46752 | 4672 (throw 'wont-work nil)) |
4673 ;; If no encoding/decoding function is given, the | |
4674 ;; corresponding encoding/decoding command also has to work | |
4675 ;; locally. | |
4676 (when (not (fboundp ef)) | |
4677 (tramp-message-for-buffer | |
4678 multi-method method user host 10 | |
4679 "Checking local encoding command `%s' for sanity" ec) | |
4680 (unless (zerop (call-process | |
4681 tramp-sh-program ;program | |
4682 nil ;input | |
4683 nil ;output buffer | |
4684 nil ;redisplay | |
4685 "-c" | |
4686 (format "%s </dev/null >/dev/null" ec))) | |
4687 (throw 'wont-work nil))) | |
4688 (when (not (fboundp df)) | |
4689 (tramp-message-for-buffer | |
4690 multi-method method user host 10 | |
4691 "Checking local decoding command `%s' for sanity" dc) | |
4692 (unless (zerop (call-process | |
4693 tramp-sh-program ;program | |
4694 nil ;input file | |
4695 nil ;output buffer | |
4696 nil ;redisplay | |
4697 "-c" | |
4698 (format "%s </dev/null >/dev/null" dc))) | |
4699 (throw 'wont-work nil))) | |
4700 ;; CCC: At this point, maybe we should check that the output | |
4701 ;; of the commands is correct. But for the moment we will | |
4702 ;; assume that commands working on empty input will also | |
4703 ;; work in practice. | |
4704 (setq found item)))) | |
4705 ;; Did we find something? If not, issue error. If so, | |
4706 ;; set connection properties. | |
4707 (unless found | |
4708 (error "Couldn't find an inline transfer encoding")) | |
4709 (let ((ec (nth 0 found)) | |
4710 (dc (nth 1 found)) | |
4711 (ef (nth 2 found)) | |
4712 (df (nth 3 found))) | |
4713 (tramp-set-encoding-command multi-method method user host ec) | |
4714 (tramp-set-decoding-command multi-method method user host dc) | |
4715 (tramp-set-encoding-function multi-method method user host ef) | |
4716 (tramp-set-decoding-function multi-method method user host df)))) | |
4717 | |
45861 | 4718 |
4719 (defun tramp-maybe-open-connection (multi-method method user host) | |
4720 "Maybe open a connection to HOST, logging in as USER, using METHOD. | |
4721 Does not do anything if a connection is already open, but re-opens the | |
4722 connection if a previous connection has died for some reason." | |
46752 | 4723 (let ((p (get-buffer-process (tramp-get-buffer multi-method method user host))) |
4724 last-cmd-time) | |
4725 ;; If too much time has passed since last command was sent, look | |
4726 ;; whether process is still alive. If it isn't, kill it. When | |
4727 ;; using ssh, it can sometimes happen that the remote end has hung | |
4728 ;; up but the local ssh client doesn't recognize this until it | |
4729 ;; tries to send some data to the remote end. So that's why we | |
4730 ;; try to send a command from time to time, then look again | |
4731 ;; whether the process is really alive. | |
4732 (save-excursion | |
4733 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4734 (when (and tramp-last-cmd-time | |
4735 (> (tramp-time-diff tramp-last-cmd-time (current-time)) 60)) | |
4736 (process-send-string p (concat "echo hello" tramp-rsh-end-of-line)) | |
4737 (unless (accept-process-output p 2) | |
4738 (delete-process p) | |
4739 (setq p nil)) | |
4740 (erase-buffer))) | |
4741 (unless (and p (processp p) (memq (process-status p) '(run open))) | |
45861 | 4742 (when (and p (processp p)) |
4743 (delete-process p)) | |
4744 (funcall (tramp-get-connection-function multi-method method) | |
4745 multi-method method user host)))) | |
4746 | |
4747 (defun tramp-send-command | |
4748 (multi-method method user host command &optional noerase) | |
4749 "Send the COMMAND to USER at HOST (logged in using METHOD). | |
4750 Erases temporary buffer before sending the command (unless NOERASE | |
4751 is true)." | |
4752 (tramp-maybe-open-connection multi-method method user host) | |
46752 | 4753 (setq tramp-last-cmd-time (current-time)) |
45861 | 4754 (when tramp-debug-buffer |
4755 (save-excursion | |
4756 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
4757 (goto-char (point-max)) | |
4758 (tramp-insert-with-face 'bold (format "$ %s\n" command)))) | |
4759 (let ((proc nil)) | |
4760 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4761 (unless noerase (erase-buffer)) | |
4762 (setq proc (get-buffer-process (current-buffer))) | |
4763 (process-send-string proc | |
4764 (concat command tramp-rsh-end-of-line)))) | |
4765 | |
4766 ;; It seems that Tru64 Unix does not like it if long strings are sent | |
4767 ;; to it in one go. (This happens when sending the Perl | |
4768 ;; `file-attributes' implementation, for instance.) Therefore, we | |
4769 ;; have this function which waits a bit at each line. | |
4770 (defun tramp-send-linewise | |
4771 (multi-method method user host string &optional noerase) | |
4772 "Send the STRING to USER at HOST linewise. | |
4773 Erases temporary buffer before sending the STRING (unless NOERASE | |
4774 is true). | |
4775 | |
4776 The STRING is expected to use Unix line-endings, but the lines sent to | |
4777 the remote host use line-endings as defined in the variable | |
4778 `tramp-rsh-end-of-line'." | |
4779 (tramp-maybe-open-connection multi-method method user host) | |
4780 (when tramp-debug-buffer | |
4781 (save-excursion | |
4782 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
4783 (goto-char (point-max)) | |
4784 (tramp-insert-with-face 'bold (format "$ %s\n" string)))) | |
4785 (let ((proc nil) | |
4786 (lines (split-string string "\n"))) | |
4787 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4788 (unless noerase (erase-buffer)) | |
4789 (setq proc (get-buffer-process (current-buffer))) | |
4790 (mapcar (lambda (x) | |
4791 (sleep-for 0.1) | |
4792 (process-send-string proc | |
4793 (concat x tramp-rsh-end-of-line))) | |
4794 lines))) | |
4795 | |
4796 (defun tramp-wait-for-output (&optional timeout) | |
4797 "Wait for output from remote rsh command." | |
4798 (let ((proc (get-buffer-process (current-buffer))) | |
4799 (found nil) | |
4800 (start-time (current-time)) | |
4801 (end-of-output (concat "^" | |
4802 (regexp-quote tramp-end-of-output) | |
4803 "$"))) | |
4804 ;; Algorithm: get waiting output. See if last line contains | |
4805 ;; end-of-output sentinel. If not, wait a bit and again get | |
4806 ;; waiting output. Repeat until timeout expires or end-of-output | |
4807 ;; sentinel is seen. Will hang if timeout is nil and | |
4808 ;; end-of-output sentinel never appears. | |
4809 (save-match-data | |
4810 (cond (timeout | |
4811 ;; Work around an XEmacs bug, where the timeout expires | |
4812 ;; faster than it should. This degenerates into polling | |
4813 ;; for buggy XEmacsen, but oh, well. | |
4814 (while (and (not found) | |
4815 (< (tramp-time-diff (current-time) start-time) | |
4816 timeout)) | |
4817 (with-timeout (timeout) | |
4818 (while (not found) | |
4819 (accept-process-output proc 1) | |
4820 (goto-char (point-max)) | |
4821 (forward-line -1) | |
4822 (setq found (looking-at end-of-output)))))) | |
4823 (t | |
4824 (while (not found) | |
4825 (accept-process-output proc 1) | |
4826 (goto-char (point-max)) | |
4827 (forward-line -1) | |
4828 (setq found (looking-at end-of-output)))))) | |
4829 ;; At this point, either the timeout has expired or we have found | |
4830 ;; the end-of-output sentinel. | |
4831 (when found | |
4832 (goto-char (point-max)) | |
4833 (forward-line -2) | |
4834 (delete-region (point) (point-max))) | |
4835 ;; Add output to debug buffer if appropriate. | |
4836 (when tramp-debug-buffer | |
4837 (append-to-buffer | |
4838 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4839 tramp-current-user tramp-current-host) | |
4840 (point-min) (point-max)) | |
4841 (when (not found) | |
4842 (save-excursion | |
4843 (set-buffer | |
4844 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4845 tramp-current-user tramp-current-host)) | |
4846 (goto-char (point-max)) | |
4847 (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
|
4848 (if timeout (format " in %d secs" timeout) "") |
45861 | 4849 "]]")))) |
4850 (goto-char (point-min)) | |
4851 ;; Return value is whether end-of-output sentinel was found. | |
4852 found)) | |
4853 | |
4854 (defun tramp-match-string-list (&optional string) | |
4855 "Returns list of all match strings. | |
4856 That is, (list (match-string 0) (match-string 1) ...), according to the | |
4857 number of matches." | |
4858 (let* ((nmatches (/ (length (match-data)) 2)) | |
4859 (i (- nmatches 1)) | |
4860 (res nil)) | |
4861 (while (>= i 0) | |
4862 (setq res (cons (match-string i string) res)) | |
4863 (setq i (- i 1))) | |
4864 res)) | |
4865 | |
4866 (defun tramp-send-command-and-check (multi-method method user host command | |
4867 &optional subshell) | |
4868 "Run COMMAND and check its exit status. | |
4869 MULTI-METHOD and METHOD specify how to log in (as USER) to the remote HOST. | |
4870 Sends `echo $?' along with the COMMAND for checking the exit status. If | |
4871 COMMAND is nil, just sends `echo $?'. Returns the exit status found. | |
4872 | |
4873 If the optional argument SUBSHELL is non-nil, the command is executed in | |
4874 a subshell, ie surrounded by parentheses." | |
4875 (tramp-send-command multi-method method user host | |
4876 (concat (if subshell "( " "") | |
4877 command | |
4878 (if command " 2>/dev/null; " "") | |
4879 "echo tramp_exit_status $?" | |
4880 (if subshell " )" " "))) | |
4881 (tramp-wait-for-output) | |
4882 (goto-char (point-max)) | |
4883 (unless (search-backward "tramp_exit_status " nil t) | |
4884 (error "Couldn't find exit status of `%s'" command)) | |
4885 (skip-chars-forward "^ ") | |
4886 (read (current-buffer))) | |
4887 | |
4888 (defun tramp-barf-unless-okay (multi-method method user host command subshell | |
4889 signal fmt &rest args) | |
4890 "Run COMMAND, check exit status, throw error if exit status not okay. | |
4891 Similar to `tramp-send-command-and-check' but accepts two more arguments | |
4892 FMT and ARGS which are passed to `error'." | |
4893 (unless (zerop (tramp-send-command-and-check | |
4894 multi-method method user host command subshell)) | |
4895 ;; CCC: really pop-to-buffer? Maybe it's appropriate to be more | |
4896 ;; silent. | |
4897 (pop-to-buffer (current-buffer)) | |
4898 (funcall 'signal signal (apply 'format fmt args)))) | |
4899 | |
4900 (defun tramp-send-region (multi-method method user host start end) | |
4901 "Send the region from START to END to remote command | |
4902 running as USER on HOST using METHOD." | |
4903 (let ((proc (get-buffer-process | |
4904 (tramp-get-buffer multi-method method user host)))) | |
4905 (unless proc | |
4906 (error "Can't send region to remote host -- not logged in")) | |
4907 (process-send-region proc start end) | |
4908 (when tramp-debug-buffer | |
4909 (append-to-buffer | |
4910 (tramp-get-debug-buffer multi-method method user host) | |
4911 start end)))) | |
4912 | |
4913 (defun tramp-send-eof (multi-method method user host) | |
4914 "Send EOF to the remote end. | |
46151
eff75835ac2e
(tramp-send-eof): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
46060
diff
changeset
|
4915 METHOD, HOST and USER specify the connection." |
45861 | 4916 (let ((proc (get-buffer-process |
4917 (tramp-get-buffer multi-method method user host)))) | |
4918 (unless proc | |
4919 (error "Can't send EOF to remote host -- not logged in")) | |
4920 (process-send-eof proc))) | |
4921 ; (process-send-string proc "\^D"))) | |
4922 | |
4923 (defun tramp-kill-process (multi-method method user host) | |
4924 "Kill the connection process used by Tramp. | |
46151
eff75835ac2e
(tramp-send-eof): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
46060
diff
changeset
|
4925 MULTI-METHOD, METHOD, USER, and HOST specify the connection." |
45861 | 4926 (let ((proc (get-buffer-process |
4927 (tramp-get-buffer multi-method method user host)))) | |
4928 (kill-process proc))) | |
4929 | |
4930 (defun tramp-discard-garbage-erase-buffer (p multi-method method user host) | |
4931 "Erase buffer, then discard subsequent garbage. | |
4932 If `tramp-discard-garbage' is nil, just erase buffer." | |
4933 (if (not tramp-discard-garbage) | |
4934 (erase-buffer) | |
4935 (while (prog1 (erase-buffer) (accept-process-output p 0.25)) | |
4936 (when tramp-debug-buffer | |
4937 (save-excursion | |
4938 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
4939 (goto-char (point-max)) | |
4940 (tramp-insert-with-face | |
4941 'bold (format "Additional characters detected\n"))))))) | |
4942 | |
4943 (defun tramp-mode-string-to-int (mode-string) | |
4944 "Converts a ten-letter `drwxrwxrwx'-style mode string into mode bits." | |
4945 (let* ((mode-chars (string-to-vector mode-string)) | |
4946 (owner-read (aref mode-chars 1)) | |
4947 (owner-write (aref mode-chars 2)) | |
4948 (owner-execute-or-setid (aref mode-chars 3)) | |
4949 (group-read (aref mode-chars 4)) | |
4950 (group-write (aref mode-chars 5)) | |
4951 (group-execute-or-setid (aref mode-chars 6)) | |
4952 (other-read (aref mode-chars 7)) | |
4953 (other-write (aref mode-chars 8)) | |
4954 (other-execute-or-sticky (aref mode-chars 9))) | |
4955 (save-match-data | |
4956 (logior | |
4957 (case owner-read | |
4958 (?r (tramp-octal-to-decimal "00400")) (?- 0) | |
4959 (t (error "Second char `%c' must be one of `r-'" owner-read))) | |
4960 (case owner-write | |
4961 (?w (tramp-octal-to-decimal "00200")) (?- 0) | |
4962 (t (error "Third char `%c' must be one of `w-'" owner-write))) | |
4963 (case owner-execute-or-setid | |
4964 (?x (tramp-octal-to-decimal "00100")) | |
4965 (?S (tramp-octal-to-decimal "04000")) | |
4966 (?s (tramp-octal-to-decimal "04100")) | |
4967 (?- 0) | |
4968 (t (error "Fourth char `%c' must be one of `xsS-'" | |
4969 owner-execute-or-setid))) | |
4970 (case group-read | |
4971 (?r (tramp-octal-to-decimal "00040")) (?- 0) | |
4972 (t (error "Fifth char `%c' must be one of `r-'" group-read))) | |
4973 (case group-write | |
4974 (?w (tramp-octal-to-decimal "00020")) (?- 0) | |
4975 (t (error "Sixth char `%c' must be one of `w-'" group-write))) | |
4976 (case group-execute-or-setid | |
4977 (?x (tramp-octal-to-decimal "00010")) | |
4978 (?S (tramp-octal-to-decimal "02000")) | |
4979 (?s (tramp-octal-to-decimal "02010")) | |
4980 (?- 0) | |
4981 (t (error "Seventh char `%c' must be one of `xsS-'" | |
4982 group-execute-or-setid))) | |
4983 (case other-read | |
4984 (?r (tramp-octal-to-decimal "00004")) (?- 0) | |
4985 (t (error "Eighth char `%c' must be one of `r-'" other-read))) | |
4986 (case other-write | |
4987 (?w (tramp-octal-to-decimal "00002")) (?- 0) | |
4988 (t (error "Nineth char `%c' must be one of `w-'" other-write))) | |
4989 (case other-execute-or-sticky | |
4990 (?x (tramp-octal-to-decimal "00001")) | |
4991 (?T (tramp-octal-to-decimal "01000")) | |
4992 (?t (tramp-octal-to-decimal "01001")) | |
4993 (?- 0) | |
4994 (t (error "Tenth char `%c' must be one of `xtT-'" | |
4995 other-execute-or-sticky))))))) | |
4996 | |
4997 | |
4998 (defun tramp-file-mode-from-int (mode) | |
4999 "Turn an integer representing a file mode into an ls(1)-like string." | |
5000 (let ((type (cdr (assoc (logand (lsh mode -12) 15) tramp-file-mode-type-map))) | |
5001 (user (logand (lsh mode -6) 7)) | |
5002 (group (logand (lsh mode -3) 7)) | |
5003 (other (logand (lsh mode -0) 7)) | |
5004 (suid (> (logand (lsh mode -9) 4) 0)) | |
5005 (sgid (> (logand (lsh mode -9) 2) 0)) | |
5006 (sticky (> (logand (lsh mode -9) 1) 0))) | |
5007 (setq user (tramp-file-mode-permissions user suid "s")) | |
5008 (setq group (tramp-file-mode-permissions group sgid "s")) | |
5009 (setq other (tramp-file-mode-permissions other sticky "t")) | |
5010 (concat type user group other))) | |
5011 | |
5012 | |
5013 (defun tramp-file-mode-permissions (perm suid suid-text) | |
5014 "Convert a permission bitset into a string. | |
5015 This is used internally by `tramp-file-mode-from-int'." | |
5016 (let ((r (> (logand perm 4) 0)) | |
5017 (w (> (logand perm 2) 0)) | |
5018 (x (> (logand perm 1) 0))) | |
5019 (concat (or (and r "r") "-") | |
5020 (or (and w "w") "-") | |
5021 (or (and suid x suid-text) ; suid, execute | |
5022 (and suid (upcase suid-text)) ; suid, !execute | |
5023 (and x "x") "-")))) ; !suid | |
5024 | |
5025 | |
5026 (defun tramp-decimal-to-octal (i) | |
5027 "Return a string consisting of the octal digits of I. | |
5028 Not actually used. Use `(format \"%o\" i)' instead?" | |
5029 (cond ((< i 0) (error "Cannot convert negative number to octal")) | |
5030 ((not (integerp i)) (error "Cannot convert non-integer to octal")) | |
5031 ((zerop i) "0") | |
5032 (t (concat (tramp-decimal-to-octal (/ i 8)) | |
5033 (number-to-string (% i 8)))))) | |
5034 | |
5035 | |
5036 ;;(defun tramp-octal-to-decimal (ostr) | |
5037 ;; "Given a string of octal digits, return a decimal number." | |
5038 ;; (cond ((null ostr) 0) | |
5039 ;; ((string= "" ostr) 0) | |
5040 ;; (t (let ((last (aref ostr (1- (length ostr)))) | |
5041 ;; (rest (substring ostr 0 (1- (length ostr))))) | |
5042 ;; (unless (and (>= last ?0) | |
5043 ;; (<= last ?7)) | |
5044 ;; (error "Not an octal digit: %c" last)) | |
5045 ;; (+ (- last ?0) (* 8 (tramp-octal-to-decimal rest))))))) | |
5046 ;; Kudos to Gerd Moellmann for this suggestion. | |
5047 (defun tramp-octal-to-decimal (ostr) | |
5048 "Given a string of octal digits, return a decimal number." | |
5049 (let ((x (or ostr ""))) | |
5050 ;; `save-match' is in `tramp-mode-string-to-int' which calls this. | |
5051 (unless (string-match "\\`[0-7]*\\'" x) | |
5052 (error "Non-octal junk in string `%s'" x)) | |
5053 (string-to-number ostr 8))) | |
5054 | |
5055 (defun tramp-shell-case-fold (string) | |
5056 "Converts STRING to shell glob pattern which ignores case." | |
5057 (mapconcat | |
5058 (lambda (c) | |
5059 (if (equal (downcase c) (upcase c)) | |
5060 (vector c) | |
5061 (format "[%c%c]" (downcase c) (upcase c)))) | |
5062 string | |
5063 "")) | |
5064 | |
5065 | |
5066 ;; ------------------------------------------------------------ | |
5067 ;; -- TRAMP file names -- | |
5068 ;; ------------------------------------------------------------ | |
5069 ;; Conversion functions between external representation and | |
5070 ;; internal data structure. Convenience functions for internal | |
5071 ;; data structure. | |
5072 | |
5073 (defstruct tramp-file-name multi-method method user host path) | |
5074 | |
5075 (defun tramp-tramp-file-p (name) | |
5076 "Return t iff NAME is a tramp file." | |
5077 (save-match-data | |
5078 (string-match tramp-file-name-regexp name))) | |
5079 | |
5080 ;; HHH: Changed. Used to assign the return value of (user-login-name) | |
5081 ;; to the `user' part of the structure if a user name was not | |
5082 ;; provided, now it assigns nil. | |
5083 (defun tramp-dissect-file-name (name) | |
5084 "Return an `tramp-file-name' structure. | |
5085 The structure consists of remote method, remote user, remote host and | |
5086 remote path name." | |
5087 (let (method) | |
5088 (save-match-data | |
5089 (unless (string-match (nth 0 tramp-file-name-structure) name) | |
5090 (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
|
5091 (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
|
5092 (if (and method (member method tramp-multi-methods)) |
45861 | 5093 ;; If it's a multi method, the file name structure contains |
5094 ;; arrays of method, user and host. | |
5095 (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
|
5096 ;; 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
|
5097 (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
|
5098 (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
|
5099 (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
|
5100 (when (not method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5101 (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
|
5102 (make-tramp-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5103 :multi-method nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5104 :method method |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5105 :user (or user nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5106 :host host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5107 :path path)))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5108 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5109 (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
|
5110 "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
|
5111 (let ((choices tramp-default-method-alist) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5112 (method tramp-default-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5113 item) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5114 (while choices |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5115 (setq item (pop choices)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5116 (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
|
5117 (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
|
5118 (setq method (nth 2 item)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5119 (setq choices nil))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5120 method)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5121 |
45861 | 5122 ;; HHH: Not Changed. Multi method. Will probably not handle the case where |
5123 ;; a user name is not provided in the "file name" very well. | |
5124 (defun tramp-dissect-multi-file-name (name) | |
5125 "Not implemented yet." | |
5126 (let ((regexp (nth 0 tramp-multi-file-name-structure)) | |
5127 (method-index (nth 1 tramp-multi-file-name-structure)) | |
5128 (hops-index (nth 2 tramp-multi-file-name-structure)) | |
5129 (path-index (nth 3 tramp-multi-file-name-structure)) | |
5130 (hop-regexp (nth 0 tramp-multi-file-name-hop-structure)) | |
5131 (hop-method-index (nth 1 tramp-multi-file-name-hop-structure)) | |
5132 (hop-user-index (nth 2 tramp-multi-file-name-hop-structure)) | |
5133 (hop-host-index (nth 3 tramp-multi-file-name-hop-structure)) | |
5134 method hops len hop-methods hop-users hop-hosts path) | |
5135 (unless (string-match (format regexp hop-regexp) name) | |
5136 (error "Not a multi tramp file name: %s" name)) | |
5137 (setq method (match-string method-index name)) | |
5138 (setq hops (match-string hops-index name)) | |
5139 (setq len (/ (length (match-data t)) 2)) | |
5140 (when (< path-index 0) (incf path-index len)) | |
5141 (setq path (match-string path-index name)) | |
5142 (let ((index 0)) | |
5143 (while (string-match hop-regexp hops index) | |
5144 (setq index (match-end 0)) | |
5145 (setq hop-methods | |
5146 (cons (match-string hop-method-index hops) hop-methods)) | |
5147 (setq hop-users | |
5148 (cons (match-string hop-user-index hops) hop-users)) | |
5149 (setq hop-hosts | |
5150 (cons (match-string hop-host-index hops) hop-hosts)))) | |
5151 (make-tramp-file-name | |
5152 :multi-method method | |
5153 :method (apply 'vector (reverse hop-methods)) | |
5154 :user (apply 'vector (reverse hop-users)) | |
5155 :host (apply 'vector (reverse hop-hosts)) | |
5156 :path path))) | |
5157 | |
5158 (defun tramp-make-tramp-file-name (multi-method method user host path) | |
5159 "Constructs a tramp file name from METHOD, USER, HOST and PATH." | |
5160 (unless tramp-make-tramp-file-format | |
5161 (error "`tramp-make-tramp-file-format' is nil")) | |
5162 (if multi-method | |
5163 (tramp-make-tramp-multi-file-name multi-method method user host path) | |
5164 (if user | |
5165 (format-spec tramp-make-tramp-file-format | |
46752 | 5166 `((?m . ,method) (?u . ,user) (?h . ,host) (?p . ,path))) |
45861 | 5167 (format-spec tramp-make-tramp-file-user-nil-format |
46752 | 5168 `((?m . ,method) (?h . ,host) (?p . ,path)))))) |
45861 | 5169 |
5170 ;; CCC: Henrik Holm: Not Changed. Multi Method. What should be done | |
5171 ;; with this when USER is nil? | |
5172 (defun tramp-make-tramp-multi-file-name (multi-method method user host path) | |
5173 "Constructs a tramp file name for a multi-hop method." | |
5174 (unless tramp-make-multi-tramp-file-format | |
5175 (error "`tramp-make-multi-tramp-file-format' is nil")) | |
5176 (let* ((prefix-format (nth 0 tramp-make-multi-tramp-file-format)) | |
5177 (hop-format (nth 1 tramp-make-multi-tramp-file-format)) | |
5178 (path-format (nth 2 tramp-make-multi-tramp-file-format)) | |
46752 | 5179 (prefix (format-spec prefix-format `((?m . ,multi-method)))) |
45861 | 5180 (hops "") |
46752 | 5181 (path (format-spec path-format `((?p . ,path)))) |
45861 | 5182 (i 0) |
5183 (len (length method))) | |
5184 (while (< i len) | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
5185 (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
|
5186 (setq hops (concat hops (format-spec hop-format |
46752 | 5187 `((?m . ,m) (?u . ,u) (?h . ,h))))) |
45861 | 5188 (incf i))) |
5189 (concat prefix hops path))) | |
5190 | |
5191 (defun tramp-make-rcp-program-file-name (user host path) | |
5192 "Create a file name suitable to be passed to `rcp'." | |
5193 (if user | |
5194 (format "%s@%s:%s" user host path) | |
5195 (format "%s:%s" host path))) | |
5196 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5197 (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
|
5198 "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
|
5199 (if user |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5200 (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
|
5201 (format "/%s:%s" host path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5202 |
45861 | 5203 (defun tramp-method-out-of-band-p (multi-method method) |
5204 "Return t if this is an out-of-band method, nil otherwise. | |
5205 It is important to check for this condition, since it is not possible | |
5206 to enter a password for the `tramp-rcp-program'." | |
5207 (tramp-get-rcp-program multi-method method)) | |
5208 | |
5209 ;; Variables local to connection. | |
5210 | |
5211 (defun tramp-get-ls-command (multi-method method user host) | |
5212 (save-excursion | |
5213 (tramp-maybe-open-connection multi-method method user host) | |
5214 (set-buffer (tramp-get-buffer multi-method method user host)) | |
5215 tramp-ls-command)) | |
5216 | |
5217 (defun tramp-get-test-groks-nt (multi-method method user host) | |
5218 (save-excursion | |
5219 (tramp-maybe-open-connection multi-method method user host) | |
5220 (set-buffer (tramp-get-buffer multi-method method user host)) | |
5221 tramp-test-groks-nt)) | |
5222 | |
5223 (defun tramp-get-file-exists-command (multi-method method user host) | |
5224 (save-excursion | |
5225 (tramp-maybe-open-connection multi-method method user host) | |
5226 (set-buffer (tramp-get-buffer multi-method method user host)) | |
5227 tramp-file-exists-command)) | |
5228 | |
5229 (defun tramp-get-remote-perl (multi-method method user host) | |
5230 (tramp-get-connection-property "perl" nil multi-method method user host)) | |
5231 | |
5232 (defun tramp-get-remote-ln (multi-method method user host) | |
5233 (tramp-get-connection-property "ln" nil multi-method method user host)) | |
5234 | |
5235 ;; Get a property of a TRAMP connection. | |
46752 | 5236 (defun tramp-get-connection-property |
5237 (property default multi-method method user host) | |
45861 | 5238 "Get the named property for the connection. |
5239 If the value is not set for the connection, return `default'" | |
5240 (tramp-maybe-open-connection multi-method method user host) | |
5241 (with-current-buffer (tramp-get-buffer multi-method method user host) | |
5242 (let (error) | |
5243 (condition-case nil | |
5244 (symbol-value (intern (concat "tramp-connection-property-" property))) | |
5245 (error default))))) | |
5246 | |
5247 ;; Set a property of a TRAMP connection. | |
46752 | 5248 (defun tramp-set-connection-property |
5249 (property value multi-method method user host) | |
45861 | 5250 "Set the named property of a TRAMP connection." |
5251 (tramp-maybe-open-connection multi-method method user host) | |
5252 (with-current-buffer (tramp-get-buffer multi-method method user host) | |
5253 (set (make-local-variable | |
5254 (intern (concat "tramp-connection-property-" property))) | |
5255 value))) | |
5256 | |
46752 | 5257 ;; Some predefined connection properties. |
5258 (defun tramp-get-encoding-command (multi-method method user host) | |
5259 (tramp-get-connection-property "encoding-command" nil | |
5260 multi-method method user host)) | |
5261 (defun tramp-set-encoding-command (multi-method method user host command) | |
5262 (tramp-set-connection-property "encoding-command" command | |
5263 multi-method method user host)) | |
5264 (defun tramp-get-decoding-command (multi-method method user host) | |
5265 (tramp-get-connection-property "decoding-command" nil | |
5266 multi-method method user host)) | |
5267 (defun tramp-set-decoding-command (multi-method method user host command) | |
5268 (tramp-set-connection-property "decoding-command" command | |
5269 multi-method method user host)) | |
5270 (defun tramp-get-encoding-function (multi-method method user host) | |
5271 (tramp-get-connection-property "encoding-function" nil | |
5272 multi-method method user host)) | |
5273 (defun tramp-set-encoding-function (multi-method method user host func) | |
5274 (tramp-set-connection-property "encoding-function" func | |
5275 multi-method method user host)) | |
5276 (defun tramp-get-decoding-function (multi-method method user host) | |
5277 (tramp-get-connection-property "decoding-function" nil | |
5278 multi-method method user host)) | |
5279 (defun tramp-set-decoding-function (multi-method method user host func) | |
5280 (tramp-set-connection-property "decoding-function" func | |
5281 multi-method method user host)) | |
45861 | 5282 |
5283 | |
5284 (defun tramp-get-connection-function (multi-method method) | |
5285 (second (or (assoc 'tramp-connection-function | |
5286 (assoc (or multi-method method tramp-default-method) | |
5287 tramp-methods)) | |
5288 (error "Method `%s' didn't specify a connection function" | |
5289 (or multi-method method))))) | |
5290 | |
5291 (defun tramp-get-remote-sh (multi-method method) | |
5292 (second (or (assoc 'tramp-remote-sh | |
5293 (assoc (or multi-method method tramp-default-method) | |
5294 tramp-methods)) | |
5295 (error "Method `%s' didn't specify a remote shell" | |
5296 (or multi-method method))))) | |
5297 | |
5298 (defun tramp-get-rsh-program (multi-method method) | |
5299 (second (or (assoc 'tramp-rsh-program | |
5300 (assoc (or multi-method method tramp-default-method) | |
5301 tramp-methods)) | |
5302 (error "Method `%s' didn't specify an rsh program" | |
5303 (or multi-method method))))) | |
5304 | |
5305 (defun tramp-get-rsh-args (multi-method method) | |
5306 (second (or (assoc 'tramp-rsh-args | |
5307 (assoc (or multi-method method tramp-default-method) | |
5308 tramp-methods)) | |
5309 (error "Method `%s' didn't specify rsh args" | |
5310 (or multi-method method))))) | |
5311 | |
5312 (defun tramp-get-rcp-program (multi-method method) | |
5313 (second (or (assoc 'tramp-rcp-program | |
5314 (assoc (or multi-method method tramp-default-method) | |
5315 tramp-methods)) | |
5316 (error "Method `%s' didn't specify an rcp program" | |
5317 (or multi-method method))))) | |
5318 | |
5319 (defun tramp-get-rcp-args (multi-method method) | |
5320 (second (or (assoc 'tramp-rcp-args | |
5321 (assoc (or multi-method method tramp-default-method) | |
5322 tramp-methods)) | |
5323 (error "Method `%s' didn't specify rcp args" | |
5324 (or multi-method method))))) | |
5325 | |
5326 (defun tramp-get-rcp-keep-date-arg (multi-method method) | |
5327 (second (or (assoc 'tramp-rcp-keep-date-arg | |
5328 (assoc (or multi-method method tramp-default-method) | |
5329 tramp-methods)) | |
5330 (error "Method `%s' didn't specify `keep-date' arg for tramp" | |
5331 (or multi-method method))))) | |
5332 | |
5333 (defun tramp-get-su-program (multi-method method) | |
5334 (second (or (assoc 'tramp-su-program | |
5335 (assoc (or multi-method method tramp-default-method) | |
5336 tramp-methods)) | |
5337 (error "Method `%s' didn't specify a su program" | |
5338 (or multi-method method))))) | |
5339 | |
5340 (defun tramp-get-su-args (multi-method method) | |
5341 (second (or (assoc 'tramp-su-args | |
5342 (assoc (or multi-method method tramp-default-method) | |
5343 tramp-methods)) | |
5344 (error "Method `%s' didn't specify su args" | |
5345 (or multi-method method))))) | |
5346 | |
5347 (defun tramp-get-telnet-program (multi-method method) | |
5348 (second (or (assoc 'tramp-telnet-program | |
5349 (assoc (or multi-method method tramp-default-method) | |
5350 tramp-methods)) | |
5351 (error "Method `%s' didn't specify a telnet program" | |
5352 (or multi-method method))))) | |
5353 | |
5354 (defun tramp-get-telnet-args (multi-method method) | |
5355 (second (or (assoc 'tramp-telnet-args | |
5356 (assoc (or multi-method method tramp-default-method) | |
5357 tramp-methods)) | |
5358 (error "Method `%s' didn't specify telnet args" | |
5359 (or multi-method method))))) | |
5360 | |
46752 | 5361 ;; (defun tramp-get-encoding-command (multi-method method) |
5362 ;; (second (or (assoc 'tramp-encoding-command | |
5363 ;; (assoc (or multi-method method tramp-default-method) | |
5364 ;; tramp-methods)) | |
5365 ;; (error "Method `%s' didn't specify an encoding command" | |
5366 ;; (or multi-method method))))) | |
5367 | |
5368 ;; (defun tramp-get-decoding-command (multi-method method) | |
5369 ;; (second (or (assoc 'tramp-decoding-command | |
5370 ;; (assoc (or multi-method method tramp-default-method) | |
5371 ;; tramp-methods)) | |
5372 ;; (error "Method `%s' didn't specify a decoding command" | |
5373 ;; (or multi-method method))))) | |
5374 | |
5375 ;; (defun tramp-get-encoding-function (multi-method method) | |
5376 ;; (second (or (assoc 'tramp-encoding-function | |
5377 ;; (assoc (or multi-method method tramp-default-method) | |
5378 ;; tramp-methods)) | |
5379 ;; (error "Method `%s' didn't specify an encoding function" | |
5380 ;; (or multi-method method))))) | |
5381 | |
5382 ;; (defun tramp-get-decoding-function (multi-method method) | |
5383 ;; (second (or (assoc 'tramp-decoding-function | |
5384 ;; (assoc (or multi-method method tramp-default-method) | |
5385 ;; tramp-methods)) | |
5386 ;; (error "Method `%s' didn't specify a decoding function" | |
5387 ;; (or multi-method method))))) | |
5388 | |
45861 | 5389 ;; Auto saving to a special directory. |
5390 | |
5391 (defun tramp-make-auto-save-file-name (fn) | |
5392 "Returns a file name in `tramp-auto-save-directory' for autosaving this file." | |
5393 (when tramp-auto-save-directory | |
5394 (unless (file-exists-p tramp-auto-save-directory) | |
5395 (make-directory tramp-auto-save-directory t))) | |
5396 ;; jka-compr doesn't like auto-saving, so by appending "~" to the | |
5397 ;; file name we make sure that jka-compr isn't used for the | |
5398 ;; auto-save file. | |
5399 (let ((buffer-file-name (expand-file-name | |
5400 (tramp-subst-strs-in-string '(("_" . "|") | |
5401 ("/" . "_a") | |
5402 (":" . "_b") | |
5403 ("|" . "__") | |
5404 ("[" . "_l") | |
5405 ("]" . "_r")) | |
5406 fn) | |
5407 tramp-auto-save-directory))) | |
5408 (make-auto-save-file-name))) | |
5409 | |
5410 (defadvice make-auto-save-file-name | |
5411 (around tramp-advice-make-auto-save-file-name () activate) | |
5412 "Invoke `tramp-make-auto-save-file-name' for tramp files." | |
5413 (if (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)) | |
5414 tramp-auto-save-directory) | |
5415 (setq ad-return-value | |
5416 (tramp-make-auto-save-file-name (buffer-file-name))) | |
5417 ad-do-it)) | |
5418 | |
5419 (defun tramp-subst-strs-in-string (alist string) | |
5420 "Replace all occurrences of the string FROM with TO in STRING. | |
5421 ALIST is of the form ((FROM . TO) ...)." | |
5422 (save-match-data | |
5423 (while alist | |
5424 (let* ((pr (car alist)) | |
5425 (from (car pr)) | |
5426 (to (cdr pr))) | |
5427 (while (string-match (regexp-quote from) string) | |
5428 (setq string (replace-match to t t string))) | |
5429 (setq alist (cdr alist)))) | |
5430 string)) | |
5431 | |
5432 (defun tramp-insert-with-face (face string) | |
5433 "Insert text with a specific face." | |
5434 (let ((start (point))) | |
5435 (insert string) | |
5436 (add-text-properties start (point) (list 'face face)))) | |
5437 | |
5438 ;; ------------------------------------------------------------ | |
5439 ;; -- Compatibility functions section -- | |
5440 ;; ------------------------------------------------------------ | |
5441 | |
5442 (defun tramp-temporary-file-directory () | |
5443 "Return name of directory for temporary files (compat function). | |
5444 For Emacs, this is the variable `temporary-file-directory', for XEmacs | |
5445 this is the function `temp-directory'." | |
5446 (cond ((boundp 'temporary-file-directory) | |
5447 (symbol-value 'temporary-file-directory)) | |
5448 ((fboundp 'temp-directory) | |
5449 (funcall (symbol-function 'temp-directory))) ;pacify byte-compiler | |
5450 ((let ((d (getenv "TEMP"))) (and d (file-directory-p d))) | |
5451 (file-name-as-directory (getenv "TEMP"))) | |
5452 ((let ((d (getenv "TMP"))) (and d (file-directory-p d))) | |
5453 (file-name-as-directory (getenv "TMP"))) | |
5454 ((let ((d (getenv "TMPDIR"))) (and d (file-directory-p d))) | |
5455 (file-name-as-directory (getenv "TMPDIR"))) | |
5456 ((file-exists-p "c:/temp") (file-name-as-directory "c:/temp")) | |
5457 (t (message (concat "Neither `temporary-file-directory' nor " | |
5458 "`temp-directory' is defined -- using /tmp.")) | |
5459 (file-name-as-directory "/tmp")))) | |
5460 | |
5461 (defun tramp-read-passwd (prompt) | |
5462 "Read a password from user (compat function). | |
5463 Invokes `read-passwd' if that is defined, else `ange-ftp-read-passwd'." | |
5464 (apply | |
5465 (if (fboundp 'read-passwd) #'read-passwd #'ange-ftp-read-passwd) | |
5466 (list prompt))) | |
5467 | |
5468 (defun tramp-time-diff (t1 t2) | |
5469 "Return the difference between the two times, in seconds. | |
5470 T1 and T2 are time values (as returned by `current-time' for example). | |
5471 | |
5472 NOTE: This function will fail if the time difference is too large to | |
5473 fit in an integer." | |
5474 ;; Pacify byte-compiler with `symbol-function'. | |
5475 (cond ((fboundp 'subtract-time) | |
5476 (cadr (funcall (symbol-function 'subtract-time) t1 t2))) | |
5477 ((fboundp 'itimer-time-difference) | |
5478 (floor (funcall | |
5479 (symbol-function 'itimer-time-difference) | |
5480 (if (< (length t1) 3) (append t1 '(0)) t1) | |
5481 (if (< (length t2) 3) (append t2 '(0)) t2)))) | |
5482 (t | |
5483 ;; snarfed from Emacs 21 time-date.el | |
5484 (cadr (let ((borrow (< (cadr t1) (cadr t2)))) | |
5485 (list (- (car t1) (car t2) (if borrow 1 0)) | |
5486 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))))) | |
5487 | |
5488 (defun tramp-coding-system-change-eol-conversion (coding-system eol-type) | |
5489 "Return a coding system like CODING-SYSTEM but with given EOL-TYPE. | |
5490 EOL-TYPE can be one of `dos', `unix', or `mac'." | |
5491 (cond ((fboundp 'coding-system-change-eol-conversion) | |
5492 (apply #'coding-system-change-eol-conversion | |
5493 (list coding-system eol-type))) | |
5494 ((fboundp 'subsidiary-coding-system) | |
5495 (apply | |
5496 #'subsidiary-coding-system | |
5497 (list coding-system | |
5498 (cond ((eq eol-type 'dos) 'crlf) | |
5499 ((eq eol-type 'unix) 'lf) | |
5500 ((eq eol-type 'mac) 'cr) | |
5501 (t | |
5502 (error "Unknown EOL-TYPE `%s', must be %s" | |
5503 eol-type | |
5504 "`dos', `unix', or `mac'")))))) | |
5505 (t (error "Can't change EOL conversion -- is MULE missing?")))) | |
5506 | |
5507 (defun tramp-split-string (string pattern) | |
5508 "Like `split-string' but omit empty strings. | |
5509 In Emacs, (split-string \"/foo/bar\" \"/\") returns (\"foo\" \"bar\"). | |
5510 This is, the first, empty, element is omitted. In XEmacs, the first | |
5511 element is not omitted. | |
5512 | |
5513 Note: this function has been written for `tramp-handle-file-truename'. | |
5514 If you want to use it for something else, you'll have to check whether | |
5515 it does the right thing." | |
5516 (delete "" (split-string string pattern))) | |
5517 | |
5518 ;; ------------------------------------------------------------ | |
5519 ;; -- Kludges section -- | |
5520 ;; ------------------------------------------------------------ | |
5521 | |
5522 ;; Currently (as of Emacs 20.5), the function `shell-quote-argument' | |
5523 ;; does not deal well with newline characters. Newline is replaced by | |
5524 ;; backslash newline. But if, say, the string `a backslash newline b' | |
5525 ;; is passed to a shell, the shell will expand this into "ab", | |
5526 ;; completely omitting the newline. This is not what was intended. | |
5527 ;; It does not appear to be possible to make the function | |
5528 ;; `shell-quote-argument' work with newlines without making it | |
5529 ;; dependent on the shell used. But within this package, we know that | |
5530 ;; we will always use a Bourne-like shell, so we use an approach which | |
5531 ;; groks newlines. | |
5532 ;; | |
5533 ;; The approach is simple: we call `shell-quote-argument', then | |
5534 ;; massage the newline part of the result. | |
5535 ;; | |
5536 ;; This function should produce a string which is grokked by a Unix | |
5537 ;; shell, even if the Emacs is running on Windows. Since this is the | |
5538 ;; kludges section, we bind `system-type' in such a way that | |
5539 ;; `shell-quote-arguments' behaves as if on Unix. | |
5540 ;; | |
5541 ;; Thanks to Mario DeWeerd for the hint that it is sufficient for this | |
5542 ;; function to work with Bourne-like shells. | |
5543 ;; | |
5544 ;; CCC: This function should be rewritten so that | |
5545 ;; `shell-quote-argument' is not used. This way, we are safe from | |
5546 ;; changes in `shell-quote-argument'. | |
5547 (defun tramp-shell-quote-argument (s) | |
5548 "Similar to `shell-quote-argument', but groks newlines. | |
5549 Only works for Bourne-like shells." | |
5550 (let ((system-type 'not-windows)) | |
5551 (save-match-data | |
5552 (let ((result (shell-quote-argument s)) | |
5553 (nl (regexp-quote (format "\\%s" tramp-rsh-end-of-line)))) | |
5554 (when (and (>= (length result) 2) | |
5555 (string= (substring result 0 2) "\\~")) | |
5556 (setq result (substring result 1))) | |
5557 (while (string-match nl result) | |
5558 (setq result (replace-match (format "'%s'" tramp-rsh-end-of-line) | |
5559 t t result))) | |
5560 result)))) | |
5561 | |
5562 ;; ;; EFS hooks itself into the file name handling stuff in more places | |
5563 ;; ;; than just `file-name-handler-alist'. The following tells EFS to stay | |
5564 ;; ;; away from tramp.el paths. | |
5565 ;; ;; | |
5566 ;; ;; This is needed because EFS installs (efs-dired-before-readin) into | |
5567 ;; ;; 'dired-before-readin-hook'. This prevents EFS from opening an FTP | |
5568 ;; ;; connection to help it's dired process. Not that I have any real | |
5569 ;; ;; idea *why* this is helpful to dired. | |
5570 ;; ;; | |
5571 ;; ;; Anyway, this advice fixes the problem (with a sledgehammer :) | |
5572 ;; ;; | |
5573 ;; ;; Daniel Pittman <daniel@danann.net> | |
5574 ;; ;; | |
5575 ;; ;; CCC: when the other defadvice calls have disappeared, make sure | |
5576 ;; ;; not to call defadvice unless it's necessary. How do we find out whether | |
5577 ;; ;; it is necessary? (featurep 'efs) is surely the wrong way -- | |
5578 ;; ;; EFS might nicht be loaded yet. | |
5579 ;; (defadvice efs-ftp-path (around dont-match-tramp-path activate protect) | |
5580 ;; "Cause efs-ftp-path to fail when the path is a TRAMP path." | |
5581 ;; (if (tramp-tramp-file-p (ad-get-arg 0)) | |
5582 ;; nil | |
5583 ;; ad-do-it)) | |
5584 | |
5585 ;; We currently use "[" and "]" in the filename format. In Emacs | |
5586 ;; 20.x, this means that Emacs wants to expand wildcards if | |
5587 ;; `find-file-wildcards' is non-nil, and then barfs because no | |
5588 ;; expansion could be found. We detect this situation and do | |
5589 ;; something really awful: we have `file-expand-wildcards' return the | |
5590 ;; original filename if it can't expand anything. Let's just hope | |
5591 ;; that this doesn't break anything else. | |
5592 ;; | |
5593 ;; Another problem is that the check is done by Emacs version, which | |
5594 ;; is really not what we want to do. Oh, well. | |
5595 | |
5596 ;;(when (and (not (featurep 'xemacs)) | |
5597 ;; (= emacs-major-version 20)) | |
5598 ;; It seems that this advice is needed in Emacs 21, too. | |
5599 (defadvice file-expand-wildcards (around tramp-fix activate) | |
5600 (let ((name (ad-get-arg 0))) | |
5601 (if (tramp-tramp-file-p name) | |
5602 ;; If it's a Tramp file, dissect it and look if wildcards | |
5603 ;; need to be expanded at all. | |
5604 (let ((v (tramp-dissect-file-name name))) | |
5605 (if (string-match "[[*?]" (tramp-file-name-path v)) | |
5606 (let ((res ad-do-it)) | |
5607 (setq ad-return-value (or res (list name)))) | |
5608 (setq ad-return-value (list name)))) | |
5609 ;; If it is not a Tramp file, just run the original function. | |
5610 (let ((res ad-do-it)) | |
5611 (setq ad-return-value (or res (list name))))))) | |
5612 ;; ) | |
5613 | |
46752 | 5614 ;; Tramp version is useful in a number of situations. |
5615 | |
5616 (defun tramp-version (arg) | |
5617 "Print version number of tramp.el in minibuffer or current buffer." | |
5618 (interactive "P") | |
5619 (if arg (insert tramp-version) (message tramp-version))) | |
5620 | |
45861 | 5621 ;; Make the `reporter` functionality available for making bug reports about |
5622 ;; the package. A most useful piece of code. | |
5623 | |
5624 (unless (fboundp 'reporter-submit-bug-report) | |
5625 (autoload 'reporter-submit-bug-report "reporter")) | |
5626 | |
5627 (defun tramp-bug () | |
5628 "Submit a bug report to the TRAMP developers." | |
5629 (interactive) | |
5630 (require 'reporter) | |
5631 (let ((reporter-prompt-for-summary-p t)) | |
5632 (reporter-submit-bug-report | |
5633 tramp-bug-report-address ; to-address | |
5634 (format "tramp (%s)" tramp-version) ; package name and version | |
5635 `(;; Current state | |
5636 tramp-ls-command | |
5637 tramp-test-groks-nt | |
5638 tramp-file-exists-command | |
5639 tramp-current-multi-method | |
5640 tramp-current-method | |
5641 tramp-current-user | |
5642 tramp-current-host | |
5643 | |
5644 ;; System defaults | |
5645 tramp-auto-save-directory ; vars to dump | |
5646 tramp-default-method | |
5647 tramp-rsh-end-of-line | |
5648 tramp-remote-path | |
5649 tramp-login-prompt-regexp | |
5650 tramp-password-prompt-regexp | |
5651 tramp-wrong-passwd-regexp | |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
5652 tramp-yesno-prompt-regexp |
45861 | 5653 tramp-temp-name-prefix |
5654 tramp-file-name-structure | |
5655 tramp-file-name-regexp | |
5656 tramp-multi-file-name-structure | |
5657 tramp-multi-file-name-hop-structure | |
5658 tramp-multi-methods | |
5659 tramp-multi-connection-function-alist | |
5660 tramp-make-tramp-file-format | |
5661 tramp-end-of-output | |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
5662 tramp-coding-commands |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
5663 tramp-actions-before-shell |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
5664 tramp-multi-actions |
45861 | 5665 |
5666 ;; Non-tramp variables of interest | |
5667 shell-prompt-pattern | |
5668 backup-by-copying | |
5669 backup-by-copying-when-linked | |
5670 backup-by-copying-when-mismatch | |
5671 ,(when (boundp 'backup-by-copying-when-privileged-mismatch) | |
5672 'backup-by-copying-when-privileged-mismatch) | |
5673 file-name-handler-alist) | |
5674 nil ; pre-hook | |
5675 nil ; post-hook | |
5676 "\ | |
5677 Enter your bug report in this message, including as much detail as you | |
5678 possibly can about the problem, what you did to cause it and what the | |
5679 local and remote machines are. | |
5680 | |
5681 If you can give a simple set of instructions to make this bug happen | |
5682 reliably, please include those. Thank you for helping kill bugs in | |
5683 TRAMP. | |
46801
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
5684 |
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
5685 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
|
5686 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
|
5687 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
|
5688 report. |
3fafc6fca8a8
Version 2.0.9 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46799
diff
changeset
|
5689 |
46802
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
5690 --bug report follows this line-- |
10aa49b3d28a
Version 2.0.10 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46801
diff
changeset
|
5691 "))) |
45861 | 5692 |
5693 (defalias 'tramp-submit-bug 'tramp-bug) | |
5694 | |
5695 (provide 'tramp) | |
5696 | |
5697 ;; Make sure that we get integration with the VC package. | |
5698 ;; When it is loaded, we need to pull in the integration module. | |
5699 ;; This must come after (provide 'tramp) because tramp-vc.el | |
5700 ;; requires tramp. | |
5701 (eval-after-load "vc" | |
5702 '(require 'tramp-vc)) | |
5703 | |
5704 ;;; TODO: | |
5705 | |
46790 | 5706 ;; * Add fallback for inline encodings. This should be used |
5707 ;; if the remote end doesn't support mimencode or a similar program. | |
5708 ;; For reading files from the remote host, we can just parse the output | |
5709 ;; of `od -b'. For writing files to the remote host, we construct | |
5710 ;; a shell program which contains only "safe" ascii characters | |
5711 ;; and which writes the right bytes to the file. We can use printf(1) | |
5712 ;; or "echo -e" or the printf function in awk and use octal escapes | |
5713 ;; for the "dangerous" characters. The null byte might be a problem. | |
5714 ;; On some systems, the octal escape doesn't work. So we try the following | |
5715 ;; two commands to write a null byte: | |
5716 ;; dd if=/dev/zero bs=1 count=1 | |
5717 ;; echo | tr '\n' '\000' | |
45861 | 5718 ;; * Cooperate with PCL-CVS. It uses start-process, which doesn't |
5719 ;; work for remote files. | |
5720 ;; * Rewrite `tramp-shell-quote-argument' to abstain from using | |
46790 | 5721 ;; `shell-quote-argument'. |
45861 | 5722 ;; * Completion gets confused when you leave out the method name. |
5723 ;; * Support `dired-compress-file' filename handler. | |
5724 ;; * In Emacs 21, `insert-directory' shows total number of bytes used | |
5725 ;; by the files in that directory. Add this here. | |
5726 ;; * Avoid screen blanking when hitting `g' in dired. (Eli Tziperman) | |
5727 ;; * Make ffap.el grok Tramp filenames. (Eli Tziperman) | |
5728 ;; * When logging in, keep looking for questions according to an alist | |
5729 ;; and then invoke the right function. | |
5730 ;; * Case-insensitive filename completion. (Norbert Goevert.) | |
5731 ;; * Running CVS remotely doesn't appear to work right. It thinks | |
5732 ;; files are locked by somebody else even if I'm the locking user. | |
5733 ;; Sometimes, one gets `No CVSROOT specified' errors from CVS. | |
5734 ;; (Skip Montanaro) | |
5735 ;; * Don't use globbing for directories with many files, as this is | |
5736 ;; likely to produce long command lines, and some shells choke on | |
5737 ;; long command lines. | |
5738 ;; * Find out about the new auto-save mechanism in Emacs 21 and | |
5739 ;; do the right thing. | |
5740 ;; * `vc-directory' does not work. It never displays any files, even | |
5741 ;; if it does show files when run locally. | |
5742 ;; * Allow correction of passwords, if the remote end allows this. | |
5743 ;; (Mark Hershberger) | |
5744 ;; * Make sure permissions of tmp file are good. | |
5745 ;; (Nelson Minar <nelson@media.mit.edu>) | |
5746 ;; * Grok passwd prompts with scp? (David Winter | |
5747 ;; <winter@nevis1.nevis.columbia.edu>). Maybe just do `ssh -l user | |
5748 ;; host', then wait a while for the passwd or passphrase prompt. If | |
5749 ;; there is one, remember the passwd/phrase. | |
5750 ;; * How to deal with MULE in `insert-file-contents' and `write-region'? | |
5751 ;; * Do asynchronous `shell-command's. | |
5752 ;; * Grok `append' parameter for `write-region'. | |
5753 ;; * Test remote ksh or bash for tilde expansion in `tramp-find-shell'? | |
5754 ;; * abbreviate-file-name | |
5755 ;; * grok ~ in tramp-remote-path (Henrik Holm <henrikh@tele.ntnu.no>) | |
5756 ;; * `C' in dired gives error `not tramp file name'. | |
5757 ;; * Also allow to omit user names when doing multi-hop. Not sure yet | |
5758 ;; what the user names should default to, though. | |
5759 ;; * better error checking. At least whenever we see something | |
5760 ;; strange when doing zerop, we should kill the process and start | |
5761 ;; again. (Greg Stark) | |
5762 ;; * Add caching for filename completion. (Greg Stark) | |
5763 ;; Of course, this has issues with usability (stale cache bites) | |
5764 ;; -- <daniel@danann.net> | |
5765 ;; * Provide a local cache of old versions of remote files for the rsync | |
5766 ;; transfer method to use. (Greg Stark) | |
5767 ;; * Remove unneeded parameters from methods. | |
5768 ;; * Invoke rsync once for copying a whole directory hierarchy. | |
5769 ;; (Francesco Potort́) | |
5770 ;; * Should we set PATH ourselves or should we rely on the remote end | |
5771 ;; to do it? | |
5772 ;; * Do the autoconf thing. | |
5773 ;; * Make it work for XEmacs 20, which is missing `with-timeout'. | |
5774 ;; * Allow non-Unix remote systems. (More a long-term thing.) | |
5775 ;; * Make it work for different encodings, and for different file name | |
5776 ;; encodings, too. (Daniel Pittman) | |
5777 ;; * Change applicable functions to pass a struct tramp-file-name rather | |
5778 ;; than the individual items MULTI-METHOD, METHOD, USER, HOST, PATH. | |
5779 ;; * Implement asynchronous shell commands. | |
5780 ;; * Clean up unused *tramp/foo* buffers after a while. (Pete Forman) | |
5781 ;; * Progress reports while copying files. (Michael Kifer) | |
5782 ;; * `Smart' connection method that uses inline for small and out of | |
5783 ;; band for large files. (Michael Kifer) | |
5784 ;; * Don't search for perl5 and perl. Instead, only search for perl and | |
5785 ;; then look if it's the right version (with `perl -v'). | |
5786 ;; * When editing a remote CVS controlled file as a different user, VC | |
5787 ;; gets confused about the file locking status. Try to find out why | |
5788 ;; the workaround doesn't work. | |
5789 ;; * When user is running ssh-agent, it would be useful to add the | |
5790 ;; passwords typed by the user to that agent. This way, the next time | |
5791 ;; round, the users don't have to type all this in again. | |
5792 ;; This would be especially useful for start-process, I think. | |
5793 ;; An easy way to implement start-process is to open a second shell | |
5794 ;; connection which is inconvenient if the user has to reenter | |
5795 ;; passwords. | |
5796 ;; * Change `copy-file' to grok the case where the filename handler | |
5797 ;; for the source and the target file are different. Right now, | |
5798 ;; it looks at the source file and then calls that handler, if | |
5799 ;; there is one. But since ange-ftp, for instance, does not know | |
5800 ;; about Tramp, it does not do the right thing if the target file | |
5801 ;; name is a Tramp name. | |
5802 | |
5803 ;; Functions for file-name-handler-alist: | |
5804 ;; diff-latest-backup-file -- in diff.el | |
5805 ;; dired-compress-file | |
5806 ;; dired-uncache -- this will be needed when we do insert-directory caching | |
5807 ;; file-name-as-directory -- use primitive? | |
5808 ;; file-name-directory -- use primitive? | |
5809 ;; file-name-nondirectory -- use primitive? | |
5810 ;; file-name-sans-versions -- use primitive? | |
5811 ;; file-newer-than-file-p | |
5812 ;; find-backup-file-name | |
5813 ;; get-file-buffer -- use primitive | |
5814 ;; load | |
5815 ;; unhandled-file-name-directory | |
5816 ;; vc-registered | |
5817 | |
5818 ;;; tramp.el ends here |