Mercurial > emacs
annotate lisp/net/tramp.el @ 46752:54b975949d6a
New version 2.0.5.
(tramp-methods): Remove inline encoding method parameters. The
encoding is now autodetected. Also shorten the list of
methods (u/m distinction gone) and rename the remaining methods to
have longer, but more mnemonic, names.
(tramp-login-prompt-regexp, tramp-password-prompt-regexp)
(tramp-wrong-passwd-regexp): Trailing `$' not needed, regexp is
matched at end of buffer anyway.
(tramp-yesno-prompt-regexp): New variable, for questions where the
user should say "yes" or "no".
(tramp-file-name-structure-unified)
(tramp-file-name-structure-separate): Allow dash in method names.
(tramp-actions-before-shell): New variable, contains list of
pattern/action pairs. Output sent by remote end is scanned for
the patterns, then the actions are executed.
(tramp-multi-actions): Like `tramp-actions-before-shell', but
executed for each hop in a multi-hop connection.
(tramp-last-cmd-time): New variable. If nothing has been sent to
remote end for 60 seconds, look to see if the remote end is still
alive.
(tramp-perl-mime-encode, tramp-perl-mime-decode): Remove. It
didn't work.
(tramp-perl-encode, tramp-perl-decode): New variables, these
require the MIME::Base64 module on the remote end.
(tramp-handle-file-attributes): Restructure logic.
(tramp-handle-file-attributes-with-ls)
(tramp-handle-file-attributes-with-perl): More debugging.
(tramp-handle-directory-files): Grok fifth arg `files-only' for
XEmacs.
(tramp-handle-make-directory, tramp-handle-delete-directory)
(tramp-handle-delete-file, tramp-handle-insert-directory): Expand
file name.
(tramp-handle-shell-command): Use `when', not `if'.
(tramp-handle-file-local-copy, tramp-handle-write-region): Adapt
to autodetection of inline encoding.
(tramp-invoke-ange-ftp): Require ange-ftp to make sure that
variable ange-ftp-name-format is defined before binding it.
(tramp-action-login, tramp-action-password, tramp-action-succeed)
(tramp-action-permission-denied, tramp-action-yesno): Functions
called from `tramp-actions-before-shell'.
(tramp-multi-action-login, tramp-multi-action-password)
(tramp-multi-action-succeed)
(tramp-multi-action-permission-denied): Functions called from
`tramp-multi-actions'.
(tramp-process-one-action, tramp-process-actions): Pattern
matching and action invocation code for
`tramp-actions-before-shell'.
(tramp-process-one-multi-action, tramp-process-multi-actions):
Same for `tramp-multi-actions'.
(tramp-open-connection-telnet, tramp-open-connection-rsh)
(tramp-open-connection-su): Process actions instead of hardwired
logic.
(tramp-multi-connect-telnet, tramp-multi-connect-rlogin)
(tramp-multi-connect-su): Ditto.
(tramp-post-connection): New method for tramp_encode and
tramp_decode scripts.
(tramp-post-connection): Invoke inline autodetection code.
(tramp-coding-commands): List of inline codings.
(tramp-find-inline-encoding): This is the inline autodetection
code.
(tramp-maybe-open-connection): If nothing was sent to connection
for 60 seconds, look if it connection is still alive.
(tramp-send-command): Remember that something was sent to the
connection.
(tramp-make-tramp-file-name, tramp-make-tramp-multi-file-name):
Use backticks for constructing alist.
(tramp-get-encoding-command, tramp-set-encoding-command)
(tramp-get-decoding-command, tramp-set-decoding-command)
(tramp-get-encoding-function, tramp-set-encoding-function)
(tramp-get-decoding-function, tramp-set-decoding-function): Use
for results of inline autodetection.
(tramp-get-encoding-command, tramp-get-decoding-command)
(tramp-get-encoding-function, tramp-get-decoding-function):
Remove these old functions.
author | Kai Großjohann <kgrossjo@eu.uu.net> |
---|---|
date | Tue, 30 Jul 2002 20:24:27 +0000 |
parents | f548d7d0c651 |
children | c217aa0214e2 |
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 | |
46752 | 72 (defconst tramp-version "2.0.5" |
45861 | 73 "This version of tramp.") |
46752 | 74 |
45861 | 75 (defconst tramp-bug-report-address "tramp-devel@mail.freesoftware.fsf.org" |
76 "Email address to send bug reports to.") | |
77 | |
78 (require 'timer) | |
79 (require 'format-spec) ;from Gnus 5.8, also in tar ball | |
80 (require 'base64) ;for the mimencode methods | |
81 (require 'shell) | |
82 (require 'advice) | |
83 | |
84 ;; ;; It does not work to load EFS after loading TRAMP. | |
85 ;; (when (fboundp 'efs-file-handler-function) | |
86 ;; (require 'efs)) | |
87 | |
88 (eval-when-compile | |
89 (require 'cl) | |
90 (require 'custom) | |
91 ;; Emacs 19.34 compatibility hack -- is this needed? | |
92 (or (>= emacs-major-version 20) | |
93 (load "cl-seq"))) | |
94 | |
95 (unless (boundp 'custom-print-functions) | |
96 (defvar custom-print-functions nil)) ; not autoloaded before Emacs 20.4 | |
97 | |
98 ;;; User Customizable Internal Variables: | |
99 | |
100 (defgroup tramp nil | |
101 "Edit remote files with a combination of rsh and rcp or similar programs." | |
102 :group 'files) | |
103 | |
104 (defcustom tramp-verbose 10 | |
105 "*Verbosity level for tramp.el. 0 means be silent, 10 is most verbose." | |
106 :group 'tramp | |
107 :type 'integer) | |
108 | |
109 (defcustom tramp-debug-buffer nil | |
110 "*Whether to send all commands and responses to a debug buffer." | |
111 :group 'tramp | |
112 :type 'boolean) | |
113 | |
114 (defcustom tramp-auto-save-directory nil | |
115 "*Put auto-save files in this directory, if set. | |
116 The idea is to use a local directory so that auto-saving is faster." | |
117 :group 'tramp | |
118 :type '(choice (const nil) | |
119 string)) | |
120 | |
121 (defcustom tramp-sh-program "/bin/sh" | |
122 "*Use this program for shell commands on the local host. | |
123 This MUST be a Bourne-like shell. This shell is used to execute | |
124 the encoding and decoding command on the local host, so if you | |
125 want to use `~' in those commands, you should choose a shell here | |
126 which groks tilde expansion. `/bin/sh' normally does not | |
127 understand tilde expansion. | |
128 | |
129 Note that this variable is not used for remote commands. There are | |
130 mechanisms in tramp.el which automatically determine the right shell to | |
131 use for the remote host." | |
132 :group 'tramp | |
133 :type '(file :must-match t)) | |
134 | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
135 (defcustom tramp-multi-sh-program |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
136 (if (memq system-type '(windows-nt)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
137 "cmd.exe" |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
138 tramp-sh-program) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
139 "*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
|
140 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
|
141 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
|
142 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
|
143 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
|
144 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
|
145 |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
146 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
|
147 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
|
148 |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
149 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
|
150 `tramp-sh-program' on other systems." |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
151 :group 'tramp |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
152 :type '(file :must-match t)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
153 |
45861 | 154 ;; CCC I have changed all occurrences of comint-quote-filename with |
155 ;; tramp-shell-quote-argument, except in tramp-handle-expand-many-files. | |
156 ;; There, comint-quote-filename was removed altogether. If it turns | |
157 ;; out to be necessary there, something will need to be done. | |
158 ;;-(defcustom tramp-file-name-quote-list | |
159 ;;- '(?] ?[ ?\| ?& ?< ?> ?\( ?\) ?\; ?\ ?\* ?\? ?\! ?\" ?\' ?\` ?# ?\@ ?\+ ) | |
160 ;;- "*Protect these characters from the remote shell. | |
161 ;;-Any character in this list is quoted (preceded with a backslash) | |
162 ;;-because it means something special to the shell. This takes effect | |
163 ;;-when sending file and directory names to the remote shell. | |
164 ;;- | |
165 ;;-See `comint-file-name-quote-list' for details." | |
166 ;;- :group 'tramp | |
167 ;;- :type '(repeat character)) | |
168 | |
169 (defcustom tramp-methods | |
170 '( ("rcp" (tramp-connection-function tramp-open-connection-rsh) | |
171 (tramp-rsh-program "rsh") | |
172 (tramp-rcp-program "rcp") | |
173 (tramp-remote-sh "/bin/sh") | |
174 (tramp-rsh-args nil) | |
175 (tramp-rcp-args nil) | |
176 (tramp-rcp-keep-date-arg "-p") | |
177 (tramp-su-program nil) | |
178 (tramp-su-args nil) | |
179 (tramp-telnet-program nil) | |
180 (tramp-telnet-args nil)) | |
181 ("scp" (tramp-connection-function tramp-open-connection-rsh) | |
182 (tramp-rsh-program "ssh") | |
183 (tramp-rcp-program "scp") | |
184 (tramp-remote-sh "/bin/sh") | |
185 (tramp-rsh-args ("-e" "none")) | |
186 (tramp-rcp-args nil) | |
187 (tramp-rcp-keep-date-arg "-p") | |
188 (tramp-su-program nil) | |
189 (tramp-su-args nil) | |
190 (tramp-telnet-program nil) | |
191 (tramp-telnet-args nil)) | |
192 ("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
|
193 (tramp-rsh-program "ssh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
194 (tramp-rcp-program "scp") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
195 (tramp-remote-sh "/bin/sh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
196 (tramp-rsh-args ("-1" "-e" "none")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
197 (tramp-rcp-args ("-1")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
198 (tramp-rcp-keep-date-arg "-p") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
199 (tramp-su-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
200 (tramp-su-args nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
201 (tramp-telnet-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
202 (tramp-telnet-args nil)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
203 ("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
|
204 (tramp-rsh-program "ssh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
205 (tramp-rcp-program "scp") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
206 (tramp-remote-sh "/bin/sh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
207 (tramp-rsh-args ("-2" "-e" "none")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
208 (tramp-rcp-args ("-2")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
209 (tramp-rcp-keep-date-arg "-p") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
210 (tramp-su-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
211 (tramp-su-args nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
212 (tramp-telnet-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
213 (tramp-telnet-args nil)) |
46752 | 214 ("scp1-old" |
215 (tramp-connection-function tramp-open-connection-rsh) | |
45861 | 216 (tramp-rsh-program "ssh1") |
217 (tramp-rcp-program "scp1") | |
218 (tramp-remote-sh "/bin/sh") | |
219 (tramp-rsh-args ("-e" "none")) | |
220 (tramp-rcp-args nil) | |
221 (tramp-rcp-keep-date-arg "-p") | |
222 (tramp-su-program nil) | |
223 (tramp-su-args nil) | |
224 (tramp-telnet-program nil) | |
225 (tramp-telnet-args nil)) | |
46752 | 226 ("scp2-old" |
227 (tramp-connection-function tramp-open-connection-rsh) | |
45861 | 228 (tramp-rsh-program "ssh2") |
229 (tramp-rcp-program "scp2") | |
230 (tramp-remote-sh "/bin/sh") | |
231 (tramp-rsh-args ("-e" "none")) | |
232 (tramp-rcp-args nil) | |
233 (tramp-rcp-keep-date-arg "-p") | |
234 (tramp-su-program nil) | |
235 (tramp-su-args nil) | |
236 (tramp-telnet-program nil) | |
237 (tramp-telnet-args nil)) | |
238 ("rsync" (tramp-connection-function tramp-open-connection-rsh) | |
239 (tramp-rsh-program "ssh") | |
240 (tramp-rcp-program "rsync") | |
241 (tramp-remote-sh "/bin/sh") | |
242 (tramp-rsh-args ("-e" "none")) | |
243 (tramp-rcp-args ("-e" "ssh")) | |
244 (tramp-rcp-keep-date-arg "-t") | |
245 (tramp-su-program nil) | |
246 (tramp-su-args nil) | |
247 (tramp-telnet-program nil) | |
248 (tramp-telnet-args nil)) | |
46752 | 249 ("rsh" (tramp-connection-function tramp-open-connection-rsh) |
45861 | 250 (tramp-rsh-program "rsh") |
251 (tramp-rcp-program nil) | |
252 (tramp-remote-sh "/bin/sh") | |
253 (tramp-rsh-args nil) | |
254 (tramp-rcp-args nil) | |
255 (tramp-rcp-keep-date-arg nil) | |
256 (tramp-su-program nil) | |
257 (tramp-su-args nil) | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
258 (tramp-telnet-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
259 (tramp-telnet-args nil)) |
46752 | 260 ("ssh" (tramp-connection-function tramp-open-connection-rsh) |
45861 | 261 (tramp-rsh-program "ssh") |
262 (tramp-rcp-program nil) | |
263 (tramp-remote-sh "/bin/sh") | |
264 (tramp-rsh-args ("-e" "none")) | |
265 (tramp-rcp-args nil) | |
266 (tramp-rcp-keep-date-arg nil) | |
267 (tramp-su-program nil) | |
268 (tramp-su-args nil) | |
46752 | 269 (tramp-telnet-program nil) |
270 (tramp-telnet-args nil)) | |
271 ("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
|
272 (tramp-rsh-program "ssh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
273 (tramp-rcp-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
274 (tramp-remote-sh "/bin/sh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
275 (tramp-rsh-args ("-1" "-e" "none")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
276 (tramp-rcp-args ("-1")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
277 (tramp-rcp-keep-date-arg nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
278 (tramp-su-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
279 (tramp-su-args nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
280 (tramp-telnet-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
281 (tramp-telnet-args nil)) |
46752 | 282 ("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
|
283 (tramp-rsh-program "ssh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
284 (tramp-rcp-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
285 (tramp-remote-sh "/bin/sh") |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
286 (tramp-rsh-args ("-2" "-e" "none")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
287 (tramp-rcp-args ("-2")) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
288 (tramp-rcp-keep-date-arg nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
289 (tramp-su-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
290 (tramp-su-args nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
291 (tramp-telnet-program nil) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
292 (tramp-telnet-args nil)) |
46752 | 293 ("ssh1-old" |
294 (tramp-connection-function tramp-open-connection-rsh) | |
45861 | 295 (tramp-rsh-program "ssh1") |
296 (tramp-rcp-program nil) | |
297 (tramp-remote-sh "/bin/sh") | |
298 (tramp-rsh-args ("-e" "none")) | |
299 (tramp-rcp-args nil) | |
300 (tramp-rcp-keep-date-arg nil) | |
301 (tramp-su-program nil) | |
302 (tramp-su-args nil) | |
303 (tramp-telnet-program nil) | |
304 (tramp-telnet-args nil)) | |
46752 | 305 ("ssh2-old" |
306 (tramp-connection-function tramp-open-connection-rsh) | |
45861 | 307 (tramp-rsh-program "ssh2") |
308 (tramp-rcp-program nil) | |
309 (tramp-remote-sh "/bin/sh") | |
310 (tramp-rsh-args ("-e" "none")) | |
311 (tramp-rcp-args nil) | |
312 (tramp-rcp-keep-date-arg nil) | |
313 (tramp-su-program nil) | |
314 (tramp-su-args nil) | |
46752 | 315 (tramp-telnet-program nil) |
316 (tramp-telnet-args nil)) | |
317 ("ssh1-old" | |
318 (tramp-connection-function tramp-open-connection-rsh) | |
319 (tramp-rsh-program "ssh1") | |
320 (tramp-rcp-program nil) | |
321 (tramp-remote-sh "/bin/sh") | |
322 (tramp-rsh-args ("-e" "none")) | |
323 (tramp-rcp-args nil) | |
324 (tramp-rcp-keep-date-arg nil) | |
325 (tramp-su-program nil) | |
326 (tramp-su-args nil) | |
45861 | 327 (tramp-telnet-program nil) |
328 (tramp-telnet-args nil)) | |
46752 | 329 ("ssh2-old" |
330 (tramp-connection-function tramp-open-connection-rsh) | |
331 (tramp-rsh-program "ssh2") | |
332 (tramp-rcp-program nil) | |
333 (tramp-remote-sh "/bin/sh") | |
334 (tramp-rsh-args ("-e" "none")) | |
335 (tramp-rcp-args nil) | |
336 (tramp-rcp-keep-date-arg nil) | |
337 (tramp-su-program nil) | |
338 (tramp-su-args nil) | |
339 (tramp-telnet-program nil) | |
340 (tramp-telnet-args nil)) | |
341 ("telnet" | |
342 (tramp-connection-function tramp-open-connection-telnet) | |
45861 | 343 (tramp-rsh-program nil) |
344 (tramp-rcp-program nil) | |
345 (tramp-remote-sh "/bin/sh") | |
346 (tramp-rsh-args nil) | |
347 (tramp-rcp-args nil) | |
348 (tramp-rcp-keep-date-arg nil) | |
349 (tramp-su-program nil) | |
350 (tramp-su-args nil) | |
351 (tramp-telnet-program "telnet") | |
352 (tramp-telnet-args nil)) | |
46752 | 353 ("su" (tramp-connection-function tramp-open-connection-su) |
45861 | 354 (tramp-rsh-program nil) |
355 (tramp-rcp-program nil) | |
356 (tramp-remote-sh "/bin/sh") | |
357 (tramp-rsh-args nil) | |
358 (tramp-rcp-args nil) | |
359 (tramp-rcp-keep-date-arg nil) | |
360 (tramp-su-program "su") | |
361 (tramp-su-args ("-" "%u")) | |
362 (tramp-telnet-program nil) | |
363 (tramp-telnet-args nil)) | |
46752 | 364 ("sudo" (tramp-connection-function tramp-open-connection-su) |
45861 | 365 (tramp-rsh-program nil) |
366 (tramp-rcp-program nil) | |
367 (tramp-remote-sh "/bin/sh") | |
368 (tramp-rsh-args nil) | |
369 (tramp-rcp-args nil) | |
370 (tramp-rcp-keep-date-arg nil) | |
371 (tramp-su-program "sudo") | |
372 (tramp-su-args ("-u" "%u" "-s")) | |
373 (tramp-telnet-program nil) | |
374 (tramp-telnet-args nil)) | |
375 ("multi" (tramp-connection-function tramp-open-connection-multi) | |
376 (tramp-rsh-program nil) | |
377 (tramp-rcp-program nil) | |
378 (tramp-remote-sh "/bin/sh") | |
379 (tramp-rsh-args nil) | |
380 (tramp-rcp-args nil) | |
381 (tramp-rcp-keep-date-arg nil) | |
382 (tramp-su-program nil) | |
383 (tramp-su-args nil) | |
384 (tramp-telnet-program nil) | |
385 (tramp-telnet-args nil)) | |
386 ("scpx" (tramp-connection-function tramp-open-connection-rsh) | |
387 (tramp-rsh-program "ssh") | |
388 (tramp-rcp-program "scp") | |
389 (tramp-remote-sh "/bin/sh") | |
390 (tramp-rsh-args ("-e" "none" "-t" "-t" "/bin/sh")) | |
391 (tramp-rcp-args nil) | |
392 (tramp-rcp-keep-date-arg "-p") | |
393 (tramp-telnet-program nil) | |
394 (tramp-telnet-args nil)) | |
46752 | 395 ("sshx" (tramp-connection-function tramp-open-connection-rsh) |
45861 | 396 (tramp-rsh-program "ssh") |
397 (tramp-rcp-program nil) | |
398 (tramp-remote-sh "/bin/sh") | |
399 (tramp-rsh-args ("-e" "none" "-t" "-t" "/bin/sh")) | |
400 (tramp-rcp-args nil) | |
401 (tramp-rcp-keep-date-arg nil) | |
402 (tramp-su-program nil) | |
403 (tramp-su-args nil) | |
404 (tramp-telnet-program nil) | |
405 (tramp-telnet-args nil)) | |
46752 | 406 ("krlogin" |
45861 | 407 (tramp-connection-function tramp-open-connection-rsh) |
408 (tramp-rsh-program "krlogin") | |
409 (tramp-rcp-program nil) | |
410 (tramp-remote-sh "/bin/sh") | |
411 (tramp-rsh-args ("-x")) | |
412 (tramp-rcp-args nil) | |
413 (tramp-rcp-keep-date-arg nil) | |
414 (tramp-su-program nil) | |
415 (tramp-su-args nil) | |
416 (tramp-telnet-program nil) | |
417 (tramp-telnet-args nil)) | |
46752 | 418 ("plink" |
45861 | 419 (tramp-connection-function tramp-open-connection-rsh) |
420 (tramp-rsh-program "plink") | |
421 (tramp-rcp-program nil) | |
422 (tramp-remote-sh "/bin/sh") | |
423 (tramp-rsh-args ("-ssh")) ;optionally add "-v" | |
424 (tramp-rcp-args nil) | |
425 (tramp-rcp-keep-date-arg nil) | |
426 (tramp-su-program nil) | |
427 (tramp-su-args nil) | |
428 (tramp-telnet-program nil) | |
429 (tramp-telnet-args nil)) | |
430 ("pscp" | |
431 (tramp-connection-function tramp-open-connection-rsh) | |
432 (tramp-rsh-program "plink") | |
433 (tramp-rcp-program "pscp") | |
434 (tramp-remote-sh "/bin/sh") | |
435 (tramp-rsh-args ("-ssh")) | |
436 (tramp-rcp-args nil) | |
437 (tramp-rcp-keep-date-arg "-p") | |
438 (tramp-su-program nil) | |
439 (tramp-su-args nil) | |
440 (tramp-telnet-program nil) | |
441 (tramp-telnet-args nil)) | |
442 ("fcp" | |
443 (tramp-connection-function tramp-open-connection-rsh) | |
444 (tramp-rsh-program "fsh") | |
445 (tramp-rcp-program "fcp") | |
446 (tramp-remote-sh "/bin/sh -i") | |
447 (tramp-rsh-args ("sh" "-i")) | |
448 (tramp-rcp-args nil) | |
449 (tramp-rcp-keep-date-arg "-p") | |
450 (tramp-su-program nil) | |
451 (tramp-su-args nil) | |
452 (tramp-telnet-program nil) | |
453 (tramp-telnet-args nil)) | |
454 ) | |
455 "*Alist of methods for remote files. | |
456 This is a list of entries of the form (NAME PARAM1 PARAM2 ...). | |
457 Each NAME stands for a remote access method. Each PARAM is a | |
458 pair of the form (KEY VALUE). The following KEYs are defined: | |
459 * `tramp-connection-function' | |
460 This specifies the function to use to connect to the remote host. | |
461 Currently, `tramp-open-connection-rsh', `tramp-open-connection-telnet' | |
462 and `tramp-open-connection-su' are defined. See the documentation | |
463 of these functions for more details. | |
464 * `tramp-remote-sh' | |
465 This specifies the Bourne shell to use on the remote host. This | |
466 MUST be a Bourne-like shell. It is normally not necessary to set | |
467 this to any value other than \"/bin/sh\": tramp wants to use a shell | |
468 which groks tilde expansion, but it can search for it. Also note | |
469 that \"/bin/sh\" exists on all Unixen, this might not be true for | |
470 the value that you decide to use. You Have Been Warned. | |
471 * `tramp-rsh-program' | |
472 This specifies the name of the program to use for rsh; this might be | |
473 the full path to rsh or the name of a workalike program. | |
474 * `tramp-rsh-args' | |
475 This specifies the list of arguments to pass to the above | |
476 mentioned program. Please note that this is a list of arguments, | |
477 that is, normally you don't want to put \"-a -b\" or \"-f foo\" | |
478 here. Instead, you want two list elements, one for \"-a\" and one | |
479 for \"-b\", or one for \"-f\" and one for \"foo\". | |
480 * `tramp-rcp-program' | |
481 This specifies the name of the program to use for rcp; this might be | |
482 the full path to rcp or the name of a workalike program. | |
483 * `tramp-rcp-args' | |
484 This specifies the list of parameters to pass to the above mentioned | |
485 program, the hints for `tramp-rsh-args' also apply here. | |
486 * `tramp-rcp-keep-date-arg' | |
487 This specifies the parameter to use for `rcp' when the timestamp | |
488 of the original file should be kept. For `rcp', use `-p', for | |
489 `rsync', use `-t'. | |
490 * `tramp-su-program' | |
491 This specifies the name of the program to use for `su'. | |
492 * `tramp-su-args' | |
493 This specifies the list of arguments to pass to `su'. | |
494 \"%u\" is replaced by the user name, use \"%%\" for a literal | |
495 percent character. | |
496 * `tramp-encoding-command' | |
497 This specifies a command to use to encode the file contents for | |
498 transfer. The command should read the raw file contents from | |
499 standard input and write the encoded file contents to standard | |
500 output. In this string, the percent escape \"%f\" should be used | |
501 to indicate the file to convert. Use \"%%\" if you need a literal | |
502 percent character in your command. | |
503 * `tramp-decoding-command' | |
504 This specifies a command to use to decode file contents encoded | |
505 with `tramp-encoding-command'. The command should read from standard | |
506 input and write to standard output. | |
507 * `tramp-encoding-function' | |
508 This specifies a function to be called to encode the file contents | |
509 on the local side. This function should accept two arguments | |
510 START and END, the beginning and end of the region to encode. The | |
511 region should be replaced with the encoded contents. | |
512 * `tramp-decoding-function' | |
513 Same for decoding on the local side. | |
514 * `tramp-telnet-program' | |
515 Specifies the telnet program to use when using | |
516 `tramp-open-connection-telnet' to log in. | |
517 * `tramp-telnet-args' | |
518 Specifies list of arguments to pass to `telnet'. The hints for | |
519 `tramp-rsh-args' also apply here. | |
520 | |
521 What does all this mean? Well, you should specify `tramp-rsh-program', | |
522 `tramp-telnet-program' or `tramp-su-program' for all methods; this program | |
523 is used to log in to the remote site. Then, there are two ways to | |
524 actually transfer the files between the local and the remote side. | |
525 One way is using an additional rcp-like program. If you want to do | |
526 this, set `tramp-rcp-program' in the method. | |
527 | |
528 Another possibility for file transfer is inline transfer, i.e. the | |
529 file is passed through the same buffer used by `tramp-rsh-program'. In | |
530 this case, the file contents need to be protected since the | |
531 `tramp-rsh-program' might use escape codes or the connection might not | |
532 be eight-bit clean. Therefore, file contents are encoded for transit. | |
533 | |
534 Two possibilities for encoding are uuencode/uudecode and mimencode. | |
535 For uuencode/uudecode you want to set `tramp-encoding-command' to | |
536 something like \"uuencode\" and `tramp-decoding-command' to \"uudecode | |
537 -p\". For mimencode you want to set `tramp-encoding-command' to | |
538 something like \"mimencode -b\" and `tramp-decoding-command' to | |
539 \"mimencode -b -u\". | |
540 | |
541 When using inline transfer, you can use a program or a Lisp function | |
542 on the local side to encode or decode the file contents. Set the | |
543 `tramp-encoding-function' and `tramp-decoding-function' parameters to nil | |
544 in order to use the commands or to the function to use. It is | |
545 possible to specify one function and the other parameter as nil. | |
546 | |
547 So, to summarize: if the method is an inline method, you must specify | |
548 `tramp-encoding-command' and `tramp-decoding-command', and | |
549 `tramp-rcp-program' must be nil. If the method is out of band, then | |
550 you must specify `tramp-rcp-program' and `tramp-rcp-args' and | |
551 `tramp-encoding-command' and `tramp-decoding-command' must be nil. | |
552 Every method, inline or out of band, must specify | |
553 `tramp-connection-function' plus the associated arguments (for | |
554 example, the telnet program if you chose | |
555 `tramp-open-connection-telnet'). | |
556 | |
557 Notes: | |
558 | |
559 When using `tramp-open-connection-su' the phrase `open connection to a | |
560 remote host' sounds strange, but it is used nevertheless, for | |
561 consistency. No connection is opened to a remote host, but `su' is | |
562 started on the local host. You are not allowed to specify a remote | |
563 host other than `localhost' or the name of the local host. | |
564 | |
565 Using a uuencode/uudecode inline method is discouraged, please use one | |
566 of the base64 methods instead since base64 encoding is much more | |
567 reliable and the commands are more standardized between the different | |
568 Unix versions. But if you can't use base64 for some reason, please | |
569 note that the default uudecode command does not work well for some | |
570 Unices, in particular AIX and Irix. For AIX, you might want to use | |
571 the following command for uudecode: | |
572 | |
573 sed '/^begin/d;/^[` ]$/d;/^end/d' | iconv -f uucode -t ISO8859-1 | |
574 | |
575 For Irix, no solution is known yet." | |
576 :group 'tramp | |
577 :type '(repeat | |
578 (cons string | |
579 (set (list (const tramp-connection-function) function) | |
580 (list (const tramp-rsh-program) | |
581 (choice (const nil) string)) | |
582 (list (const tramp-rcp-program) | |
583 (choice (const nil) string)) | |
584 (list (const tramp-remote-sh) | |
585 (choice (const nil) string)) | |
586 (list (const tramp-rsh-args) (repeat string)) | |
587 (list (const tramp-rcp-args) (repeat string)) | |
588 (list (const tramp-rcp-keep-date-arg) | |
589 (choice (const nil) string)) | |
590 (list (const tramp-su-program) | |
591 (choice (const nil) string)) | |
592 (list (const tramp-su-args) (repeat string)) | |
593 (list (const tramp-encoding-command) | |
594 (choice (const nil) string)) | |
595 (list (const tramp-decoding-command) | |
596 (choice (const nil) string)) | |
597 (list (const tramp-encoding-function) | |
598 (choice (const nil) function)) | |
599 (list (const tramp-decoding-function) | |
600 (choice (const nil) function)) | |
601 (list (const tramp-telnet-program) | |
602 (choice (const nil) string)) | |
603 (list (const tramp-telnet-args) (repeat string)))))) | |
604 | |
605 (defcustom tramp-multi-methods '("multi" "multiu") | |
606 "*List of multi-hop methods. | |
607 Each entry in this list should be a method name as mentioned in the | |
608 variable `tramp-methods'." | |
609 :group 'tramp | |
610 :type '(repeat string)) | |
611 | |
612 (defcustom tramp-multi-connection-function-alist | |
613 '(("telnet" tramp-multi-connect-telnet "telnet %h%n") | |
614 ("rsh" tramp-multi-connect-rlogin "rsh %h -l %u%n") | |
615 ("ssh" tramp-multi-connect-rlogin "ssh %h -l %u%n") | |
616 ("su" tramp-multi-connect-su "su - %u%n") | |
617 ("sudo" tramp-multi-connect-su "sudo -u %u -s%n")) | |
618 "*List of connection functions for multi-hop methods. | |
619 Each list item is a list of three items (METHOD FUNCTION COMMAND), | |
620 where METHOD is the name as used in the file name, FUNCTION is the | |
621 function to be executed, and COMMAND is the shell command used for | |
622 connecting. | |
623 | |
624 COMMAND may contain percent escapes. `%u' will be replaced with the | |
625 user name, `%h' will be replaced with the host name, and `%n' will be | |
626 replaced with an end-of-line character, as specified in the variable | |
627 `tramp-rsh-end-of-line'. Use `%%' for a literal percent character. | |
628 Note that the interpretation of the percent escapes also depends on | |
629 the FUNCTION. For example, the `%u' escape is forbidden with the | |
630 function `tramp-multi-connect-telnet'. See the documentation of the | |
631 various functions for details." | |
632 :group 'tramp | |
633 :type '(repeat (list string function string))) | |
634 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
635 (defcustom tramp-default-method "sm" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
636 ;;(if (featurep 'xemacs) "sm" "ftp") |
45861 | 637 "*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
|
638 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
|
639 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
|
640 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
641 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
|
642 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
|
643 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
|
644 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
|
645 :group 'tramp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
646 :type 'string) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
647 |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
648 (defcustom tramp-default-method-alist |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
649 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
650 nil |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
651 '(("\\`ftp\\." "" "ftp") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
652 ("" "\\`\\(anonymous\\|ftp\\)\\'" "ftp"))) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
653 "*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
|
654 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
|
655 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
|
656 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
|
657 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
|
658 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
|
659 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
660 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
|
661 empty string for the user name. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
662 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
663 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
|
664 :group 'tramp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
665 :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
|
666 (regexp :tag "User regexp") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
667 (string :tag "Method")))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
668 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
669 (defcustom tramp-ftp-method "ftp" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
670 "*When this method name is used, forward all calls to Ange-FTP." |
45861 | 671 :group 'tramp |
672 :type 'string) | |
673 | |
674 (defcustom tramp-rsh-end-of-line "\n" | |
675 "*String used for end of line in rsh connections. | |
676 I don't think this ever needs to be changed, so please tell me about it | |
677 if you need to change this." | |
678 :group 'tramp | |
679 :type 'string) | |
680 | |
681 (defcustom tramp-remote-path | |
682 '("/bin" "/usr/bin" "/usr/sbin" "/usr/local/bin" "/usr/ccs/bin" | |
683 "/local/bin" "/local/freeware/bin" "/local/gnu/bin" | |
684 "/usr/freeware/bin" "/usr/pkg/bin" "/usr/contrib/bin") | |
685 "*List of directories to search for executables on remote host. | |
686 Please notify me about other semi-standard directories to include here. | |
687 | |
688 You can use `~' in this list, but when searching for a shell which groks | |
689 tilde expansion, all directory names starting with `~' will be ignored." | |
690 :group 'tramp | |
691 :type '(repeat string)) | |
692 | |
693 (defcustom tramp-login-prompt-regexp | |
46752 | 694 ".*ogin: *" |
45861 | 695 "*Regexp matching login-like prompts. |
46752 | 696 The regexp should match at end of buffer." |
45861 | 697 :group 'tramp |
698 :type 'regexp) | |
699 | |
700 (defcustom tramp-password-prompt-regexp | |
46752 | 701 "^.*\\([pP]assword\\|passphrase.*\\):\^@? *" |
45861 | 702 "*Regexp matching password-like prompts. |
46752 | 703 The regexp should match at end of buffer. |
45861 | 704 |
705 The `sudo' program appears to insert a `^@' character into the prompt." | |
706 :group 'tramp | |
707 :type 'regexp) | |
708 | |
709 (defcustom tramp-wrong-passwd-regexp | |
710 (concat "^.*\\(Permission denied.\\|Login [Ii]ncorrect\\|" | |
711 "Received signal [0-9]+\\|Connection \\(refused\\|closed\\)\\|" | |
46752 | 712 "Sorry, try again.\\|Name or service not known\\).*") |
45861 | 713 "*Regexp matching a `login failed' message. |
46752 | 714 The regexp should match at end of buffer." |
715 :group 'tramp | |
716 :type 'regexp) | |
717 | |
718 (defcustom tramp-yesno-prompt-regexp | |
719 "Are you sure you want to continue connecting (yes/no)\\? *" | |
720 "Regular expression matching all queries which need to be confirmed. | |
721 The confirmation should be done with yes or no. | |
722 The regexp should match at end of buffer." | |
45861 | 723 :group 'tramp |
724 :type 'regexp) | |
725 | |
726 (defcustom tramp-temp-name-prefix "tramp." | |
727 "*Prefix to use for temporary files. | |
728 If this is a relative file name (such as \"tramp.\"), it is considered | |
729 relative to the directory name returned by the function | |
730 `tramp-temporary-file-directory' (which see). It may also be an | |
731 absolute file name; don't forget to include a prefix for the filename | |
732 part, though." | |
733 :group 'tramp | |
734 :type 'string) | |
735 | |
736 (defcustom tramp-discard-garbage nil | |
737 "*If non-nil, try to discard garbage sent by remote shell. | |
738 Some shells send such garbage upon connection setup." | |
739 :group 'tramp | |
740 :type 'boolean) | |
741 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
742 (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
|
743 "*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
|
744 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
|
745 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
|
746 arguments. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
747 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
748 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
|
749 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
|
750 shell from reading its init file." |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
751 :group 'tramp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
752 :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
|
753 |
45861 | 754 ;; File name format. |
755 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
756 (defconst tramp-file-name-structure-unified |
46752 | 757 (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
|
758 "\\(\\([^:@/]+\\)@\\)?" ;user |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
759 "\\([^:/]+\\):" ;host |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
760 "\\(.*\\)\\'") ;path |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
761 2 4 5 6) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
762 "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
|
763 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
|
764 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
|
765 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
766 (defconst tramp-file-name-structure-separate |
46752 | 767 (list (concat "\\`/\\[\\(\\([a-zA-Z0-9-]+\\)/\\)?" ;method |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
768 "\\(\\([-a-zA-Z0-9_#/:]+\\)@\\)?" ;user |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
769 "\\([-a-zA-Z0-9_#/:@.]+\\)\\]" ;host |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
770 "\\(.*\\)\\'") ;path |
45861 | 771 2 4 5 6) |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
772 "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
|
773 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
|
774 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
|
775 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
|
776 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
777 (defcustom tramp-file-name-structure |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
778 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
779 tramp-file-name-structure-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
780 tramp-file-name-structure-unified) |
45861 | 781 "*List of five elements (REGEXP METHOD USER HOST FILE), detailing \ |
782 the tramp file name structure. | |
783 | |
784 The first element REGEXP is a regular expression matching a tramp file | |
785 name. The regex should contain parentheses around the method name, | |
786 the user name, the host name, and the file name parts. | |
787 | |
788 The second element METHOD is a number, saying which pair of | |
789 parentheses matches the method name. The third element USER is | |
790 similar, but for the user name. The fourth element HOST is similar, | |
791 but for the host name. The fifth element FILE is for the file name. | |
792 These numbers are passed directly to `match-string', which see. That | |
793 means the opening parentheses are counted to identify the pair. | |
794 | |
795 See also `tramp-file-name-regexp' and `tramp-make-tramp-file-format'." | |
796 :group 'tramp | |
797 :type '(list (regexp :tag "File name regexp") | |
798 (integer :tag "Paren pair for method name") | |
799 (integer :tag "Paren pair for user name ") | |
800 (integer :tag "Paren pair for host name ") | |
801 (integer :tag "Paren pair for file name "))) | |
802 | |
803 ;;;###autoload | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
804 (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
|
805 "\\`/[^/:]+:" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
806 "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
|
807 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
|
808 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
|
809 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
810 ;;;###autoload |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
811 (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
|
812 "\\`/\\[.*\\]" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
813 "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
|
814 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
|
815 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
|
816 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
817 ;;;###autoload |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
818 (defcustom tramp-file-name-regexp |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
819 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
820 tramp-file-name-regexp-separate |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
821 tramp-file-name-regexp-unified) |
45861 | 822 "*Regular expression matching file names handled by tramp. |
823 This regexp should match tramp file names but no other file names. | |
824 \(When tramp.el is loaded, this regular expression is prepended to | |
825 `file-name-handler-alist', and that is searched sequentially. Thus, | |
826 if the tramp entry appears rather early in the `file-name-handler-alist' | |
827 and is a bit too general, then some files might be considered tramp | |
828 files which are not really tramp files. | |
829 | |
830 Please note that the entry in `file-name-handler-alist' is made when | |
831 this file (tramp.el) is loaded. This means that this variable must be set | |
832 before loading tramp.el. Alternatively, `file-name-handler-alist' can be | |
833 updated after changing this variable. | |
834 | |
835 Also see `tramp-file-name-structure' and `tramp-make-tramp-file-format'." | |
836 :group 'tramp | |
837 :type 'regexp) | |
838 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
839 (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
|
840 "/%m:%u@%h:%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
841 "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
|
842 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
|
843 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
|
844 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
845 (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
|
846 "/[%m/%u@%h]%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
847 "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
|
848 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
|
849 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
|
850 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
851 (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
|
852 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
853 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
|
854 tramp-make-tramp-file-format-unified) |
45861 | 855 "*Format string saying how to construct tramp file name. |
856 `%m' is replaced by the method name. | |
857 `%u' is replaced by the user name. | |
858 `%h' is replaced by the host name. | |
859 `%p' is replaced by the file name. | |
860 `%%' is replaced by %. | |
861 | |
862 Also see `tramp-file-name-structure' and `tramp-file-name-regexp'." | |
863 :group 'tramp | |
864 :type 'string) | |
865 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
866 (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
|
867 "/%m:%h:%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
868 "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
|
869 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
|
870 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
|
871 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
872 (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
|
873 "/[%m/%h]%p" |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
874 "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
|
875 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
|
876 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
|
877 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
878 (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
|
879 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
880 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
|
881 tramp-make-tramp-file-user-nil-format-unified) |
45861 | 882 "*Format string saying how to construct tramp file name when the user name is not known. |
883 `%m' is replaced by the method name. | |
884 `%h' is replaced by the host name. | |
885 `%p' is replaced by the file name. | |
886 `%%' is replaced by %. | |
887 | |
888 Also see `tramp-make-tramp-file-format', `tramp-file-name-structure', and `tramp-file-name-regexp'." | |
889 :group 'tramp | |
890 :type 'string) | |
891 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
892 (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
|
893 (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
|
894 "\\(\\(%s\\)+\\)" ;hops |
46347
3996ea20e5e3
(tramp-multi-file-name-structure-unified): Add
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46307
diff
changeset
|
895 "\\(.*\\)\\'") ;path |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
896 2 3 -1) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
897 "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
|
898 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
|
899 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
|
900 |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
901 (defconst tramp-multi-file-name-structure-separate |
45861 | 902 (list (concat |
903 ;; prefix | |
46347
3996ea20e5e3
(tramp-multi-file-name-structure-unified): Add
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46307
diff
changeset
|
904 "\\`/\\[\\(\\([a-z0-9]+\\)?\\)" |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
905 ;; regexp specifying the hops |
45861 | 906 "\\(\\(%s\\)+\\)" |
907 ;; path name | |
908 "\\]\\(.*\\)\\'") | |
909 2 ;number of pair to match method | |
910 3 ;number of pair to match hops | |
911 -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
|
912 "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
|
913 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
|
914 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
|
915 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
916 (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
|
917 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
918 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
|
919 tramp-multi-file-name-structure-unified) |
45861 | 920 "*Describes the file name structure of `multi' files. |
921 Multi files allow you to contact a remote host in several hops. | |
922 This is a list of four elements (REGEXP METHOD HOP PATH). | |
923 | |
924 The first element, REGEXP, gives a regular expression to match against | |
925 the file name. In this regular expression, `%s' is replaced with the | |
926 value of `tramp-multi-file-name-hop-structure'. (Note: in order to | |
927 allow multiple hops, you normally want to use something like | |
928 \"\\\\(\\\\(%s\\\\)+\\\\)\" in the regular expression. The outer pair | |
929 of parentheses is used for the HOP element, see below.) | |
930 | |
931 All remaining elements are numbers. METHOD gives the number of the | |
932 paren pair which matches the method name. HOP gives the number of the | |
933 paren pair which matches the hop sequence. PATH gives the number of | |
934 the paren pair which matches the path name on the remote host. | |
935 | |
936 PATH can also be negative, which means to count from the end. Ie, a | |
937 value of -1 means the last paren pair. | |
938 | |
939 I think it would be good if the regexp matches the whole of the | |
940 string, but I haven't actually tried what happens if it doesn't..." | |
941 :group 'tramp | |
942 :type '(list (regexp :tag "File name regexp") | |
943 (integer :tag "Paren pair for method name") | |
944 (integer :tag "Paren pair for hops") | |
945 (integer :tag "Paren pair to match path"))) | |
946 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
947 (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
|
948 (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
|
949 "\\([^@:/]+\\)@" ;user |
46347
3996ea20e5e3
(tramp-multi-file-name-structure-unified): Add
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46307
diff
changeset
|
950 "\\([^:/]+\\):") ;host |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
951 1 2 3) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
952 "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
|
953 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
|
954 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
|
955 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
956 (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
|
957 (list (concat "/\\([a-z0-9_]+\\):" ;hop method |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
958 "\\([a-z0-9_]+\\)@" ;user |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
959 "\\([a-z0-9.-]+\\)") ;host |
45861 | 960 1 2 3) |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
961 "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
|
962 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
|
963 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
|
964 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
965 (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
|
966 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
967 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
|
968 tramp-multi-file-name-hop-structure-unified) |
45861 | 969 "*Describes the structure of a hop in multi files. |
970 This is a list of four elements (REGEXP METHOD USER HOST). First | |
971 element REGEXP is used to match against the hop. Pair number METHOD | |
972 matches the method of one hop, pair number USER matches the user of | |
973 one hop, pair number HOST matches the host of one hop. | |
974 | |
975 This regular expression should match exactly all of one hop." | |
976 :group 'tramp | |
977 :type '(list (regexp :tag "Hop regexp") | |
978 (integer :tag "Paren pair for method name") | |
979 (integer :tag "Paren pair for user name") | |
980 (integer :tag "Paren pair for host name"))) | |
981 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
982 (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
|
983 (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
|
984 "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
|
985 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
|
986 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
|
987 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
988 (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
|
989 (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
|
990 "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
|
991 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
|
992 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
|
993 |
45861 | 994 (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
|
995 (if (featurep 'xemacs) |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
996 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
|
997 tramp-make-multi-tramp-file-format-unified) |
45861 | 998 "*Describes how to construct a `multi' file name. |
999 This is a list of three elements PREFIX, HOP and PATH. | |
1000 | |
1001 The first element PREFIX says how to construct the prefix, the second | |
1002 element HOP specifies what each hop looks like, and the final element | |
1003 PATH says how to construct the path name. | |
1004 | |
1005 In PREFIX, `%%' means `%' and `%m' means the method name. | |
1006 | |
1007 In HOP, `%%' means `%' and `%m', `%u', `%h' mean the hop method, hop | |
1008 user and hop host, respectively. | |
1009 | |
1010 In PATH, `%%' means `%' and `%p' means the path name. | |
1011 | |
1012 The resulting file name always contains one copy of PREFIX and one | |
1013 copy of PATH, but there is one copy of HOP for each hop in the file | |
1014 name. | |
1015 | |
1016 Note: the current implementation requires the prefix to contain the | |
1017 method name, followed by all the hops, and the path name must come | |
1018 last." | |
1019 :group 'tramp | |
1020 :type '(list string string string)) | |
1021 | |
1022 (defcustom tramp-terminal-type "dumb" | |
1023 "*Value of TERM environment variable for logging in to remote host. | |
1024 Because Tramp wants to parse the output of the remote shell, it is easily | |
1025 confused by ANSI color escape sequences and suchlike. Often, shell init | |
1026 files conditionalize this setup based on the TERM environment variable." | |
1027 :group 'tramp | |
1028 :type 'string) | |
1029 | |
1030 (defcustom tramp-completion-without-shell-p nil | |
1031 "*If nil, use shell wildcards for completion, else rely on Lisp only. | |
1032 Using shell wildcards for completions has the advantage that it can be | |
1033 fast even in large directories, but completion is always | |
1034 case-sensitive. Relying on Lisp only means that case-insensitive | |
1035 completion is possible (subject to the variable `completion-ignore-case'), | |
1036 but it might be slow on large directories." | |
1037 :group 'tramp | |
1038 :type 'boolean) | |
1039 | |
46752 | 1040 (defcustom tramp-actions-before-shell |
1041 '((tramp-password-prompt-regexp tramp-action-password) | |
1042 (tramp-login-prompt-regexp tramp-action-login) | |
1043 (shell-prompt-pattern tramp-action-succeed) | |
1044 (tramp-wrong-passwd-regexp tramp-action-permission-denied) | |
1045 (tramp-yesno-prompt-regexp tramp-action-yesno)) | |
1046 "List of pattern/action pairs. | |
1047 Whenever a pattern matches, the corresponding action is performed. | |
1048 Each item looks like (PATTERN ACTION). | |
1049 | |
1050 The PATTERN should be a symbol, a variable. The value of this | |
1051 variable gives the regular expression to search for. Note that the | |
1052 regexp must match at the end of the buffer, \"\\'\" is implicitly | |
1053 appended to it. | |
1054 | |
1055 The ACTION should also be a symbol, but a function. When the | |
1056 corresponding PATTERN matches, the ACTION function is called." | |
1057 :group 'tramp | |
1058 :type '(repeat (list variable function))) | |
1059 | |
1060 (defcustom tramp-multi-actions | |
1061 '((tramp-password-prompt-regexp tramp-multi-action-password) | |
1062 (tramp-login-prompt-regexp tramp-multi-action-login) | |
1063 (shell-prompt-pattern tramp-multi-action-succeed) | |
1064 (tramp-wrong-passwd-regexp tramp-multi-action-permission-denied)) | |
1065 "List of pattern/action pairs. | |
1066 This list is used for each hop in multi-hop connections. | |
1067 See `tramp-actions-before-shell' for more info." | |
1068 :group 'tramp | |
1069 :type '(repeat (list variable function))) | |
1070 | |
45861 | 1071 ;;; Internal Variables: |
1072 | |
1073 (defvar tramp-buffer-file-attributes nil | |
1074 "Holds the `ls -ild' output for the current buffer. | |
1075 This variable is local to each buffer. It is not used if the remote | |
1076 machine groks Perl. If it is used, it's used as an emulation for | |
1077 the visited file modtime.") | |
1078 (make-variable-buffer-local 'tramp-buffer-file-attributes) | |
1079 | |
1080 (defvar tramp-end-of-output "/////" | |
1081 "String used to recognize end of output.") | |
1082 | |
1083 (defvar tramp-connection-function nil | |
1084 "This internal variable holds a parameter for `tramp-methods'. | |
1085 In the connection buffer, this variable has the value of the like-named | |
1086 method parameter, as specified in `tramp-methods' (which see).") | |
1087 | |
1088 (defvar tramp-remote-sh nil | |
1089 "This internal variable holds a parameter for `tramp-methods'. | |
1090 In the connection buffer, this variable has the value of the like-named | |
1091 method parameter, as specified in `tramp-methods' (which see).") | |
1092 | |
1093 (defvar tramp-rsh-program nil | |
1094 "This internal variable holds a parameter for `tramp-methods'. | |
1095 In the connection buffer, this variable has the value of the like-named | |
1096 method parameter, as specified in `tramp-methods' (which see).") | |
1097 | |
1098 (defvar tramp-rsh-args 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-rcp-program 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-rcp-args 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-rcp-keep-date-arg 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-encoding-command 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-decoding-command 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-encoding-function nil | |
1129 "This internal variable holds a parameter for `tramp-methods'. | |
1130 In the connection buffer, this variable has the value of the like-named | |
1131 method parameter, as specified in `tramp-methods' (which see).") | |
1132 | |
1133 (defvar tramp-decoding-function 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-telnet-program nil | |
1139 "This internal variable holds a parameter for `tramp-methods'. | |
1140 In the connection buffer, this variable has the value of the like-named | |
1141 method parameter, as specified in `tramp-methods' (which see).") | |
1142 | |
1143 (defvar tramp-telnet-args nil | |
1144 "This internal variable holds a parameter for `tramp-methods'. | |
1145 In the connection buffer, this variable has the value of the like-named | |
1146 method parameter, as specified in `tramp-methods' (which see).") | |
1147 | |
1148 ;; CCC `local in each buffer'? | |
1149 (defvar tramp-ls-command nil | |
1150 "This command is used to get a long listing with numeric user and group ids. | |
1151 This variable is automatically made buffer-local to each rsh process buffer | |
1152 upon opening the connection.") | |
1153 | |
1154 (defvar tramp-current-multi-method nil | |
1155 "Name of `multi' connection method for this *tramp* buffer, or nil if not multi. | |
1156 This variable is automatically made buffer-local to each rsh process buffer | |
1157 upon opening the connection.") | |
1158 | |
1159 (defvar tramp-current-method nil | |
1160 "Connection method for this *tramp* buffer. | |
1161 This variable is automatically made buffer-local to each rsh process buffer | |
1162 upon opening the connection.") | |
1163 | |
1164 (defvar tramp-current-user nil | |
1165 "Remote login name for this *tramp* buffer. | |
1166 This variable is automatically made buffer-local to each rsh process buffer | |
1167 upon opening the connection.") | |
1168 | |
1169 (defvar tramp-current-host nil | |
1170 "Remote host for this *tramp* buffer. | |
1171 This variable is automatically made buffer-local to each rsh process buffer | |
1172 upon opening the connection.") | |
1173 | |
1174 (defvar tramp-test-groks-nt nil | |
1175 "Whether the `test' command groks the `-nt' switch. | |
1176 \(`test A -nt B' tests if file A is newer than file B.) | |
1177 This variable is automatically made buffer-local to each rsh process buffer | |
1178 upon opening the connection.") | |
1179 | |
1180 (defvar tramp-file-exists-command nil | |
1181 "Command to use for checking if a file exists. | |
1182 This variable is automatically made buffer-local to each rsh process buffer | |
1183 upon opening the connection.") | |
1184 | |
1185 ;; Perl script to implement `file-attributes' in a Lisp `read'able output. | |
1186 ;; If you are hacking on this, note that you get *no* output unless this | |
1187 ;; spits out a complete line, including the '\n' at the end. | |
1188 (defconst tramp-perl-file-attributes (concat | |
1189 "$f = $ARGV[0]; | |
1190 @s = lstat($f); | |
1191 if (($s[2] & 0170000) == 0120000) { $l = readlink($f); $l = \"\\\"$l\\\"\"; } | |
1192 elsif (($s[2] & 0170000) == 040000) { $l = \"t\"; } | |
1193 else { $l = \"nil\" }; | |
1194 printf(\"(%s %u %u %u (%u %u) (%u %u) (%u %u) %u %u t (%u . %u) (%u %u))\\n\", | |
1195 $l, $s[3], $s[4], $s[5], $s[8] >> 16 & 0xffff, $s[8] & 0xffff, | |
1196 $s[9] >> 16 & 0xffff, $s[9] & 0xffff, $s[10] >> 16 & 0xffff, $s[10] & 0xffff, | |
1197 $s[7], $s[2], $s[1] >> 16 & 0xffff, $s[1] & 0xffff, $s[0] >> 16 & 0xffff, $s[0] & 0xffff);" | |
1198 ) | |
1199 "Perl script to produce output suitable for use with `file-attributes' | |
1200 on the remote file system.") | |
1201 | |
46752 | 1202 ;; ;; These two use uu encoding. |
1203 ;; (defvar tramp-perl-encode "%s -e'\ | |
1204 ;; print qq(begin 644 xxx\n); | |
1205 ;; my $s = q(); | |
1206 ;; my $res = q(); | |
1207 ;; while (read(STDIN, $s, 45)) { | |
1208 ;; print pack(q(u), $s); | |
1209 ;; } | |
1210 ;; print qq(`\n); | |
1211 ;; print qq(end\n); | |
1212 ;; '" | |
1213 ;; "Perl program to use for encoding a file. | |
1214 ;; Escape sequence %s is replaced with name of Perl binary.") | |
1215 | |
1216 ;; (defvar tramp-perl-decode "%s -ne ' | |
1217 ;; print unpack q(u), $_; | |
1218 ;; '" | |
1219 ;; "Perl program to use for decoding a file. | |
1220 ;; Escape sequence %s is replaced with name of Perl binary.") | |
1221 | |
1222 ;; These two use base64 encoding. | |
1223 (defvar tramp-perl-encode | |
1224 "perl -MMIME::Base64 -0777 -ne 'print encode_base64($_)'" | |
1225 "Perl program to use for encoding a file. | |
1226 Escape sequence %s is replaced with name of Perl binary.") | |
1227 | |
1228 (defvar tramp-perl-decode | |
1229 "perl -MMIME::Base64 -0777 -ne 'print decode_base64($_)'" | |
1230 "Perl program to use for decoding a file. | |
1231 Escape sequence %s is replaced with name of Perl binary.") | |
45861 | 1232 |
1233 ; These values conform to `file-attributes' from XEmacs 21.2. | |
1234 ; GNU Emacs and other tools not checked. | |
1235 (defconst tramp-file-mode-type-map '((0 . "-") ; Normal file (SVID-v2 and XPG2) | |
1236 (1 . "p") ; fifo | |
1237 (2 . "c") ; character device | |
1238 (3 . "m") ; multiplexed character device (v7) | |
1239 (4 . "d") ; directory | |
1240 (5 . "?") ; Named special file (XENIX) | |
1241 (6 . "b") ; block device | |
1242 (7 . "?") ; multiplexed block device (v7) | |
1243 (8 . "-") ; regular file | |
1244 (9 . "n") ; network special file (HP-UX) | |
1245 (10 . "l") ; symlink | |
1246 (11 . "?") ; ACL shadow inode (Solaris, not userspace) | |
1247 (12 . "s") ; socket | |
1248 (13 . "D") ; door special (Solaris) | |
1249 (14 . "w")) ; whiteout (BSD) | |
1250 "A list of file types returned from the `stat' system call. | |
1251 This is used to map a mode number to a permission string.") | |
1252 | |
1253 (defvar tramp-dos-coding-system | |
1254 (if (and (fboundp 'coding-system-p) | |
1255 (funcall 'coding-system-p '(dos))) | |
1256 'dos | |
1257 'undecided-dos) | |
1258 "Some Emacsen know the `dos' coding system, others need `undecided-dos'.") | |
1259 | |
46752 | 1260 (defvar tramp-last-cmd-time nil |
1261 "Internal Tramp variable recording the time when the last cmd was sent. | |
1262 This variable is buffer-local in every buffer.") | |
1263 (make-variable-buffer-local 'tramp-last-cmd-time) | |
45861 | 1264 |
1265 ;; New handlers should be added here. The following operations can be | |
1266 ;; handled using the normal primitives: file-name-as-directory, | |
1267 ;; file-name-directory, file-name-nondirectory, | |
1268 ;; file-name-sans-versions, get-file-buffer. | |
1269 (defconst tramp-file-name-handler-alist | |
1270 '( | |
1271 (load . tramp-handle-load) | |
1272 (make-symbolic-link . tramp-handle-make-symbolic-link) | |
1273 (file-name-directory . tramp-handle-file-name-directory) | |
1274 (file-name-nondirectory . tramp-handle-file-name-nondirectory) | |
1275 (file-truename . tramp-handle-file-truename) | |
1276 (file-exists-p . tramp-handle-file-exists-p) | |
1277 (file-directory-p . tramp-handle-file-directory-p) | |
1278 (file-executable-p . tramp-handle-file-executable-p) | |
1279 (file-accessible-directory-p . tramp-handle-file-accessible-directory-p) | |
1280 (file-readable-p . tramp-handle-file-readable-p) | |
1281 (file-regular-p . tramp-handle-file-regular-p) | |
1282 (file-symlink-p . tramp-handle-file-symlink-p) | |
1283 (file-writable-p . tramp-handle-file-writable-p) | |
1284 (file-ownership-preserved-p . tramp-handle-file-ownership-preserved-p) | |
1285 (file-newer-than-file-p . tramp-handle-file-newer-than-file-p) | |
1286 (file-attributes . tramp-handle-file-attributes) | |
1287 (file-modes . tramp-handle-file-modes) | |
1288 (file-directory-files . tramp-handle-file-directory-files) | |
1289 (directory-files . tramp-handle-directory-files) | |
1290 (file-name-all-completions . tramp-handle-file-name-all-completions) | |
1291 (file-name-completion . tramp-handle-file-name-completion) | |
1292 (add-name-to-file . tramp-handle-add-name-to-file) | |
1293 (copy-file . tramp-handle-copy-file) | |
1294 (rename-file . tramp-handle-rename-file) | |
1295 (set-file-modes . tramp-handle-set-file-modes) | |
1296 (make-directory . tramp-handle-make-directory) | |
1297 (delete-directory . tramp-handle-delete-directory) | |
1298 (delete-file . tramp-handle-delete-file) | |
1299 (directory-file-name . tramp-handle-directory-file-name) | |
1300 (shell-command . tramp-handle-shell-command) | |
1301 (insert-directory . tramp-handle-insert-directory) | |
1302 (expand-file-name . tramp-handle-expand-file-name) | |
1303 (file-local-copy . tramp-handle-file-local-copy) | |
1304 (insert-file-contents . tramp-handle-insert-file-contents) | |
1305 (write-region . tramp-handle-write-region) | |
1306 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory) | |
1307 (dired-call-process . tramp-handle-dired-call-process) | |
1308 (dired-recursive-delete-directory | |
1309 . tramp-handle-dired-recursive-delete-directory) | |
1310 (set-visited-file-modtime . tramp-handle-set-visited-file-modtime) | |
1311 (verify-visited-file-modtime . tramp-handle-verify-visited-file-modtime)) | |
1312 "Alist of handler functions. | |
1313 Operations not mentioned here will be handled by the normal Emacs functions.") | |
1314 | |
1315 ;;; Internal functions which must come first. | |
1316 | |
1317 (defsubst tramp-message (level fmt-string &rest args) | |
1318 "Emit a message depending on verbosity level. | |
1319 First arg LEVEL says to be quiet if `tramp-verbose' is less than LEVEL. The | |
1320 message is emitted only if `tramp-verbose' is greater than or equal to LEVEL. | |
1321 Calls function `message' with FMT-STRING as control string and the remaining | |
1322 ARGS to actually emit the message (if applicable). | |
1323 | |
1324 This function expects to be called from the tramp buffer only!" | |
1325 (when (<= level tramp-verbose) | |
1326 (apply #'message (concat "tramp: " fmt-string) args) | |
1327 (when tramp-debug-buffer | |
1328 (save-excursion | |
1329 (set-buffer | |
1330 (tramp-get-debug-buffer | |
1331 tramp-current-multi-method tramp-current-method | |
1332 tramp-current-user tramp-current-host)) | |
1333 (goto-char (point-max)) | |
1334 (tramp-insert-with-face | |
1335 'italic | |
1336 (concat "# " (apply #'format fmt-string args) "\n")))))) | |
1337 | |
1338 (defun tramp-message-for-buffer | |
1339 (multi-method method user host level fmt-string &rest args) | |
1340 "Like `tramp-message' but temporarily switches to the tramp buffer. | |
1341 First three args METHOD, USER, and HOST identify the tramp buffer to use, | |
1342 remaining args passed to `tramp-message'." | |
1343 (save-excursion | |
1344 (set-buffer (tramp-get-buffer multi-method method user host)) | |
1345 (apply 'tramp-message level fmt-string args))) | |
1346 | |
1347 (defsubst tramp-line-end-position nil | |
1348 "Return point at end of line. | |
1349 Calls `line-end-position' or `point-at-eol' if defined, else | |
1350 own implementation." | |
1351 (cond | |
1352 ((fboundp 'line-end-position) (funcall 'line-end-position)) | |
1353 ((fboundp 'point-at-eol) (funcall 'point-at-eol)) | |
1354 (t (save-excursion (end-of-line) (point))))) | |
1355 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1356 (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
|
1357 "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
|
1358 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1359 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
|
1360 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
|
1361 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
|
1362 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
|
1363 `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
|
1364 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
|
1365 `foo-user', `foo-host', `foo-path'. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1366 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1367 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
|
1368 `progn'). |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1369 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1370 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
|
1371 `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
|
1372 `(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
|
1373 (,(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
|
1374 (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
|
1375 (,(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
|
1376 (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
|
1377 (,(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
|
1378 (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
|
1379 (,(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
|
1380 (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
|
1381 (,(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
|
1382 (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
|
1383 ,@body)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1384 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1385 (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
|
1386 |
45861 | 1387 ;;; File Name Handler Functions: |
1388 | |
1389 (defun tramp-handle-make-symbolic-link | |
1390 (filename linkname &optional ok-if-already-exists) | |
1391 "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
|
1392 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
|
1393 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
|
1394 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
|
1395 |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1396 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
|
1397 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
|
1398 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
|
1399 target of the symlink differ." |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1400 (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
|
1401 (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
|
1402 (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
|
1403 filename linkname ok-if-already-exists)) |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1404 (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
|
1405 (cwd (file-name-directory l-path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1406 (unless ln |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1407 (signal 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1408 (list "Making a symbolic link." |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1409 "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
|
1410 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1411 ;; 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
|
1412 (when (file-exists-p linkname) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1413 ;; What to do? |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1414 (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
|
1415 (and (numberp ok-if-already-exists) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1416 (not (yes-or-no-p |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1417 (format |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1418 "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
|
1419 l-path))))) |
46307
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1420 (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
|
1421 (delete-file linkname))) |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1422 |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1423 ;; 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
|
1424 (when (tramp-tramp-file-p filename) |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1425 (setq filename (tramp-file-name-path |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1426 (tramp-dissect-file-name |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1427 (expand-file-name filename))))) |
45861 | 1428 |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1429 ;; 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
|
1430 ;; 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
|
1431 ;; that FILENAME belongs to. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1432 (zerop |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1433 (tramp-send-command-and-check |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1434 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
|
1435 (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
|
1436 cwd ln |
46307
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1437 filename |
a2d047d50fb9
(tramp-handle-make-symbolic-link): Implement.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46306
diff
changeset
|
1438 l-path) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1439 t))))) |
45861 | 1440 |
1441 | |
1442 (defun tramp-handle-load (file &optional noerror nomessage nosuffix must-suffix) | |
1443 "Like `load' for tramp files. Not implemented!" | |
1444 (unless (file-name-absolute-p file) | |
1445 (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
|
1446 (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
|
1447 (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
|
1448 (tramp-invoke-ange-ftp 'load |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1449 file noerror nomessage nosuffix must-suffix)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1450 (unless nosuffix |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1451 (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
|
1452 (setq file (concat file ".elc"))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1453 ((file-exists-p (concat file ".el")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1454 (setq file (concat file ".el"))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1455 (when must-suffix |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1456 ;; 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
|
1457 ;; Included for safety's sake. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1458 (unless (or (file-name-directory file) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1459 (string-match "\\.elc?\\'" file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1460 (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
|
1461 file))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1462 (unless noerror |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1463 (when (not (file-exists-p file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1464 (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
|
1465 (if (not (file-exists-p file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1466 nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1467 (unless nomessage |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1468 (message "Loading %s..." file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1469 (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
|
1470 ;; 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
|
1471 (load local-copy noerror t t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1472 (delete-file local-copy)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1473 (unless nomessage |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1474 (message "Loading %s...done" file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1475 t))) |
45861 | 1476 |
1477 ;; Path manipulation functions that grok TRAMP paths... | |
1478 (defun tramp-handle-file-name-directory (file) | |
1479 "Like `file-name-directory' but aware of TRAMP files." | |
1480 ;; 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
|
1481 (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
|
1482 (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
|
1483 (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
|
1484 ;; 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
|
1485 ;; (1) (string= path "") |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1486 ;; (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
|
1487 ;; 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
|
1488 ;; 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
|
1489 ;; "/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
|
1490 ;; We should do some investigation. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
1491 (if (string= path "") |
45861 | 1492 ;; For a filename like "/[foo]", we return "/". The `else' |
1493 ;; case would return "/[foo]" unchanged. But if we do that, | |
1494 ;; then `file-expand-wildcards' ceases to work. It's not | |
1495 ;; quite clear to me what's the intuition that tells that this | |
1496 ;; behavior is the right behavior, but oh, well. | |
1497 "/" | |
1498 ;; run the command on the path portion only | |
1499 ;; CCC: This should take into account the remote machine type, no? | |
1500 ;; --daniel <daniel@danann.net> | |
1501 (tramp-make-tramp-file-name multi-method method user host | |
1502 ;; This will not recurse... | |
1503 (or (file-name-directory path) ""))))) | |
1504 | |
1505 (defun tramp-handle-file-name-nondirectory (file) | |
1506 "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
|
1507 (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
|
1508 (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
|
1509 (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
|
1510 (file-name-nondirectory path))) |
45861 | 1511 |
1512 (defun tramp-handle-file-truename (filename &optional counter prev-dirs) | |
1513 "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
|
1514 (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
|
1515 ;; Ange-FTP does not support truename processing. It returns the |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1516 ;; file name as-is. So that's what we do, too. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1517 (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
|
1518 filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1519 (let* ((steps (tramp-split-string path "/")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1520 (pathdir (let ((directory-sep-char ?/)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1521 (file-name-as-directory path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1522 (is-dir (string= path pathdir)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1523 (thisstep nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1524 (numchase 0) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1525 ;; 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
|
1526 ;; 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
|
1527 ;; 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
|
1528 ;; 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
|
1529 (numchase-limit 20) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1530 (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
|
1531 (curstri "") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1532 symlink-target) |
45861 | 1533 (tramp-message-for-buffer |
1534 multi-method method user host | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1535 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
|
1536 (while (and steps (< numchase numchase-limit)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1537 (setq thisstep (pop steps)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1538 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1539 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1540 10 "Check %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1541 (mapconcat 'identity |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1542 (append '("") (reverse result) (list thisstep)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1543 "/")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1544 (setq symlink-target |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1545 (nth 0 (tramp-handle-file-attributes |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1546 (tramp-make-tramp-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1547 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1548 (mapconcat 'identity |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1549 (append '("") (reverse result) (list thisstep)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1550 "/"))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1551 (cond ((string= "." thisstep) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1552 (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
|
1553 10 "Ignoring step `.'")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1554 ((string= ".." thisstep) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1555 (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
|
1556 10 "Processing step `..'") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1557 (pop result)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1558 ((stringp symlink-target) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1559 ;; It's a symlink, follow it. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1560 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1561 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1562 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
|
1563 (setq numchase (1+ numchase)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1564 (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
|
1565 (setq result nil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1566 (setq steps |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1567 (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
|
1568 (t |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1569 ;; It's a file. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1570 (setq result (cons thisstep result))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1571 (when (>= numchase numchase-limit) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1572 (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
|
1573 (setq result (reverse result)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1574 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1575 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1576 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
|
1577 filename (mapconcat 'identity (cons "" result) "/")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1578 (tramp-make-tramp-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1579 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1580 (concat (mapconcat 'identity (cons "" result) "/") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1581 (if is-dir "/" "")))))) |
45861 | 1582 |
1583 ;; Basic functions. | |
1584 | |
1585 (defun tramp-handle-file-exists-p (filename) | |
1586 "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
|
1587 (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
|
1588 (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
|
1589 (tramp-invoke-ange-ftp 'file-exists-p filename)) |
45861 | 1590 (save-excursion |
1591 (zerop (tramp-send-command-and-check | |
1592 multi-method method user host | |
1593 (format | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1594 (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
|
1595 (tramp-shell-quote-argument path))))))) |
45861 | 1596 |
1597 ;; CCC: This should check for an error condition and signal failure | |
1598 ;; when something goes wrong. | |
1599 ;; Daniel Pittman <daniel@danann.net> | |
1600 (defun tramp-handle-file-attributes (filename &optional nonnumeric) | |
1601 "Like `file-attributes' for tramp files. | |
1602 Optional argument NONNUMERIC means return user and group name | |
1603 rather than as numbers." | |
46752 | 1604 (let (result) |
1605 (with-parsed-tramp-file-name filename nil | |
1606 (when (tramp-ange-ftp-file-name-p multi-method method) | |
1607 (tramp-invoke-ange-ftp 'file-attributes filename)) | |
1608 (when (tramp-handle-file-exists-p filename) | |
1609 ;; file exists, find out stuff | |
1610 (save-excursion | |
45861 | 1611 (if (tramp-get-remote-perl multi-method method user host) |
46752 | 1612 (setq result |
1613 (tramp-handle-file-attributes-with-perl | |
1614 multi-method method user host path nonnumeric)) | |
1615 (setq result | |
1616 (tramp-handle-file-attributes-with-ls | |
1617 multi-method method user host path nonnumeric)))))) | |
1618 result)) | |
45861 | 1619 |
1620 | |
1621 (defun tramp-handle-file-attributes-with-ls | |
1622 (multi-method method user host path &optional nonnumeric) | |
1623 "Implement `file-attributes' for tramp files using the ls(1) command." | |
1624 (let (symlinkp dirp | |
1625 res-inode res-filemodes res-numlinks | |
1626 res-uid res-gid res-size res-symlink-target) | |
46752 | 1627 (tramp-message-for-buffer multi-method method user host 10 |
1628 "file attributes with ls: %s" | |
1629 (tramp-make-tramp-file-name | |
1630 multi-method method user host path)) | |
45861 | 1631 (tramp-send-command |
1632 multi-method method user host | |
1633 (format "%s %s %s" | |
1634 (tramp-get-ls-command multi-method method user host) | |
1635 (if nonnumeric "-ild" "-ildn") | |
1636 (tramp-shell-quote-argument path))) | |
1637 (tramp-wait-for-output) | |
1638 ;; parse `ls -l' output ... | |
1639 ;; ... inode | |
1640 (setq res-inode | |
1641 (condition-case err | |
1642 (read (current-buffer)) | |
1643 (invalid-read-syntax | |
1644 (when (and (equal (cadr err) | |
1645 "Integer constant overflow in reader") | |
1646 (string-match | |
1647 "^[0-9]+\\([0-9][0-9][0-9][0-9][0-9]\\)\\'" | |
1648 (caddr err))) | |
1649 (let* ((big (read (substring (caddr err) 0 | |
1650 (match-beginning 1)))) | |
1651 (small (read (match-string 1 (caddr err)))) | |
1652 (twiddle (/ small 65536))) | |
1653 (cons (+ big twiddle) | |
1654 (- small (* twiddle 65536)))))))) | |
1655 ;; ... file mode flags | |
1656 (setq res-filemodes (symbol-name (read (current-buffer)))) | |
1657 ;; ... number links | |
1658 (setq res-numlinks (read (current-buffer))) | |
1659 ;; ... uid and gid | |
1660 (setq res-uid (read (current-buffer))) | |
1661 (setq res-gid (read (current-buffer))) | |
1662 (unless nonnumeric | |
1663 (unless (numberp res-uid) (setq res-uid -1)) | |
1664 (unless (numberp res-gid) (setq res-gid -1))) | |
1665 ;; ... size | |
1666 (setq res-size (read (current-buffer))) | |
1667 ;; From the file modes, figure out other stuff. | |
1668 (setq symlinkp (eq ?l (aref res-filemodes 0))) | |
1669 (setq dirp (eq ?d (aref res-filemodes 0))) | |
1670 ;; if symlink, find out file name pointed to | |
1671 (when symlinkp | |
1672 (search-forward "-> ") | |
1673 (setq res-symlink-target | |
1674 (buffer-substring (point) | |
1675 (tramp-line-end-position)))) | |
1676 ;; return data gathered | |
1677 (list | |
1678 ;; 0. t for directory, string (name linked to) for symbolic | |
1679 ;; link, or nil. | |
1680 (or dirp res-symlink-target nil) | |
1681 ;; 1. Number of links to file. | |
1682 res-numlinks | |
1683 ;; 2. File uid. | |
1684 res-uid | |
1685 ;; 3. File gid. | |
1686 res-gid | |
1687 ;; 4. Last access time, as a list of two integers. First | |
1688 ;; integer has high-order 16 bits of time, second has low 16 | |
1689 ;; bits. | |
1690 ;; 5. Last modification time, likewise. | |
1691 ;; 6. Last status change time, likewise. | |
1692 '(0 0) '(0 0) '(0 0) ;CCC how to find out? | |
1693 ;; 7. Size in bytes (-1, if number is out of range). | |
1694 res-size | |
1695 ;; 8. File modes, as a string of ten letters or dashes as in ls -l. | |
1696 res-filemodes | |
1697 ;; 9. t iff file's gid would change if file were deleted and | |
1698 ;; recreated. | |
1699 nil ;hm? | |
1700 ;; 10. inode number. | |
1701 res-inode | |
1702 ;; 11. Device number. | |
1703 -1 ;hm? | |
1704 ))) | |
1705 | |
1706 (defun tramp-handle-file-attributes-with-perl | |
1707 (multi-method method user host path &optional nonnumeric) | |
1708 "Implement `file-attributes' for tramp files using a Perl script. | |
1709 | |
1710 The Perl command is sent to the remote machine when the connection | |
1711 is initially created and is kept cached by the remote shell." | |
46752 | 1712 (tramp-message-for-buffer multi-method method user host 10 |
1713 "file attributes with perl: %s" | |
1714 (tramp-make-tramp-file-name | |
1715 multi-method method user host path)) | |
45861 | 1716 (tramp-send-command |
1717 multi-method method user host | |
1718 (format "tramp_file_attributes %s" | |
1719 (tramp-shell-quote-argument path))) | |
1720 (tramp-wait-for-output) | |
1721 (let ((result (read (current-buffer)))) | |
1722 (setcar (nthcdr 8 result) | |
1723 (tramp-file-mode-from-int (nth 8 result))) | |
1724 result)) | |
1725 | |
1726 (defun tramp-handle-set-visited-file-modtime (&optional time-list) | |
1727 "Like `set-visited-file-modtime' for tramp files." | |
1728 (unless (buffer-file-name) | |
1729 (error "Can't set-visited-file-modtime: buffer `%s' not visiting a file" | |
1730 (buffer-name))) | |
1731 (when time-list | |
1732 (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
|
1733 (let ((f (buffer-file-name)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1734 (coding-system-used nil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1735 (with-parsed-tramp-file-name f nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1736 ;; This operation is not handled by Ange-FTP! |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1737 (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
|
1738 (throw 'tramp-forward-to-ange-ftp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1739 (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
|
1740 (list time-list)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1741 (let* ((attr (file-attributes f)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1742 (modtime (nth 5 attr))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1743 ;; 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
|
1744 ;; `tramp-handle-file-attributes-with-ls'. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1745 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1746 (setq coding-system-used last-coding-system-used)) |
45861 | 1747 (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
|
1748 (tramp-run-real-handler 'set-visited-file-modtime (list modtime)) |
45861 | 1749 (save-excursion |
1750 (tramp-send-command | |
1751 multi-method method user host | |
1752 (format "%s -ild %s" | |
1753 (tramp-get-ls-command multi-method method user host) | |
1754 (tramp-shell-quote-argument path))) | |
1755 (tramp-wait-for-output) | |
1756 (setq attr (buffer-substring (point) | |
1757 (progn (end-of-line) (point))))) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1758 (setq tramp-buffer-file-attributes attr)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1759 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1760 (setq last-coding-system-used coding-system-used)) |
45861 | 1761 nil)))) |
1762 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1763 ;; CCC continue here |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1764 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1765 ;; 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
|
1766 ;; `tramp-handle-set-visited-file-modtime'. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1767 (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
|
1768 "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
|
1769 (with-current-buffer buf |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1770 (let ((f (buffer-file-name))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1771 (with-parsed-tramp-file-name f nil |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
1772 (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
|
1773 ;; 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
|
1774 ;; on the arg list. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1775 (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
|
1776 user host path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1777 (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
|
1778 (let* ((attr (file-attributes f)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1779 (modtime (nth 5 attr))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1780 (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
|
1781 ;; 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
|
1782 ;; 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
|
1783 ;; (HIGH . LOW)? |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1784 (let ((mt (visited-file-modtime))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1785 (< (abs (tramp-time-diff |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1786 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
|
1787 (attr |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1788 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1789 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1790 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1791 (format "%s -ild %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1792 (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
|
1793 user host) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1794 (tramp-shell-quote-argument path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1795 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1796 (setq attr (buffer-substring |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1797 (point) (progn (end-of-line) (point))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1798 (equal tramp-buffer-file-attributes attr)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1799 ;; 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
|
1800 (t nil))))))) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1801 |
45861 | 1802 (defadvice clear-visited-file-modtime (after tramp activate) |
1803 "Set `tramp-buffer-file-attributes' back to nil. | |
1804 Tramp uses this variable as an emulation for the actual modtime of the file, | |
1805 if the remote host can't provide the modtime." | |
1806 (setq tramp-buffer-file-attributes nil)) | |
1807 | |
1808 (defun tramp-handle-set-file-modes (filename mode) | |
1809 "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
|
1810 (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
|
1811 (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
|
1812 (tramp-invoke-ange-ftp 'set-file-modes filename mode)) |
45861 | 1813 (save-excursion |
1814 (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
|
1815 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1816 (format "chmod %s %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1817 (tramp-decimal-to-octal mode) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1818 (tramp-shell-quote-argument path)))) |
45861 | 1819 (signal 'file-error |
1820 (list "Doing chmod" | |
1821 ;; FIXME: extract the proper text from chmod's stderr. | |
1822 "error while changing file's mode" | |
1823 filename)))))) | |
1824 | |
1825 ;; Simple functions using the `test' command. | |
1826 | |
1827 (defun tramp-handle-file-executable-p (filename) | |
1828 "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
|
1829 (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
|
1830 (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
|
1831 (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
|
1832 (zerop (tramp-run-test "-x" filename)))) |
45861 | 1833 |
1834 (defun tramp-handle-file-readable-p (filename) | |
1835 "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
|
1836 (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
|
1837 (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
|
1838 (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
|
1839 (zerop (tramp-run-test "-r" filename)))) |
45861 | 1840 |
1841 (defun tramp-handle-file-accessible-directory-p (filename) | |
1842 "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
|
1843 (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
|
1844 (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
|
1845 (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
|
1846 (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
|
1847 (zerop (tramp-run-test "-r" filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1848 (zerop (tramp-run-test "-x" filename))))) |
45861 | 1849 |
1850 ;; When the remote shell is started, it looks for a shell which groks | |
1851 ;; tilde expansion. Here, we assume that all shells which grok tilde | |
1852 ;; expansion will also provide a `test' command which groks `-nt' (for | |
1853 ;; newer than). If this breaks, tell me about it and I'll try to do | |
1854 ;; something smarter about it. | |
1855 (defun tramp-handle-file-newer-than-file-p (file1 file2) | |
1856 "Like `file-newer-than-file-p' for tramp files." | |
1857 (cond ((not (file-exists-p file1)) | |
1858 nil) | |
1859 ((not (file-exists-p file2)) | |
1860 t) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1861 ;; 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
|
1862 ;; 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
|
1863 ;; message. Todo: make a better error message. |
45861 | 1864 (t |
1865 (save-excursion | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1866 (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
|
1867 (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
|
1868 (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
|
1869 (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
|
1870 (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
|
1871 file1 file2)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1872 (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
|
1873 (equal v1-method v2-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1874 (equal v1-user v2-user) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1875 (equal v1-host v2-host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1876 (signal 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1877 (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
|
1878 file1 file2))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1879 (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
|
1880 (tramp-tramp-file-p file2)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1881 (signal 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1882 (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
|
1883 file1 file2))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1884 (if (tramp-get-test-groks-nt |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1885 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
|
1886 (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
|
1887 (zerop (tramp-run-test2 "tramp_test_nt" file1 file2))))))))) |
45861 | 1888 |
1889 ;; Functions implemented using the basic functions above. | |
1890 | |
1891 (defun tramp-handle-file-modes (filename) | |
1892 "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
|
1893 (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
|
1894 (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
|
1895 (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
|
1896 (when (file-exists-p filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1897 (tramp-mode-string-to-int |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1898 (nth 8 (tramp-handle-file-attributes filename)))))) |
45861 | 1899 |
1900 (defun tramp-handle-file-directory-p (filename) | |
1901 "Like `file-directory-p' for tramp files." | |
1902 ;; Care must be taken that this function returns `t' for symlinks | |
1903 ;; pointing to directories. Surely the most obvious implementation | |
1904 ;; would be `test -d', but that returns false for such symlinks. | |
1905 ;; CCC: Stefan Monnier says that `test -d' follows symlinks. And | |
1906 ;; I now think he's right. So we could be using `test -d', couldn't | |
1907 ;; we? | |
1908 ;; | |
1909 ;; 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
|
1910 (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
|
1911 (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
|
1912 (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
|
1913 (save-excursion |
45861 | 1914 (zerop |
1915 (tramp-send-command-and-check | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1916 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1917 (format "test -d %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1918 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1919 t))))) ;run command in subshell |
45861 | 1920 |
1921 (defun tramp-handle-file-regular-p (filename) | |
1922 "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
|
1923 (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
|
1924 (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
|
1925 (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
|
1926 (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
|
1927 (eq ?- (aref (nth 8 (tramp-handle-file-attributes filename)) 0))))) |
45861 | 1928 |
1929 (defun tramp-handle-file-symlink-p (filename) | |
1930 "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
|
1931 (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
|
1932 (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
|
1933 (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
|
1934 (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
|
1935 (when (stringp x) x)))) |
45861 | 1936 |
1937 (defun tramp-handle-file-writable-p (filename) | |
1938 "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
|
1939 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1940 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1941 (tramp-invoke-ange-ftp 'file-writable-p filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1942 (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
|
1943 ;; Existing files must be writable. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1944 (zerop (tramp-run-test "-w" filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1945 ;; 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
|
1946 (and (zerop (tramp-run-test |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1947 "-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
|
1948 (zerop (tramp-run-test |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1949 "-w" (tramp-handle-file-name-directory filename))))))) |
45861 | 1950 |
1951 (defun tramp-handle-file-ownership-preserved-p (filename) | |
1952 "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
|
1953 (with-parsed-tramp-file-name filename nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1954 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1955 (tramp-invoke-ange-ftp 'file-ownership-preserved-p filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1956 (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
|
1957 ;; Existing files must be writable. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1958 (zerop (tramp-run-test "-O" filename))))) |
45861 | 1959 |
1960 ;; Other file name ops. | |
1961 | |
1962 ;; ;; Matthias Köppe <mkoeppe@mail.math.uni-magdeburg.de> | |
1963 ;; (defun tramp-handle-directory-file-name (directory) | |
1964 ;; "Like `directory-file-name' for tramp files." | |
1965 ;; (if (and (eq (aref directory (- (length directory) 1)) ?/) | |
1966 ;; (not (eq (aref directory (- (length directory) 2)) ?:))) | |
1967 ;; (substring directory 0 (- (length directory) 1)) | |
1968 ;; directory)) | |
1969 | |
1970 ;; Philippe Troin <phil@fifi.org> | |
1971 (defun tramp-handle-directory-file-name (directory) | |
1972 "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
|
1973 (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
|
1974 (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
|
1975 (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
|
1976 (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
|
1977 (save-match-data |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1978 (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
|
1979 (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
|
1980 (/= (match-end 0) directory-length-1)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1981 (substring directory 0 directory-length-1) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1982 directory))))) |
45861 | 1983 |
1984 ;; Directory listings. | |
1985 | |
46752 | 1986 (defun tramp-handle-directory-files (directory |
1987 &optional full match nosort files-only) | |
45861 | 1988 "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
|
1989 (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
|
1990 (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
|
1991 (tramp-invoke-ange-ftp 'directory-files |
46752 | 1992 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
|
1993 (let (result x) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1994 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1995 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1996 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1997 (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
|
1998 nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
1999 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2000 "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
|
2001 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2002 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2003 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2004 (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
|
2005 " -a | cat")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2006 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2007 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2008 (while (zerop (forward-line -1)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2009 (setq x (buffer-substring (point) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2010 (tramp-line-end-position))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2011 (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
|
2012 (if full |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2013 (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
|
2014 x) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2015 result) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2016 (push x result)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2017 (tramp-send-command multi-method method user host "cd") |
46752 | 2018 (tramp-wait-for-output) |
2019 ;; Remove non-files or non-directories if necessary. Using | |
2020 ;; the remote shell for this would probably be way faster. | |
2021 ;; Maybe something could be adapted from | |
2022 ;; tramp-handle-file-name-all-completions. | |
2023 (when files-only | |
2024 (let ((temp (nreverse result)) | |
2025 item) | |
2026 (setq result nil) | |
2027 (if (equal files-only t) | |
2028 ;; files only | |
2029 (while temp | |
2030 (setq item (pop temp)) | |
2031 (when (file-regular-p item) | |
2032 (push item result))) | |
2033 ;; directories only | |
2034 (while temp | |
2035 (setq item (pop temp)) | |
2036 (when (file-directory-p item) | |
2037 (push item result))))))) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2038 result))) |
45861 | 2039 |
2040 ;; This function should return "foo/" for directories and "bar" for | |
2041 ;; files. We use `ls -ad' to get a list of files (including | |
2042 ;; directories), and `find . -type d \! -name . -prune' to get a list | |
2043 ;; of directories. | |
2044 (defun tramp-handle-file-name-all-completions (filename directory) | |
2045 "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
|
2046 (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
|
2047 (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
|
2048 (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
|
2049 filename directory)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2050 (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
|
2051 (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
|
2052 result) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2053 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2054 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2055 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2056 (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
|
2057 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2058 "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
|
2059 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2060 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2061 ;; 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
|
2062 ;; 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
|
2063 ;; rock. --daniel@danann.net |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2064 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2065 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2066 (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
|
2067 "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
|
2068 "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
|
2069 (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
|
2070 (if (or nowild (zerop (length filename))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2071 "" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2072 (format "-d %s*" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2073 (tramp-shell-quote-argument filename))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2074 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2075 ;; Now grab the output. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2076 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2077 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2078 (while (zerop (forward-line -1)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2079 (push (buffer-substring (point) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2080 (tramp-line-end-position)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2081 result)) |
45861 | 2082 |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2083 (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
|
2084 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2085 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2086 ;; Return the list. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2087 (if nowild |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2088 (all-completions filename (mapcar 'list result)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2089 result)))))) |
45861 | 2090 |
2091 | |
2092 ;; The following isn't needed for Emacs 20 but for 19.34? | |
2093 (defun tramp-handle-file-name-completion (filename directory) | |
2094 "Like `file-name-completion' for tramp files." | |
2095 (unless (tramp-tramp-file-p directory) | |
2096 (error | |
2097 "tramp-handle-file-name-completion invoked on non-tramp directory `%s'" | |
2098 directory)) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2099 (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
|
2100 (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
|
2101 (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
|
2102 filename directory)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2103 (try-completion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2104 filename |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2105 (mapcar (lambda (x) (cons x nil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2106 (tramp-handle-file-name-all-completions filename directory))))) |
45861 | 2107 |
2108 ;; cp, mv and ln | |
2109 | |
2110 (defun tramp-handle-add-name-to-file | |
2111 (filename newname &optional ok-if-already-exists) | |
2112 "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
|
2113 (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
|
2114 (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
|
2115 (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
|
2116 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
|
2117 (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
|
2118 (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
|
2119 (equal v1-method v2-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2120 (equal v1-user v2-user) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2121 (equal v1-host v2-host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2122 (error "add-name-to-file: %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2123 "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
|
2124 (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
|
2125 (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
|
2126 (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
|
2127 filename newname ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2128 (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
|
2129 (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
|
2130 filename newname ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2131 (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
|
2132 (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
|
2133 filename newname ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2134 (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
|
2135 (file-exists-p newname) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2136 (not (numberp ok-if-already-exists)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2137 (y-or-n-p |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2138 (format |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2139 "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
|
2140 newname))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2141 (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
|
2142 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2143 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
|
2144 (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
|
2145 (tramp-shell-quote-argument v2-path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2146 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2147 "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
|
2148 (buffer-name)))))) |
45861 | 2149 |
2150 (defun tramp-handle-copy-file | |
2151 (filename newname &optional ok-if-already-exists keep-date) | |
2152 "Like `copy-file' for tramp files." | |
2153 ;; Check if both files are local -- invoke normal copy-file. | |
2154 ;; Otherwise, use tramp from local system. | |
2155 (setq filename (expand-file-name filename)) | |
2156 (setq newname (expand-file-name newname)) | |
2157 ;; At least one file a tramp file? | |
2158 (if (or (tramp-tramp-file-p filename) | |
2159 (tramp-tramp-file-p newname)) | |
2160 (tramp-do-copy-or-rename-file | |
2161 'copy filename newname ok-if-already-exists keep-date) | |
2162 (tramp-run-real-handler | |
2163 'copy-file | |
2164 (list filename newname ok-if-already-exists keep-date)))) | |
2165 | |
2166 (defun tramp-handle-rename-file | |
2167 (filename newname &optional ok-if-already-exists) | |
2168 "Like `rename-file' for tramp files." | |
2169 ;; Check if both files are local -- invoke normal rename-file. | |
2170 ;; Otherwise, use tramp from local system. | |
2171 (setq filename (expand-file-name filename)) | |
2172 (setq newname (expand-file-name newname)) | |
2173 ;; At least one file a tramp file? | |
2174 (if (or (tramp-tramp-file-p filename) | |
2175 (tramp-tramp-file-p newname)) | |
2176 (tramp-do-copy-or-rename-file | |
2177 'rename filename newname ok-if-already-exists) | |
2178 (tramp-run-real-handler 'rename-file | |
2179 (list filename newname ok-if-already-exists)))) | |
2180 | |
2181 (defun tramp-do-copy-or-rename-file | |
2182 (op filename newname &optional ok-if-already-exists keep-date) | |
2183 "Copy or rename a remote file. | |
2184 OP must be `copy' or `rename' and indicates the operation to perform. | |
2185 FILENAME specifies the file to copy or rename, NEWNAME is the name of | |
2186 the new file (for copy) or the new name of the file (for rename). | |
2187 OK-IF-ALREADY-EXISTS means don't barf if NEWNAME exists already. | |
2188 KEEP-DATE means to make sure that NEWNAME has the same timestamp | |
2189 as FILENAME. | |
2190 | |
2191 This function is invoked by `tramp-handle-copy-file' and | |
2192 `tramp-handle-rename-file'. It is an error if OP is neither of `copy' | |
2193 and `rename'. FILENAME and NEWNAME must be absolute file names." | |
2194 (unless (memq op '(copy rename)) | |
2195 (error "Unknown operation `%s', must be `copy' or `rename'" op)) | |
2196 (unless ok-if-already-exists | |
2197 (when (file-exists-p newname) | |
2198 (signal 'file-already-exists | |
2199 (list newname)))) | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2200 (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
|
2201 (t2 (tramp-tramp-file-p newname))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2202 ;; 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
|
2203 (cond |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2204 ((and t1 t2) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2205 ;; Both are Tramp files. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2206 (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
|
2207 (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
|
2208 ;; Possibly invoke Ange-FTP. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2209 (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
|
2210 (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
|
2211 (tramp-invoke-ange-ftp |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2212 (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
|
2213 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
|
2214 ;; 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
|
2215 (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
|
2216 (equal v1-method v2-method) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2217 (equal v1-host v2-host) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2218 (equal v1-user v2-user)) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2219 ;; 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
|
2220 ;; 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
|
2221 ;; directly. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2222 (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
|
2223 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
|
2224 v1-path v2-path keep-date) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2225 ;; 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
|
2226 ;; 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
|
2227 ;; 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
|
2228 ;; 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
|
2229 ;; 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
|
2230 ;; 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
|
2231 ;; 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
|
2232 ;; 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
|
2233 ;; source and target file. |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2234 |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2235 ;; 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
|
2236 ;; 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
|
2237 ;; can invoke rcp directly. Note that |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2238 ;; 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
|
2239 ;; 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
|
2240 (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
|
2241 op filename newname keep-date))))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2242 ((or t1 t2) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2243 ;; 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
|
2244 (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
|
2245 (t |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2246 ;; 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
|
2247 (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
|
2248 |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2249 (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
|
2250 "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
|
2251 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
|
2252 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
|
2253 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
|
2254 (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
|
2255 (when keep-date |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2256 (tramp-message |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2257 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
|
2258 " with inline copying across machines"))) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2259 (save-excursion |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2260 (set-buffer trampbuf) (erase-buffer) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2261 (insert-file-contents-literally filename) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2262 (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
|
2263 (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
|
2264 ;; 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
|
2265 (unless (eq op 'copy) |
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
2266 (delete-file filename)))) |
45861 | 2267 |
2268 (defun tramp-do-copy-or-rename-file-directly | |
2269 (op multi-method method user host path1 path2 keep-date) | |
2270 "Invokes `cp' or `mv' on the remote system. | |
2271 OP must be one of `copy' or `rename', indicating `cp' or `mv', | |
2272 respectively. METHOD, USER, and HOST specify the connection. | |
2273 PATH1 and PATH2 specify the two arguments of `cp' or `mv'. | |
2274 If KEEP-DATE is non-nil, preserve the time stamp when copying." | |
2275 ;; CCC: What happens to the timestamp when renaming? | |
2276 (let ((cmd (cond ((and (eq op 'copy) keep-date) "cp -f -p") | |
2277 ((eq op 'copy) "cp -f") | |
2278 ((eq op 'rename) "mv -f") | |
2279 (t (error | |
2280 "Unknown operation `%s', must be `copy' or `rename'" | |
2281 op))))) | |
2282 (save-excursion | |
2283 (tramp-barf-unless-okay | |
2284 multi-method method user host | |
2285 (format "%s %s %s" | |
2286 cmd | |
2287 (tramp-shell-quote-argument path1) | |
2288 (tramp-shell-quote-argument path2)) | |
2289 nil 'file-error | |
2290 "Copying directly failed, see buffer `%s' for details." | |
2291 (buffer-name))))) | |
2292 | |
2293 ;; mkdir | |
2294 (defun tramp-handle-make-directory (dir &optional parents) | |
2295 "Like `make-directory' for tramp files." | |
46752 | 2296 (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
|
2297 (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
|
2298 (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
|
2299 (tramp-invoke-ange-ftp 'make-directory dir parents)) |
45861 | 2300 (tramp-barf-unless-okay |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2301 multi-method method user host |
45861 | 2302 (format " %s %s" |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2303 (if parents "mkdir -p" "mkdir") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2304 (tramp-shell-quote-argument path)) |
45861 | 2305 nil 'file-error |
2306 "Couldn't make directory %s" dir))) | |
2307 | |
2308 ;; CCC error checking? | |
2309 (defun tramp-handle-delete-directory (directory) | |
2310 "Like `delete-directory' for tramp files." | |
46752 | 2311 (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
|
2312 (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
|
2313 (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
|
2314 (tramp-invoke-ange-ftp 'delete-directory directory)) |
45861 | 2315 (save-excursion |
2316 (tramp-send-command | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2317 multi-method method user host |
45861 | 2318 (format "rmdir %s ; echo ok" |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2319 (tramp-shell-quote-argument path))) |
45861 | 2320 (tramp-wait-for-output)))) |
2321 | |
2322 (defun tramp-handle-delete-file (filename) | |
2323 "Like `delete-file' for tramp files." | |
46752 | 2324 (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
|
2325 (with-parsed-tramp-file-name filename nil |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2326 (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
|
2327 (tramp-invoke-ange-ftp 'delete-file filename)) |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2328 (save-excursion |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2329 (unless (zerop (tramp-send-command-and-check |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2330 multi-method method user host |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2331 (format "rm -f %s" |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2332 (tramp-shell-quote-argument path)))) |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
2333 (signal 'file-error "Couldn't delete Tramp file"))))) |
45861 | 2334 |
2335 ;; Dired. | |
2336 | |
2337 ;; CCC: This does not seem to be enough. Something dies when | |
2338 ;; we try and delete two directories under TRAMP :/ | |
2339 (defun tramp-handle-dired-recursive-delete-directory (filename) | |
2340 "Recursively delete the directory given. | |
2341 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
|
2342 (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
|
2343 (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
|
2344 (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
|
2345 filename)) |
45861 | 2346 ;; run a shell command 'rm -r <path>' |
2347 ;; Code shamelessly stolen for the dired implementation and, um, hacked :) | |
2348 (or (tramp-handle-file-exists-p filename) | |
2349 (signal | |
2350 'file-error | |
2351 (list "Removing old file name" "no such directory" filename))) | |
2352 ;; Which is better, -r or -R? (-r works for me <daniel@danann.net>) | |
2353 (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
|
2354 (format "rm -r %s" (tramp-shell-quote-argument path))) |
45861 | 2355 ;; Wait for the remote system to return to us... |
2356 ;; This might take a while, allow it plenty of time. | |
2357 (tramp-wait-for-output 120) | |
2358 ;; Make sure that it worked... | |
2359 (and (tramp-handle-file-exists-p filename) | |
2360 (error "Failed to recusively delete %s" filename)))) | |
2361 | |
2362 | |
2363 (defun tramp-handle-dired-call-process (program discard &rest arguments) | |
2364 "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
|
2365 (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
|
2366 (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
|
2367 (let ((default-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2368 (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
|
2369 (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
|
2370 program discard arguments))) |
45861 | 2371 (save-excursion |
2372 (tramp-barf-unless-okay | |
2373 multi-method method user host | |
2374 (format "cd %s" (tramp-shell-quote-argument path)) | |
2375 nil 'file-error | |
2376 "tramp-handle-dired-call-process: Couldn't `cd %s'" | |
2377 (tramp-shell-quote-argument path)) | |
2378 (tramp-send-command | |
2379 multi-method method user host | |
2380 (mapconcat #'tramp-shell-quote-argument (cons program arguments) " ")) | |
2381 (tramp-wait-for-output)) | |
2382 (unless discard | |
2383 (insert-buffer (tramp-get-buffer multi-method method user host))) | |
2384 (save-excursion | |
2385 (prog1 | |
2386 (tramp-send-command-and-check multi-method method user host nil) | |
2387 (tramp-send-command multi-method method user host "cd") | |
2388 (tramp-wait-for-output))))) | |
2389 | |
2390 ;; Pacify byte-compiler. The function is needed on XEmacs only. I'm | |
2391 ;; not sure at all that this is the right way to do it, but let's hope | |
2392 ;; it works for now, and wait for a guru to point out the Right Way to | |
2393 ;; achieve this. | |
2394 ;;(eval-when-compile | |
2395 ;; (unless (fboundp 'dired-insert-set-properties) | |
2396 ;; (fset 'dired-insert-set-properties 'ignore))) | |
2397 ;; Gerd suggests this: | |
2398 (eval-when-compile (require 'dired)) | |
2399 ;; Note that dired is required at run-time, too, when it is needed. | |
2400 ;; It is only needed on XEmacs for the function | |
2401 ;; `dired-insert-set-properties'. | |
2402 | |
2403 (defun tramp-handle-insert-directory | |
2404 (filename switches &optional wildcard full-directory-p) | |
2405 "Like `insert-directory' for tramp files." | |
46752 | 2406 (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
|
2407 (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
|
2408 (when (tramp-ange-ftp-file-name-p multi-method method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2409 (tramp-invoke-ange-ftp 'insert-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2410 filename switches wildcard full-directory-p)) |
45861 | 2411 (tramp-message-for-buffer |
2412 multi-method method user host 10 | |
2413 "Inserting directory `ls %s %s', wildcard %s, fulldir %s" | |
2414 switches filename (if wildcard "yes" "no") | |
2415 (if full-directory-p "yes" "no")) | |
2416 (when wildcard | |
2417 (setq wildcard (file-name-nondirectory path)) | |
2418 (setq path (file-name-directory path))) | |
2419 (when (listp switches) | |
2420 (setq switches (mapconcat 'identity switches " "))) | |
2421 (unless full-directory-p | |
2422 (setq switches (concat "-d " switches))) | |
2423 (when wildcard | |
2424 (setq switches (concat switches " " wildcard))) | |
2425 (save-excursion | |
2426 ;; If `full-directory-p', we just say `ls -l FILENAME'. | |
2427 ;; Else we chdir to the parent directory, then say `ls -ld BASENAME'. | |
2428 (if full-directory-p | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2429 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2430 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2431 (format "%s %s %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2432 (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
|
2433 switches |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2434 (if wildcard |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2435 path |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2436 (tramp-shell-quote-argument (concat path "."))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2437 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2438 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2439 (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
|
2440 (file-name-directory path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2441 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2442 "Couldn't `cd %s'" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2443 (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
|
2444 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2445 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2446 (format "%s %s %s" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2447 (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
|
2448 switches |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2449 (if full-directory-p |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2450 ;; 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
|
2451 ;; listing for symlinks, too. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2452 (concat (file-name-as-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2453 (file-name-nondirectory path)) ".") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2454 (file-name-nondirectory path))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2455 (sit-for 1) ;needed for rsh but not ssh? |
45861 | 2456 (tramp-wait-for-output)) |
2457 (insert-buffer (tramp-get-buffer multi-method method user host)) | |
2458 ;; On XEmacs, we want to call (exchange-point-and-mark t), but | |
2459 ;; that doesn't exist on Emacs, so we use this workaround instead. | |
2460 ;; Since zmacs-region-stays doesn't exist in Emacs, this ought to | |
2461 ;; be safe. Thanks to Daniel Pittman <daniel@danann.net>. | |
2462 (let ((zmacs-region-stays t)) | |
2463 (exchange-point-and-mark)) | |
2464 (save-excursion | |
2465 (tramp-send-command multi-method method user host "cd") | |
2466 (tramp-wait-for-output)) | |
2467 ;; Another XEmacs specialty follows. What's the right way to do | |
2468 ;; it? | |
2469 (when (and (featurep 'xemacs) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2470 (eq major-mode 'dired-mode)) |
45861 | 2471 (save-excursion |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2472 (require 'dired) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2473 (dired-insert-set-properties (point) (mark t)))))) |
45861 | 2474 |
2475 ;; Continuation of kluge to pacify byte-compiler. | |
2476 ;;(eval-when-compile | |
2477 ;; (when (eq (symbol-function 'dired-insert-set-properties) 'ignore) | |
2478 ;; (fmakunbound 'dired-insert-set-properties))) | |
2479 | |
2480 ;; CCC is this the right thing to do? | |
2481 (defun tramp-handle-unhandled-file-name-directory (filename) | |
2482 "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
|
2483 (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
|
2484 (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
|
2485 (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
|
2486 filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2487 (expand-file-name "~/"))) |
45861 | 2488 |
2489 ;; Canonicalization of file names. | |
2490 | |
2491 (defun tramp-drop-volume-letter (name) | |
2492 "Cut off unnecessary drive letter from file NAME. | |
2493 The function `tramp-handle-expand-file-name' calls `expand-file-name' | |
2494 locally on a remote file name. When the local system is a W32 system | |
2495 but the remote system is Unix, this introduces a superfluous drive | |
2496 letter into the file name. This function removes it. | |
2497 | |
2498 Doesn't do anything if the NAME does not start with a drive letter." | |
2499 (if (and (> (length name) 1) | |
2500 (char-equal (aref name 1) ?:) | |
2501 (let ((c1 (aref name 0))) | |
2502 (or (and (>= c1 ?A) (<= c1 ?Z)) | |
2503 (and (>= c1 ?a) (<= c1 ?z))))) | |
2504 (substring name 2) | |
2505 name)) | |
2506 | |
2507 (defun tramp-handle-expand-file-name (name &optional dir) | |
2508 "Like `expand-file-name' for tramp files." | |
2509 ;; If DIR is not given, use DEFAULT-DIRECTORY or "/". | |
2510 (setq dir (or dir default-directory "/")) | |
2511 ;; Unless NAME is absolute, concat DIR and NAME. | |
2512 (unless (file-name-absolute-p name) | |
2513 (setq name (concat (file-name-as-directory dir) name))) | |
2514 ;; If NAME is not a tramp file, run the real handler | |
2515 (if (not (tramp-tramp-file-p name)) | |
2516 (tramp-run-real-handler 'expand-file-name | |
2517 (list name nil)) | |
2518 ;; Dissect NAME. | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2519 (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
|
2520 (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
|
2521 (tramp-invoke-ange-ftp 'expand-file-name name nil)) |
45861 | 2522 (unless (file-name-absolute-p path) |
2523 (setq path (concat "~/" path))) | |
2524 (save-excursion | |
2525 ;; Tilde expansion if necessary. This needs a shell which | |
2526 ;; groks tilde expansion! The function `tramp-find-shell' is | |
2527 ;; supposed to find such a shell on the remote host. Please | |
2528 ;; tell me about it when this doesn't work on your system. | |
2529 (when (string-match "\\`\\(~[^/]*\\)\\(.*\\)\\'" path) | |
2530 (let ((uname (match-string 1 path)) | |
2531 (fname (match-string 2 path))) | |
2532 ;; CCC fanatic error checking? | |
2533 (set-buffer (tramp-get-buffer multi-method method user host)) | |
2534 (erase-buffer) | |
2535 (tramp-send-command | |
2536 multi-method method user host | |
2537 (format "cd %s; pwd" uname) | |
2538 t) | |
2539 (tramp-wait-for-output) | |
2540 (goto-char (point-min)) | |
2541 (setq uname (buffer-substring (point) (tramp-line-end-position))) | |
2542 (setq path (concat uname fname)) | |
2543 (erase-buffer))) | |
2544 ;; No tilde characters in file name, do normal | |
2545 ;; expand-file-name (this does "/./" and "/../"). We bind | |
2546 ;; directory-sep-char here for XEmacs on Windows, which would | |
2547 ;; otherwise use backslash. | |
2548 (let ((directory-sep-char ?/)) | |
2549 (tramp-make-tramp-file-name | |
2550 multi-method method user host | |
2551 (tramp-drop-volume-letter | |
2552 (tramp-run-real-handler 'expand-file-name (list path))))))))) | |
2553 | |
2554 ;; Remote commands. | |
2555 | |
2556 (defun tramp-handle-shell-command (command &optional output-buffer error-buffer) | |
2557 "Like `shell-command' for tramp files. | |
2558 This will break if COMMAND prints a newline, followed by the value of | |
2559 `tramp-end-of-output', followed by another newline." | |
46752 | 2560 (when (tramp-tramp-file-p default-directory) |
2561 (with-parsed-tramp-file-name default-directory nil | |
2562 (when (tramp-ange-ftp-file-name-p multi-method method) | |
2563 (let ((default-directory (tramp-make-ange-ftp-file-name | |
2564 user host path))) | |
2565 (tramp-invoke-ange-ftp 'shell-command | |
2566 command output-buffer error-buffer))) | |
2567 (let (status) | |
2568 (when (string-match "&[ \t]*\\'" command) | |
2569 (error "Tramp doesn't grok asynchronous shell commands, yet")) | |
2570 (when error-buffer | |
2571 (error "Tramp doesn't grok optional third arg ERROR-BUFFER, yet")) | |
2572 (save-excursion | |
2573 (tramp-barf-unless-okay | |
2574 multi-method method user host | |
2575 (format "cd %s" (tramp-shell-quote-argument path)) | |
2576 nil 'file-error | |
2577 "tramp-handle-shell-command: Couldn't `cd %s'" | |
2578 (tramp-shell-quote-argument path)) | |
2579 (tramp-send-command multi-method method user host | |
2580 (concat command "; tramp_old_status=$?")) | |
2581 ;; This will break if the shell command prints "/////" | |
2582 ;; somewhere. Let's just hope for the best... | |
2583 (tramp-wait-for-output)) | |
2584 (unless output-buffer | |
2585 (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
|
2586 (set-buffer output-buffer) |
46752 | 2587 (erase-buffer)) |
2588 (unless (bufferp output-buffer) | |
2589 (setq output-buffer (current-buffer))) | |
2590 (set-buffer output-buffer) | |
2591 (insert-buffer (tramp-get-buffer multi-method method user host)) | |
2592 (save-excursion | |
2593 (tramp-send-command multi-method method user host "cd") | |
2594 (tramp-wait-for-output) | |
2595 (tramp-send-command | |
2596 multi-method method user host | |
2597 (concat "tramp_set_exit_status $tramp_old_status;" | |
2598 " echo tramp_exit_status $?")) | |
2599 (tramp-wait-for-output) | |
2600 (goto-char (point-max)) | |
2601 (unless (search-backward "tramp_exit_status " nil t) | |
2602 (error "Couldn't find exit status of `%s'" command)) | |
2603 (skip-chars-forward "^ ") | |
2604 (setq status (read (current-buffer)))) | |
2605 (unless (zerop (buffer-size)) | |
2606 (pop-to-buffer output-buffer)) | |
2607 status))) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2608 ;; 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
|
2609 ;; 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
|
2610 (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
|
2611 default-directory) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2612 (tramp-run-real-handler 'shell-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2613 (list command output-buffer error-buffer))) |
45861 | 2614 |
2615 ;; File Editing. | |
2616 | |
2617 (defsubst tramp-make-temp-file () | |
2618 (funcall (if (fboundp 'make-temp-file) 'make-temp-file 'make-temp-name) | |
2619 (expand-file-name tramp-temp-name-prefix | |
2620 (tramp-temporary-file-directory)))) | |
2621 | |
2622 (defun tramp-handle-file-local-copy (filename) | |
2623 "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
|
2624 (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
|
2625 (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
|
2626 (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
|
2627 (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
|
2628 tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2629 (unless (file-exists-p filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2630 (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
|
2631 filename)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2632 (setq tmpfil (tramp-make-temp-file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2633 (cond ((tramp-get-rcp-program multi-method method) |
46752 | 2634 ;; 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
|
2635 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2636 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2637 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
|
2638 (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
|
2639 (unless (equal |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2640 0 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2641 (apply #'call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2642 (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
|
2643 nil trampbuf nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2644 (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
|
2645 (list |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2646 (tramp-make-rcp-program-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2647 user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2648 (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2649 tmpfil)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2650 (pop-to-buffer trampbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2651 (error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2652 (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
|
2653 "see buffer `%s' for details") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2654 (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
|
2655 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2656 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2657 5 "Fetching %s to tmp file %s...done" filename tmpfil)) |
46752 | 2658 ((and (tramp-get-encoding-command multi-method method user host) |
2659 (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
|
2660 ;; Use inline encoding for file transfer. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2661 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2662 ;; 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
|
2663 ;; tramp-current-user, tramp-current-host. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2664 (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
|
2665 (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
|
2666 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2667 multi-method method user host |
46752 | 2668 (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
|
2669 " < " (tramp-shell-quote-argument path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2670 nil 'file-error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2671 "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
|
2672 (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
|
2673 ;; Remove trailing status code |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2674 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2675 (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
|
2676 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2677 (tramp-message 5 "Decoding remote file %s..." filename) |
46752 | 2678 (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
|
2679 (fboundp (tramp-get-decoding-function |
46752 | 2680 multi-method method user host))) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2681 ;; 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
|
2682 ;; method, we call it. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2683 (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
|
2684 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2685 (erase-buffer) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2686 (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
|
2687 user host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2688 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2689 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2690 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
|
2691 filename |
46752 | 2692 (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
|
2693 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2694 (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
|
2695 (funcall (tramp-get-decoding-function |
46752 | 2696 multi-method method user host) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2697 (point-min) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2698 (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2699 (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
|
2700 (kill-buffer tmpbuf)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2701 ;; 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
|
2702 ;; 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
|
2703 (let ((tmpfil2 (tramp-make-temp-file))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2704 (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
|
2705 (tramp-message |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2706 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
|
2707 filename |
46752 | 2708 (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
|
2709 (call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2710 tramp-sh-program |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2711 tmpfil2 ;input |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2712 nil ;output |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2713 nil ;display |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2714 "-c" (concat (tramp-get-decoding-command |
46752 | 2715 multi-method method user host) |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2716 " > " tmpfil)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2717 (delete-file tmpfil2))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2718 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2719 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2720 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
|
2721 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2722 (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
|
2723 tmpfil))) |
45861 | 2724 |
2725 | |
2726 (defun tramp-handle-insert-file-contents | |
2727 (filename &optional visit beg end replace) | |
2728 "Like `insert-file-contents' for tramp files." | |
2729 (barf-if-buffer-read-only) | |
2730 (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
|
2731 (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
|
2732 (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
|
2733 (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
|
2734 filename visit beg end replace)) |
45861 | 2735 (if (not (tramp-handle-file-exists-p filename)) |
2736 (progn | |
2737 (when visit | |
2738 (setq buffer-file-name filename) | |
2739 (set-visited-file-modtime) | |
2740 (set-buffer-modified-p nil)) | |
2741 (signal 'file-error | |
2742 (format "File `%s' not found on remote host" filename)) | |
2743 (list (tramp-handle-expand-file-name filename) 0)) | |
2744 (let ((local-copy (tramp-handle-file-local-copy filename)) | |
2745 (coding-system-used nil) | |
2746 (result nil)) | |
2747 (when visit | |
2748 (setq buffer-file-name filename) | |
2749 (set-visited-file-modtime) | |
2750 (set-buffer-modified-p nil)) | |
2751 (tramp-message-for-buffer | |
2752 multi-method method user host | |
2753 9 "Inserting local temp file `%s'..." local-copy) | |
2754 (setq result | |
2755 (tramp-run-real-handler 'insert-file-contents | |
2756 (list local-copy nil beg end replace))) | |
2757 ;; Now `last-coding-system-used' has right value. Remember it. | |
2758 (when (boundp 'last-coding-system-used) | |
2759 (setq coding-system-used last-coding-system-used)) | |
2760 (tramp-message 9 "Inserting local temp file `%s'...done" local-copy) | |
2761 (delete-file local-copy) | |
2762 (when (boundp 'last-coding-system-used) | |
2763 (setq last-coding-system-used coding-system-used)) | |
2764 (list (expand-file-name filename) | |
2765 (second result)))))) | |
2766 | |
2767 ;; CCC grok APPEND, LOCKNAME, CONFIRM | |
2768 (defun tramp-handle-write-region | |
2769 (start end filename &optional append visit lockname confirm) | |
2770 "Like `write-region' for tramp files." | |
2771 (unless (eq append nil) | |
2772 (error "Cannot append to file using tramp (`%s')" filename)) | |
2773 (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
|
2774 ;; 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
|
2775 ;; 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
|
2776 ;; Ange-ftp ignores it, too. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2777 ;; (when (and lockname (stringp lockname)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2778 ;; (setq lockname (expand-file-name lockname))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2779 ;; (unless (or (eq lockname nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2780 ;; (string= lockname filename)) |
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 ;; "tramp-handle-write-region: LOCKNAME must be nil or equal FILENAME")) |
45861 | 2783 ;; XEmacs takes a coding system as the sevent argument, not `confirm' |
2784 (when (and (not (featurep 'xemacs)) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2785 confirm (file-exists-p filename)) |
45861 | 2786 (unless (y-or-n-p (format "File %s exists; overwrite anyway? " |
2787 filename)) | |
2788 (error "File not overwritten"))) | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2789 (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
|
2790 (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
|
2791 (tramp-invoke-ange-ftp 'write-region |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2792 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
|
2793 (let ((curbuf (current-buffer)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2794 (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
|
2795 (rcp-args (tramp-get-rcp-args multi-method method)) |
46752 | 2796 (encoding-command |
2797 (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
|
2798 (encoding-function |
46752 | 2799 (tramp-get-encoding-function multi-method method user host)) |
2800 (decoding-command | |
2801 (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
|
2802 (trampbuf (get-buffer-create "*tramp output*")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2803 ;; 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
|
2804 ;; 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
|
2805 ;; 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
|
2806 ;; 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
|
2807 ;; 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
|
2808 ;; 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
|
2809 coding-system-used |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2810 tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2811 ;; 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
|
2812 ;; 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
|
2813 ;; because this makes the logic simpler. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2814 (setq tmpfil (tramp-make-temp-file)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2815 ;; 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
|
2816 ;; 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
|
2817 ;; `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
|
2818 (tramp-run-real-handler |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2819 'write-region |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2820 (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
|
2821 (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
|
2822 (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
|
2823 ;; 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
|
2824 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2825 (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
|
2826 ;; 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
|
2827 ;; 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
|
2828 ;; 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
|
2829 ;; 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
|
2830 ;; _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
|
2831 ;; 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
|
2832 (cond (rcp-program |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2833 ;; 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
|
2834 (let ((argl (append rcp-args |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2835 (list |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2836 tmpfil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2837 (tramp-make-rcp-program-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2838 user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2839 (tramp-shell-quote-argument path)))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2840 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2841 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2842 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
|
2843 (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
|
2844 (when tramp-debug-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2845 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2846 (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
|
2847 method user host)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2848 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2849 (tramp-insert-with-face |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2850 '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
|
2851 (mapconcat 'identity argl " "))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2852 (unless (equal 0 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2853 (apply #'call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2854 rcp-program nil trampbuf nil argl)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2855 (pop-to-buffer trampbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2856 (error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2857 "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
|
2858 filename rcp-program)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2859 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2860 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2861 6 "Transferring file using `%s'...done" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2862 rcp-program))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2863 ((and encoding-command decoding-command) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2864 ;; Use inline file transfer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2865 (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
|
2866 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2867 ;; Encode tmpfil into tmpbuf |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2868 (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
|
2869 5 "Encoding region...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2870 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2871 (erase-buffer) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2872 ;; Use encoding function or command. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2873 (if (and encoding-function |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2874 (fboundp encoding-function)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2875 (progn |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2876 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2877 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2878 6 "Encoding region using function...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2879 (insert-file-contents-literally tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2880 ;; 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
|
2881 ;; 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
|
2882 ;; both of the following conditions are |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2883 ;; 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
|
2884 ;; 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
|
2885 ;; default-directory is remote. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2886 ;; (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
|
2887 ;; 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
|
2888 ;; tmp file anyway. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2889 (let ((default-directory |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2890 (tramp-temporary-file-directory))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2891 (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
|
2892 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2893 (unless (bolp) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2894 (newline))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2895 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2896 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2897 6 "Encoding region using command...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2898 (unless (equal 0 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2899 (call-process |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2900 tramp-sh-program |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2901 tmpfil ;input = local tmp file |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2902 t ;output is current buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2903 nil ;don't redisplay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2904 "-c" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2905 encoding-command)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2906 (pop-to-buffer trampbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2907 (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
|
2908 " command `%s' failed") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2909 filename encoding-command))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2910 ;; 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
|
2911 ;; 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
|
2912 ;; 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
|
2913 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2914 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2915 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
|
2916 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2917 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2918 (format "%s >%s <<'EOF'" |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2919 decoding-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2920 (tramp-shell-quote-argument path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2921 (set-buffer tmpbuf) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2922 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2923 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2924 6 "Sending data to remote host...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2925 (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
|
2926 (point-min) (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2927 ;; wait for remote decoding to complete |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2928 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2929 multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2930 6 "Sending end of data token...") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2931 (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2932 multi-method method user host "EOF") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2933 (tramp-message-for-buffer |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2934 multi-method method user host 6 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2935 "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
|
2936 (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
|
2937 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2938 (tramp-barf-unless-okay |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2939 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
|
2940 (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
|
2941 " decode using `%s' failed") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2942 filename decoding-command) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2943 (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
|
2944 filename) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2945 (kill-buffer tmpbuf)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2946 (t |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2947 (error |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2948 (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
|
2949 "decoding command or an rcp program") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2950 method))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2951 (delete-file tmpfil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2952 (unless (equal curbuf (current-buffer)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2953 (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
|
2954 curbuf (current-buffer))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2955 (when (eq visit t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2956 (set-visited-file-modtime)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2957 ;; 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
|
2958 (when (boundp 'last-coding-system-used) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2959 (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
|
2960 (when (or (eq visit t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2961 (eq visit nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2962 (stringp visit)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
2963 (message "Wrote %s" filename))))) |
45861 | 2964 |
2965 ;; Call down to the real handler. | |
2966 ;; Because EFS does not play nicely with TRAMP (both systems match an | |
2967 ;; TRAMP path) it is needed to disable efs as well as tramp for the | |
2968 ;; operation. | |
2969 ;; | |
2970 ;; Other than that, this is the canon file-handler code that the doco | |
2971 ;; says should be used here. Which is nice. | |
2972 ;; | |
2973 ;; Under XEmacs current, EFS also hooks in as | |
2974 ;; efs-sifn-handler-function to handle any path with environment | |
2975 ;; variables. This has two implications: | |
2976 ;; 1) That EFS may not be completely dead (yet) for TRAMP paths | |
2977 ;; 2) That TRAMP might want to do the same thing. | |
2978 ;; Details as they come in. | |
2979 ;; | |
2980 ;; Daniel Pittman <daniel@danann.net> | |
2981 | |
2982 ;; (defun tramp-run-real-handler (operation args) | |
2983 ;; "Invoke normal file name handler for OPERATION. | |
2984 ;; This inhibits EFS and Ange-FTP, too, because they conflict with tramp. | |
2985 ;; First arg specifies the OPERATION, remaining ARGS are passed to the | |
2986 ;; OPERATION." | |
2987 ;; (let ((inhibit-file-name-handlers | |
2988 ;; (list 'tramp-file-name-handler | |
2989 ;; 'efs-file-handler-function | |
2990 ;; 'ange-ftp-hook-function | |
2991 ;; (and (eq inhibit-file-name-operation operation) | |
2992 ;; inhibit-file-name-handlers))) | |
2993 ;; (inhibit-file-name-operation operation)) | |
2994 ;; (apply operation args))) | |
2995 | |
2996 (defun tramp-run-real-handler (operation args) | |
2997 "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
|
2998 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
|
2999 pass to the OPERATION." |
45861 | 3000 (let ((inhibit-file-name-handlers |
3001 (list 'tramp-file-name-handler | |
3002 (and (eq inhibit-file-name-operation operation) | |
3003 inhibit-file-name-handlers))) | |
3004 (inhibit-file-name-operation operation)) | |
3005 (apply operation args))) | |
3006 | |
3007 ;; Main function. | |
3008 ;;;###autoload | |
3009 (defun tramp-file-name-handler (operation &rest args) | |
3010 "Invoke tramp file name handler. | |
3011 Falls back to normal file name handler if no tramp file name handler exists." | |
3012 (let ((fn (assoc operation tramp-file-name-handler-alist))) | |
3013 (if fn | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3014 (catch 'tramp-forward-to-ange-ftp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3015 (save-match-data (apply (cdr fn) args))) |
45861 | 3016 (tramp-run-real-handler operation args)))) |
3017 | |
3018 ;; Register in file name handler alist | |
3019 ;;;###autoload | |
3020 (add-to-list 'file-name-handler-alist | |
3021 (cons tramp-file-name-regexp 'tramp-file-name-handler)) | |
3022 | |
46306
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3023 ;; 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
|
3024 ;; |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3025 ;; * 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
|
3026 ;; * 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
|
3027 ;; 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
|
3028 ;; * 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
|
3029 ;; |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3030 ;; 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
|
3031 ;; 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
|
3032 (defun tramp-disable-ange-ftp () |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3033 "Turn Ange-FTP off. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3034 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
|
3035 `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
|
3036 `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
|
3037 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
|
3038 `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
|
3039 `tramp-default-method-alist'. |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3040 |
66cce4969490
(tramp-default-method): New default method "sm"
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46166
diff
changeset
|
3041 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
|
3042 present for backward compatibility." |
46060
40298ba8e901
(tramp-handle-ange-ftp): Fix typo.
Andreas Schwab <schwab@suse.de>
parents:
46048
diff
changeset
|
3043 (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
|
3044 (a2 (rassq 'ange-ftp-completion-hook-function file-name-handler-alist))) |
45861 | 3045 (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
|
3046 (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
|
3047 (tramp-disable-ange-ftp) |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3048 |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3049 (defun tramp-repair-jka-compr () |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3050 "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
|
3051 `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
|
3052 necessary anymore." |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3053 (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
|
3054 (when jka |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3055 (setq file-name-handler-alist |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3056 (cons jka (delete jka file-name-handler-alist)))))) |
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
3057 (tramp-repair-jka-compr) |
45861 | 3058 |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3059 (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
|
3060 "Invoke the Ange-FTP handler function and throw." |
46752 | 3061 (or 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
|
3062 (let ((ange-ftp-name-format |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3063 (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
|
3064 (nth 3 tramp-file-name-structure) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3065 (nth 2 tramp-file-name-structure) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3066 (nth 4 tramp-file-name-structure)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3067 (throw 'tramp-forward-to-ange-ftp |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3068 (apply 'ange-ftp-hook-function operation args)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3069 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3070 (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
|
3071 "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
|
3072 (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
|
3073 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3074 |
45861 | 3075 ;;; Interactions with other packages: |
3076 | |
3077 ;; -- complete.el -- | |
3078 | |
3079 ;; This function contributed by Ed Sabol | |
3080 (defun tramp-handle-expand-many-files (name) | |
3081 "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
|
3082 (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
|
3083 (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
|
3084 (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
|
3085 (save-match-data |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3086 (if (or (string-match "\\*" name) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3087 (string-match "\\?" name) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3088 (string-match "\\[.*\\]" name)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3089 (save-excursion |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3090 ;; Dissect NAME. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3091 (let (bufstr) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3092 ;; Perhaps invoke Ange-FTP. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3093 (when (string= method tramp-ftp-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3094 (signal 'tramp-run-ange-ftp (list 0))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3095 ;; 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
|
3096 ;; 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
|
3097 ;; 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
|
3098 ;; don't bother. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3099 ;;-(let ((comint-file-name-quote-list |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3100 ;;- (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
|
3101 ;;- '(?\* ?\? ?[ ?])))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3102 ;;- (tramp-send-command |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3103 ;;- multi-method method user host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3104 ;;- (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
|
3105 ;;- (tramp-wait-for-output)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3106 (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
|
3107 (format "echo %s" path)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3108 (tramp-wait-for-output) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3109 (setq bufstr (buffer-substring (point-min) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3110 (tramp-line-end-position))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3111 (goto-char (point-min)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3112 (if (string-equal path bufstr) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3113 nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3114 (insert "(\"") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3115 (while (search-forward " " nil t) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3116 (delete-backward-char 1) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3117 (insert "\" \"")) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3118 (goto-char (point-max)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3119 (delete-backward-char 1) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3120 (insert "\")") |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3121 (goto-char (point-min)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3122 (mapcar |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3123 (function (lambda (x) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3124 (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
|
3125 user host x))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3126 (read (current-buffer)))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3127 (list (tramp-handle-expand-file-name name)))))) |
45861 | 3128 |
3129 ;; Check for complete.el and override PC-expand-many-files if appropriate. | |
3130 (eval-when-compile | |
3131 (defun tramp-save-PC-expand-many-files (name))); avoid compiler warning | |
3132 | |
3133 (defun tramp-setup-complete () | |
3134 (fset 'tramp-save-PC-expand-many-files | |
3135 (symbol-function 'PC-expand-many-files)) | |
3136 (defun PC-expand-many-files (name) | |
3137 (if (tramp-tramp-file-p name) | |
3138 (tramp-handle-expand-many-files name) | |
3139 (tramp-save-PC-expand-many-files name)))) | |
3140 | |
3141 ;; Why isn't eval-after-load sufficient? | |
3142 (if (fboundp 'PC-expand-many-files) | |
3143 (tramp-setup-complete) | |
3144 (eval-after-load "complete" '(tramp-setup-complete))) | |
3145 | |
3146 | |
3147 | |
3148 | |
3149 ;;; Internal Functions: | |
3150 | |
3151 (defun tramp-set-auto-save () | |
3152 (when (and (buffer-file-name) | |
3153 (tramp-tramp-file-p (buffer-file-name)) | |
3154 auto-save-default) | |
3155 (auto-save-mode 1))) | |
3156 (add-hook 'find-file-hooks 'tramp-set-auto-save t) | |
3157 | |
3158 (defun tramp-run-test (switch filename) | |
3159 "Run `test' on the remote system, given a SWITCH and a FILENAME. | |
3160 Returns the exit code of the `test' program." | |
3161 (let ((v (tramp-dissect-file-name filename))) | |
3162 (save-excursion | |
3163 (tramp-send-command-and-check | |
3164 (tramp-file-name-multi-method v) (tramp-file-name-method v) | |
3165 (tramp-file-name-user v) (tramp-file-name-host v) | |
3166 (format "test %s %s" switch | |
3167 (tramp-shell-quote-argument (tramp-file-name-path v))))))) | |
3168 | |
3169 (defun tramp-run-test2 (program file1 file2 &optional switch) | |
3170 "Run `test'-like PROGRAM on the remote system, given FILE1, FILE2. | |
3171 The optional SWITCH is inserted between the two files. | |
3172 Returns the exit code of the `test' PROGRAM. Barfs if the methods, | |
3173 hosts, or files, disagree." | |
3174 (let* ((v1 (tramp-dissect-file-name file1)) | |
3175 (v2 (tramp-dissect-file-name file2)) | |
3176 (mmethod1 (tramp-file-name-multi-method v1)) | |
3177 (mmethod2 (tramp-file-name-multi-method v2)) | |
3178 (method1 (tramp-file-name-method v1)) | |
3179 (method2 (tramp-file-name-method v2)) | |
3180 (user1 (tramp-file-name-user v1)) | |
3181 (user2 (tramp-file-name-user v2)) | |
3182 (host1 (tramp-file-name-host v1)) | |
3183 (host2 (tramp-file-name-host v2)) | |
3184 (path1 (tramp-file-name-path v1)) | |
3185 (path2 (tramp-file-name-path v2))) | |
3186 (unless (and method1 method2 host1 host2 | |
3187 (equal mmethod1 mmethod2) | |
3188 (equal method1 method2) | |
3189 (equal user1 user2) | |
3190 (equal host1 host2)) | |
3191 (error "tramp-run-test2: %s" | |
3192 "only implemented for same method, same user, same host")) | |
3193 (save-excursion | |
3194 (tramp-send-command-and-check | |
3195 mmethod1 method1 user1 host1 | |
3196 (format "%s %s %s %s" | |
3197 program | |
3198 (tramp-shell-quote-argument path1) | |
3199 (or switch "") | |
3200 (tramp-shell-quote-argument path2)))))) | |
3201 | |
3202 (defun tramp-buffer-name (multi-method method user host) | |
3203 "A name for the connection buffer for USER at HOST using METHOD." | |
3204 (cond (multi-method | |
3205 (tramp-buffer-name-multi-method "tramp" multi-method method user host)) | |
3206 (user | |
3207 (format "*tramp/%s %s@%s*" method user host)) | |
3208 (t | |
3209 (format "*tramp/%s %s*" method host)))) | |
3210 | |
3211 (defun tramp-buffer-name-multi-method (prefix multi-method method user host) | |
3212 "A name for the multi method connection buffer. | |
3213 MULTI-METHOD gives the multi method, METHOD the array of methods, | |
3214 USER the array of user names, HOST the array of host names." | |
3215 (unless (and (= (length method) (length user)) | |
3216 (= (length method) (length host))) | |
3217 (error "Syntax error in multi method (implementation error)")) | |
3218 (let ((len (length method)) | |
3219 (i 0) | |
3220 string-list) | |
3221 (while (< i len) | |
3222 (setq string-list | |
3223 (cons (if (aref user i) | |
3224 (format "%s#%s@%s:" (aref method i) | |
3225 (aref user i) (aref host i)) | |
3226 (format "%s@%s:" (aref method i) (aref host i))) | |
3227 string-list)) | |
3228 (incf i)) | |
3229 (format "*%s/%s %s*" | |
3230 prefix multi-method | |
3231 (apply 'concat (reverse string-list))))) | |
3232 | |
3233 (defun tramp-get-buffer (multi-method method user host) | |
3234 "Get the connection buffer to be used for USER at HOST using METHOD." | |
3235 (get-buffer-create (tramp-buffer-name multi-method method user host))) | |
3236 | |
3237 (defun tramp-debug-buffer-name (multi-method method user host) | |
3238 "A name for the debug buffer for USER at HOST using METHOD." | |
3239 (cond (multi-method | |
3240 (tramp-buffer-name-multi-method "debug tramp" | |
3241 multi-method method user host)) | |
3242 (user | |
3243 (format "*debug tramp/%s %s@%s*" method user host)) | |
3244 (t | |
3245 (format "*debug tramp/%s %s*" method host)))) | |
3246 | |
3247 (defun tramp-get-debug-buffer (multi-method method user host) | |
3248 "Get the debug buffer for USER at HOST using METHOD." | |
3249 (get-buffer-create (tramp-debug-buffer-name multi-method method user host))) | |
3250 | |
3251 (defun tramp-find-executable (multi-method method user host | |
3252 progname dirlist ignore-tilde) | |
3253 "Searches for PROGNAME in all directories mentioned in DIRLIST. | |
3254 First args METHOD, USER and HOST specify the connection, PROGNAME | |
3255 is the program to search for, and DIRLIST gives the list of directories | |
3256 to search. If IGNORE-TILDE is non-nil, directory names starting | |
3257 with `~' will be ignored. | |
3258 | |
3259 Returns the full path name of PROGNAME, if found, and nil otherwise. | |
3260 | |
3261 This function expects to be in the right *tramp* buffer." | |
3262 (let (result) | |
3263 (when ignore-tilde | |
3264 ;; Remove all ~/foo directories from dirlist. In Emacs 20, | |
3265 ;; `remove' is in CL, and we want to avoid CL dependencies. | |
3266 (let (newdl d) | |
3267 (while dirlist | |
3268 (setq d (car dirlist)) | |
3269 (setq dirlist (cdr dirlist)) | |
3270 (unless (char-equal ?~ (aref d 0)) | |
3271 (setq newdl (cons d newdl)))) | |
3272 (setq dirlist (nreverse newdl)))) | |
3273 (tramp-send-command | |
3274 multi-method method user host | |
3275 (format (concat "while read d; " | |
3276 "do if test -x $d/%s -a -f $d/%s; " | |
3277 "then echo tramp_executable $d/%s; " | |
3278 "break; fi; done <<'EOF'") | |
3279 progname progname progname)) | |
3280 (mapcar (lambda (d) | |
3281 (tramp-send-command multi-method method user host d)) | |
3282 dirlist) | |
3283 (tramp-send-command multi-method method user host "EOF") | |
3284 (tramp-wait-for-output) | |
3285 (goto-char (point-max)) | |
3286 (when (search-backward "tramp_executable " nil t) | |
3287 (skip-chars-forward "^ ") | |
3288 (skip-chars-forward " ") | |
3289 (buffer-substring (point) (tramp-line-end-position))))) | |
3290 | |
3291 (defun tramp-set-remote-path (multi-method method user host var dirlist) | |
3292 "Sets the remote environment VAR to existing directories from DIRLIST. | |
3293 I.e., for each directory in DIRLIST, it is tested whether it exists and if | |
3294 so, it is added to the environment variable VAR." | |
3295 (let ((existing-dirs | |
3296 (mapcar | |
3297 (lambda (x) | |
3298 (when (and | |
3299 (file-exists-p | |
3300 (tramp-make-tramp-file-name multi-method method user host x)) | |
3301 (file-directory-p | |
3302 (tramp-make-tramp-file-name multi-method method user host x))) | |
3303 x)) | |
3304 dirlist))) | |
3305 (tramp-send-command | |
3306 multi-method method user host | |
3307 (concat var "=" | |
3308 (mapconcat 'identity (delq nil existing-dirs) ":") | |
3309 "; export " var)) | |
3310 (tramp-wait-for-output))) | |
3311 | |
3312 ;; -- communication with external shell -- | |
3313 | |
3314 (defun tramp-find-file-exists-command (multi-method method user host) | |
3315 "Find a command on the remote host for checking if a file exists. | |
3316 Here, we are looking for a command which has zero exit status if the | |
3317 file exists and nonzero exit status otherwise." | |
3318 (make-local-variable 'tramp-file-exists-command) | |
3319 (tramp-message 10 "Finding command to check if file exists") | |
3320 (let ((existing | |
3321 (tramp-make-tramp-file-name | |
3322 multi-method method user host | |
3323 "/")) ;assume this file always exists | |
3324 (nonexisting | |
3325 (tramp-make-tramp-file-name | |
3326 multi-method method user host | |
3327 "/ this file does not exist "))) ;assume this never exists | |
3328 ;; The algorithm is as follows: we try a list of several commands. | |
3329 ;; For each command, we first run `$cmd /' -- this should return | |
3330 ;; true, as the root directory always exists. And then we run | |
3331 ;; `$cmd /this\ file\ does\ not\ exist', hoping that the file indeed | |
3332 ;; does not exist. This should return false. We use the first | |
3333 ;; command we find that seems to work. | |
3334 ;; The list of commands to try is as follows: | |
3335 ;; `ls -d' This works on most systems, but NetBSD 1.4 | |
3336 ;; has a bug: `ls' always returns zero exit | |
3337 ;; status, even for files which don't exist. | |
3338 ;; `test -e' Some Bourne shells have a `test' builtin | |
3339 ;; which does not know the `-e' option. | |
3340 ;; `/bin/test -e' For those, the `test' binary on disk normally | |
3341 ;; provides the option. Alas, the binary | |
3342 ;; is sometimes `/bin/test' and sometimes it's | |
3343 ;; `/usr/bin/test'. | |
3344 ;; `/usr/bin/test -e' In case `/bin/test' does not exist. | |
3345 (unless (or | |
3346 (and (setq tramp-file-exists-command "ls -d %s") | |
3347 (tramp-handle-file-exists-p existing) | |
3348 (not (tramp-handle-file-exists-p nonexisting))) | |
3349 (and (setq tramp-file-exists-command "test -e %s") | |
3350 (tramp-handle-file-exists-p existing) | |
3351 (not (tramp-handle-file-exists-p nonexisting))) | |
3352 (and (setq tramp-file-exists-command "/bin/test -e %s") | |
3353 (tramp-handle-file-exists-p existing) | |
3354 (not (tramp-handle-file-exists-p nonexisting))) | |
3355 (and (setq tramp-file-exists-command "/usr/bin/test -e %s") | |
3356 (tramp-handle-file-exists-p existing) | |
3357 (not (tramp-handle-file-exists-p nonexisting)))) | |
3358 (error "Couldn't find command to check if file exists.")))) | |
3359 | |
3360 | |
3361 ;; CCC test ksh or bash found for tilde expansion? | |
3362 (defun tramp-find-shell (multi-method method user host) | |
3363 "Find a shell on the remote host which groks tilde expansion." | |
3364 (let ((shell nil)) | |
3365 (tramp-send-command multi-method method user host "echo ~root") | |
3366 (tramp-wait-for-output) | |
3367 (cond | |
3368 ((string-match "^~root$" (buffer-string)) | |
3369 (setq shell | |
3370 (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
|
3371 "bash" tramp-remote-path t) |
45861 | 3372 (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
|
3373 "ksh" tramp-remote-path t))) |
45861 | 3374 (unless shell |
3375 (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
|
3376 ;; Find arguments for this shell. |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3377 (let ((alist tramp-sh-extra-args) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3378 item extra-args) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3379 (while (and alist (null extra-args)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3380 (setq item (pop alist)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3381 (when (string-match (car item) shell) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3382 (setq extra-args (cdr item)))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3383 (when extra-args (setq shell (concat shell " " extra-args)))) |
45861 | 3384 (tramp-message |
3385 5 "Starting remote shell `%s' for tilde expansion..." shell) | |
3386 (tramp-send-command | |
3387 multi-method method user host | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
3388 (concat "PS1='$ ' ; exec " shell)) ; |
45861 | 3389 (unless (tramp-wait-for-regexp |
3390 (get-buffer-process (current-buffer)) | |
3391 60 (format "\\(\\$ *\\|\\(%s\\)\\'\\)" shell-prompt-pattern)) | |
3392 (pop-to-buffer (buffer-name)) | |
3393 (error "Couldn't find remote `%s' prompt." shell)) | |
3394 (process-send-string nil (format "PS1='%s%s%s'; PS2=''; PS3=''%s" | |
3395 tramp-rsh-end-of-line | |
3396 tramp-end-of-output | |
3397 tramp-rsh-end-of-line | |
3398 tramp-rsh-end-of-line)) | |
3399 (tramp-wait-for-output) | |
3400 (tramp-send-command multi-method method user host "echo hello") | |
3401 (tramp-message 5 "Waiting for remote `%s' to start up..." shell) | |
3402 (unless (tramp-wait-for-output 5) | |
3403 (unless (tramp-wait-for-output 5) | |
3404 (pop-to-buffer (buffer-name)) | |
3405 (error "Couldn't start remote `%s', see buffer `%s' for details" | |
3406 shell (buffer-name)))) | |
3407 (tramp-message 5 "Waiting for remote `%s' to start up...done" shell)) | |
3408 (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
|
3409 (tramp-get-remote-sh multi-method method)))))) |
45861 | 3410 |
3411 (defun tramp-check-ls-command (multi-method method user host cmd) | |
3412 "Checks whether the given `ls' executable groks `-n'. | |
3413 METHOD, USER and HOST specify the connection, CMD (the full path name of) | |
3414 the `ls' executable. Returns t if CMD supports the `-n' option, nil | |
3415 otherwise." | |
3416 (tramp-message 9 "Checking remote `%s' command for `-n' option" | |
3417 cmd) | |
3418 (when (tramp-handle-file-executable-p | |
3419 (tramp-make-tramp-file-name multi-method method user host cmd)) | |
3420 (let ((result nil)) | |
3421 (tramp-message 7 "Testing remote command `%s' for -n..." cmd) | |
3422 (setq result | |
3423 (tramp-send-command-and-check | |
3424 multi-method method user host | |
3425 (format "%s -lnd / >/dev/null" | |
3426 cmd))) | |
3427 (tramp-message 7 "Testing remote command `%s' for -n...%s" | |
3428 cmd | |
3429 (if (zerop result) "okay" "failed")) | |
3430 (zerop result)))) | |
3431 | |
3432 (defun tramp-check-ls-commands (multi-method method user host cmd dirlist) | |
3433 "Checks whether the given `ls' executable in one of the dirs groks `-n'. | |
3434 Returns nil if none was found, else the command is returned." | |
3435 (let ((dl dirlist) | |
3436 (result nil)) | |
3437 ;; It would be better to use the CL function `find', but | |
3438 ;; we don't want run-time dependencies on CL. | |
3439 (while (and dl (not result)) | |
3440 (let ((x (concat (file-name-as-directory (car dl)) cmd))) | |
3441 (when (tramp-check-ls-command multi-method method user host x) | |
3442 (setq result x))) | |
3443 (setq dl (cdr dl))) | |
3444 result)) | |
3445 | |
3446 (defun tramp-find-ls-command (multi-method method user host) | |
3447 "Finds an `ls' command which groks the `-n' option, returning nil if failed. | |
3448 \(This option prints numeric user and group ids in a long listing.)" | |
3449 (tramp-message 9 "Finding a suitable `ls' command") | |
3450 (or | |
3451 (tramp-check-ls-commands multi-method method user host "ls" tramp-remote-path) | |
3452 (tramp-check-ls-commands multi-method method user host "gnuls" tramp-remote-path) | |
3453 (tramp-check-ls-commands multi-method method user host "gls" tramp-remote-path))) | |
3454 | |
3455 ;; ------------------------------------------------------------ | |
3456 ;; -- Functions for establishing connection -- | |
3457 ;; ------------------------------------------------------------ | |
3458 | |
46752 | 3459 ;; The following functions are actions to be taken when seeing certain |
3460 ;; prompts from the remote host. See the variable | |
3461 ;; `tramp-actions-before-shell' for usage of these functions. | |
3462 | |
3463 (defun tramp-action-login (p multi-method method user host) | |
3464 "Send the login name." | |
3465 (tramp-message 9 "Sending login name `%s'" | |
3466 (or user (user-login-name))) | |
3467 (erase-buffer) | |
3468 (process-send-string nil (concat (or user (user-login-name)) | |
3469 tramp-rsh-end-of-line))) | |
3470 | |
3471 (defun tramp-action-password (p multi-method method user host) | |
3472 "Query the user for a password." | |
3473 (when (tramp-method-out-of-band-p multi-method method) | |
3474 (kill-process (get-buffer-process (current-buffer))) | |
3475 (error (concat "Out of band method `%s' not applicable " | |
3476 "for remote shell asking for a password") | |
3477 method)) | |
3478 (tramp-enter-password p (match-string 0))) | |
3479 | |
3480 (defun tramp-action-succeed (p multi-method method user host) | |
3481 "Signal success in finding shell prompt." | |
3482 (tramp-message 9 "Found remote shell prompt.") | |
3483 (erase-buffer) | |
3484 (throw 'tramp-action 'ok)) | |
3485 | |
3486 (defun tramp-action-permission-denied (p multi-method method user host) | |
3487 "Signal permission denied." | |
3488 (tramp-message 9 "Permission denied by remote host.") | |
3489 (kill-process p) | |
3490 (erase-buffer) | |
3491 (throw 'tramp-action 'permission-denied)) | |
3492 | |
3493 (defun tramp-action-yesno (p multi-method method user host) | |
3494 "Ask the user if he is sure." | |
3495 (save-window-excursion | |
3496 (pop-to-buffer (tramp-get-buffer multi-method method user host)) | |
3497 (unless (yes-or-no-p (match-string 0)) | |
3498 (kill-process p) | |
3499 (erase-buffer) | |
3500 (throw 'tramp-action 'permission-denied)) | |
3501 (process-send-string p (concat "yes" tramp-rsh-end-of-line)) | |
3502 (erase-buffer))) | |
3503 | |
3504 ;; The following functions are specifically for multi connections. | |
3505 | |
3506 (defun tramp-multi-action-login (p method user host) | |
3507 "Send the login name." | |
3508 (tramp-message 9 "Sending login name `%s'" user) | |
3509 (erase-buffer) | |
3510 (process-send-string p (concat user tramp-rsh-end-of-line))) | |
3511 | |
3512 (defun tramp-multi-action-password (p method user host) | |
3513 "Query the user for a password." | |
3514 (tramp-enter-password p (match-string 0))) | |
3515 | |
3516 (defun tramp-multi-action-succeed (p method user host) | |
3517 "Signal success in finding shell prompt." | |
3518 (tramp-message 9 "Found shell prompt on `%s'" host) | |
3519 (erase-buffer) | |
3520 (throw 'tramp-action 'ok)) | |
3521 | |
3522 (defun tramp-multi-action-permission-denied (p method user host) | |
3523 "Signal permission denied." | |
3524 (tramp-message 9 "Permission denied by remote host `%s'" host) | |
3525 (kill-process p) | |
3526 (erase-buffer) | |
3527 (throw 'tramp-action 'permission-denied)) | |
3528 | |
3529 ;; Functions for processing the actions. | |
3530 | |
3531 (defun tramp-process-one-action (p multi-method method user host actions) | |
3532 "Wait for output from the shell and perform one action." | |
3533 (let (found item pattern action todo) | |
3534 (erase-buffer) | |
3535 (tramp-message 9 "Waiting 60s for prompt from remote shell") | |
3536 (with-timeout (60 (throw 'tramp-action 'timeout)) | |
3537 (while (not found) | |
3538 (accept-process-output p 1) | |
3539 (goto-char (point-min)) | |
3540 (setq todo actions) | |
3541 (while todo | |
3542 (goto-char (point-min)) | |
3543 (setq item (pop todo)) | |
3544 (setq pattern (symbol-value (nth 0 item))) | |
3545 (setq action (nth 1 item)) | |
3546 (tramp-message 10 "Looking for pattern %s" pattern) | |
3547 (when (re-search-forward (concat pattern "\\'") nil t) | |
3548 (setq found (funcall action p multi-method method user host))))) | |
3549 found))) | |
3550 | |
3551 (defun tramp-process-actions (p multi-method method user host actions) | |
3552 "Perform actions until success." | |
3553 (let (exit) | |
3554 (while (not exit) | |
3555 (tramp-message 10 "Processing actions") | |
3556 (setq exit | |
3557 (catch 'tramp-action | |
3558 (tramp-process-one-action | |
3559 p multi-method method user host actions) | |
3560 nil))) | |
3561 (unless (eq exit 'ok) | |
3562 (error "Login failed")))) | |
3563 | |
3564 ;; For multi-actions. | |
3565 | |
3566 (defun tramp-process-one-multi-action (p method user host actions) | |
3567 "Wait for output from the shell and perform one action." | |
3568 (let (found item pattern action todo) | |
3569 (erase-buffer) | |
3570 (tramp-message 9 "Waiting 60s for prompt from remote shell") | |
3571 (with-timeout (60 (throw 'tramp-action 'timeout)) | |
3572 (while (not found) | |
3573 (accept-process-output p 1) | |
3574 (setq todo actions) | |
3575 (goto-char (point-min)) | |
3576 (while todo | |
3577 (goto-char (point-min)) | |
3578 (setq item (pop todo)) | |
3579 (setq pattern (symbol-value (nth 0 item))) | |
3580 (setq action (nth 1 item)) | |
3581 (tramp-message 10 "Looking for pattern %s" pattern) | |
3582 (when (re-search-forward (concat pattern "\\'") nil t) | |
3583 (setq found (funcall action p method user host))))) | |
3584 found))) | |
3585 | |
3586 (defun tramp-process-multi-actions (p method user host actions) | |
3587 "Perform actions until success." | |
3588 (let (exit) | |
3589 (while (not exit) | |
3590 (setq exit | |
3591 (catch 'tramp-action | |
3592 (tramp-process-one-multi-action p method user host actions) | |
3593 nil))) | |
3594 (unless (eq exit 'ok) | |
3595 (error "Login failed")))) | |
3596 | |
3597 ;; The actual functions for opening connections. | |
45861 | 3598 |
3599 (defun tramp-open-connection-telnet (multi-method method user host) | |
3600 "Open a connection using a telnet METHOD. | |
3601 This starts the command `telnet HOST ARGS'[*], then waits for a remote | |
3602 login prompt, then sends the user name USER, then waits for a remote | |
3603 password prompt. It queries the user for the password, then sends the | |
3604 password to the remote host. | |
3605 | |
3606 If USER is nil, uses value returned by `(user-login-name)' instead. | |
3607 | |
3608 Recognition of the remote shell prompt is based on the variable | |
3609 `shell-prompt-pattern' which must be set up correctly. | |
3610 | |
3611 Please note that it is NOT possible to use this connection method | |
3612 together with an out-of-band transfer method! You must use an inline | |
3613 transfer method. | |
3614 | |
3615 Maybe the different regular expressions need to be tuned. | |
3616 | |
3617 * Actually, the telnet program as well as the args to be used can be | |
3618 specified in the method parameters, see the variable `tramp-methods'." | |
3619 (save-match-data | |
3620 (when (tramp-method-out-of-band-p multi-method method) | |
3621 (error "Cannot use out-of-band method `%s' with telnet connection method" | |
3622 method)) | |
3623 (when multi-method | |
3624 (error "Cannot multi-connect using telnet connection method")) | |
3625 (tramp-pre-connection multi-method method user host) | |
3626 (tramp-message 7 "Opening connection for %s@%s using %s..." | |
3627 (or user (user-login-name)) host method) | |
3628 (let ((process-environment (copy-sequence process-environment))) | |
3629 (setenv "TERM" tramp-terminal-type) | |
3630 (let* ((default-directory (tramp-temporary-file-directory)) | |
3631 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
3632 (> emacs-major-version 20)) | |
3633 tramp-dos-coding-system)) | |
3634 (p (apply 'start-process | |
3635 (tramp-buffer-name multi-method method user host) | |
3636 (tramp-get-buffer multi-method method user host) | |
3637 (tramp-get-telnet-program multi-method method) | |
3638 host | |
3639 (tramp-get-telnet-args multi-method method))) | |
3640 (found nil) | |
3641 (pw nil)) | |
3642 (process-kill-without-query p) | |
46752 | 3643 (set-buffer (tramp-get-buffer multi-method method user host)) |
3644 (erase-buffer) | |
3645 (tramp-process-actions p multi-method method user host | |
3646 tramp-actions-before-shell) | |
3647 | |
3648 ;; (tramp-message 9 "Waiting for login prompt...") | |
3649 ;; (unless (tramp-wait-for-regexp p nil tramp-login-prompt-regexp) | |
3650 ;; (pop-to-buffer (buffer-name)) | |
3651 ;; (kill-process p) | |
3652 ;; (error "Couldn't find remote login prompt")) | |
3653 ;; (erase-buffer) | |
3654 ;; ;; Remote login defaults to local one. | |
3655 ;; (tramp-message 9 "Sending login name %s" (or user (user-login-name))) | |
3656 ;; (process-send-string p (concat (or user (user-login-name)) | |
3657 ;; tramp-rsh-end-of-line)) | |
3658 ;; (tramp-message 9 "Waiting for password prompt...") | |
3659 ;; (unless (setq found (tramp-wait-for-regexp | |
3660 ;; p nil tramp-password-prompt-regexp)) | |
3661 ;; (pop-to-buffer (buffer-name)) | |
3662 ;; (kill-process p) | |
3663 ;; (error "Couldn't find remote password prompt")) | |
3664 ;; (erase-buffer) | |
3665 ;; (setq pw (tramp-read-passwd (car found))) | |
3666 ;; (tramp-message 9 "Sending password") | |
3667 ;; (process-send-string p (concat pw tramp-rsh-end-of-line)) | |
3668 ;; (tramp-message 9 "Waiting 30s for remote shell to come up...") | |
3669 ;; (unless (setq found | |
3670 ;; (tramp-wait-for-regexp | |
3671 ;; p 30 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3672 ;; tramp-wrong-passwd-regexp | |
3673 ;; shell-prompt-pattern))) | |
3674 ;; (pop-to-buffer (buffer-name)) | |
3675 ;; (kill-process p) | |
3676 ;; (error "Couldn't find remote shell prompt")) | |
3677 ;; (when (nth 1 found) | |
3678 ;; (pop-to-buffer (buffer-name)) | |
3679 ;; (kill-process p) | |
3680 ;; (error "Login failed: %s" (nth 1 found))) | |
3681 | |
45861 | 3682 (tramp-open-connection-setup-interactive-shell |
3683 p multi-method method user host) | |
3684 (tramp-post-connection multi-method method user host))))) | |
3685 | |
46752 | 3686 |
45861 | 3687 (defun tramp-open-connection-rsh (multi-method method user host) |
3688 "Open a connection using an rsh METHOD. | |
3689 This starts the command `rsh HOST -l USER'[*], then waits for a remote | |
3690 password or shell prompt. If a password prompt is seen, the user is | |
3691 queried for a password, this function sends the password to the remote | |
3692 host and waits for a shell prompt. | |
3693 | |
3694 If USER is nil, start the command `rsh HOST'[*] instead | |
3695 | |
3696 Recognition of the remote shell prompt is based on the variable | |
3697 `shell-prompt-pattern' which must be set up correctly. | |
3698 | |
3699 Please note that it is NOT possible to use this connection method with | |
3700 an out-of-band transfer method if this function asks the user for a | |
3701 password! You must use an inline transfer method in this case. | |
3702 Sadly, the transfer method cannot be switched on the fly, instead you | |
3703 must specify the right method in the file name. | |
3704 | |
46010
d07b0e5f80b9
(tramp-open-connection-rsh): Support a kludgy feature for the
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46009
diff
changeset
|
3705 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
|
3706 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
|
3707 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
|
3708 |
45861 | 3709 * Actually, the rsh program to be used can be specified in the |
3710 method parameters, see the variable `tramp-methods'." | |
3711 (save-match-data | |
3712 (when multi-method | |
3713 (error "Cannot multi-connect using rsh connection method")) | |
3714 (tramp-pre-connection multi-method method user host) | |
3715 (if user | |
3716 (tramp-message 7 "Opening connection for %s@%s using %s..." | |
3717 user host method) | |
3718 (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
|
3719 (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
|
3720 (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
|
3721 (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
|
3722 (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
|
3723 (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
|
3724 ;; 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
|
3725 ;; 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
|
3726 (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
|
3727 (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
|
3728 (setq host (match-string 1 host))) |
45861 | 3729 (setenv "TERM" tramp-terminal-type) |
3730 (let* ((default-directory (tramp-temporary-file-directory)) | |
3731 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
3732 (> emacs-major-version 20)) | |
3733 tramp-dos-coding-system)) | |
3734 (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
|
3735 (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
|
3736 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
|
3737 (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
|
3738 host rsh-args))) |
45861 | 3739 (found nil)) |
3740 (process-kill-without-query p) | |
46752 | 3741 |
3742 (set-buffer buf) | |
3743 (tramp-process-actions p multi-method method user host | |
3744 tramp-actions-before-shell) | |
3745 | |
3746 ;; (tramp-message 9 "Waiting 60s for shell or passwd prompt from %s" host) | |
3747 ;; (setq found | |
3748 ;; (tramp-wait-for-regexp | |
3749 ;; p 60 | |
3750 ;; (format | |
3751 ;; "\\(%s\\)\\|\\(%s\\)\\'" | |
3752 ;; tramp-password-prompt-regexp | |
3753 ;; shell-prompt-pattern))) | |
3754 ;; (unless found | |
3755 ;; (pop-to-buffer (buffer-name)) | |
3756 ;; (kill-process p) | |
3757 ;; (error "Couldn't find remote shell or passwd prompt")) | |
3758 ;; (when (nth 1 found) | |
3759 ;; (when (tramp-method-out-of-band-p multi-method method) | |
3760 ;; (pop-to-buffer (buffer-name)) | |
3761 ;; (kill-process p) | |
3762 ;; (error (concat "Out of band method `%s' not applicable" | |
3763 ;; " for remote shell asking for a password") | |
3764 ;; method)) | |
3765 ;; (erase-buffer) | |
3766 ;; (tramp-message 9 "Sending password...") | |
3767 ;; (tramp-enter-password p (nth 1 found)) | |
3768 ;; (tramp-message 9 "Sent password, waiting 60s for remote shell prompt") | |
3769 ;; (setq found (tramp-wait-for-regexp p 60 | |
3770 ;; (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3771 ;; tramp-wrong-passwd-regexp | |
3772 ;; shell-prompt-pattern)))) | |
3773 ;; (unless found | |
3774 ;; (pop-to-buffer (buffer-name)) | |
3775 ;; (kill-process p) | |
3776 ;; (error "Couldn't find remote shell prompt")) | |
3777 ;; (when (nth 1 found) | |
3778 ;; (pop-to-buffer (buffer-name)) | |
3779 ;; (kill-process p) | |
3780 ;; (error "Login failed: %s" (nth 1 found))) | |
3781 | |
45861 | 3782 (tramp-message 7 "Initializing remote shell") |
3783 (tramp-open-connection-setup-interactive-shell | |
3784 p multi-method method user host) | |
3785 (tramp-post-connection multi-method method user host))))) | |
3786 | |
3787 (defun tramp-open-connection-su (multi-method method user host) | |
3788 "Open a connection using the `su' program with METHOD. | |
3789 This starts `su - USER', then waits for a password prompt. The HOST | |
3790 name must be equal to the local host name or to `localhost'. | |
3791 | |
3792 If USER is nil, uses value returned by user-login-name instead. | |
3793 | |
3794 Recognition of the remote shell prompt is based on the variable | |
3795 `shell-prompt-pattern' which must be set up correctly. Note that the | |
3796 other user may have a different shell prompt than you do, so it is not | |
3797 at all unlikely that this variable is set up wrongly!" | |
3798 (save-match-data | |
3799 (when (tramp-method-out-of-band-p multi-method method) | |
3800 (error "Cannot use out-of-band method `%s' with `su' connection method" | |
3801 method)) | |
3802 (unless (or (string-match (concat "^" (regexp-quote host)) | |
3803 (system-name)) | |
3804 (string= "localhost" host)) | |
3805 (error | |
3806 "Cannot connect to different host `%s' with `su' connection method" | |
3807 host)) | |
3808 (when (not user) | |
3809 (error "Must give user name for `su' connection method")) | |
3810 (tramp-pre-connection multi-method method user host) | |
3811 (tramp-message 7 "Opening connection for `%s' using `%s'..." | |
3812 (or user (user-login-name)) method) | |
3813 (let ((process-environment (copy-sequence process-environment))) | |
3814 (setenv "TERM" tramp-terminal-type) | |
3815 (let* ((default-directory (tramp-temporary-file-directory)) | |
3816 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
3817 (> emacs-major-version 20)) | |
3818 tramp-dos-coding-system)) | |
3819 (p (apply 'start-process | |
46752 | 3820 (tramp-buffer-name multi-method method user host) |
3821 (tramp-get-buffer multi-method method user host) | |
45861 | 3822 (tramp-get-su-program multi-method method) |
3823 (mapcar | |
3824 '(lambda (x) | |
46752 | 3825 (format-spec x `((?u . ,user)))) |
45861 | 3826 (tramp-get-su-args multi-method method)))) |
3827 (found nil) | |
3828 (pw nil)) | |
3829 (process-kill-without-query p) | |
46752 | 3830 (set-buffer (tramp-get-buffer multi-method method user host)) |
3831 (tramp-process-actions p multi-method method user host | |
3832 tramp-actions-before-shell) | |
3833 | |
3834 ;; (tramp-message 9 "Waiting 30s for shell or password prompt...") | |
3835 ;; (unless (setq found (tramp-wait-for-regexp | |
3836 ;; p 30 | |
3837 ;; (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3838 ;; tramp-password-prompt-regexp | |
3839 ;; shell-prompt-pattern))) | |
3840 ;; (pop-to-buffer (buffer-name)) | |
3841 ;; (kill-process p) | |
3842 ;; (error "Couldn't find shell or password prompt")) | |
3843 ;; (when (nth 1 found) | |
3844 ;; (erase-buffer) | |
3845 ;; (setq pw (tramp-read-passwd (car found))) | |
3846 ;; (tramp-message 9 "Sending password") | |
3847 ;; (process-send-string p (concat pw tramp-rsh-end-of-line)) | |
3848 ;; (tramp-message 9 "Waiting 30s for remote shell to come up...") | |
3849 ;; (unless (setq found | |
3850 ;; (tramp-wait-for-regexp | |
3851 ;; p 30 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3852 ;; tramp-wrong-passwd-regexp | |
3853 ;; shell-prompt-pattern))) | |
3854 ;; (pop-to-buffer (buffer-name)) | |
3855 ;; (kill-process p) | |
3856 ;; (error "Couldn't find remote shell prompt")) | |
3857 ;; (when (nth 1 found) | |
3858 ;; (pop-to-buffer (buffer-name)) | |
3859 ;; (kill-process p) | |
3860 ;; (error "`su' failed: %s" (nth 1 found)))) | |
3861 | |
45861 | 3862 (tramp-open-connection-setup-interactive-shell |
3863 p multi-method method user host) | |
3864 (tramp-post-connection multi-method method | |
3865 user host))))) | |
3866 | |
3867 ;; HHH: Not Changed. Multi method. It is not clear to me how this can | |
3868 ;; handle not giving a user name in the "file name". | |
3869 ;; | |
3870 ;; This is more difficult than for the single-hop method. In the | |
3871 ;; multi-hop-method, the desired behaviour should be that the | |
3872 ;; user must specify names for the telnet hops of which the user | |
3873 ;; name is different than the "original" name (or different from | |
3874 ;; the previous hop. | |
3875 (defun tramp-open-connection-multi (multi-method method user host) | |
3876 "Open a multi-hop connection using METHOD. | |
3877 This uses a slightly changed file name syntax. The idea is to say | |
3878 [multi/telnet:u1@h1/rsh:u2@h2]/path/to/file | |
3879 This will use telnet to log in as u1 to h1, then use rsh from there to | |
3880 log in as u2 to h2." | |
3881 (save-match-data | |
3882 (unless multi-method | |
3883 (error "Multi-hop open connection function called on non-multi method")) | |
3884 (when (tramp-method-out-of-band-p multi-method method) | |
3885 (error "No out of band multi-hop connections")) | |
3886 (unless (and (arrayp method) (not (stringp method))) | |
3887 (error "METHOD must be an array of strings for multi methods")) | |
3888 (unless (and (arrayp user) (not (stringp user))) | |
3889 (error "USER must be an array of strings for multi methods")) | |
3890 (unless (and (arrayp host) (not (stringp host))) | |
3891 (error "HOST must be an array of strings for multi methods")) | |
3892 (unless (and (= (length method) (length user)) | |
3893 (= (length method) (length host))) | |
3894 (error "Arrays METHOD, USER, HOST must have equal length")) | |
3895 (tramp-pre-connection multi-method method user host) | |
3896 (tramp-message 7 "Opening `%s' connection..." multi-method) | |
3897 (let ((process-environment (copy-sequence process-environment))) | |
3898 (setenv "TERM" tramp-terminal-type) | |
3899 (let* ((default-directory (tramp-temporary-file-directory)) | |
3900 (coding-system-for-read (unless (and (not (featurep 'xemacs)) | |
3901 (> emacs-major-version 20)) | |
3902 tramp-dos-coding-system)) | |
3903 (p (start-process (tramp-buffer-name multi-method method user host) | |
3904 (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
|
3905 tramp-multi-sh-program)) |
45861 | 3906 (num-hops (length method)) |
3907 (i 0)) | |
3908 (process-kill-without-query p) | |
3909 (tramp-message 9 "Waiting 60s for local shell to come up...") | |
3910 (unless (tramp-wait-for-regexp | |
3911 p 60 (format "%s\\'" shell-prompt-pattern)) | |
3912 (pop-to-buffer (buffer-name)) | |
3913 (kill-process p) | |
3914 (error "Couldn't find local shell prompt")) | |
3915 ;; Now do all the connections as specified. | |
3916 (while (< i num-hops) | |
3917 (let* ((m (aref method i)) | |
3918 (u (aref user i)) | |
3919 (h (aref host i)) | |
3920 (entry (assoc m tramp-multi-connection-function-alist)) | |
3921 (multi-func (nth 1 entry)) | |
3922 (command (nth 2 entry))) | |
3923 ;; The multi-funcs don't need to do save-match-data, as that | |
3924 ;; is done here. | |
3925 (funcall multi-func p m u h command) | |
3926 (erase-buffer) | |
3927 (incf i))) | |
3928 (tramp-open-connection-setup-interactive-shell | |
3929 p multi-method method user host) | |
3930 (tramp-post-connection multi-method method user host))))) | |
3931 | |
3932 ;; HHH: Changed. Multi method. Don't know how to handle this in the case | |
3933 ;; of no user name provided. Hack to make it work as it did before: | |
3934 ;; changed `user' to `(or user (user-login-name))' in the places where | |
3935 ;; the value is actually used. | |
3936 (defun tramp-multi-connect-telnet (p method user host command) | |
3937 "Issue `telnet' command. | |
3938 Uses shell COMMAND to issue a `telnet' command to log in as USER to | |
3939 HOST. You can use percent escapes in COMMAND: `%h' is replaced with | |
3940 the host name, and `%n' is replaced with an end of line character, as | |
3941 set in `tramp-rsh-end-of-line'. Use `%%' if you want a literal percent | |
3942 character. | |
3943 | |
3944 If USER is nil, uses the return value of (user-login-name) instead." | |
46752 | 3945 (let ((cmd (format-spec command |
3946 `((?h . ,host) (?n . ,tramp-rsh-end-of-line)))) | |
3947 (cmd1 (format-spec command `((?h . ,host) (?n . "")))) | |
45861 | 3948 found pw) |
3949 (erase-buffer) | |
3950 (tramp-message 9 "Sending telnet command `%s'" cmd1) | |
3951 (process-send-string p cmd) | |
46752 | 3952 (tramp-process-multi-actions p method user host |
3953 tramp-multi-actions) | |
3954 | |
3955 ;; (tramp-message 9 "Waiting 30s for login prompt from %s" host) | |
3956 ;; (unless (tramp-wait-for-regexp p 30 tramp-login-prompt-regexp) | |
3957 ;; (pop-to-buffer (buffer-name)) | |
3958 ;; (kill-process p) | |
3959 ;; (error "Couldn't find login prompt from host %s" host)) | |
3960 ;; (erase-buffer) | |
3961 ;; (tramp-message 9 "Sending login name %s" (or user (user-login-name))) | |
3962 ;; (process-send-string p (concat (or user (user-login-name)) tramp-rsh-end-of-line)) | |
3963 ;; (tramp-message 9 "Waiting for password prompt") | |
3964 ;; (unless (setq found (tramp-wait-for-regexp p nil tramp-password-prompt-regexp)) | |
3965 ;; (pop-to-buffer (buffer-name)) | |
3966 ;; (kill-process p) | |
3967 ;; (error "Couldn't find password prompt from host %s" host)) | |
3968 ;; (erase-buffer) | |
3969 ;; (setq pw (tramp-read-passwd | |
3970 ;; (format "Password for %s@%s, %s" (or user (user-login-name)) host found))) | |
3971 ;; (tramp-message 9 "Sending password") | |
3972 ;; (process-send-string p (concat pw tramp-rsh-end-of-line)) | |
3973 ;; (tramp-message 9 "Waiting 60s for remote shell to come up...") | |
3974 ;; (unless (setq found (tramp-wait-for-regexp | |
3975 ;; p 60 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
3976 ;; tramp-wrong-passwd-regexp | |
3977 ;; shell-prompt-pattern))) | |
3978 ;; (pop-to-buffer (buffer-name)) | |
3979 ;; (kill-process p) | |
3980 ;; (error "Couldn't find shell prompt from host %s" host)) | |
3981 ;; (when (nth 1 found) | |
3982 ;; (pop-to-buffer (buffer-name)) | |
3983 ;; (kill-process p) | |
3984 ;; (error "Login to %s failed: %s" (nth 2 found))) | |
3985 )) | |
45861 | 3986 |
3987 ;; HHH: Changed. Multi method. Don't know how to handle this in the case | |
3988 ;; of no user name provided. Hack to make it work as it did before: | |
3989 ;; changed `user' to `(or user (user-login-name))' in the places where | |
3990 ;; the value is actually used. | |
3991 (defun tramp-multi-connect-rlogin (p method user host command) | |
3992 "Issue `rlogin' command. | |
3993 Uses shell COMMAND to issue an `rlogin' command to log in as USER to | |
3994 HOST. You can use percent escapes in COMMAND. `%u' will be replaced | |
3995 with the user name, `%h' will be replaced with the host name, and `%n' | |
3996 will be replaced with the value of `tramp-rsh-end-of-line'. You can use | |
3997 `%%' if you want to use a literal percent character. | |
3998 | |
3999 If USER is nil, uses the return value of (user-login-name) instead." | |
46752 | 4000 (let ((cmd (format-spec command `((?h . ,host) |
4001 (?u . ,(or user (user-login-name))) | |
4002 (?n . ,tramp-rsh-end-of-line)))) | |
4003 (cmd1 (format-spec command `((?h . ,host) | |
4004 (?u . ,(or user (user-login-name))) | |
4005 (?n . "")))) | |
45861 | 4006 found) |
4007 (erase-buffer) | |
4008 (tramp-message 9 "Sending rlogin command `%s'" cmd1) | |
4009 (process-send-string p cmd) | |
46752 | 4010 (tramp-process-multi-actions p method user host |
4011 tramp-multi-actions) | |
4012 ;; (tramp-message 9 "Waiting 60s for shell or passwd prompt from %s" host) | |
4013 ;; (unless (setq found | |
4014 ;; (tramp-wait-for-regexp p 60 | |
4015 ;; (format "\\(%s\\)\\|\\(%s\\)\\'" | |
4016 ;; tramp-password-prompt-regexp | |
4017 ;; shell-prompt-pattern))) | |
4018 ;; (pop-to-buffer (buffer-name)) | |
4019 ;; (kill-process p) | |
4020 ;; (error "Couldn't find remote shell or passwd prompt")) | |
4021 ;; (when (nth 1 found) | |
4022 ;; (erase-buffer) | |
4023 ;; (tramp-message 9 "Sending password...") | |
4024 ;; (tramp-enter-password p (nth 1 found)) | |
4025 ;; (tramp-message 9 "Sent password, waiting 60s for remote shell prompt") | |
4026 ;; (setq found (tramp-wait-for-regexp p 60 | |
4027 ;; (format "\\(%s\\)\\|\\(%s\\)\\'" | |
4028 ;; tramp-wrong-passwd-regexp | |
4029 ;; shell-prompt-pattern)))) | |
4030 ;; (unless found | |
4031 ;; (pop-to-buffer (buffer-name)) | |
4032 ;; (kill-process p) | |
4033 ;; (error "Couldn't find remote shell prompt")) | |
4034 ;; (when (nth 1 found) | |
4035 ;; (pop-to-buffer (buffer-name)) | |
4036 ;; (kill-process p) | |
4037 ;; (error "Login failed: %s" (nth 1 found))) | |
4038 )) | |
45861 | 4039 |
4040 ;; HHH: Changed. Multi method. Don't know how to handle this in the case | |
4041 ;; of no user name provided. Hack to make it work as it did before: | |
4042 ;; changed `user' to `(or user (user-login-name))' in the places where | |
4043 ;; the value is actually used. | |
4044 (defun tramp-multi-connect-su (p method user host command) | |
4045 "Issue `su' command. | |
4046 Uses shell COMMAND to issue a `su' command to log in as USER on | |
4047 HOST. The HOST name is ignored, this just changes the user id on the | |
4048 host currently logged in to. | |
4049 | |
4050 If USER is nil, uses the return value of (user-login-name) instead. | |
4051 | |
4052 You can use percent escapes in the COMMAND. `%u' is replaced with the | |
4053 user name, and `%n' is replaced with the value of | |
4054 `tramp-rsh-end-of-line'. Use `%%' if you want a literal percent | |
4055 character." | |
46752 | 4056 (let ((cmd (format-spec command `((?u . ,(or user (user-login-name))) |
4057 (?n . ,tramp-rsh-end-of-line)))) | |
4058 (cmd1 (format-spec command `((?u . ,(or user (user-login-name))) | |
4059 (?n . "")))) | |
45861 | 4060 found) |
4061 (erase-buffer) | |
4062 (tramp-message 9 "Sending su command `%s'" cmd1) | |
4063 (process-send-string p cmd) | |
46752 | 4064 (tramp-process-multi-actions p method user host |
4065 tramp-multi-actions) | |
4066 ;; (tramp-message 9 "Waiting 60s for shell or passwd prompt for %s" (or user (user-login-name))) | |
4067 ;; (unless (setq found (tramp-wait-for-regexp | |
4068 ;; p 60 (format "\\(%s\\)\\|\\(%s\\)\\'" | |
4069 ;; tramp-password-prompt-regexp | |
4070 ;; shell-prompt-pattern))) | |
4071 ;; (pop-to-buffer (buffer-name)) | |
4072 ;; (kill-process p) | |
4073 ;; (error "Couldn't find shell or passwd prompt for %s" | |
4074 ;; (or user (user-login-name)))) | |
4075 ;; (when (nth 1 found) | |
4076 ;; (tramp-message 9 "Sending password...") | |
4077 ;; (tramp-enter-password p (nth 1 found)) | |
4078 ;; (erase-buffer) | |
4079 ;; (tramp-message 9 "Sent password, waiting 60s for remote shell prompt") | |
4080 ;; (setq found (tramp-wait-for-regexp p 60 | |
4081 ;; (format "\\(%s\\)\\|\\(%s\\)\\'" | |
4082 ;; tramp-wrong-passwd-regexp | |
4083 ;; shell-prompt-pattern)))) | |
4084 ;; (unless found | |
4085 ;; (pop-to-buffer (buffer-name)) | |
4086 ;; (kill-process p) | |
4087 ;; (error "Couldn't find remote shell prompt")) | |
4088 ;; (when (nth 1 found) | |
4089 ;; (pop-to-buffer (buffer-name)) | |
4090 ;; (kill-process p) | |
4091 ;; (error "Login failed: %s" (nth 1 found))) | |
4092 )) | |
45861 | 4093 |
4094 ;; Utility functions. | |
4095 | |
4096 (defun tramp-wait-for-regexp (proc timeout regexp) | |
4097 "Wait for a REGEXP to appear from process PROC within TIMEOUT seconds. | |
4098 Expects the output of PROC to be sent to the current buffer. Returns | |
4099 the string that matched, or nil. Waits indefinitely if TIMEOUT is | |
4100 nil." | |
4101 (let ((found nil) | |
4102 (start-time (current-time))) | |
4103 (cond (timeout | |
4104 ;; Work around a bug in XEmacs 21, where the timeout | |
4105 ;; expires faster than it should. This degenerates | |
4106 ;; to polling for buggy XEmacsen, but oh, well. | |
4107 (while (and (not found) | |
4108 (< (tramp-time-diff (current-time) start-time) | |
4109 timeout)) | |
4110 (with-timeout (timeout) | |
4111 (while (not found) | |
4112 (accept-process-output proc 1) | |
4113 (goto-char (point-min)) | |
4114 (setq found (when (re-search-forward regexp nil t) | |
4115 (tramp-match-string-list))))))) | |
4116 (t | |
4117 (while (not found) | |
4118 (accept-process-output proc 1) | |
4119 (goto-char (point-min)) | |
4120 (setq found (when (re-search-forward regexp nil t) | |
4121 (tramp-match-string-list)))))) | |
4122 (when tramp-debug-buffer | |
4123 (append-to-buffer | |
4124 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4125 tramp-current-user tramp-current-host) | |
4126 (point-min) (point-max)) | |
4127 (when (not found) | |
4128 (save-excursion | |
4129 (set-buffer | |
4130 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4131 tramp-current-user tramp-current-host)) | |
4132 (goto-char (point-max)) | |
4133 (insert "[[Regexp `" regexp "' not found" | |
46048
05db6f1e91ca
(tramp-file-name-structure)
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46010
diff
changeset
|
4134 (if timeout (format " in %d secs" timeout) "") |
45861 | 4135 "]]")))) |
4136 found)) | |
4137 | |
4138 (defun tramp-enter-password (p prompt) | |
4139 "Prompt for a password and send it to the remote end. | |
4140 Uses PROMPT as a prompt and sends the password to process P." | |
4141 (let ((pw (tramp-read-passwd prompt))) | |
46752 | 4142 (erase-buffer) |
45861 | 4143 (process-send-string p (concat pw tramp-rsh-end-of-line)))) |
4144 | |
4145 ;; HHH: Not Changed. This might handle the case where USER is not | |
4146 ;; given in the "File name" very poorly. Then, the local | |
4147 ;; variable tramp-current user will be set to nil. | |
4148 (defun tramp-pre-connection (multi-method method user host) | |
4149 "Do some setup before actually logging in. | |
4150 METHOD, USER and HOST specify the connection." | |
4151 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4152 (set (make-local-variable 'tramp-current-multi-method) multi-method) | |
4153 (set (make-local-variable 'tramp-current-method) method) | |
4154 (set (make-local-variable 'tramp-current-user) user) | |
4155 (set (make-local-variable 'tramp-current-host) host) | |
4156 (set (make-local-variable 'inhibit-eol-conversion) nil) | |
4157 (erase-buffer)) | |
4158 | |
4159 (defun tramp-open-connection-setup-interactive-shell | |
4160 (p multi-method method user host) | |
4161 "Set up an interactive shell. | |
4162 Mainly sets the prompt and the echo correctly. P is the shell process | |
4163 to set up. METHOD, USER and HOST specify the connection." | |
4164 ;; Wait a bit in case the remote end feels like sending a little | |
4165 ;; junk first. It seems that fencepost.gnu.org does this when doing | |
4166 ;; a Kerberos login. | |
4167 (sit-for 1) | |
4168 (tramp-discard-garbage-erase-buffer p multi-method method user host) | |
4169 (process-send-string nil (format "exec %s%s" | |
4170 (tramp-get-remote-sh multi-method method) | |
4171 tramp-rsh-end-of-line)) | |
4172 (when tramp-debug-buffer | |
4173 (save-excursion | |
4174 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
4175 (goto-char (point-max)) | |
4176 (tramp-insert-with-face | |
4177 'bold (format "$ exec %s\n" (tramp-get-remote-sh multi-method method))))) | |
4178 (tramp-message 9 "Waiting 30s for remote `%s' to come up..." | |
4179 (tramp-get-remote-sh multi-method method)) | |
4180 (unless (tramp-wait-for-regexp | |
4181 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4182 (pop-to-buffer (buffer-name)) | |
4183 (error "Remote `%s' didn't come up. See buffer `%s' for details" | |
4184 (tramp-get-remote-sh multi-method method) (buffer-name))) | |
4185 (tramp-message 9 "Setting up remote shell environment") | |
4186 (tramp-discard-garbage-erase-buffer p multi-method method user host) | |
4187 (process-send-string | |
4188 nil (format "stty -inlcr -echo kill '^U'%s" tramp-rsh-end-of-line)) | |
4189 (unless (tramp-wait-for-regexp | |
4190 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4191 (pop-to-buffer (buffer-name)) | |
4192 (error "Couldn't `stty -echo', see buffer `%s'" (buffer-name))) | |
4193 (erase-buffer) | |
4194 (process-send-string nil (format "TERM=dumb; export TERM%s" | |
4195 tramp-rsh-end-of-line)) | |
4196 (unless (tramp-wait-for-regexp | |
4197 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4198 (pop-to-buffer (buffer-name)) | |
4199 (error "Couldn't `TERM=dumb; export TERM', see buffer `%s'" (buffer-name))) | |
4200 ;; Try to set up the coding system correctly. | |
4201 ;; CCC this can't be the right way to do it. Hm. | |
4202 (save-excursion | |
4203 (erase-buffer) | |
4204 (tramp-message 9 "Determining coding system") | |
4205 (process-send-string nil (format "echo foo ; echo bar %s" | |
4206 tramp-rsh-end-of-line)) | |
4207 (unless (tramp-wait-for-regexp | |
4208 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4209 (pop-to-buffer (buffer-name)) | |
4210 (error "Couldn't `echo foo; echo bar' to determine line endings'")) | |
4211 (goto-char (point-min)) | |
4212 (if (featurep 'mule) | |
4213 ;; Use MULE to select the right EOL convention for communicating | |
4214 ;; with the process. | |
4215 (let* ((cs (or (process-coding-system p) (cons 'undecided 'undecided))) | |
4216 cs-decode cs-encode) | |
4217 (when (symbolp cs) (setq cs (cons cs cs))) | |
4218 (setq cs-decode (car cs)) | |
4219 (setq cs-encode (cdr cs)) | |
4220 (unless cs-decode (setq cs-decode 'undecided)) | |
4221 (unless cs-encode (setq cs-encode 'undecided)) | |
4222 (setq cs-encode (tramp-coding-system-change-eol-conversion | |
4223 cs-encode 'unix)) | |
4224 (when (search-forward "\r" nil t) | |
4225 (setq cs-decode (tramp-coding-system-change-eol-conversion | |
4226 cs-decode 'dos))) | |
4227 (set-buffer-process-coding-system cs-decode cs-encode)) | |
4228 ;; Look for ^M and do something useful if found. | |
4229 (when (search-forward "\r" nil t) | |
4230 ;; We have found a ^M but cannot frob the process coding system | |
4231 ;; because we're running on a non-MULE Emacs. Let's try | |
4232 ;; stty, instead. | |
4233 (tramp-message 9 "Trying `stty -onlcr'") | |
4234 (process-send-string nil (format "stty -onlcr%s" tramp-rsh-end-of-line)) | |
4235 (unless (tramp-wait-for-regexp | |
4236 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4237 (pop-to-buffer (buffer-name)) | |
4238 (error "Couldn't `stty -onlcr', see buffer `%s'" (buffer-name)))))) | |
4239 (erase-buffer) | |
4240 (tramp-message | |
4241 9 "Waiting 30s for `HISTFILE=$HOME/.tramp_history; HISTSIZE=1'") | |
4242 (process-send-string | |
4243 nil (format "HISTFILE=$HOME/.tramp_history; HISTSIZE=1%s" | |
4244 tramp-rsh-end-of-line)) | |
4245 (unless (tramp-wait-for-regexp | |
4246 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4247 (pop-to-buffer (buffer-name)) | |
4248 (error (concat "Couldn't `HISTFILE=$HOME/.tramp_history; " | |
4249 "HISTSIZE=1', see buffer `%s'") | |
4250 (buffer-name))) | |
4251 (erase-buffer) | |
4252 (tramp-message 9 "Waiting 30s for `set +o vi +o emacs'") | |
4253 (process-send-string | |
4254 nil (format "set +o vi +o emacs%s" ;mustn't `>/dev/null' with AIX? | |
4255 tramp-rsh-end-of-line)) | |
4256 (unless (tramp-wait-for-regexp | |
4257 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4258 (pop-to-buffer (buffer-name)) | |
4259 (error "Couldn't `set +o vi +o emacs', see buffer `%s'" | |
4260 (buffer-name))) | |
4261 (erase-buffer) | |
4262 (tramp-message 9 "Waiting 30s for `unset MAIL MAILCHECK MAILPATH'") | |
4263 (process-send-string | |
4264 nil (format "unset MAIL MAILCHECK MAILPATH 1>/dev/null 2>/dev/null%s" | |
4265 tramp-rsh-end-of-line)) | |
4266 (unless (tramp-wait-for-regexp | |
4267 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4268 (pop-to-buffer (buffer-name)) | |
4269 (error "Couldn't `unset MAIL MAILCHECK MAILPATH', see buffer `%s'" | |
4270 (buffer-name))) | |
4271 (erase-buffer) | |
4272 (tramp-message 9 "Waiting 30s for `unset CDPATH'") | |
4273 (process-send-string | |
4274 nil (format "unset CDPATH%s" tramp-rsh-end-of-line)) | |
4275 (unless (tramp-wait-for-regexp | |
4276 p 30 (format "\\(\\$ *\\|%s\\)\\'" shell-prompt-pattern)) | |
4277 (pop-to-buffer (buffer-name)) | |
4278 (error "Couldn't `unset CDPATH', see buffer `%s'" | |
4279 (buffer-name))) | |
4280 (erase-buffer) | |
4281 (tramp-message 9 "Setting shell prompt") | |
4282 (tramp-send-command | |
4283 multi-method method user host | |
4284 (format "PS1='%s%s%s'; PS2=''; PS3=''" | |
4285 tramp-rsh-end-of-line | |
4286 tramp-end-of-output | |
4287 tramp-rsh-end-of-line)) | |
4288 (tramp-wait-for-output) | |
4289 (tramp-send-command multi-method method user host "echo hello") | |
4290 (tramp-message 9 "Waiting for remote `%s' to come up..." | |
4291 (tramp-get-remote-sh multi-method method)) | |
4292 (unless (tramp-wait-for-output 5) | |
4293 (unless (tramp-wait-for-output 5) | |
4294 (pop-to-buffer (buffer-name)) | |
4295 (error "Couldn't set remote shell prompt. See buffer `%s' for details" | |
4296 (buffer-name)))) | |
4297 (tramp-message 7 "Waiting for remote `%s' to come up...done" | |
4298 (tramp-get-remote-sh multi-method method))) | |
4299 | |
4300 (defun tramp-post-connection (multi-method method user host) | |
4301 "Prepare a remote shell before being able to work on it. | |
4302 METHOD, USER and HOST specify the connection. | |
4303 Among other things, this finds a shell which groks tilde expansion, | |
4304 tries to find an `ls' command which groks the `-n' option, sets the | |
4305 locale to C and sets up the remote shell search path." | |
4306 ;; Search for a good shell before searching for a command which | |
4307 ;; checks if a file exists. This is done because Tramp wants to use | |
4308 ;; "test foo; echo $?" to check if various conditions hold, and | |
4309 ;; there are buggy /bin/sh implementations which don't execute the | |
4310 ;; "echo $?" part if the "test" part has an error. In particular, | |
4311 ;; the Solaris /bin/sh is a problem. I'm betting that all systems | |
4312 ;; with buggy /bin/sh implementations will have a working bash or | |
4313 ;; ksh. Whee... | |
4314 (tramp-find-shell multi-method method user host) | |
4315 (tramp-find-file-exists-command multi-method method user host) | |
4316 (sit-for 1) | |
4317 ;; Without (sit-for 0.1) at least, my machine will almost always blow | |
4318 ;; up on 'not numberp /root' - a race that causes the 'echo ~root' | |
4319 ;; output of (tramp-find-shell) to show up along with the output of | |
4320 ;; (tramp-find-ls-command) testing. | |
4321 ;; | |
4322 ;; I can't work out why this is a problem though. The (tramp-wait-for-output) | |
4323 ;; call in (tramp-find-shell) *should* make this not happen, I thought. | |
4324 ;; | |
4325 ;; After much debugging I couldn't find any problem with the implementation | |
4326 ;; of that function though. The workaround stays for me at least. :/ | |
4327 ;; | |
4328 ;; Daniel Pittman <daniel@danann.net> | |
4329 (make-local-variable 'tramp-ls-command) | |
4330 (setq tramp-ls-command (tramp-find-ls-command multi-method method user host)) | |
4331 (unless tramp-ls-command | |
4332 (tramp-message | |
4333 1 | |
4334 "Danger! Couldn't find ls which groks -n. Muddling through anyway") | |
4335 (setq tramp-ls-command | |
4336 (tramp-find-executable multi-method method user host | |
4337 "ls" tramp-remote-path nil))) | |
4338 (unless tramp-ls-command | |
4339 (error "Fatal error: Couldn't find remote executable `ls'")) | |
4340 (tramp-message 5 "Using remote command `%s' for getting directory listings" | |
4341 tramp-ls-command) | |
4342 (tramp-send-command multi-method method user host | |
4343 (concat "tramp_set_exit_status () {" tramp-rsh-end-of-line | |
4344 "return $1" tramp-rsh-end-of-line | |
4345 "}")) | |
4346 (tramp-wait-for-output) | |
4347 ;; Set remote PATH variable. | |
4348 (tramp-set-remote-path multi-method method user host "PATH" tramp-remote-path) | |
4349 ;; Tell remote shell to use standard time format, needed for | |
4350 ;; parsing `ls -l' output. | |
4351 (tramp-send-command multi-method method user host | |
4352 "LC_TIME=C; export LC_TIME; echo huhu") | |
4353 (tramp-wait-for-output) | |
4354 (tramp-send-command multi-method method user host | |
4355 "mesg n; echo huhu") | |
4356 (tramp-wait-for-output) | |
4357 (tramp-send-command multi-method method user host | |
4358 "biff n ; echo huhu") | |
4359 (tramp-wait-for-output) | |
4360 ;; Unalias ls(1) to work around issues with those silly people who make it | |
4361 ;; spit out ANSI escapes or whatever. | |
4362 (tramp-send-command multi-method method user host | |
4363 "unalias ls; echo huhu") | |
4364 (tramp-wait-for-output) | |
4365 ;; Does `test A -nt B' work? Use abominable `find' construct if it | |
4366 ;; doesn't. BSD/OS 4.0 wants the parentheses around the command, | |
4367 ;; for otherwise the shell crashes. | |
4368 (erase-buffer) | |
4369 (make-local-variable 'tramp-test-groks-nt) | |
4370 (tramp-send-command multi-method method user host | |
4371 "( test / -nt / )") | |
4372 (tramp-wait-for-output) | |
4373 (goto-char (point-min)) | |
4374 (setq tramp-test-groks-nt | |
4375 (looking-at (format "\n%s\n" (regexp-quote tramp-end-of-output)))) | |
4376 (unless tramp-test-groks-nt | |
4377 (tramp-send-command | |
4378 multi-method method user host | |
4379 (concat "tramp_test_nt () {" tramp-rsh-end-of-line | |
4380 "test -n \"`find $1 -prune -newer $2 -print`\"" tramp-rsh-end-of-line | |
4381 "}"))) | |
4382 (tramp-wait-for-output) | |
4383 ;; Find a `perl'. | |
4384 (erase-buffer) | |
4385 (let ((tramp-remote-perl | |
4386 (or (tramp-find-executable multi-method method user host | |
4387 "perl5" tramp-remote-path nil) | |
4388 (tramp-find-executable multi-method method user host | |
4389 "perl" tramp-remote-path nil)))) | |
4390 (when tramp-remote-perl | |
4391 (tramp-set-connection-property "perl" tramp-remote-perl multi-method method user host) | |
4392 ;; Set up stat in Perl if we can. | |
4393 (when tramp-remote-perl | |
4394 (tramp-message 5 "Sending the Perl `file-attributes' implementation.") | |
4395 (tramp-send-linewise | |
4396 multi-method method user host | |
4397 (concat "tramp_file_attributes () {\n" | |
4398 tramp-remote-perl | |
4399 " -e '" tramp-perl-file-attributes "' $1 2>/dev/null\n" | |
4400 "}")) | |
4401 (tramp-wait-for-output) | |
46752 | 4402 (tramp-message 5 "Sending the Perl `mime-encode' implementation.") |
4403 (tramp-send-linewise | |
4404 multi-method method user host | |
4405 (concat "tramp_encode () {\n" | |
4406 (format tramp-perl-encode tramp-remote-perl) | |
4407 " 2>/dev/null" | |
4408 "\n}")) | |
4409 (tramp-wait-for-output) | |
4410 (tramp-message 5 "Sending the Perl `mime-decode' implementation.") | |
4411 (tramp-send-linewise | |
4412 multi-method method user host | |
4413 (concat "tramp_decode () {\n" | |
4414 (format tramp-perl-decode tramp-remote-perl) | |
4415 " 2>/dev/null" | |
4416 "\n}")) | |
4417 (tramp-wait-for-output)))) | |
45861 | 4418 ;; Find ln(1) |
4419 (erase-buffer) | |
4420 (let ((ln (tramp-find-executable multi-method method user host | |
4421 "ln" tramp-remote-path nil))) | |
4422 (when ln | |
4423 (tramp-set-connection-property "ln" ln multi-method method user host))) | |
4424 (erase-buffer) | |
46752 | 4425 ;; Find the right encoding/decoding commands to use. |
4426 (unless (tramp-get-rcp-program multi-method method) | |
4427 (tramp-find-inline-encoding multi-method method user host)) | |
45861 | 4428 ;; If encoding/decoding command are given, test to see if they work. |
4429 ;; CCC: Maybe it would be useful to run the encoder both locally and | |
4430 ;; remotely to see if they produce the same result. | |
46752 | 4431 (let ((decoding (tramp-get-decoding-command multi-method method user host)) |
4432 (encoding (tramp-get-encoding-command multi-method method user host)) | |
45861 | 4433 (magic-string "xyzzy")) |
4434 (when (and (or decoding encoding) (not (and decoding encoding))) | |
4435 (tramp-kill-process multi-method method user host) | |
4436 (error | |
4437 "Must give both decoding and encoding command in method definition")) | |
4438 (when (and decoding encoding) | |
4439 (tramp-message | |
4440 5 | |
4441 "Checking to see if encoding/decoding commands work on remote host...") | |
4442 (tramp-send-command | |
4443 multi-method method user host | |
4444 (format "echo %s | %s | %s" | |
4445 (tramp-shell-quote-argument magic-string) encoding decoding)) | |
4446 (tramp-wait-for-output) | |
4447 (unless (looking-at (regexp-quote magic-string)) | |
4448 (tramp-kill-process multi-method method user host) | |
4449 (error "Remote host cannot execute de/encoding commands. See buffer `%s' for details" | |
4450 (buffer-name))) | |
4451 (erase-buffer) | |
4452 (tramp-message | |
4453 5 "Checking to see if encoding/decoding commands work on remote host...done")))) | |
4454 | |
46752 | 4455 ;; CCC: We should either implement a Perl version of base64 encoding |
4456 ;; and decoding. Then we just use that in the last item. The other | |
4457 ;; alternative is to use the Perl version of UU encoding. But then | |
4458 ;; we need a Lisp version of uuencode. | |
4459 (defvar tramp-coding-commands | |
4460 '(("mimencode -b" "mimencode -u -b" | |
4461 base64-encode-region base64-decode-region) | |
4462 ("mmencode -b" "mmencode -u -b" | |
4463 base64-encode-region base64-decode-region) | |
4464 ("recode data..base64" "recode base64..data" | |
4465 base64-encode-region base64-decode-region) | |
4466 ("uuencode xxx" "uudecode -o -" | |
4467 nil uudecode-decode-region) | |
4468 ("uuencode xxx" "uudecode -p" | |
4469 nil uudecode-decode-region) | |
4470 ("tramp_encode" "tramp_decode" | |
4471 base64-encode-region base64-decode-region)) | |
4472 "List of coding commands for inline transfer. | |
4473 Each item is a list (ENCODING-COMMAND DECODING-COMMAND | |
4474 ENCODING-FUNCTION DECODING-FUNCTION). | |
4475 | |
4476 Each item can be a string, giving a command, or a symbol, giving | |
4477 a function. | |
4478 | |
4479 The ENCODING-COMMAND should be a command accepting a plain file on | |
4480 standard input and writing the encoded file to standard output. The | |
4481 DECODING-COMMAND should be a command accepting an encoded file on | |
4482 standard input and writing the decoded file to standard output. | |
4483 | |
4484 The ENCODING-FUNCTION and DECODING-FUNCTION functions will be called | |
4485 with two arguments, start and end of region, and are expected to | |
4486 replace the region contents with the encoded or decoded results, | |
4487 respectively.") | |
4488 | |
4489 (defun tramp-find-inline-encoding (multi-method method user host) | |
4490 "Find an inline transfer encoding that works. | |
4491 Goes through the list `tramp-coding-commands'." | |
4492 (let ((commands tramp-coding-commands) | |
4493 item found) | |
4494 (while (and commands (null found)) | |
4495 (setq item (pop commands)) | |
4496 (catch 'wont-work | |
4497 (let ((ec (nth 0 item)) | |
4498 (dc (nth 1 item)) | |
4499 (ef (nth 2 item)) | |
4500 (df (nth 3 item))) | |
4501 ;; Check if encoding and decoding commands can be called | |
4502 ;; remotely with null input and output. This makes sure there | |
4503 ;; are no syntax errors and the command is really found. | |
4504 (tramp-message-for-buffer | |
4505 multi-method method user host 10 | |
4506 "Checking remote encoding command `%s' for sanity" ec) | |
4507 (unless (zerop (tramp-send-command-and-check | |
4508 multi-method method user host | |
4509 (format "%s </dev/null >/dev/null" ec) t)) | |
4510 (throw 'wont-work nil)) | |
4511 (tramp-message-for-buffer | |
4512 multi-method method user host 10 | |
4513 "Checking remote decoding command `%s' for sanity" dc) | |
4514 (unless (zerop (tramp-send-command-and-check | |
4515 multi-method method user host | |
4516 (format "%s </dev/null >/dev/null" dc) t)) | |
4517 (throw 'wont-work nil)) | |
4518 ;; If no encoding/decoding function is given, the | |
4519 ;; corresponding encoding/decoding command also has to work | |
4520 ;; locally. | |
4521 (when (not (fboundp ef)) | |
4522 (tramp-message-for-buffer | |
4523 multi-method method user host 10 | |
4524 "Checking local encoding command `%s' for sanity" ec) | |
4525 (unless (zerop (call-process | |
4526 tramp-sh-program ;program | |
4527 nil ;input | |
4528 nil ;output buffer | |
4529 nil ;redisplay | |
4530 "-c" | |
4531 (format "%s </dev/null >/dev/null" ec))) | |
4532 (throw 'wont-work nil))) | |
4533 (when (not (fboundp df)) | |
4534 (tramp-message-for-buffer | |
4535 multi-method method user host 10 | |
4536 "Checking local decoding command `%s' for sanity" dc) | |
4537 (unless (zerop (call-process | |
4538 tramp-sh-program ;program | |
4539 nil ;input file | |
4540 nil ;output buffer | |
4541 nil ;redisplay | |
4542 "-c" | |
4543 (format "%s </dev/null >/dev/null" dc))) | |
4544 (throw 'wont-work nil))) | |
4545 ;; CCC: At this point, maybe we should check that the output | |
4546 ;; of the commands is correct. But for the moment we will | |
4547 ;; assume that commands working on empty input will also | |
4548 ;; work in practice. | |
4549 (setq found item)))) | |
4550 ;; Did we find something? If not, issue error. If so, | |
4551 ;; set connection properties. | |
4552 (unless found | |
4553 (error "Couldn't find an inline transfer encoding")) | |
4554 (let ((ec (nth 0 found)) | |
4555 (dc (nth 1 found)) | |
4556 (ef (nth 2 found)) | |
4557 (df (nth 3 found))) | |
4558 (tramp-set-encoding-command multi-method method user host ec) | |
4559 (tramp-set-decoding-command multi-method method user host dc) | |
4560 (tramp-set-encoding-function multi-method method user host ef) | |
4561 (tramp-set-decoding-function multi-method method user host df)))) | |
4562 | |
45861 | 4563 |
4564 (defun tramp-maybe-open-connection (multi-method method user host) | |
4565 "Maybe open a connection to HOST, logging in as USER, using METHOD. | |
4566 Does not do anything if a connection is already open, but re-opens the | |
4567 connection if a previous connection has died for some reason." | |
46752 | 4568 (let ((p (get-buffer-process (tramp-get-buffer multi-method method user host))) |
4569 last-cmd-time) | |
4570 ;; If too much time has passed since last command was sent, look | |
4571 ;; whether process is still alive. If it isn't, kill it. When | |
4572 ;; using ssh, it can sometimes happen that the remote end has hung | |
4573 ;; up but the local ssh client doesn't recognize this until it | |
4574 ;; tries to send some data to the remote end. So that's why we | |
4575 ;; try to send a command from time to time, then look again | |
4576 ;; whether the process is really alive. | |
4577 (save-excursion | |
4578 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4579 (when (and tramp-last-cmd-time | |
4580 (> (tramp-time-diff tramp-last-cmd-time (current-time)) 60)) | |
4581 (process-send-string p (concat "echo hello" tramp-rsh-end-of-line)) | |
4582 (unless (accept-process-output p 2) | |
4583 (delete-process p) | |
4584 (setq p nil)) | |
4585 (erase-buffer))) | |
4586 (unless (and p (processp p) (memq (process-status p) '(run open))) | |
45861 | 4587 (when (and p (processp p)) |
4588 (delete-process p)) | |
4589 (funcall (tramp-get-connection-function multi-method method) | |
4590 multi-method method user host)))) | |
4591 | |
4592 (defun tramp-send-command | |
4593 (multi-method method user host command &optional noerase) | |
4594 "Send the COMMAND to USER at HOST (logged in using METHOD). | |
4595 Erases temporary buffer before sending the command (unless NOERASE | |
4596 is true)." | |
4597 (tramp-maybe-open-connection multi-method method user host) | |
46752 | 4598 (setq tramp-last-cmd-time (current-time)) |
45861 | 4599 (when tramp-debug-buffer |
4600 (save-excursion | |
4601 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
4602 (goto-char (point-max)) | |
4603 (tramp-insert-with-face 'bold (format "$ %s\n" command)))) | |
4604 (let ((proc nil)) | |
4605 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4606 (unless noerase (erase-buffer)) | |
4607 (setq proc (get-buffer-process (current-buffer))) | |
4608 (process-send-string proc | |
4609 (concat command tramp-rsh-end-of-line)))) | |
4610 | |
4611 ;; It seems that Tru64 Unix does not like it if long strings are sent | |
4612 ;; to it in one go. (This happens when sending the Perl | |
4613 ;; `file-attributes' implementation, for instance.) Therefore, we | |
4614 ;; have this function which waits a bit at each line. | |
4615 (defun tramp-send-linewise | |
4616 (multi-method method user host string &optional noerase) | |
4617 "Send the STRING to USER at HOST linewise. | |
4618 Erases temporary buffer before sending the STRING (unless NOERASE | |
4619 is true). | |
4620 | |
4621 The STRING is expected to use Unix line-endings, but the lines sent to | |
4622 the remote host use line-endings as defined in the variable | |
4623 `tramp-rsh-end-of-line'." | |
4624 (tramp-maybe-open-connection multi-method method user host) | |
4625 (when tramp-debug-buffer | |
4626 (save-excursion | |
4627 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
4628 (goto-char (point-max)) | |
4629 (tramp-insert-with-face 'bold (format "$ %s\n" string)))) | |
4630 (let ((proc nil) | |
4631 (lines (split-string string "\n"))) | |
4632 (set-buffer (tramp-get-buffer multi-method method user host)) | |
4633 (unless noerase (erase-buffer)) | |
4634 (setq proc (get-buffer-process (current-buffer))) | |
4635 (mapcar (lambda (x) | |
4636 (sleep-for 0.1) | |
4637 (process-send-string proc | |
4638 (concat x tramp-rsh-end-of-line))) | |
4639 lines))) | |
4640 | |
4641 (defun tramp-wait-for-output (&optional timeout) | |
4642 "Wait for output from remote rsh command." | |
4643 (let ((proc (get-buffer-process (current-buffer))) | |
4644 (found nil) | |
4645 (start-time (current-time)) | |
4646 (end-of-output (concat "^" | |
4647 (regexp-quote tramp-end-of-output) | |
4648 "$"))) | |
4649 ;; Algorithm: get waiting output. See if last line contains | |
4650 ;; end-of-output sentinel. If not, wait a bit and again get | |
4651 ;; waiting output. Repeat until timeout expires or end-of-output | |
4652 ;; sentinel is seen. Will hang if timeout is nil and | |
4653 ;; end-of-output sentinel never appears. | |
4654 (save-match-data | |
4655 (cond (timeout | |
4656 ;; Work around an XEmacs bug, where the timeout expires | |
4657 ;; faster than it should. This degenerates into polling | |
4658 ;; for buggy XEmacsen, but oh, well. | |
4659 (while (and (not found) | |
4660 (< (tramp-time-diff (current-time) start-time) | |
4661 timeout)) | |
4662 (with-timeout (timeout) | |
4663 (while (not found) | |
4664 (accept-process-output proc 1) | |
4665 (goto-char (point-max)) | |
4666 (forward-line -1) | |
4667 (setq found (looking-at end-of-output)))))) | |
4668 (t | |
4669 (while (not found) | |
4670 (accept-process-output proc 1) | |
4671 (goto-char (point-max)) | |
4672 (forward-line -1) | |
4673 (setq found (looking-at end-of-output)))))) | |
4674 ;; At this point, either the timeout has expired or we have found | |
4675 ;; the end-of-output sentinel. | |
4676 (when found | |
4677 (goto-char (point-max)) | |
4678 (forward-line -2) | |
4679 (delete-region (point) (point-max))) | |
4680 ;; Add output to debug buffer if appropriate. | |
4681 (when tramp-debug-buffer | |
4682 (append-to-buffer | |
4683 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4684 tramp-current-user tramp-current-host) | |
4685 (point-min) (point-max)) | |
4686 (when (not found) | |
4687 (save-excursion | |
4688 (set-buffer | |
4689 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | |
4690 tramp-current-user tramp-current-host)) | |
4691 (goto-char (point-max)) | |
4692 (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
|
4693 (if timeout (format " in %d secs" timeout) "") |
45861 | 4694 "]]")))) |
4695 (goto-char (point-min)) | |
4696 ;; Return value is whether end-of-output sentinel was found. | |
4697 found)) | |
4698 | |
4699 (defun tramp-match-string-list (&optional string) | |
4700 "Returns list of all match strings. | |
4701 That is, (list (match-string 0) (match-string 1) ...), according to the | |
4702 number of matches." | |
4703 (let* ((nmatches (/ (length (match-data)) 2)) | |
4704 (i (- nmatches 1)) | |
4705 (res nil)) | |
4706 (while (>= i 0) | |
4707 (setq res (cons (match-string i string) res)) | |
4708 (setq i (- i 1))) | |
4709 res)) | |
4710 | |
4711 (defun tramp-send-command-and-check (multi-method method user host command | |
4712 &optional subshell) | |
4713 "Run COMMAND and check its exit status. | |
4714 MULTI-METHOD and METHOD specify how to log in (as USER) to the remote HOST. | |
4715 Sends `echo $?' along with the COMMAND for checking the exit status. If | |
4716 COMMAND is nil, just sends `echo $?'. Returns the exit status found. | |
4717 | |
4718 If the optional argument SUBSHELL is non-nil, the command is executed in | |
4719 a subshell, ie surrounded by parentheses." | |
4720 (tramp-send-command multi-method method user host | |
4721 (concat (if subshell "( " "") | |
4722 command | |
4723 (if command " 2>/dev/null; " "") | |
4724 "echo tramp_exit_status $?" | |
4725 (if subshell " )" " "))) | |
4726 (tramp-wait-for-output) | |
4727 (goto-char (point-max)) | |
4728 (unless (search-backward "tramp_exit_status " nil t) | |
4729 (error "Couldn't find exit status of `%s'" command)) | |
4730 (skip-chars-forward "^ ") | |
4731 (read (current-buffer))) | |
4732 | |
4733 (defun tramp-barf-unless-okay (multi-method method user host command subshell | |
4734 signal fmt &rest args) | |
4735 "Run COMMAND, check exit status, throw error if exit status not okay. | |
4736 Similar to `tramp-send-command-and-check' but accepts two more arguments | |
4737 FMT and ARGS which are passed to `error'." | |
4738 (unless (zerop (tramp-send-command-and-check | |
4739 multi-method method user host command subshell)) | |
4740 ;; CCC: really pop-to-buffer? Maybe it's appropriate to be more | |
4741 ;; silent. | |
4742 (pop-to-buffer (current-buffer)) | |
4743 (funcall 'signal signal (apply 'format fmt args)))) | |
4744 | |
4745 (defun tramp-send-region (multi-method method user host start end) | |
4746 "Send the region from START to END to remote command | |
4747 running as USER on HOST using METHOD." | |
4748 (let ((proc (get-buffer-process | |
4749 (tramp-get-buffer multi-method method user host)))) | |
4750 (unless proc | |
4751 (error "Can't send region to remote host -- not logged in")) | |
4752 (process-send-region proc start end) | |
4753 (when tramp-debug-buffer | |
4754 (append-to-buffer | |
4755 (tramp-get-debug-buffer multi-method method user host) | |
4756 start end)))) | |
4757 | |
4758 (defun tramp-send-eof (multi-method method user host) | |
4759 "Send EOF to the remote end. | |
46151
eff75835ac2e
(tramp-send-eof): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
46060
diff
changeset
|
4760 METHOD, HOST and USER specify the connection." |
45861 | 4761 (let ((proc (get-buffer-process |
4762 (tramp-get-buffer multi-method method user host)))) | |
4763 (unless proc | |
4764 (error "Can't send EOF to remote host -- not logged in")) | |
4765 (process-send-eof proc))) | |
4766 ; (process-send-string proc "\^D"))) | |
4767 | |
4768 (defun tramp-kill-process (multi-method method user host) | |
4769 "Kill the connection process used by Tramp. | |
46151
eff75835ac2e
(tramp-send-eof): Fix typo.
Juanma Barranquero <lekktu@gmail.com>
parents:
46060
diff
changeset
|
4770 MULTI-METHOD, METHOD, USER, and HOST specify the connection." |
45861 | 4771 (let ((proc (get-buffer-process |
4772 (tramp-get-buffer multi-method method user host)))) | |
4773 (kill-process proc))) | |
4774 | |
4775 (defun tramp-discard-garbage-erase-buffer (p multi-method method user host) | |
4776 "Erase buffer, then discard subsequent garbage. | |
4777 If `tramp-discard-garbage' is nil, just erase buffer." | |
4778 (if (not tramp-discard-garbage) | |
4779 (erase-buffer) | |
4780 (while (prog1 (erase-buffer) (accept-process-output p 0.25)) | |
4781 (when tramp-debug-buffer | |
4782 (save-excursion | |
4783 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | |
4784 (goto-char (point-max)) | |
4785 (tramp-insert-with-face | |
4786 'bold (format "Additional characters detected\n"))))))) | |
4787 | |
4788 (defun tramp-mode-string-to-int (mode-string) | |
4789 "Converts a ten-letter `drwxrwxrwx'-style mode string into mode bits." | |
4790 (let* ((mode-chars (string-to-vector mode-string)) | |
4791 (owner-read (aref mode-chars 1)) | |
4792 (owner-write (aref mode-chars 2)) | |
4793 (owner-execute-or-setid (aref mode-chars 3)) | |
4794 (group-read (aref mode-chars 4)) | |
4795 (group-write (aref mode-chars 5)) | |
4796 (group-execute-or-setid (aref mode-chars 6)) | |
4797 (other-read (aref mode-chars 7)) | |
4798 (other-write (aref mode-chars 8)) | |
4799 (other-execute-or-sticky (aref mode-chars 9))) | |
4800 (save-match-data | |
4801 (logior | |
4802 (case owner-read | |
4803 (?r (tramp-octal-to-decimal "00400")) (?- 0) | |
4804 (t (error "Second char `%c' must be one of `r-'" owner-read))) | |
4805 (case owner-write | |
4806 (?w (tramp-octal-to-decimal "00200")) (?- 0) | |
4807 (t (error "Third char `%c' must be one of `w-'" owner-write))) | |
4808 (case owner-execute-or-setid | |
4809 (?x (tramp-octal-to-decimal "00100")) | |
4810 (?S (tramp-octal-to-decimal "04000")) | |
4811 (?s (tramp-octal-to-decimal "04100")) | |
4812 (?- 0) | |
4813 (t (error "Fourth char `%c' must be one of `xsS-'" | |
4814 owner-execute-or-setid))) | |
4815 (case group-read | |
4816 (?r (tramp-octal-to-decimal "00040")) (?- 0) | |
4817 (t (error "Fifth char `%c' must be one of `r-'" group-read))) | |
4818 (case group-write | |
4819 (?w (tramp-octal-to-decimal "00020")) (?- 0) | |
4820 (t (error "Sixth char `%c' must be one of `w-'" group-write))) | |
4821 (case group-execute-or-setid | |
4822 (?x (tramp-octal-to-decimal "00010")) | |
4823 (?S (tramp-octal-to-decimal "02000")) | |
4824 (?s (tramp-octal-to-decimal "02010")) | |
4825 (?- 0) | |
4826 (t (error "Seventh char `%c' must be one of `xsS-'" | |
4827 group-execute-or-setid))) | |
4828 (case other-read | |
4829 (?r (tramp-octal-to-decimal "00004")) (?- 0) | |
4830 (t (error "Eighth char `%c' must be one of `r-'" other-read))) | |
4831 (case other-write | |
4832 (?w (tramp-octal-to-decimal "00002")) (?- 0) | |
4833 (t (error "Nineth char `%c' must be one of `w-'" other-write))) | |
4834 (case other-execute-or-sticky | |
4835 (?x (tramp-octal-to-decimal "00001")) | |
4836 (?T (tramp-octal-to-decimal "01000")) | |
4837 (?t (tramp-octal-to-decimal "01001")) | |
4838 (?- 0) | |
4839 (t (error "Tenth char `%c' must be one of `xtT-'" | |
4840 other-execute-or-sticky))))))) | |
4841 | |
4842 | |
4843 (defun tramp-file-mode-from-int (mode) | |
4844 "Turn an integer representing a file mode into an ls(1)-like string." | |
4845 (let ((type (cdr (assoc (logand (lsh mode -12) 15) tramp-file-mode-type-map))) | |
4846 (user (logand (lsh mode -6) 7)) | |
4847 (group (logand (lsh mode -3) 7)) | |
4848 (other (logand (lsh mode -0) 7)) | |
4849 (suid (> (logand (lsh mode -9) 4) 0)) | |
4850 (sgid (> (logand (lsh mode -9) 2) 0)) | |
4851 (sticky (> (logand (lsh mode -9) 1) 0))) | |
4852 (setq user (tramp-file-mode-permissions user suid "s")) | |
4853 (setq group (tramp-file-mode-permissions group sgid "s")) | |
4854 (setq other (tramp-file-mode-permissions other sticky "t")) | |
4855 (concat type user group other))) | |
4856 | |
4857 | |
4858 (defun tramp-file-mode-permissions (perm suid suid-text) | |
4859 "Convert a permission bitset into a string. | |
4860 This is used internally by `tramp-file-mode-from-int'." | |
4861 (let ((r (> (logand perm 4) 0)) | |
4862 (w (> (logand perm 2) 0)) | |
4863 (x (> (logand perm 1) 0))) | |
4864 (concat (or (and r "r") "-") | |
4865 (or (and w "w") "-") | |
4866 (or (and suid x suid-text) ; suid, execute | |
4867 (and suid (upcase suid-text)) ; suid, !execute | |
4868 (and x "x") "-")))) ; !suid | |
4869 | |
4870 | |
4871 (defun tramp-decimal-to-octal (i) | |
4872 "Return a string consisting of the octal digits of I. | |
4873 Not actually used. Use `(format \"%o\" i)' instead?" | |
4874 (cond ((< i 0) (error "Cannot convert negative number to octal")) | |
4875 ((not (integerp i)) (error "Cannot convert non-integer to octal")) | |
4876 ((zerop i) "0") | |
4877 (t (concat (tramp-decimal-to-octal (/ i 8)) | |
4878 (number-to-string (% i 8)))))) | |
4879 | |
4880 | |
4881 ;;(defun tramp-octal-to-decimal (ostr) | |
4882 ;; "Given a string of octal digits, return a decimal number." | |
4883 ;; (cond ((null ostr) 0) | |
4884 ;; ((string= "" ostr) 0) | |
4885 ;; (t (let ((last (aref ostr (1- (length ostr)))) | |
4886 ;; (rest (substring ostr 0 (1- (length ostr))))) | |
4887 ;; (unless (and (>= last ?0) | |
4888 ;; (<= last ?7)) | |
4889 ;; (error "Not an octal digit: %c" last)) | |
4890 ;; (+ (- last ?0) (* 8 (tramp-octal-to-decimal rest))))))) | |
4891 ;; Kudos to Gerd Moellmann for this suggestion. | |
4892 (defun tramp-octal-to-decimal (ostr) | |
4893 "Given a string of octal digits, return a decimal number." | |
4894 (let ((x (or ostr ""))) | |
4895 ;; `save-match' is in `tramp-mode-string-to-int' which calls this. | |
4896 (unless (string-match "\\`[0-7]*\\'" x) | |
4897 (error "Non-octal junk in string `%s'" x)) | |
4898 (string-to-number ostr 8))) | |
4899 | |
4900 (defun tramp-shell-case-fold (string) | |
4901 "Converts STRING to shell glob pattern which ignores case." | |
4902 (mapconcat | |
4903 (lambda (c) | |
4904 (if (equal (downcase c) (upcase c)) | |
4905 (vector c) | |
4906 (format "[%c%c]" (downcase c) (upcase c)))) | |
4907 string | |
4908 "")) | |
4909 | |
4910 | |
4911 ;; ------------------------------------------------------------ | |
4912 ;; -- TRAMP file names -- | |
4913 ;; ------------------------------------------------------------ | |
4914 ;; Conversion functions between external representation and | |
4915 ;; internal data structure. Convenience functions for internal | |
4916 ;; data structure. | |
4917 | |
4918 (defstruct tramp-file-name multi-method method user host path) | |
4919 | |
4920 (defun tramp-tramp-file-p (name) | |
4921 "Return t iff NAME is a tramp file." | |
4922 (save-match-data | |
4923 (string-match tramp-file-name-regexp name))) | |
4924 | |
4925 ;; HHH: Changed. Used to assign the return value of (user-login-name) | |
4926 ;; to the `user' part of the structure if a user name was not | |
4927 ;; provided, now it assigns nil. | |
4928 (defun tramp-dissect-file-name (name) | |
4929 "Return an `tramp-file-name' structure. | |
4930 The structure consists of remote method, remote user, remote host and | |
4931 remote path name." | |
4932 (let (method) | |
4933 (save-match-data | |
4934 (unless (string-match (nth 0 tramp-file-name-structure) name) | |
4935 (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
|
4936 (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
|
4937 (if (and method (member method tramp-multi-methods)) |
45861 | 4938 ;; If it's a multi method, the file name structure contains |
4939 ;; arrays of method, user and host. | |
4940 (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
|
4941 ;; 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
|
4942 (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
|
4943 (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
|
4944 (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
|
4945 (when (not method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4946 (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
|
4947 (make-tramp-file-name |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4948 :multi-method nil |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4949 :method method |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4950 :user (or user nil) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4951 :host host |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4952 :path path)))))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4953 |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4954 (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
|
4955 "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
|
4956 (let ((choices tramp-default-method-alist) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4957 (method tramp-default-method) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4958 item) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4959 (while choices |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4960 (setq item (pop choices)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4961 (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
|
4962 (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
|
4963 (setq method (nth 2 item)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4964 (setq choices nil))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4965 method)) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
4966 |
45861 | 4967 ;; HHH: Not Changed. Multi method. Will probably not handle the case where |
4968 ;; a user name is not provided in the "file name" very well. | |
4969 (defun tramp-dissect-multi-file-name (name) | |
4970 "Not implemented yet." | |
4971 (let ((regexp (nth 0 tramp-multi-file-name-structure)) | |
4972 (method-index (nth 1 tramp-multi-file-name-structure)) | |
4973 (hops-index (nth 2 tramp-multi-file-name-structure)) | |
4974 (path-index (nth 3 tramp-multi-file-name-structure)) | |
4975 (hop-regexp (nth 0 tramp-multi-file-name-hop-structure)) | |
4976 (hop-method-index (nth 1 tramp-multi-file-name-hop-structure)) | |
4977 (hop-user-index (nth 2 tramp-multi-file-name-hop-structure)) | |
4978 (hop-host-index (nth 3 tramp-multi-file-name-hop-structure)) | |
4979 method hops len hop-methods hop-users hop-hosts path) | |
4980 (unless (string-match (format regexp hop-regexp) name) | |
4981 (error "Not a multi tramp file name: %s" name)) | |
4982 (setq method (match-string method-index name)) | |
4983 (setq hops (match-string hops-index name)) | |
4984 (setq len (/ (length (match-data t)) 2)) | |
4985 (when (< path-index 0) (incf path-index len)) | |
4986 (setq path (match-string path-index name)) | |
4987 (let ((index 0)) | |
4988 (while (string-match hop-regexp hops index) | |
4989 (setq index (match-end 0)) | |
4990 (setq hop-methods | |
4991 (cons (match-string hop-method-index hops) hop-methods)) | |
4992 (setq hop-users | |
4993 (cons (match-string hop-user-index hops) hop-users)) | |
4994 (setq hop-hosts | |
4995 (cons (match-string hop-host-index hops) hop-hosts)))) | |
4996 (make-tramp-file-name | |
4997 :multi-method method | |
4998 :method (apply 'vector (reverse hop-methods)) | |
4999 :user (apply 'vector (reverse hop-users)) | |
5000 :host (apply 'vector (reverse hop-hosts)) | |
5001 :path path))) | |
5002 | |
5003 (defun tramp-make-tramp-file-name (multi-method method user host path) | |
5004 "Constructs a tramp file name from METHOD, USER, HOST and PATH." | |
5005 (unless tramp-make-tramp-file-format | |
5006 (error "`tramp-make-tramp-file-format' is nil")) | |
5007 (if multi-method | |
5008 (tramp-make-tramp-multi-file-name multi-method method user host path) | |
5009 (if user | |
5010 (format-spec tramp-make-tramp-file-format | |
46752 | 5011 `((?m . ,method) (?u . ,user) (?h . ,host) (?p . ,path))) |
45861 | 5012 (format-spec tramp-make-tramp-file-user-nil-format |
46752 | 5013 `((?m . ,method) (?h . ,host) (?p . ,path)))))) |
45861 | 5014 |
5015 ;; CCC: Henrik Holm: Not Changed. Multi Method. What should be done | |
5016 ;; with this when USER is nil? | |
5017 (defun tramp-make-tramp-multi-file-name (multi-method method user host path) | |
5018 "Constructs a tramp file name for a multi-hop method." | |
5019 (unless tramp-make-multi-tramp-file-format | |
5020 (error "`tramp-make-multi-tramp-file-format' is nil")) | |
5021 (let* ((prefix-format (nth 0 tramp-make-multi-tramp-file-format)) | |
5022 (hop-format (nth 1 tramp-make-multi-tramp-file-format)) | |
5023 (path-format (nth 2 tramp-make-multi-tramp-file-format)) | |
46752 | 5024 (prefix (format-spec prefix-format `((?m . ,multi-method)))) |
45861 | 5025 (hops "") |
46752 | 5026 (path (format-spec path-format `((?p . ,path)))) |
45861 | 5027 (i 0) |
5028 (len (length method))) | |
5029 (while (< i len) | |
46584
f548d7d0c651
Bump version to 2.0.2.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
46347
diff
changeset
|
5030 (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
|
5031 (setq hops (concat hops (format-spec hop-format |
46752 | 5032 `((?m . ,m) (?u . ,u) (?h . ,h))))) |
45861 | 5033 (incf i))) |
5034 (concat prefix hops path))) | |
5035 | |
5036 (defun tramp-make-rcp-program-file-name (user host path) | |
5037 "Create a file name suitable to be passed to `rcp'." | |
5038 (if user | |
5039 (format "%s@%s:%s" user host path) | |
5040 (format "%s:%s" host path))) | |
5041 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5042 (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
|
5043 "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
|
5044 (if user |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5045 (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
|
5046 (format "/%s:%s" host path))) |
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5047 |
45861 | 5048 (defun tramp-method-out-of-band-p (multi-method method) |
5049 "Return t if this is an out-of-band method, nil otherwise. | |
5050 It is important to check for this condition, since it is not possible | |
5051 to enter a password for the `tramp-rcp-program'." | |
5052 (tramp-get-rcp-program multi-method method)) | |
5053 | |
5054 ;; Variables local to connection. | |
5055 | |
5056 (defun tramp-get-ls-command (multi-method method user host) | |
5057 (save-excursion | |
5058 (tramp-maybe-open-connection multi-method method user host) | |
5059 (set-buffer (tramp-get-buffer multi-method method user host)) | |
5060 tramp-ls-command)) | |
5061 | |
5062 (defun tramp-get-test-groks-nt (multi-method method user host) | |
5063 (save-excursion | |
5064 (tramp-maybe-open-connection multi-method method user host) | |
5065 (set-buffer (tramp-get-buffer multi-method method user host)) | |
5066 tramp-test-groks-nt)) | |
5067 | |
5068 (defun tramp-get-file-exists-command (multi-method method user host) | |
5069 (save-excursion | |
5070 (tramp-maybe-open-connection multi-method method user host) | |
5071 (set-buffer (tramp-get-buffer multi-method method user host)) | |
5072 tramp-file-exists-command)) | |
5073 | |
5074 (defun tramp-get-remote-perl (multi-method method user host) | |
5075 (tramp-get-connection-property "perl" nil multi-method method user host)) | |
5076 | |
5077 (defun tramp-get-remote-ln (multi-method method user host) | |
5078 (tramp-get-connection-property "ln" nil multi-method method user host)) | |
5079 | |
5080 ;; Get a property of a TRAMP connection. | |
46752 | 5081 (defun tramp-get-connection-property |
5082 (property default multi-method method user host) | |
45861 | 5083 "Get the named property for the connection. |
5084 If the value is not set for the connection, return `default'" | |
5085 (tramp-maybe-open-connection multi-method method user host) | |
5086 (with-current-buffer (tramp-get-buffer multi-method method user host) | |
5087 (let (error) | |
5088 (condition-case nil | |
5089 (symbol-value (intern (concat "tramp-connection-property-" property))) | |
5090 (error default))))) | |
5091 | |
5092 ;; Set a property of a TRAMP connection. | |
46752 | 5093 (defun tramp-set-connection-property |
5094 (property value multi-method method user host) | |
45861 | 5095 "Set the named property of a TRAMP connection." |
5096 (tramp-maybe-open-connection multi-method method user host) | |
5097 (with-current-buffer (tramp-get-buffer multi-method method user host) | |
5098 (set (make-local-variable | |
5099 (intern (concat "tramp-connection-property-" property))) | |
5100 value))) | |
5101 | |
46752 | 5102 ;; Some predefined connection properties. |
5103 (defun tramp-get-encoding-command (multi-method method user host) | |
5104 (tramp-get-connection-property "encoding-command" nil | |
5105 multi-method method user host)) | |
5106 (defun tramp-set-encoding-command (multi-method method user host command) | |
5107 (tramp-set-connection-property "encoding-command" command | |
5108 multi-method method user host)) | |
5109 (defun tramp-get-decoding-command (multi-method method user host) | |
5110 (tramp-get-connection-property "decoding-command" nil | |
5111 multi-method method user host)) | |
5112 (defun tramp-set-decoding-command (multi-method method user host command) | |
5113 (tramp-set-connection-property "decoding-command" command | |
5114 multi-method method user host)) | |
5115 (defun tramp-get-encoding-function (multi-method method user host) | |
5116 (tramp-get-connection-property "encoding-function" nil | |
5117 multi-method method user host)) | |
5118 (defun tramp-set-encoding-function (multi-method method user host func) | |
5119 (tramp-set-connection-property "encoding-function" func | |
5120 multi-method method user host)) | |
5121 (defun tramp-get-decoding-function (multi-method method user host) | |
5122 (tramp-get-connection-property "decoding-function" nil | |
5123 multi-method method user host)) | |
5124 (defun tramp-set-decoding-function (multi-method method user host func) | |
5125 (tramp-set-connection-property "decoding-function" func | |
5126 multi-method method user host)) | |
45861 | 5127 |
5128 | |
5129 (defun tramp-get-connection-function (multi-method method) | |
5130 (second (or (assoc 'tramp-connection-function | |
5131 (assoc (or multi-method method tramp-default-method) | |
5132 tramp-methods)) | |
5133 (error "Method `%s' didn't specify a connection function" | |
5134 (or multi-method method))))) | |
5135 | |
5136 (defun tramp-get-remote-sh (multi-method method) | |
5137 (second (or (assoc 'tramp-remote-sh | |
5138 (assoc (or multi-method method tramp-default-method) | |
5139 tramp-methods)) | |
5140 (error "Method `%s' didn't specify a remote shell" | |
5141 (or multi-method method))))) | |
5142 | |
5143 (defun tramp-get-rsh-program (multi-method method) | |
5144 (second (or (assoc 'tramp-rsh-program | |
5145 (assoc (or multi-method method tramp-default-method) | |
5146 tramp-methods)) | |
5147 (error "Method `%s' didn't specify an rsh program" | |
5148 (or multi-method method))))) | |
5149 | |
5150 (defun tramp-get-rsh-args (multi-method method) | |
5151 (second (or (assoc 'tramp-rsh-args | |
5152 (assoc (or multi-method method tramp-default-method) | |
5153 tramp-methods)) | |
5154 (error "Method `%s' didn't specify rsh args" | |
5155 (or multi-method method))))) | |
5156 | |
5157 (defun tramp-get-rcp-program (multi-method method) | |
5158 (second (or (assoc 'tramp-rcp-program | |
5159 (assoc (or multi-method method tramp-default-method) | |
5160 tramp-methods)) | |
5161 (error "Method `%s' didn't specify an rcp program" | |
5162 (or multi-method method))))) | |
5163 | |
5164 (defun tramp-get-rcp-args (multi-method method) | |
5165 (second (or (assoc 'tramp-rcp-args | |
5166 (assoc (or multi-method method tramp-default-method) | |
5167 tramp-methods)) | |
5168 (error "Method `%s' didn't specify rcp args" | |
5169 (or multi-method method))))) | |
5170 | |
5171 (defun tramp-get-rcp-keep-date-arg (multi-method method) | |
5172 (second (or (assoc 'tramp-rcp-keep-date-arg | |
5173 (assoc (or multi-method method tramp-default-method) | |
5174 tramp-methods)) | |
5175 (error "Method `%s' didn't specify `keep-date' arg for tramp" | |
5176 (or multi-method method))))) | |
5177 | |
5178 (defun tramp-get-su-program (multi-method method) | |
5179 (second (or (assoc 'tramp-su-program | |
5180 (assoc (or multi-method method tramp-default-method) | |
5181 tramp-methods)) | |
5182 (error "Method `%s' didn't specify a su program" | |
5183 (or multi-method method))))) | |
5184 | |
5185 (defun tramp-get-su-args (multi-method method) | |
5186 (second (or (assoc 'tramp-su-args | |
5187 (assoc (or multi-method method tramp-default-method) | |
5188 tramp-methods)) | |
5189 (error "Method `%s' didn't specify su args" | |
5190 (or multi-method method))))) | |
5191 | |
5192 (defun tramp-get-telnet-program (multi-method method) | |
5193 (second (or (assoc 'tramp-telnet-program | |
5194 (assoc (or multi-method method tramp-default-method) | |
5195 tramp-methods)) | |
5196 (error "Method `%s' didn't specify a telnet program" | |
5197 (or multi-method method))))) | |
5198 | |
5199 (defun tramp-get-telnet-args (multi-method method) | |
5200 (second (or (assoc 'tramp-telnet-args | |
5201 (assoc (or multi-method method tramp-default-method) | |
5202 tramp-methods)) | |
5203 (error "Method `%s' didn't specify telnet args" | |
5204 (or multi-method method))))) | |
5205 | |
46752 | 5206 ;; (defun tramp-get-encoding-command (multi-method method) |
5207 ;; (second (or (assoc 'tramp-encoding-command | |
5208 ;; (assoc (or multi-method method tramp-default-method) | |
5209 ;; tramp-methods)) | |
5210 ;; (error "Method `%s' didn't specify an encoding command" | |
5211 ;; (or multi-method method))))) | |
5212 | |
5213 ;; (defun tramp-get-decoding-command (multi-method method) | |
5214 ;; (second (or (assoc 'tramp-decoding-command | |
5215 ;; (assoc (or multi-method method tramp-default-method) | |
5216 ;; tramp-methods)) | |
5217 ;; (error "Method `%s' didn't specify a decoding command" | |
5218 ;; (or multi-method method))))) | |
5219 | |
5220 ;; (defun tramp-get-encoding-function (multi-method method) | |
5221 ;; (second (or (assoc 'tramp-encoding-function | |
5222 ;; (assoc (or multi-method method tramp-default-method) | |
5223 ;; tramp-methods)) | |
5224 ;; (error "Method `%s' didn't specify an encoding function" | |
5225 ;; (or multi-method method))))) | |
5226 | |
5227 ;; (defun tramp-get-decoding-function (multi-method method) | |
5228 ;; (second (or (assoc 'tramp-decoding-function | |
5229 ;; (assoc (or multi-method method tramp-default-method) | |
5230 ;; tramp-methods)) | |
5231 ;; (error "Method `%s' didn't specify a decoding function" | |
5232 ;; (or multi-method method))))) | |
5233 | |
45861 | 5234 ;; Auto saving to a special directory. |
5235 | |
5236 (defun tramp-make-auto-save-file-name (fn) | |
5237 "Returns a file name in `tramp-auto-save-directory' for autosaving this file." | |
5238 (when tramp-auto-save-directory | |
5239 (unless (file-exists-p tramp-auto-save-directory) | |
5240 (make-directory tramp-auto-save-directory t))) | |
5241 ;; jka-compr doesn't like auto-saving, so by appending "~" to the | |
5242 ;; file name we make sure that jka-compr isn't used for the | |
5243 ;; auto-save file. | |
5244 (let ((buffer-file-name (expand-file-name | |
5245 (tramp-subst-strs-in-string '(("_" . "|") | |
5246 ("/" . "_a") | |
5247 (":" . "_b") | |
5248 ("|" . "__") | |
5249 ("[" . "_l") | |
5250 ("]" . "_r")) | |
5251 fn) | |
5252 tramp-auto-save-directory))) | |
5253 (make-auto-save-file-name))) | |
5254 | |
5255 (defadvice make-auto-save-file-name | |
5256 (around tramp-advice-make-auto-save-file-name () activate) | |
5257 "Invoke `tramp-make-auto-save-file-name' for tramp files." | |
5258 (if (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)) | |
5259 tramp-auto-save-directory) | |
5260 (setq ad-return-value | |
5261 (tramp-make-auto-save-file-name (buffer-file-name))) | |
5262 ad-do-it)) | |
5263 | |
5264 (defun tramp-subst-strs-in-string (alist string) | |
5265 "Replace all occurrences of the string FROM with TO in STRING. | |
5266 ALIST is of the form ((FROM . TO) ...)." | |
5267 (save-match-data | |
5268 (while alist | |
5269 (let* ((pr (car alist)) | |
5270 (from (car pr)) | |
5271 (to (cdr pr))) | |
5272 (while (string-match (regexp-quote from) string) | |
5273 (setq string (replace-match to t t string))) | |
5274 (setq alist (cdr alist)))) | |
5275 string)) | |
5276 | |
5277 (defun tramp-insert-with-face (face string) | |
5278 "Insert text with a specific face." | |
5279 (let ((start (point))) | |
5280 (insert string) | |
5281 (add-text-properties start (point) (list 'face face)))) | |
5282 | |
5283 ;; ------------------------------------------------------------ | |
5284 ;; -- Compatibility functions section -- | |
5285 ;; ------------------------------------------------------------ | |
5286 | |
5287 (defun tramp-temporary-file-directory () | |
5288 "Return name of directory for temporary files (compat function). | |
5289 For Emacs, this is the variable `temporary-file-directory', for XEmacs | |
5290 this is the function `temp-directory'." | |
5291 (cond ((boundp 'temporary-file-directory) | |
5292 (symbol-value 'temporary-file-directory)) | |
5293 ((fboundp 'temp-directory) | |
5294 (funcall (symbol-function 'temp-directory))) ;pacify byte-compiler | |
5295 ((let ((d (getenv "TEMP"))) (and d (file-directory-p d))) | |
5296 (file-name-as-directory (getenv "TEMP"))) | |
5297 ((let ((d (getenv "TMP"))) (and d (file-directory-p d))) | |
5298 (file-name-as-directory (getenv "TMP"))) | |
5299 ((let ((d (getenv "TMPDIR"))) (and d (file-directory-p d))) | |
5300 (file-name-as-directory (getenv "TMPDIR"))) | |
5301 ((file-exists-p "c:/temp") (file-name-as-directory "c:/temp")) | |
5302 (t (message (concat "Neither `temporary-file-directory' nor " | |
5303 "`temp-directory' is defined -- using /tmp.")) | |
5304 (file-name-as-directory "/tmp")))) | |
5305 | |
5306 (defun tramp-read-passwd (prompt) | |
5307 "Read a password from user (compat function). | |
5308 Invokes `read-passwd' if that is defined, else `ange-ftp-read-passwd'." | |
5309 (apply | |
5310 (if (fboundp 'read-passwd) #'read-passwd #'ange-ftp-read-passwd) | |
5311 (list prompt))) | |
5312 | |
5313 (defun tramp-time-diff (t1 t2) | |
5314 "Return the difference between the two times, in seconds. | |
5315 T1 and T2 are time values (as returned by `current-time' for example). | |
5316 | |
5317 NOTE: This function will fail if the time difference is too large to | |
5318 fit in an integer." | |
5319 ;; Pacify byte-compiler with `symbol-function'. | |
5320 (cond ((fboundp 'subtract-time) | |
5321 (cadr (funcall (symbol-function 'subtract-time) t1 t2))) | |
5322 ((fboundp 'itimer-time-difference) | |
5323 (floor (funcall | |
5324 (symbol-function 'itimer-time-difference) | |
5325 (if (< (length t1) 3) (append t1 '(0)) t1) | |
5326 (if (< (length t2) 3) (append t2 '(0)) t2)))) | |
5327 (t | |
5328 ;; snarfed from Emacs 21 time-date.el | |
5329 (cadr (let ((borrow (< (cadr t1) (cadr t2)))) | |
5330 (list (- (car t1) (car t2) (if borrow 1 0)) | |
5331 (- (+ (if borrow 65536 0) (cadr t1)) (cadr t2)))))))) | |
5332 | |
5333 (defun tramp-coding-system-change-eol-conversion (coding-system eol-type) | |
5334 "Return a coding system like CODING-SYSTEM but with given EOL-TYPE. | |
5335 EOL-TYPE can be one of `dos', `unix', or `mac'." | |
5336 (cond ((fboundp 'coding-system-change-eol-conversion) | |
5337 (apply #'coding-system-change-eol-conversion | |
5338 (list coding-system eol-type))) | |
5339 ((fboundp 'subsidiary-coding-system) | |
5340 (apply | |
5341 #'subsidiary-coding-system | |
5342 (list coding-system | |
5343 (cond ((eq eol-type 'dos) 'crlf) | |
5344 ((eq eol-type 'unix) 'lf) | |
5345 ((eq eol-type 'mac) 'cr) | |
5346 (t | |
5347 (error "Unknown EOL-TYPE `%s', must be %s" | |
5348 eol-type | |
5349 "`dos', `unix', or `mac'")))))) | |
5350 (t (error "Can't change EOL conversion -- is MULE missing?")))) | |
5351 | |
5352 (defun tramp-split-string (string pattern) | |
5353 "Like `split-string' but omit empty strings. | |
5354 In Emacs, (split-string \"/foo/bar\" \"/\") returns (\"foo\" \"bar\"). | |
5355 This is, the first, empty, element is omitted. In XEmacs, the first | |
5356 element is not omitted. | |
5357 | |
5358 Note: this function has been written for `tramp-handle-file-truename'. | |
5359 If you want to use it for something else, you'll have to check whether | |
5360 it does the right thing." | |
5361 (delete "" (split-string string pattern))) | |
5362 | |
5363 ;; ------------------------------------------------------------ | |
5364 ;; -- Kludges section -- | |
5365 ;; ------------------------------------------------------------ | |
5366 | |
5367 ;; Currently (as of Emacs 20.5), the function `shell-quote-argument' | |
5368 ;; does not deal well with newline characters. Newline is replaced by | |
5369 ;; backslash newline. But if, say, the string `a backslash newline b' | |
5370 ;; is passed to a shell, the shell will expand this into "ab", | |
5371 ;; completely omitting the newline. This is not what was intended. | |
5372 ;; It does not appear to be possible to make the function | |
5373 ;; `shell-quote-argument' work with newlines without making it | |
5374 ;; dependent on the shell used. But within this package, we know that | |
5375 ;; we will always use a Bourne-like shell, so we use an approach which | |
5376 ;; groks newlines. | |
5377 ;; | |
5378 ;; The approach is simple: we call `shell-quote-argument', then | |
5379 ;; massage the newline part of the result. | |
5380 ;; | |
5381 ;; This function should produce a string which is grokked by a Unix | |
5382 ;; shell, even if the Emacs is running on Windows. Since this is the | |
5383 ;; kludges section, we bind `system-type' in such a way that | |
5384 ;; `shell-quote-arguments' behaves as if on Unix. | |
5385 ;; | |
5386 ;; Thanks to Mario DeWeerd for the hint that it is sufficient for this | |
5387 ;; function to work with Bourne-like shells. | |
5388 ;; | |
5389 ;; CCC: This function should be rewritten so that | |
5390 ;; `shell-quote-argument' is not used. This way, we are safe from | |
5391 ;; changes in `shell-quote-argument'. | |
5392 (defun tramp-shell-quote-argument (s) | |
5393 "Similar to `shell-quote-argument', but groks newlines. | |
5394 Only works for Bourne-like shells." | |
5395 (let ((system-type 'not-windows)) | |
5396 (save-match-data | |
5397 (let ((result (shell-quote-argument s)) | |
5398 (nl (regexp-quote (format "\\%s" tramp-rsh-end-of-line)))) | |
5399 (when (and (>= (length result) 2) | |
5400 (string= (substring result 0 2) "\\~")) | |
5401 (setq result (substring result 1))) | |
5402 (while (string-match nl result) | |
5403 (setq result (replace-match (format "'%s'" tramp-rsh-end-of-line) | |
5404 t t result))) | |
5405 result)))) | |
5406 | |
5407 ;; ;; EFS hooks itself into the file name handling stuff in more places | |
5408 ;; ;; than just `file-name-handler-alist'. The following tells EFS to stay | |
5409 ;; ;; away from tramp.el paths. | |
5410 ;; ;; | |
5411 ;; ;; This is needed because EFS installs (efs-dired-before-readin) into | |
5412 ;; ;; 'dired-before-readin-hook'. This prevents EFS from opening an FTP | |
5413 ;; ;; connection to help it's dired process. Not that I have any real | |
5414 ;; ;; idea *why* this is helpful to dired. | |
5415 ;; ;; | |
5416 ;; ;; Anyway, this advice fixes the problem (with a sledgehammer :) | |
5417 ;; ;; | |
5418 ;; ;; Daniel Pittman <daniel@danann.net> | |
5419 ;; ;; | |
5420 ;; ;; CCC: when the other defadvice calls have disappeared, make sure | |
5421 ;; ;; not to call defadvice unless it's necessary. How do we find out whether | |
5422 ;; ;; it is necessary? (featurep 'efs) is surely the wrong way -- | |
5423 ;; ;; EFS might nicht be loaded yet. | |
5424 ;; (defadvice efs-ftp-path (around dont-match-tramp-path activate protect) | |
5425 ;; "Cause efs-ftp-path to fail when the path is a TRAMP path." | |
5426 ;; (if (tramp-tramp-file-p (ad-get-arg 0)) | |
5427 ;; nil | |
5428 ;; ad-do-it)) | |
5429 | |
5430 ;; We currently use "[" and "]" in the filename format. In Emacs | |
5431 ;; 20.x, this means that Emacs wants to expand wildcards if | |
5432 ;; `find-file-wildcards' is non-nil, and then barfs because no | |
5433 ;; expansion could be found. We detect this situation and do | |
5434 ;; something really awful: we have `file-expand-wildcards' return the | |
5435 ;; original filename if it can't expand anything. Let's just hope | |
5436 ;; that this doesn't break anything else. | |
5437 ;; | |
5438 ;; Another problem is that the check is done by Emacs version, which | |
5439 ;; is really not what we want to do. Oh, well. | |
5440 | |
5441 ;;(when (and (not (featurep 'xemacs)) | |
5442 ;; (= emacs-major-version 20)) | |
5443 ;; It seems that this advice is needed in Emacs 21, too. | |
5444 (defadvice file-expand-wildcards (around tramp-fix activate) | |
5445 (let ((name (ad-get-arg 0))) | |
5446 (if (tramp-tramp-file-p name) | |
5447 ;; If it's a Tramp file, dissect it and look if wildcards | |
5448 ;; need to be expanded at all. | |
5449 (let ((v (tramp-dissect-file-name name))) | |
5450 (if (string-match "[[*?]" (tramp-file-name-path v)) | |
5451 (let ((res ad-do-it)) | |
5452 (setq ad-return-value (or res (list name)))) | |
5453 (setq ad-return-value (list name)))) | |
5454 ;; If it is not a Tramp file, just run the original function. | |
5455 (let ((res ad-do-it)) | |
5456 (setq ad-return-value (or res (list name))))))) | |
5457 ;; ) | |
5458 | |
46752 | 5459 ;; Tramp version is useful in a number of situations. |
5460 | |
5461 (defun tramp-version (arg) | |
5462 "Print version number of tramp.el in minibuffer or current buffer." | |
5463 (interactive "P") | |
5464 (if arg (insert tramp-version) (message tramp-version))) | |
5465 | |
45861 | 5466 ;; Make the `reporter` functionality available for making bug reports about |
5467 ;; the package. A most useful piece of code. | |
5468 | |
5469 (unless (fboundp 'reporter-submit-bug-report) | |
5470 (autoload 'reporter-submit-bug-report "reporter")) | |
5471 | |
5472 (defun tramp-bug () | |
5473 "Submit a bug report to the TRAMP developers." | |
5474 (interactive) | |
5475 (require 'reporter) | |
5476 (let ((reporter-prompt-for-summary-p t)) | |
5477 (reporter-submit-bug-report | |
5478 tramp-bug-report-address ; to-address | |
5479 (format "tramp (%s)" tramp-version) ; package name and version | |
5480 `(;; Current state | |
5481 tramp-ls-command | |
5482 tramp-test-groks-nt | |
5483 tramp-file-exists-command | |
5484 tramp-current-multi-method | |
5485 tramp-current-method | |
5486 tramp-current-user | |
5487 tramp-current-host | |
5488 | |
5489 ;; System defaults | |
5490 tramp-auto-save-directory ; vars to dump | |
5491 tramp-default-method | |
5492 tramp-rsh-end-of-line | |
5493 tramp-remote-path | |
5494 tramp-login-prompt-regexp | |
5495 tramp-password-prompt-regexp | |
5496 tramp-wrong-passwd-regexp | |
5497 tramp-temp-name-prefix | |
5498 tramp-file-name-structure | |
5499 tramp-file-name-regexp | |
5500 tramp-multi-file-name-structure | |
5501 tramp-multi-file-name-hop-structure | |
5502 tramp-multi-methods | |
5503 tramp-multi-connection-function-alist | |
5504 tramp-make-tramp-file-format | |
5505 tramp-end-of-output | |
5506 | |
5507 ;; Non-tramp variables of interest | |
5508 shell-prompt-pattern | |
5509 backup-by-copying | |
5510 backup-by-copying-when-linked | |
5511 backup-by-copying-when-mismatch | |
5512 ,(when (boundp 'backup-by-copying-when-privileged-mismatch) | |
5513 'backup-by-copying-when-privileged-mismatch) | |
5514 file-name-handler-alist) | |
5515 nil ; pre-hook | |
5516 nil ; post-hook | |
5517 "\ | |
5518 Enter your bug report in this message, including as much detail as you | |
5519 possibly can about the problem, what you did to cause it and what the | |
5520 local and remote machines are. | |
5521 | |
5522 If you can give a simple set of instructions to make this bug happen | |
5523 reliably, please include those. Thank you for helping kill bugs in | |
5524 TRAMP. | |
5525 --bug report follows this line--"))) | |
5526 | |
5527 (defalias 'tramp-submit-bug 'tramp-bug) | |
5528 | |
5529 (provide 'tramp) | |
5530 | |
5531 ;; Make sure that we get integration with the VC package. | |
5532 ;; When it is loaded, we need to pull in the integration module. | |
5533 ;; This must come after (provide 'tramp) because tramp-vc.el | |
5534 ;; requires tramp. | |
5535 (eval-after-load "vc" | |
5536 '(require 'tramp-vc)) | |
5537 | |
5538 ;;; TODO: | |
5539 | |
46009
72200622ada8
(tramp-ftp-method): New user option.
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
45861
diff
changeset
|
5540 ;; * Revise the comments near the beginning of the file. |
45861 | 5541 ;; * Cooperate with PCL-CVS. It uses start-process, which doesn't |
5542 ;; work for remote files. | |
5543 ;; * Rewrite `tramp-shell-quote-argument' to abstain from using | |
5544 ;; `shell-quote-argument'. | |
5545 ;; * Completion gets confused when you leave out the method name. | |
5546 ;; * Support `dired-compress-file' filename handler. | |
5547 ;; * In Emacs 21, `insert-directory' shows total number of bytes used | |
5548 ;; by the files in that directory. Add this here. | |
5549 ;; * Avoid screen blanking when hitting `g' in dired. (Eli Tziperman) | |
5550 ;; * Make ffap.el grok Tramp filenames. (Eli Tziperman) | |
5551 ;; * When logging in, keep looking for questions according to an alist | |
5552 ;; and then invoke the right function. | |
5553 ;; * Case-insensitive filename completion. (Norbert Goevert.) | |
5554 ;; * Running CVS remotely doesn't appear to work right. It thinks | |
5555 ;; files are locked by somebody else even if I'm the locking user. | |
5556 ;; Sometimes, one gets `No CVSROOT specified' errors from CVS. | |
5557 ;; (Skip Montanaro) | |
5558 ;; * Don't use globbing for directories with many files, as this is | |
5559 ;; likely to produce long command lines, and some shells choke on | |
5560 ;; long command lines. | |
5561 ;; * Find out about the new auto-save mechanism in Emacs 21 and | |
5562 ;; do the right thing. | |
5563 ;; * `vc-directory' does not work. It never displays any files, even | |
5564 ;; if it does show files when run locally. | |
5565 ;; * Allow correction of passwords, if the remote end allows this. | |
5566 ;; (Mark Hershberger) | |
5567 ;; * Make sure permissions of tmp file are good. | |
5568 ;; (Nelson Minar <nelson@media.mit.edu>) | |
5569 ;; * Grok passwd prompts with scp? (David Winter | |
5570 ;; <winter@nevis1.nevis.columbia.edu>). Maybe just do `ssh -l user | |
5571 ;; host', then wait a while for the passwd or passphrase prompt. If | |
5572 ;; there is one, remember the passwd/phrase. | |
5573 ;; * How to deal with MULE in `insert-file-contents' and `write-region'? | |
5574 ;; * Do asynchronous `shell-command's. | |
5575 ;; * Grok `append' parameter for `write-region'. | |
5576 ;; * Test remote ksh or bash for tilde expansion in `tramp-find-shell'? | |
5577 ;; * abbreviate-file-name | |
5578 ;; * grok ~ in tramp-remote-path (Henrik Holm <henrikh@tele.ntnu.no>) | |
5579 ;; * `C' in dired gives error `not tramp file name'. | |
5580 ;; * Also allow to omit user names when doing multi-hop. Not sure yet | |
5581 ;; what the user names should default to, though. | |
5582 ;; * better error checking. At least whenever we see something | |
5583 ;; strange when doing zerop, we should kill the process and start | |
5584 ;; again. (Greg Stark) | |
5585 ;; * Add caching for filename completion. (Greg Stark) | |
5586 ;; Of course, this has issues with usability (stale cache bites) | |
5587 ;; -- <daniel@danann.net> | |
5588 ;; * Provide a local cache of old versions of remote files for the rsync | |
5589 ;; transfer method to use. (Greg Stark) | |
5590 ;; * Remove unneeded parameters from methods. | |
5591 ;; * Invoke rsync once for copying a whole directory hierarchy. | |
5592 ;; (Francesco Potort́) | |
5593 ;; * Should we set PATH ourselves or should we rely on the remote end | |
5594 ;; to do it? | |
5595 ;; * Do the autoconf thing. | |
5596 ;; * Make it work for XEmacs 20, which is missing `with-timeout'. | |
5597 ;; * Allow non-Unix remote systems. (More a long-term thing.) | |
5598 ;; * Make it work for different encodings, and for different file name | |
5599 ;; encodings, too. (Daniel Pittman) | |
5600 ;; * Change applicable functions to pass a struct tramp-file-name rather | |
5601 ;; than the individual items MULTI-METHOD, METHOD, USER, HOST, PATH. | |
5602 ;; * Implement asynchronous shell commands. | |
5603 ;; * Clean up unused *tramp/foo* buffers after a while. (Pete Forman) | |
5604 ;; * Progress reports while copying files. (Michael Kifer) | |
5605 ;; * `Smart' connection method that uses inline for small and out of | |
5606 ;; band for large files. (Michael Kifer) | |
5607 ;; * Don't search for perl5 and perl. Instead, only search for perl and | |
5608 ;; then look if it's the right version (with `perl -v'). | |
5609 ;; * When editing a remote CVS controlled file as a different user, VC | |
5610 ;; gets confused about the file locking status. Try to find out why | |
5611 ;; the workaround doesn't work. | |
5612 ;; * When user is running ssh-agent, it would be useful to add the | |
5613 ;; passwords typed by the user to that agent. This way, the next time | |
5614 ;; round, the users don't have to type all this in again. | |
5615 ;; This would be especially useful for start-process, I think. | |
5616 ;; An easy way to implement start-process is to open a second shell | |
5617 ;; connection which is inconvenient if the user has to reenter | |
5618 ;; passwords. | |
5619 ;; * Change `copy-file' to grok the case where the filename handler | |
5620 ;; for the source and the target file are different. Right now, | |
5621 ;; it looks at the source file and then calls that handler, if | |
5622 ;; there is one. But since ange-ftp, for instance, does not know | |
5623 ;; about Tramp, it does not do the right thing if the target file | |
5624 ;; name is a Tramp name. | |
5625 | |
5626 ;; Functions for file-name-handler-alist: | |
5627 ;; diff-latest-backup-file -- in diff.el | |
5628 ;; dired-compress-file | |
5629 ;; dired-uncache -- this will be needed when we do insert-directory caching | |
5630 ;; file-name-as-directory -- use primitive? | |
5631 ;; file-name-directory -- use primitive? | |
5632 ;; file-name-nondirectory -- use primitive? | |
5633 ;; file-name-sans-versions -- use primitive? | |
5634 ;; file-newer-than-file-p | |
5635 ;; find-backup-file-name | |
5636 ;; get-file-buffer -- use primitive | |
5637 ;; load | |
5638 ;; unhandled-file-name-directory | |
5639 ;; vc-registered | |
5640 | |
5641 ;;; tramp.el ends here |