aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2007-10-27 13:57:43 +0000
committerMichael Albinus2007-10-27 13:57:43 +0000
commita4aeb9a424b711c8cfece8700f79d0832c762a99 (patch)
treeb85511b11a01a33b49acf544b2a7ce06e67ed9c1
parent2697297fb56b6e6895d9d428d9797369c7ff3d49 (diff)
downloademacs-a4aeb9a424b711c8cfece8700f79d0832c762a99.tar.gz
emacs-a4aeb9a424b711c8cfece8700f79d0832c762a99.zip
* net/tramp.el (tramp-wrong-passwd-regexp): Tune regexp.
(tramp-get-remote-tmpdir): New defun. (tramp-make-tramp-temp-file): Use it. (tramp-local-call-process): New defun. Replace all calls of `call-process' by this when appropriate. (tramp-handle-write-region): Replace calls of `file-attributes' by `tramp-compat-file-attributes'. (tramp-find-shell, tramp-open-connection-setup-interactive-shell): Make the first command a `tramp-send-command' call, with let-bind of `tramp-end-of-output'. (tramp-version, tramp-bug, tramp-reporter-dump-variable) (tramp-load-report-modules, tramp-append-tramp-buffers): Move to tramp-cmds.el. * net/tramp-fish.el (tramp-fish-handle-copy-file) (tramp-fish-do-copy-or-rename-file) (tramp-fish-do-copy-or-rename-file-directly): * net/tramp-smb.el (tramp-smb-handle-copy-file): Add parameter PRESERVE-UID-GID.
-rw-r--r--lisp/ChangeLog22
-rw-r--r--lisp/net/tramp-cmds.el260
-rw-r--r--lisp/net/tramp-fish.el15
-rw-r--r--lisp/net/tramp-smb.el7
-rw-r--r--lisp/net/tramp.el431
5 files changed, 387 insertions, 348 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index a009176c98a..533f9ebef12 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,25 @@
12007-10-27 Michael Albinus <michael.albinus@gmx.de>
2
3 * net/tramp.el (tramp-wrong-passwd-regexp): Tune regexp.
4 (tramp-get-remote-tmpdir): New defun.
5 (tramp-make-tramp-temp-file): Use it.
6 (tramp-local-call-process): New defun. Replace all calls of
7 `call-process' by this when appropriate.
8 (tramp-handle-write-region): Replace calls of `file-attributes' by
9 `tramp-compat-file-attributes'.
10 (tramp-find-shell, tramp-open-connection-setup-interactive-shell):
11 Make the first command a `tramp-send-command' call, with let-bind
12 of `tramp-end-of-output'.
13 (tramp-version, tramp-bug, tramp-reporter-dump-variable)
14 (tramp-load-report-modules, tramp-append-tramp-buffers): Move to
15 tramp-cmds.el.
16
17 * net/tramp-fish.el (tramp-fish-handle-copy-file)
18 (tramp-fish-do-copy-or-rename-file)
19 (tramp-fish-do-copy-or-rename-file-directly):
20 * net/tramp-smb.el (tramp-smb-handle-copy-file):
21 Add parameter PRESERVE-UID-GID.
22
12007-10-27 Eli Zaretskii <eliz@gnu.org> 232007-10-27 Eli Zaretskii <eliz@gnu.org>
2 24
3 * time.el (zoneinfo-style-world-list, legacy-style-world-list): 25 * time.el (zoneinfo-style-world-list, legacy-style-world-list):
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el
index 72e57799dc4..85ce4a93aa6 100644
--- a/lisp/net/tramp-cmds.el
+++ b/lisp/net/tramp-cmds.el
@@ -125,12 +125,270 @@ This includes password cache, file cache, connection cache, buffers."
125 (dolist (name (tramp-list-remote-buffers)) 125 (dolist (name (tramp-list-remote-buffers))
126 (when (bufferp (get-buffer name)) (kill-buffer name)))) 126 (when (bufferp (get-buffer name)) (kill-buffer name))))
127 127
128;; Tramp version is useful in a number of situations.
129
130(defun tramp-version (arg)
131 "Print version number of tramp.el in minibuffer or current buffer."
132 (interactive "P")
133 (if arg (insert tramp-version) (message tramp-version)))
134
135;; Make the `reporter` functionality available for making bug reports about
136;; the package. A most useful piece of code.
137
138(autoload 'reporter-submit-bug-report "reporter")
139
140(defun tramp-bug ()
141 "Submit a bug report to the Tramp developers."
142 (interactive)
143 (require 'reporter)
144 (catch 'dont-send
145 (let ((reporter-prompt-for-summary-p t))
146 (reporter-submit-bug-report
147 tramp-bug-report-address ; to-address
148 (format "tramp (%s)" tramp-version) ; package name and version
149 (delq nil
150 `(;; Current state
151 tramp-current-method
152 tramp-current-user
153 tramp-current-host
154
155 ;; System defaults
156 tramp-auto-save-directory ; vars to dump
157 tramp-default-method
158 tramp-default-method-alist
159 tramp-default-host
160 tramp-default-proxies-alist
161 tramp-default-user
162 tramp-default-user-alist
163 tramp-rsh-end-of-line
164 tramp-default-password-end-of-line
165 tramp-login-prompt-regexp
166 ;; Mask non-7bit characters
167 (tramp-password-prompt-regexp . tramp-reporter-dump-variable)
168 tramp-wrong-passwd-regexp
169 tramp-yesno-prompt-regexp
170 tramp-yn-prompt-regexp
171 tramp-terminal-prompt-regexp
172 tramp-temp-name-prefix
173 tramp-file-name-structure
174 tramp-file-name-regexp
175 tramp-methods
176 tramp-end-of-output
177 tramp-local-coding-commands
178 tramp-remote-coding-commands
179 tramp-actions-before-shell
180 tramp-actions-copy-out-of-band
181 tramp-terminal-type
182 ;; Mask non-7bit characters
183 (tramp-shell-prompt-pattern . tramp-reporter-dump-variable)
184 ,(when (boundp 'tramp-backup-directory-alist)
185 'tramp-backup-directory-alist)
186 ,(when (boundp 'tramp-bkup-backup-directory-info)
187 'tramp-bkup-backup-directory-info)
188 ;; Dump cache.
189 (tramp-cache-data . tramp-reporter-dump-variable)
190
191 ;; Non-tramp variables of interest
192 ;; Mask non-7bit characters
193 (shell-prompt-pattern . tramp-reporter-dump-variable)
194 backup-by-copying
195 backup-by-copying-when-linked
196 backup-by-copying-when-mismatch
197 ,(when (boundp 'backup-by-copying-when-privileged-mismatch)
198 'backup-by-copying-when-privileged-mismatch)
199 ,(when (boundp 'password-cache)
200 'password-cache)
201 ,(when (boundp 'password-cache-expiry)
202 'password-cache-expiry)
203 ,(when (boundp 'backup-directory-alist)
204 'backup-directory-alist)
205 ,(when (boundp 'bkup-backup-directory-info)
206 'bkup-backup-directory-info)
207 file-name-handler-alist))
208
209 'tramp-load-report-modules ; pre-hook
210 'tramp-append-tramp-buffers ; post-hook
211 "\
212Enter your bug report in this message, including as much detail
213as you possibly can about the problem, what you did to cause it
214and what the local and remote machines are.
215
216If you can give a simple set of instructions to make this bug
217happen reliably, please include those. Thank you for helping
218kill bugs in Tramp.
219
220Another useful thing to do is to put
221
222 (setq tramp-verbose 8)
223
224in the ~/.emacs file and to repeat the bug. Then, include the
225contents of the *tramp/foo* buffer and the *debug tramp/foo*
226buffer in your bug report.
227
228--bug report follows this line--
229"))))
230
231(defun tramp-reporter-dump-variable (varsym mailbuf)
232 "Pretty-print the value of the variable in symbol VARSYM.
233Used for non-7bit chars in strings."
234 (let* ((reporter-eval-buffer (symbol-value 'reporter-eval-buffer))
235 (val (with-current-buffer reporter-eval-buffer
236 (symbol-value varsym))))
237
238 (if (hash-table-p val)
239 ;; Pretty print the cache.
240 (set varsym (read (format "(%s)" (tramp-cache-print val))))
241 ;; There are characters to be masked.
242 (when (and (boundp 'mm-7bit-chars)
243 (string-match
244 (concat "[^" (symbol-value 'mm-7bit-chars) "]") val))
245 (with-current-buffer reporter-eval-buffer
246 (set varsym (format "(base64-decode-string \"%s\""
247 (base64-encode-string val))))))
248
249 ;; Dump variable.
250 (funcall (symbol-function 'reporter-dump-variable) varsym mailbuf)
251
252 (unless (hash-table-p val)
253 ;; Remove string quotation.
254 (forward-line -1)
255 (when (looking-at
256 (concat "\\(^.*\\)" "\"" ;; \1 "
257 "\\((base64-decode-string \\)" "\\\\" ;; \2 \
258 "\\(\".*\\)" "\\\\" ;; \3 \
259 "\\(\")\\)" "\"$")) ;; \4 "
260 (replace-match "\\1\\2\\3\\4")
261 (beginning-of-line)
262 (insert " ;; variable encoded due to non-printable characters\n"))
263 (forward-line 1))
264
265 ;; Reset VARSYM to old value.
266 (with-current-buffer reporter-eval-buffer
267 (set varsym val))))
268
269(defun tramp-load-report-modules ()
270 "Load needed modules for reporting."
271
272 ;; We load message.el and mml.el from Gnus.
273 (if (featurep 'xemacs)
274 (progn
275 (load "message" 'noerror)
276 (load "mml" 'noerror))
277 (require 'message nil 'noerror)
278 (require 'mml nil 'noerror))
279 (when (functionp 'message-mode)
280 (funcall (symbol-function 'message-mode)))
281 (when (functionp 'mml-mode)
282 (funcall (symbol-function 'mml-mode) t)))
283
284(defun tramp-append-tramp-buffers ()
285 "Append Tramp buffers and buffer local variables into the bug report."
286
287 (goto-char (point-max))
288
289 ;; Dump buffer local variables.
290 (dolist (buffer
291 (delq nil
292 (mapcar
293 '(lambda (b)
294 (when (string-match "\\*tramp/" (buffer-name b)) b))
295 (buffer-list))))
296 (let ((reporter-eval-buffer buffer)
297 (buffer-name (buffer-name buffer))
298 (elbuf (get-buffer-create " *tmp-reporter-buffer*")))
299 (with-current-buffer elbuf
300 (emacs-lisp-mode)
301 (erase-buffer)
302 (insert "\n(setq\n")
303 (lisp-indent-line)
304 (funcall (symbol-function 'reporter-dump-variable)
305 'buffer-name (current-buffer))
306 (dolist (varsym-or-cons-cell (buffer-local-variables buffer))
307 (let ((varsym (or (car-safe varsym-or-cons-cell)
308 varsym-or-cons-cell)))
309 (when (string-match "tramp" (symbol-name varsym))
310 (funcall
311 (symbol-function 'reporter-dump-variable)
312 varsym (current-buffer)))))
313 (lisp-indent-line)
314 (insert ")\n"))
315 (insert-buffer-substring elbuf)))
316
317 ;; Append buffers only when we are in message mode.
318 (when (and
319 (eq major-mode 'message-mode)
320 (boundp 'mml-mode)
321 (symbol-value 'mml-mode))
322
323 (let ((tramp-buf-regexp "\\*\\(debug \\)?tramp/")
324 (buffer-list (funcall (symbol-function 'tramp-list-tramp-buffers)))
325 (curbuf (current-buffer)))
326
327 ;; There is at least one Tramp buffer.
328 (when buffer-list
329 (switch-to-buffer (list-buffers-noselect nil))
330 (delete-other-windows)
331 (setq buffer-read-only nil)
332 (goto-char (point-min))
333 (while (not (eobp))
334 (if (re-search-forward
335 tramp-buf-regexp (tramp-compat-line-end-position) t)
336 (forward-line 1)
337 (forward-line 0)
338 (let ((start (point)))
339 (forward-line 1)
340 (kill-region start (point)))))
341 (insert "
342The buffer(s) above will be appended to this message. If you
343don't want to append a buffer because it contains sensitive data,
344or because the buffer is too large, you should delete the
345respective buffer. The buffer(s) will contain user and host
346names. Passwords will never be included there.")
347
348 (when (>= tramp-verbose 6)
349 (insert "\n\n")
350 (let ((start (point)))
351 (insert "\
352Please note that you have set `tramp-verbose' to a value of at
353least 6. Therefore, the contents of files might be included in
354the debug buffer(s).")
355 (add-text-properties start (point) (list 'face 'italic))))
356
357 (set-buffer-modified-p nil)
358 (setq buffer-read-only t)
359 (goto-char (point-min))
360
361 (if (y-or-n-p "Do you want to append the buffer(s)? ")
362 ;; OK, let's send. First we delete the buffer list.
363 (progn
364 (kill-buffer nil)
365 (switch-to-buffer curbuf)
366 (goto-char (point-max))
367 (insert "\n\
368This is a special notion of the `gnus/message' package. If you
369use another mail agent (by copying the contents of this buffer)
370please ensure that the buffers are attached to your email.\n\n")
371 (dolist (buffer buffer-list)
372 (funcall (symbol-function 'mml-insert-empty-tag)
373 'part 'type "text/plain" 'encoding "base64"
374 'disposition "attachment" 'buffer buffer
375 'description buffer))
376 (set-buffer-modified-p nil))
377
378 ;; Don't send. Delete the message buffer.
379 (set-buffer curbuf)
380 (set-buffer-modified-p nil)
381 (kill-buffer nil)
382 (throw 'dont-send nil))))))
383
384(defalias 'tramp-submit-bug 'tramp-bug)
385
128(provide 'tramp-cmds) 386(provide 'tramp-cmds)
129 387
130;;; TODO: 388;;; TODO:
131 389
132;; * Clean up unused *tramp/foo* buffers after a while. (Pete Forman) 390;; * Clean up unused *tramp/foo* buffers after a while. (Pete Forman)
133;; * WIBNI there was an interactive command prompting for tramp 391;; * WIBNI there was an interactive command prompting for Tramp
134;; method, hostname, username and filename and translates the user 392;; method, hostname, username and filename and translates the user
135;; input into the correct filename syntax (depending on the Emacs 393;; input into the correct filename syntax (depending on the Emacs
136;; flavor) (Reiner Steib) 394;; flavor) (Reiner Steib)
diff --git a/lisp/net/tramp-fish.el b/lisp/net/tramp-fish.el
index 7116d144061..95091c276bc 100644
--- a/lisp/net/tramp-fish.el
+++ b/lisp/net/tramp-fish.el
@@ -308,10 +308,10 @@ pass to the OPERATION."
308 v1 'file-error "Error with add-name-to-file %s" newname))))) 308 v1 'file-error "Error with add-name-to-file %s" newname)))))
309 309
310(defun tramp-fish-handle-copy-file 310(defun tramp-fish-handle-copy-file
311 (filename newname &optional ok-if-already-exists keep-date) 311 (filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
312 "Like `copy-file' for Tramp files." 312 "Like `copy-file' for Tramp files."
313 (tramp-fish-do-copy-or-rename-file 313 (tramp-fish-do-copy-or-rename-file
314 'copy filename newname ok-if-already-exists keep-date)) 314 'copy filename newname ok-if-already-exists keep-date preserve-uid-gid))
315 315
316(defun tramp-fish-handle-delete-directory (directory) 316(defun tramp-fish-handle-delete-directory (directory)
317 "Like `delete-directory' for Tramp files." 317 "Like `delete-directory' for Tramp files."
@@ -346,7 +346,7 @@ pass to the OPERATION."
346 ;; Unless NAME is absolute, concat DIR and NAME. 346 ;; Unless NAME is absolute, concat DIR and NAME.
347 (unless (file-name-absolute-p name) 347 (unless (file-name-absolute-p name)
348 (setq name (concat (file-name-as-directory dir) name))) 348 (setq name (concat (file-name-as-directory dir) name)))
349 ;; If NAME is not a tramp file, run the real handler 349 ;; If NAME is not a Tramp file, run the real handler,
350 (if (or (tramp-completion-mode-p) (not (tramp-tramp-file-p name))) 350 (if (or (tramp-completion-mode-p) (not (tramp-tramp-file-p name)))
351 (tramp-drop-volume-letter 351 (tramp-drop-volume-letter
352 (tramp-run-real-handler 'expand-file-name (list name nil))) 352 (tramp-run-real-handler 'expand-file-name (list name nil)))
@@ -835,7 +835,7 @@ target of the symlink differ."
835;; Internal file name functions 835;; Internal file name functions
836 836
837(defun tramp-fish-do-copy-or-rename-file 837(defun tramp-fish-do-copy-or-rename-file
838 (op filename newname &optional ok-if-already-exists keep-date) 838 (op filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
839 "Copy or rename a remote file. 839 "Copy or rename a remote file.
840OP must be `copy' or `rename' and indicates the operation to 840OP must be `copy' or `rename' and indicates the operation to
841perform. FILENAME specifies the file to copy or rename, NEWNAME 841perform. FILENAME specifies the file to copy or rename, NEWNAME
@@ -869,7 +869,7 @@ file names."
869 ;; directly. 869 ;; directly.
870 ((tramp-equal-remote filename newname) 870 ((tramp-equal-remote filename newname)
871 (tramp-fish-do-copy-or-rename-file-directly 871 (tramp-fish-do-copy-or-rename-file-directly
872 op filename newname keep-date)) 872 op filename newname keep-date preserve-uid-gid))
873 ;; No shortcut was possible. So we copy the 873 ;; No shortcut was possible. So we copy the
874 ;; file first. If the operation was `rename', we go 874 ;; file first. If the operation was `rename', we go
875 ;; back and delete the original file (if the copy was 875 ;; back and delete the original file (if the copy was
@@ -899,12 +899,13 @@ file names."
899 (tramp-flush-file-property v (file-name-directory localname))))))) 899 (tramp-flush-file-property v (file-name-directory localname)))))))
900 900
901(defun tramp-fish-do-copy-or-rename-file-directly 901(defun tramp-fish-do-copy-or-rename-file-directly
902 (op filename newname keep-date) 902 (op filename newname keep-date preserve-uid-gid)
903 "Invokes `COPY' or `RENAME' on the remote system. 903 "Invokes `COPY' or `RENAME' on the remote system.
904OP must be one of `copy' or `rename', indicating `cp' or `mv', 904OP must be one of `copy' or `rename', indicating `cp' or `mv',
905respectively. VEC specifies the connection. LOCALNAME1 and 905respectively. VEC specifies the connection. LOCALNAME1 and
906LOCALNAME2 specify the two arguments of `cp' or `mv'. If 906LOCALNAME2 specify the two arguments of `cp' or `mv'. If
907KEEP-DATE is non-nil, preserve the time stamp when copying." 907KEEP-DATE is non-nil, preserve the time stamp when copying.
908PRESERVE-UID-GID is completely ignored."
908 (with-parsed-tramp-file-name filename v1 909 (with-parsed-tramp-file-name filename v1
909 (with-parsed-tramp-file-name newname v2 910 (with-parsed-tramp-file-name newname v2
910 (tramp-fish-send-command 911 (tramp-fish-send-command
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el
index b4e68c77624..c6c064daaf6 100644
--- a/lisp/net/tramp-smb.el
+++ b/lisp/net/tramp-smb.el
@@ -205,9 +205,10 @@ pass to the OPERATION."
205;; File name primitives 205;; File name primitives
206 206
207(defun tramp-smb-handle-copy-file 207(defun tramp-smb-handle-copy-file
208 (filename newname &optional ok-if-already-exists keep-date) 208 (filename newname &optional ok-if-already-exists keep-date preserve-uid-gid)
209 "Like `copy-file' for Tramp files. 209 "Like `copy-file' for Tramp files.
210KEEP-DATE is not handled in case NEWNAME resides on an SMB server." 210KEEP-DATE is not handled in case NEWNAME resides on an SMB server.
211PRESERVE-UID-GID is completely ignored."
211 (setq filename (expand-file-name filename) 212 (setq filename (expand-file-name filename)
212 newname (expand-file-name newname)) 213 newname (expand-file-name newname))
213 214
@@ -574,7 +575,7 @@ Catches errors for shares like \"C$/\", which are common in Microsoft Windows."
574 (with-parsed-tramp-file-name filename nil 575 (with-parsed-tramp-file-name filename nil
575 (unless (eq append nil) 576 (unless (eq append nil)
576 (tramp-error 577 (tramp-error
577 v 'file-error "Cannot append to file using tramp (`%s')" filename)) 578 v 'file-error "Cannot append to file using Tramp (`%s')" filename))
578 ;; XEmacs takes a coding system as the seventh argument, not `confirm'. 579 ;; XEmacs takes a coding system as the seventh argument, not `confirm'.
579 (when (and (not (featurep 'xemacs)) 580 (when (and (not (featurep 'xemacs))
580 confirm (file-exists-p filename)) 581 confirm (file-exists-p filename))
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index b54641b311e..4886c1917aa 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -560,7 +560,7 @@ pair of the form (KEY VALUE). The following KEYs are defined:
560 * `tramp-remote-sh' 560 * `tramp-remote-sh'
561 This specifies the Bourne shell to use on the remote host. This 561 This specifies the Bourne shell to use on the remote host. This
562 MUST be a Bourne-like shell. It is normally not necessary to set 562 MUST be a Bourne-like shell. It is normally not necessary to set
563 this to any value other than \"/bin/sh\": tramp wants to use a shell 563 this to any value other than \"/bin/sh\": Tramp wants to use a shell
564 which groks tilde expansion, but it can search for it. Also note 564 which groks tilde expansion, but it can search for it. Also note
565 that \"/bin/sh\" exists on all Unixen, this might not be true for 565 that \"/bin/sh\" exists on all Unixen, this might not be true for
566 the value that you decide to use. You Have Been Warned. 566 the value that you decide to use. You Have Been Warned.
@@ -972,7 +972,7 @@ The `sudo' program appears to insert a `^@' character into the prompt."
972(defcustom tramp-wrong-passwd-regexp 972(defcustom tramp-wrong-passwd-regexp
973 (concat "^.*" 973 (concat "^.*"
974 ;; These strings should be on the last line 974 ;; These strings should be on the last line
975 (regexp-opt '("Permission denied." 975 (regexp-opt '("Permission denied"
976 "Login incorrect" 976 "Login incorrect"
977 "Login Incorrect" 977 "Login Incorrect"
978 "Connection refused" 978 "Connection refused"
@@ -1117,12 +1117,12 @@ It can have the following values:
1117 ((equal tramp-syntax 'sep) "/[") 1117 ((equal tramp-syntax 'sep) "/[")
1118 ((equal tramp-syntax 'url) "/") 1118 ((equal tramp-syntax 'url) "/")
1119 (t (error "Wrong `tramp-syntax' defined"))) 1119 (t (error "Wrong `tramp-syntax' defined")))
1120 "*String matching the very beginning of tramp file names. 1120 "*String matching the very beginning of Tramp file names.
1121Used in `tramp-make-tramp-file-name'.") 1121Used in `tramp-make-tramp-file-name'.")
1122 1122
1123(defconst tramp-prefix-regexp 1123(defconst tramp-prefix-regexp
1124 (concat "^" (regexp-quote tramp-prefix-format)) 1124 (concat "^" (regexp-quote tramp-prefix-format))
1125 "*Regexp matching the very beginning of tramp file names. 1125 "*Regexp matching the very beginning of Tramp file names.
1126Should always start with \"^\". Derived from `tramp-prefix-format'.") 1126Should always start with \"^\". Derived from `tramp-prefix-format'.")
1127 1127
1128(defconst tramp-method-regexp 1128(defconst tramp-method-regexp
@@ -1214,9 +1214,9 @@ Derived from `tramp-postfix-host-format'.")
1214 2 4 5 7) 1214 2 4 5 7)
1215 1215
1216 "*List of five elements (REGEXP METHOD USER HOST FILE), detailing \ 1216 "*List of five elements (REGEXP METHOD USER HOST FILE), detailing \
1217the tramp file name structure. 1217the Tramp file name structure.
1218 1218
1219The first element REGEXP is a regular expression matching a tramp file 1219The first element REGEXP is a regular expression matching a Tramp file
1220name. The regex should contain parentheses around the method name, 1220name. The regex should contain parentheses around the method name,
1221the user name, the host name, and the file name parts. 1221the user name, the host name, and the file name parts.
1222 1222
@@ -1256,11 +1256,11 @@ See `tramp-file-name-structure' for more explanations.")
1256 ((equal tramp-syntax 'url) tramp-file-name-regexp-url) 1256 ((equal tramp-syntax 'url) tramp-file-name-regexp-url)
1257 (t (error "Wrong `tramp-syntax' defined"))) 1257 (t (error "Wrong `tramp-syntax' defined")))
1258 "*Regular expression matching file names handled by Tramp. 1258 "*Regular expression matching file names handled by Tramp.
1259This regexp should match tramp file names but no other file names. 1259This regexp should match Tramp file names but no other file names.
1260\(When tramp.el is loaded, this regular expression is prepended to 1260\(When tramp.el is loaded, this regular expression is prepended to
1261`file-name-handler-alist', and that is searched sequentially. Thus, 1261`file-name-handler-alist', and that is searched sequentially. Thus,
1262if the tramp entry appears rather early in the `file-name-handler-alist' 1262if the Tramp entry appears rather early in the `file-name-handler-alist'
1263and is a bit too general, then some files might be considered tramp 1263and is a bit too general, then some files might be considered Tramp
1264files which are not really Tramp files. 1264files which are not really Tramp files.
1265 1265
1266Please note that the entry in `file-name-handler-alist' is made when 1266Please note that the entry in `file-name-handler-alist' is made when
@@ -1302,8 +1302,8 @@ See `tramp-file-name-structure' for more explanations.")
1302 ((equal tramp-syntax 'sep) tramp-completion-file-name-regexp-separate) 1302 ((equal tramp-syntax 'sep) tramp-completion-file-name-regexp-separate)
1303 ((equal tramp-syntax 'url) tramp-completion-file-name-regexp-url) 1303 ((equal tramp-syntax 'url) tramp-completion-file-name-regexp-url)
1304 (t (error "Wrong `tramp-syntax' defined"))) 1304 (t (error "Wrong `tramp-syntax' defined")))
1305 "*Regular expression matching file names handled by tramp completion. 1305 "*Regular expression matching file names handled by Tramp completion.
1306This regexp should match partial tramp file names only. 1306This regexp should match partial Tramp file names only.
1307 1307
1308Please note that the entry in `file-name-handler-alist' is made when 1308Please note that the entry in `file-name-handler-alist' is made when
1309this file (tramp.el) is loaded. This means that this variable must be set 1309this file (tramp.el) is loaded. This means that this variable must be set
@@ -1752,7 +1752,7 @@ This is used to map a mode number to a permission string.")
1752 "Alist of handler functions. 1752 "Alist of handler functions.
1753Operations not mentioned here will be handled by the normal Emacs functions.") 1753Operations not mentioned here will be handled by the normal Emacs functions.")
1754 1754
1755;; Handlers for partial tramp file names. For Emacs just 1755;; Handlers for partial Tramp file names. For Emacs just
1756;; `file-name-all-completions' is needed. 1756;; `file-name-all-completions' is needed.
1757;;;###autoload 1757;;;###autoload
1758(defconst tramp-completion-file-name-handler-alist 1758(defconst tramp-completion-file-name-handler-alist
@@ -1815,7 +1815,7 @@ ARGS to actually emit the message (if applicable)."
1815 1815
1816(defsubst tramp-message (vec-or-proc level fmt-string &rest args) 1816(defsubst tramp-message (vec-or-proc level fmt-string &rest args)
1817 "Emit a message depending on verbosity level. 1817 "Emit a message depending on verbosity level.
1818VEC-OR-PROC identifies the tramp buffer to use. It can be either a 1818VEC-OR-PROC identifies the Tramp buffer to use. It can be either a
1819vector or a process. LEVEL says to be quiet if `tramp-verbose' is 1819vector or a process. LEVEL says to be quiet if `tramp-verbose' is
1820less than LEVEL. The message is emitted only if `tramp-verbose' is 1820less than LEVEL. The message is emitted only if `tramp-verbose' is
1821greater than or equal to LEVEL. 1821greater than or equal to LEVEL.
@@ -1966,7 +1966,8 @@ Return the local name of the temporary file."
1966 (tramp-file-name-method vec) 1966 (tramp-file-name-method vec)
1967 (tramp-file-name-user vec) 1967 (tramp-file-name-user vec)
1968 (tramp-file-name-host vec) 1968 (tramp-file-name-host vec)
1969 (expand-file-name tramp-temp-name-prefix "/tmp"))) 1969 (expand-file-name
1970 tramp-temp-name-prefix (tramp-get-remote-tmpdir vec))))
1970 result) 1971 result)
1971 (while (not result) 1972 (while (not result)
1972 ;; `make-temp-file' would be the natural choice for 1973 ;; `make-temp-file' would be the natural choice for
@@ -2017,7 +2018,9 @@ Example:
2017 (if (string-match "^HKEY_CURRENT_USER" (nth 1 (car v))) 2018 (if (string-match "^HKEY_CURRENT_USER" (nth 1 (car v)))
2018 ;; Windows registry. 2019 ;; Windows registry.
2019 (and (memq system-type '(cygwin windows-nt)) 2020 (and (memq system-type '(cygwin windows-nt))
2020 (zerop (call-process "reg" nil nil nil "query" (nth 1 (car v))))) 2021 (zerop
2022 (tramp-local-call-process
2023 "reg" nil nil nil "query" (nth 1 (car v)))))
2021 ;; Configuration file. 2024 ;; Configuration file.
2022 (file-exists-p (nth 1 (car v))))) 2025 (file-exists-p (nth 1 (car v)))))
2023 (setq r (delete (car v) r))) 2026 (setq r (delete (car v) r)))
@@ -2163,7 +2166,7 @@ target of the symlink differ."
2163 (unless nomessage (tramp-message v 0 "Loading %s...done" file)) 2166 (unless nomessage (tramp-message v 0 "Loading %s...done" file))
2164 t))) 2167 t)))
2165 2168
2166;; Localname manipulation functions that grok TRAMP localnames... 2169;; Localname manipulation functions that grok Tramp localnames...
2167(defun tramp-handle-file-name-directory (file) 2170(defun tramp-handle-file-name-directory (file)
2168 "Like `file-name-directory' but aware of Tramp files." 2171 "Like `file-name-directory' but aware of Tramp files."
2169 ;; Everything except the last filename thing is the directory. We 2172 ;; Everything except the last filename thing is the directory. We
@@ -2548,7 +2551,7 @@ of."
2548 ;; We handle also the local part, because in older Emacsen, 2551 ;; We handle also the local part, because in older Emacsen,
2549 ;; without `set-file-times', this function is an alias for this. 2552 ;; without `set-file-times', this function is an alias for this.
2550 ;; We are local, so we don't need the UTC settings. 2553 ;; We are local, so we don't need the UTC settings.
2551 (call-process 2554 (tramp-local-call-process
2552 "touch" nil nil nil "-t" 2555 "touch" nil nil nil "-t"
2553 (format-time-string "%Y%m%d%H%M.%S" time) 2556 (format-time-string "%Y%m%d%H%M.%S" time)
2554 (tramp-shell-quote-argument filename))))) 2557 (tramp-shell-quote-argument filename)))))
@@ -2573,16 +2576,12 @@ and gid of the corresponding user is taken. Both parameters must be integers."
2573 (tramp-shell-quote-argument localname))))) 2576 (tramp-shell-quote-argument localname)))))
2574 2577
2575 ;; We handle also the local part, because there doesn't exist 2578 ;; We handle also the local part, because there doesn't exist
2576 ;; `set-file-uid-gid'. 2579 ;; `set-file-uid-gid'. On Win32 "chown" might not work.
2577 (let ((uid (or (and (integerp uid) uid) (tramp-get-local-uid 'integer))) 2580 (let ((uid (or (and (integerp uid) uid) (tramp-get-local-uid 'integer)))
2578 (gid (or (and (integerp gid) gid) (tramp-get-local-gid 'integer))) 2581 (gid (or (and (integerp gid) gid) (tramp-get-local-gid 'integer))))
2579 (default-directory (tramp-compat-temporary-file-directory))) 2582 (tramp-local-call-process
2580 ;; "chown" might not exist, for example on Win32. 2583 "chown" nil nil nil
2581 (condition-case nil 2584 (format "%d:%d" uid gid) (tramp-shell-quote-argument filename)))))
2582 (call-process
2583 "chown" nil nil nil
2584 (format "%d:%d" uid gid) (tramp-shell-quote-argument filename))
2585 (error nil)))))
2586 2585
2587;; Simple functions using the `test' command. 2586;; Simple functions using the `test' command.
2588 2587
@@ -2897,7 +2896,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
2897 (setq filename (expand-file-name filename)) 2896 (setq filename (expand-file-name filename))
2898 (setq newname (expand-file-name newname)) 2897 (setq newname (expand-file-name newname))
2899 (cond 2898 (cond
2900 ;; At least one file a tramp file? 2899 ;; At least one file a Tramp file?
2901 ((or (tramp-tramp-file-p filename) 2900 ((or (tramp-tramp-file-p filename)
2902 (tramp-tramp-file-p newname)) 2901 (tramp-tramp-file-p newname))
2903 (tramp-do-copy-or-rename-file 2902 (tramp-do-copy-or-rename-file
@@ -2915,10 +2914,10 @@ and gid of the corresponding user is taken. Both parameters must be integers."
2915 (filename newname &optional ok-if-already-exists) 2914 (filename newname &optional ok-if-already-exists)
2916 "Like `rename-file' for Tramp files." 2915 "Like `rename-file' for Tramp files."
2917 ;; Check if both files are local -- invoke normal rename-file. 2916 ;; Check if both files are local -- invoke normal rename-file.
2918 ;; Otherwise, use tramp from local system. 2917 ;; Otherwise, use Tramp from local system.
2919 (setq filename (expand-file-name filename)) 2918 (setq filename (expand-file-name filename))
2920 (setq newname (expand-file-name newname)) 2919 (setq newname (expand-file-name newname))
2921 ;; At least one file a tramp file? 2920 ;; At least one file a Tramp file?
2922 (if (or (tramp-tramp-file-p filename) 2921 (if (or (tramp-tramp-file-p filename)
2923 (tramp-tramp-file-p newname)) 2922 (tramp-tramp-file-p newname))
2924 (tramp-do-copy-or-rename-file 2923 (tramp-do-copy-or-rename-file
@@ -3309,7 +3308,7 @@ be a local filename. The method used must be an out-of-band method."
3309;; Dired. 3308;; Dired.
3310 3309
3311;; CCC: This does not seem to be enough. Something dies when 3310;; CCC: This does not seem to be enough. Something dies when
3312;; we try and delete two directories under TRAMP :/ 3311;; we try and delete two directories under Tramp :/
3313(defun tramp-handle-dired-recursive-delete-directory (filename) 3312(defun tramp-handle-dired-recursive-delete-directory (filename)
3314 "Recursively delete the directory given. 3313 "Recursively delete the directory given.
3315This is like `dired-recursive-delete-directory' for Tramp files." 3314This is like `dired-recursive-delete-directory' for Tramp files."
@@ -3455,7 +3454,7 @@ This is like `dired-recursive-delete-directory' for Tramp files."
3455 "" 3454 ""
3456 (tramp-shell-quote-argument 3455 (tramp-shell-quote-argument
3457 (file-name-nondirectory localname)))))) 3456 (file-name-nondirectory localname))))))
3458 ;; We cannot use `insert-buffer-substring' because the tramp buffer 3457 ;; We cannot use `insert-buffer-substring' because the Tramp buffer
3459 ;; changes its contents before insertion due to calling 3458 ;; changes its contents before insertion due to calling
3460 ;; `expand-file' and alike. 3459 ;; `expand-file' and alike.
3461 (insert 3460 (insert
@@ -3729,6 +3728,20 @@ beginning of local filename are not substituted."
3729 ;; Return exit status. 3728 ;; Return exit status.
3730 ret))) 3729 ret)))
3731 3730
3731(defun tramp-local-call-process
3732 (program &optional infile destination display &rest args)
3733 "Calls `call-process' on the local host.
3734This is needed because for some Emacs flavors Tramp has
3735defadviced `call-process' to behave like `process-file'. The
3736Lisp error raised when PROGRAM is nil is trapped also, returning 1."
3737 (let ((default-directory
3738 (if (file-remote-p default-directory)
3739 (tramp-compat-temporary-file-directory)
3740 default-directory)))
3741 (if (executable-find program)
3742 (apply 'call-process program infile destination display args)
3743 1)))
3744
3732(defun tramp-handle-call-process-region 3745(defun tramp-handle-call-process-region
3733 (start end program &optional delete buffer display &rest args) 3746 (start end program &optional delete buffer display &rest args)
3734 "Like `call-process-region' for Tramp files." 3747 "Like `call-process-region' for Tramp files."
@@ -4052,9 +4065,9 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
4052 (unless (y-or-n-p (format "File %s exists; overwrite anyway? " filename)) 4065 (unless (y-or-n-p (format "File %s exists; overwrite anyway? " filename))
4053 (tramp-error v 'file-error "File not overwritten"))) 4066 (tramp-error v 'file-error "File not overwritten")))
4054 4067
4055 (let ((uid (or (nth 2 (file-attributes filename 'integer)) 4068 (let ((uid (or (nth 2 (tramp-compat-file-attributes filename 'integer))
4056 (tramp-get-remote-uid v 'integer))) 4069 (tramp-get-remote-uid v 'integer)))
4057 (gid (or (nth 3 (file-attributes filename 'integer)) 4070 (gid (or (nth 3 (tramp-compat-file-attributes filename 'integer))
4058 (tramp-get-remote-gid v 'integer)))) 4071 (tramp-get-remote-gid v 'integer))))
4059 4072
4060 (if (and (tramp-local-host-p v) 4073 (if (and (tramp-local-host-p v)
@@ -4173,17 +4186,15 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
4173 (when file-precious-flag 4186 (when file-precious-flag
4174 (erase-buffer) 4187 (erase-buffer)
4175 (and 4188 (and
4176 ;; cksum runs locally 4189 ;; cksum runs locally, if possible.
4177 (let ((default-directory 4190 (zerop (tramp-local-call-process "cksum" tmpfile t))
4178 (tramp-compat-temporary-file-directory))) 4191 ;; cksum runs remotely.
4179 (zerop (call-process "cksum" tmpfile t)))
4180 ;; cksum runs remotely
4181 (zerop 4192 (zerop
4182 (tramp-send-command-and-check 4193 (tramp-send-command-and-check
4183 v 4194 v
4184 (format 4195 (format
4185 "cksum <%s" (tramp-shell-quote-argument localname)))) 4196 "cksum <%s" (tramp-shell-quote-argument localname))))
4186 ;; ... they are different 4197 ;; ... they are different.
4187 (not 4198 (not
4188 (string-equal 4199 (string-equal
4189 (buffer-string) 4200 (buffer-string)
@@ -4367,7 +4378,7 @@ ARGS are the arguments OPERATION has been called with."
4367;;;###autoload 4378;;;###autoload
4368(defun tramp-file-name-handler (operation &rest args) 4379(defun tramp-file-name-handler (operation &rest args)
4369 "Invoke Tramp file name handler. 4380 "Invoke Tramp file name handler.
4370Falls back to normal file name handler if no tramp file name handler exists." 4381Falls back to normal file name handler if no Tramp file name handler exists."
4371 (save-match-data 4382 (save-match-data
4372 (let* ((filename (apply 'tramp-file-name-for-operation operation args)) 4383 (let* ((filename (apply 'tramp-file-name-for-operation operation args))
4373 (completion (tramp-completion-mode-p)) 4384 (completion (tramp-completion-mode-p))
@@ -4433,8 +4444,8 @@ Fall back to normal file name handler if no Tramp handler exists."
4433 4444
4434;;;###autoload 4445;;;###autoload
4435(progn (defun tramp-completion-file-name-handler (operation &rest args) 4446(progn (defun tramp-completion-file-name-handler (operation &rest args)
4436 "Invoke tramp file name completion handler. 4447 "Invoke Tramp file name completion handler.
4437Falls back to normal file name handler if no tramp file name handler exists." 4448Falls back to normal file name handler if no Tramp file name handler exists."
4438;; (setq edebug-trace t) 4449;; (setq edebug-trace t)
4439;; (edebug-trace "%s" (with-output-to-string (backtrace))) 4450;; (edebug-trace "%s" (with-output-to-string (backtrace)))
4440 4451
@@ -4449,7 +4460,7 @@ Falls back to normal file name handler if no tramp file name handler exists."
4449 4460
4450;;;###autoload 4461;;;###autoload
4451(defsubst tramp-register-file-name-handler () 4462(defsubst tramp-register-file-name-handler ()
4452 "Add tramp file name handler to `file-name-handler-alist'." 4463 "Add Tramp file name handler to `file-name-handler-alist'."
4453 ;; Remove autoloaded handler from file name handler alist. Useful, 4464 ;; Remove autoloaded handler from file name handler alist. Useful,
4454 ;; if `tramp-syntax' has been changed. 4465 ;; if `tramp-syntax' has been changed.
4455 (let ((a1 (rassq 'tramp-file-name-handler file-name-handler-alist))) 4466 (let ((a1 (rassq 'tramp-file-name-handler file-name-handler-alist)))
@@ -4472,7 +4483,7 @@ Falls back to normal file name handler if no tramp file name handler exists."
4472 4483
4473;;;###autoload 4484;;;###autoload
4474(defsubst tramp-register-completion-file-name-handler () 4485(defsubst tramp-register-completion-file-name-handler ()
4475 "Add tramp completion file name handler to `file-name-handler-alist'." 4486 "Add Tramp completion file name handler to `file-name-handler-alist'."
4476 ;; Remove autoloaded handler from file name handler alist. Useful, 4487 ;; Remove autoloaded handler from file name handler alist. Useful,
4477 ;; if `tramp-syntax' has been changed. 4488 ;; if `tramp-syntax' has been changed.
4478 (let ((a1 (rassq 4489 (let ((a1 (rassq
@@ -4535,8 +4546,8 @@ should never be set globally, the intention is to let-bind it.")
4535;; risky, because completing a file might require loading other files, 4546;; risky, because completing a file might require loading other files,
4536;; like "~/.netrc", and for them it shouldn't be decided based on that 4547;; like "~/.netrc", and for them it shouldn't be decided based on that
4537;; variable. On the other hand, those files shouldn't have partial 4548;; variable. On the other hand, those files shouldn't have partial
4538;; tramp file name syntax. Maybe another variable should be introduced 4549;; Tramp file name syntax. Maybe another variable should be introduced
4539;; overwriting this check in such cases. Or we change tramp file name 4550;; overwriting this check in such cases. Or we change Tramp file name
4540;; syntax in order to avoid ambiguities, like in XEmacs ... 4551;; syntax in order to avoid ambiguities, like in XEmacs ...
4541(defun tramp-completion-mode-p () 4552(defun tramp-completion-mode-p ()
4542 "Checks whether method / user name / host name completion is active." 4553 "Checks whether method / user name / host name completion is active."
@@ -5037,7 +5048,7 @@ User is always nil."
5037 (let ((default-directory (tramp-compat-temporary-file-directory)) 5048 (let ((default-directory (tramp-compat-temporary-file-directory))
5038 res) 5049 res)
5039 (with-temp-buffer 5050 (with-temp-buffer
5040 (when (zerop (call-process "reg" nil t nil "query" registry)) 5051 (when (zerop (tramp-local-call-process "reg" nil t nil "query" registry))
5041 (goto-char (point-min)) 5052 (goto-char (point-min))
5042 (while (not (eobp)) 5053 (while (not (eobp))
5043 (push (tramp-parse-putty-group registry) res)))) 5054 (push (tramp-parse-putty-group registry) res))))
@@ -5331,11 +5342,9 @@ file exists and nonzero exit status otherwise."
5331 (when extra-args (setq shell (concat shell " " extra-args)))) 5342 (when extra-args (setq shell (concat shell " " extra-args))))
5332 (tramp-message 5343 (tramp-message
5333 vec 5 "Starting remote shell `%s' for tilde expansion..." shell) 5344 vec 5 "Starting remote shell `%s' for tilde expansion..." shell)
5334 (tramp-message 5345 (let ((tramp-end-of-output "$ "))
5335 vec 6 (format "PROMPT_COMMAND='' PS1='$ ' exec %s" shell)) 5346 (tramp-send-command
5336 ;; We just send a string only without checking resulting prompt. 5347 vec (format "PROMPT_COMMAND='' PS1='$ ' exec %s" shell) t))
5337 (tramp-send-string
5338 vec (format "PROMPT_COMMAND='' PS1='$ ' exec %s" shell))
5339 (tramp-message vec 5 "Setting remote shell prompt...") 5348 (tramp-message vec 5 "Setting remote shell prompt...")
5340 ;; Douglas Gray Stephens <DGrayStephens@slb.com> says that we 5349 ;; Douglas Gray Stephens <DGrayStephens@slb.com> says that we
5341 ;; must use "\n" here, not tramp-rsh-end-of-line. Kai left the 5350 ;; must use "\n" here, not tramp-rsh-end-of-line. Kai left the
@@ -5611,16 +5620,14 @@ process to set up. VEC specifies the connection."
5611 ;; called as sh) on startup; this way, we avoid the startup file 5620 ;; called as sh) on startup; this way, we avoid the startup file
5612 ;; clobbering $PS1. $PROMP_COMMAND is another way to set the prompt 5621 ;; clobbering $PS1. $PROMP_COMMAND is another way to set the prompt
5613 ;; in /bin/bash, it must be discarded as well. 5622 ;; in /bin/bash, it must be discarded as well.
5614 (tramp-message 5623 (let ((tramp-end-of-output "$ "))
5615 vec 6 (format "exec env 'ENV=' 'PROMPT_COMMAND=' 'PS1=$ ' %s" 5624 (tramp-send-command
5616 (tramp-get-method-parameter 5625 vec
5617 (tramp-file-name-method vec) 'tramp-remote-sh))) 5626 (format
5618 ;; We just send a string only without checking resulting prompt. 5627 "exec env 'ENV=' 'PROMPT_COMMAND=' 'PS1=$ ' %s"
5619 (tramp-send-string 5628 (tramp-get-method-parameter
5620 vec 5629 (tramp-file-name-method vec) 'tramp-remote-sh))
5621 (format "exec env 'ENV=' 'PROMPT_COMMAND=' 'PS1=$ ' %s" 5630 t))
5622 (tramp-get-method-parameter
5623 (tramp-file-name-method vec) 'tramp-remote-sh)))
5624 (tramp-message vec 5 "Setting shell prompt") 5631 (tramp-message vec 5 "Setting shell prompt")
5625 ;; Douglas Gray Stephens <DGrayStephens@slb.com> says that we must 5632 ;; Douglas Gray Stephens <DGrayStephens@slb.com> says that we must
5626 ;; use "\n" here, not tramp-rsh-end-of-line. 5633 ;; use "\n" here, not tramp-rsh-end-of-line.
@@ -5906,18 +5913,15 @@ INPUT can also be nil which means `/dev/null'.
5906OUTPUT can be a string (which specifies a filename), or t (which 5913OUTPUT can be a string (which specifies a filename), or t (which
5907means standard output and thus the current buffer), or nil (which 5914means standard output and thus the current buffer), or nil (which
5908means discard it)." 5915means discard it)."
5909 (let ((default-directory (tramp-compat-temporary-file-directory))) 5916 (tramp-local-call-process
5910 (call-process 5917 tramp-encoding-shell
5911 tramp-encoding-shell ;program 5918 (when (and input (not (string-match "%s" cmd))) input)
5912 (when (and input (not (string-match "%s" cmd))) 5919 (if (eq output t) t nil)
5913 input) ;input 5920 nil
5914 (if (eq output t) t nil) ;output 5921 tramp-encoding-command-switch
5915 nil ;redisplay 5922 (concat
5916 tramp-encoding-command-switch 5923 (if (string-match "%s" cmd) (format cmd input) cmd)
5917 ;; actual shell command 5924 (if (stringp output) (concat "> " output) ""))))
5918 (concat
5919 (if (string-match "%s" cmd) (format cmd input) cmd)
5920 (if (stringp output) (concat "> " output) "")))))
5921 5925
5922(defun tramp-compute-multi-hops (vec) 5926(defun tramp-compute-multi-hops (vec)
5923 "Expands VEC according to `tramp-default-proxies-alist'. 5927 "Expands VEC according to `tramp-default-proxies-alist'.
@@ -6514,7 +6518,7 @@ Not actually used. Use `(format \"%o\" i)' instead?"
6514 6518
6515 6519
6516;; ------------------------------------------------------------ 6520;; ------------------------------------------------------------
6517;; -- TRAMP file names -- 6521;; -- Tramp file names --
6518;; ------------------------------------------------------------ 6522;; ------------------------------------------------------------
6519;; Conversion functions between external representation and 6523;; Conversion functions between external representation and
6520;; internal data structure. Convenience functions for internal 6524;; internal data structure. Convenience functions for internal
@@ -6558,7 +6562,7 @@ Not actually used. Use `(format \"%o\" i)' instead?"
6558 (string-to-number (match-string 2 host))))) 6562 (string-to-number (match-string 2 host)))))
6559 6563
6560(defun tramp-tramp-file-p (name) 6564(defun tramp-tramp-file-p (name)
6561 "Return t if NAME is a tramp file." 6565 "Return t if NAME is a Tramp file."
6562 (save-match-data 6566 (save-match-data
6563 (string-match tramp-file-name-regexp name))) 6567 (string-match tramp-file-name-regexp name)))
6564 6568
@@ -6608,7 +6612,7 @@ non-nil, the file name parts are not expanded to their default
6608values." 6612values."
6609 (save-match-data 6613 (save-match-data
6610 (let ((match (string-match (nth 0 tramp-file-name-structure) name))) 6614 (let ((match (string-match (nth 0 tramp-file-name-structure) name)))
6611 (unless match (error "Not a tramp file name: %s" name)) 6615 (unless match (error "Not a Tramp file name: %s" name))
6612 (let ((method (match-string (nth 1 tramp-file-name-structure) name)) 6616 (let ((method (match-string (nth 1 tramp-file-name-structure) name))
6613 (user (match-string (nth 2 tramp-file-name-structure) name)) 6617 (user (match-string (nth 2 tramp-file-name-structure) name))
6614 (host (match-string (nth 3 tramp-file-name-structure) name)) 6618 (host (match-string (nth 3 tramp-file-name-structure) name))
@@ -6726,6 +6730,18 @@ necessary only. This function will be used in file name completion."
6726 x)) 6730 x))
6727 remote-path))))) 6731 remote-path)))))
6728 6732
6733(defun tramp-get-remote-tmpdir (vec)
6734 (with-connection-property vec "tmp-directory"
6735 (let ((dir (tramp-shell-quote-argument "/tmp")))
6736 (if (and (zerop
6737 (tramp-send-command-and-check
6738 vec (format "%s -d %s" (tramp-get-test-command vec) dir)))
6739 (zerop
6740 (tramp-send-command-and-check
6741 vec (format "%s -w %s" (tramp-get-test-command vec) dir))))
6742 dir
6743 (tramp-error vec 'file-error "Directory %s not accessible" dir)))))
6744
6729(defun tramp-get-ls-command (vec) 6745(defun tramp-get-ls-command (vec)
6730 (with-connection-property vec "ls" 6746 (with-connection-property vec "ls"
6731 (with-current-buffer (tramp-get-buffer vec) 6747 (with-current-buffer (tramp-get-buffer vec)
@@ -7161,265 +7177,6 @@ Only works for Bourne-like shells."
7161 (add-hook 'tramp-unload-hook 7177 (add-hook 'tramp-unload-hook
7162 '(lambda () (ad-unadvise 'file-expand-wildcards)))) 7178 '(lambda () (ad-unadvise 'file-expand-wildcards))))
7163 7179
7164;; Tramp version is useful in a number of situations.
7165
7166(defun tramp-version (arg)
7167 "Print version number of tramp.el in minibuffer or current buffer."
7168 (interactive "P")
7169 (if arg (insert tramp-version) (message tramp-version)))
7170
7171;; Make the `reporter` functionality available for making bug reports about
7172;; the package. A most useful piece of code.
7173
7174(unless (fboundp 'reporter-submit-bug-report)
7175 (autoload 'reporter-submit-bug-report "reporter"))
7176
7177(defun tramp-bug ()
7178 "Submit a bug report to the TRAMP developers."
7179 (interactive)
7180 (require 'reporter)
7181 (catch 'dont-send
7182 (let ((reporter-prompt-for-summary-p t))
7183 (reporter-submit-bug-report
7184 tramp-bug-report-address ; to-address
7185 (format "tramp (%s)" tramp-version) ; package name and version
7186 (delq nil
7187 `(;; Current state
7188 tramp-current-method
7189 tramp-current-user
7190 tramp-current-host
7191
7192 ;; System defaults
7193 tramp-auto-save-directory ; vars to dump
7194 tramp-default-method
7195 tramp-default-method-alist
7196 tramp-default-host
7197 tramp-default-proxies-alist
7198 tramp-default-user
7199 tramp-default-user-alist
7200 tramp-rsh-end-of-line
7201 tramp-default-password-end-of-line
7202 tramp-login-prompt-regexp
7203 ;; Mask non-7bit characters
7204 (tramp-password-prompt-regexp . tramp-reporter-dump-variable)
7205 tramp-wrong-passwd-regexp
7206 tramp-yesno-prompt-regexp
7207 tramp-yn-prompt-regexp
7208 tramp-terminal-prompt-regexp
7209 tramp-temp-name-prefix
7210 tramp-file-name-structure
7211 tramp-file-name-regexp
7212 tramp-methods
7213 tramp-end-of-output
7214 tramp-local-coding-commands
7215 tramp-remote-coding-commands
7216 tramp-actions-before-shell
7217 tramp-actions-copy-out-of-band
7218 tramp-terminal-type
7219 ;; Mask non-7bit characters
7220 (tramp-shell-prompt-pattern . tramp-reporter-dump-variable)
7221 ,(when (boundp 'tramp-backup-directory-alist)
7222 'tramp-backup-directory-alist)
7223 ,(when (boundp 'tramp-bkup-backup-directory-info)
7224 'tramp-bkup-backup-directory-info)
7225 ;; Dump cache.
7226 (tramp-cache-data . tramp-reporter-dump-variable)
7227
7228 ;; Non-tramp variables of interest
7229 ;; Mask non-7bit characters
7230 (shell-prompt-pattern . tramp-reporter-dump-variable)
7231 backup-by-copying
7232 backup-by-copying-when-linked
7233 backup-by-copying-when-mismatch
7234 ,(when (boundp 'backup-by-copying-when-privileged-mismatch)
7235 'backup-by-copying-when-privileged-mismatch)
7236 ,(when (boundp 'password-cache)
7237 'password-cache)
7238 ,(when (boundp 'password-cache-expiry)
7239 'password-cache-expiry)
7240 ,(when (boundp 'backup-directory-alist)
7241 'backup-directory-alist)
7242 ,(when (boundp 'bkup-backup-directory-info)
7243 'bkup-backup-directory-info)
7244 file-name-handler-alist))
7245
7246 'tramp-load-report-modules ; pre-hook
7247 'tramp-append-tramp-buffers ; post-hook
7248 "\
7249Enter your bug report in this message, including as much detail
7250as you possibly can about the problem, what you did to cause it
7251and what the local and remote machines are.
7252
7253If you can give a simple set of instructions to make this bug
7254happen reliably, please include those. Thank you for helping
7255kill bugs in Tramp.
7256
7257Another useful thing to do is to put
7258
7259 (setq tramp-verbose 8)
7260
7261in the ~/.emacs file and to repeat the bug. Then, include the
7262contents of the *tramp/foo* buffer and the *debug tramp/foo*
7263buffer in your bug report.
7264
7265--bug report follows this line--
7266"))))
7267
7268(defun tramp-reporter-dump-variable (varsym mailbuf)
7269 "Pretty-print the value of the variable in symbol VARSYM.
7270Used for non-7bit chars in strings."
7271 (let* ((reporter-eval-buffer (symbol-value 'reporter-eval-buffer))
7272 (val (with-current-buffer reporter-eval-buffer
7273 (symbol-value varsym))))
7274
7275 (if (hash-table-p val)
7276 ;; Pretty print the cache.
7277 (set varsym (read (format "(%s)" (tramp-cache-print val))))
7278 ;; There are characters to be masked.
7279 (when (and (boundp 'mm-7bit-chars)
7280 (string-match
7281 (concat "[^" (symbol-value 'mm-7bit-chars) "]") val))
7282 (with-current-buffer reporter-eval-buffer
7283 (set varsym (format "(base64-decode-string \"%s\""
7284 (base64-encode-string val))))))
7285
7286 ;; Dump variable.
7287 (funcall (symbol-function 'reporter-dump-variable) varsym mailbuf)
7288
7289 (unless (hash-table-p val)
7290 ;; Remove string quotation.
7291 (forward-line -1)
7292 (when (looking-at
7293 (concat "\\(^.*\\)" "\"" ;; \1 "
7294 "\\((base64-decode-string \\)" "\\\\" ;; \2 \
7295 "\\(\".*\\)" "\\\\" ;; \3 \
7296 "\\(\")\\)" "\"$")) ;; \4 "
7297 (replace-match "\\1\\2\\3\\4")
7298 (beginning-of-line)
7299 (insert " ;; variable encoded due to non-printable characters\n"))
7300 (forward-line 1))
7301
7302 ;; Reset VARSYM to old value.
7303 (with-current-buffer reporter-eval-buffer
7304 (set varsym val))))
7305
7306(defun tramp-load-report-modules ()
7307 "Load needed modules for reporting."
7308
7309 ;; We load message.el and mml.el from Gnus.
7310 (if (featurep 'xemacs)
7311 (progn
7312 (load "message" 'noerror)
7313 (load "mml" 'noerror))
7314 (require 'message nil 'noerror)
7315 (require 'mml nil 'noerror))
7316 (when (functionp 'message-mode)
7317 (funcall (symbol-function 'message-mode)))
7318 (when (functionp 'mml-mode)
7319 (funcall (symbol-function 'mml-mode) t)))
7320
7321(defun tramp-append-tramp-buffers ()
7322 "Append Tramp buffers and buffer local variables into the bug report."
7323
7324 (goto-char (point-max))
7325
7326 ;; Dump buffer local variables.
7327 (dolist (buffer
7328 (delq nil
7329 (mapcar
7330 '(lambda (b)
7331 (when (string-match "\\*tramp/" (buffer-name b)) b))
7332 (buffer-list))))
7333 (let ((reporter-eval-buffer buffer)
7334 (buffer-name (buffer-name buffer))
7335 (elbuf (get-buffer-create " *tmp-reporter-buffer*")))
7336 (with-current-buffer elbuf
7337 (emacs-lisp-mode)
7338 (erase-buffer)
7339 (insert "\n(setq\n")
7340 (lisp-indent-line)
7341 (funcall (symbol-function 'reporter-dump-variable)
7342 'buffer-name (current-buffer))
7343 (dolist (varsym-or-cons-cell (buffer-local-variables buffer))
7344 (let ((varsym (or (car-safe varsym-or-cons-cell)
7345 varsym-or-cons-cell)))
7346 (when (string-match "tramp" (symbol-name varsym))
7347 (funcall
7348 (symbol-function 'reporter-dump-variable)
7349 varsym (current-buffer)))))
7350 (lisp-indent-line)
7351 (insert ")\n"))
7352 (insert-buffer-substring elbuf)))
7353
7354 ;; Append buffers only when we are in message mode.
7355 (when (and
7356 (eq major-mode 'message-mode)
7357 (boundp 'mml-mode)
7358 (symbol-value 'mml-mode))
7359
7360 (let ((tramp-buf-regexp "\\*\\(debug \\)?tramp/")
7361 (buffer-list (funcall (symbol-function 'tramp-list-tramp-buffers)))
7362 (curbuf (current-buffer)))
7363
7364 ;; There is at least one Tramp buffer.
7365 (when buffer-list
7366 (switch-to-buffer (list-buffers-noselect nil))
7367 (delete-other-windows)
7368 (setq buffer-read-only nil)
7369 (goto-char (point-min))
7370 (while (not (eobp))
7371 (if (re-search-forward
7372 tramp-buf-regexp (tramp-compat-line-end-position) t)
7373 (forward-line 1)
7374 (forward-line 0)
7375 (let ((start (point)))
7376 (forward-line 1)
7377 (kill-region start (point)))))
7378 (insert "
7379The buffer(s) above will be appended to this message. If you
7380don't want to append a buffer because it contains sensitive data,
7381or because the buffer is too large, you should delete the
7382respective buffer. The buffer(s) will contain user and host
7383names. Passwords will never be included there.")
7384
7385 (when (>= tramp-verbose 6)
7386 (insert "\n\n")
7387 (let ((start (point)))
7388 (insert "\
7389Please note that you have set `tramp-verbose' to a value of at
7390least 6. Therefore, the contents of files might be included in
7391the debug buffer(s).")
7392 (add-text-properties start (point) (list 'face 'italic))))
7393
7394 (set-buffer-modified-p nil)
7395 (setq buffer-read-only t)
7396 (goto-char (point-min))
7397
7398 (if (y-or-n-p "Do you want to append the buffer(s)? ")
7399 ;; OK, let's send. First we delete the buffer list.
7400 (progn
7401 (kill-buffer nil)
7402 (switch-to-buffer curbuf)
7403 (goto-char (point-max))
7404 (insert "\n\
7405This is a special notion of the `gnus/message' package. If you
7406use another mail agent (by copying the contents of this buffer)
7407please ensure that the buffers are attached to your email.\n\n")
7408 (dolist (buffer buffer-list)
7409 (funcall (symbol-function 'mml-insert-empty-tag)
7410 'part 'type "text/plain" 'encoding "base64"
7411 'disposition "attachment" 'buffer buffer
7412 'description buffer))
7413 (set-buffer-modified-p nil))
7414
7415 ;; Don't send. Delete the message buffer.
7416 (set-buffer curbuf)
7417 (set-buffer-modified-p nil)
7418 (kill-buffer nil)
7419 (throw 'dont-send nil))))))
7420
7421(defalias 'tramp-submit-bug 'tramp-bug)
7422
7423;; Checklist for `tramp-unload-hook' 7180;; Checklist for `tramp-unload-hook'
7424;; - Unload all `tramp-*' packages 7181;; - Unload all `tramp-*' packages
7425;; - Reset `file-name-handler-alist' 7182;; - Reset `file-name-handler-alist'
@@ -7521,7 +7278,7 @@ please ensure that the buffers are attached to your email.\n\n")
7521;; having the possibility of passing a local file there to a local 7278;; having the possibility of passing a local file there to a local
7522;; Emacs session (in case I can arrange for a connection back) would 7279;; Emacs session (in case I can arrange for a connection back) would
7523;; be nice. 7280;; be nice.
7524;; Likely the corresponding tramp server should not allow the 7281;; Likely the corresponding Tramp server should not allow the
7525;; equivalent of the emacsclient -eval option in order to make this 7282;; equivalent of the emacsclient -eval option in order to make this
7526;; reasonably unproblematic. And maybe trampclient should have some 7283;; reasonably unproblematic. And maybe trampclient should have some
7527;; way of passing credentials, like by using an SSL socket or 7284;; way of passing credentials, like by using an SSL socket or