aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2009-08-28 12:11:58 +0000
committerMichael Albinus2009-08-28 12:11:58 +0000
commitaa485f7ca58bcf9ed4fc9ee5999334028c16ba9f (patch)
tree057afb10ce4083b7ed3ce4792ca208ad58748823
parent7e3242e4fc8819ece649aeac9a6db169ddd8f7be (diff)
downloademacs-aa485f7ca58bcf9ed4fc9ee5999334028c16ba9f.tar.gz
emacs-aa485f7ca58bcf9ed4fc9ee5999334028c16ba9f.zip
* net/tramp.el (all): Replace "'(lambda" by "(lambda".
(tramp-handle-file-local-copy): Unset `file-name-handler-alist' when writing the temp file. Otherwise, epa-file gets confused. (tramp-register-file-name-handlers): Make it a defun. Move also `epa-file-handler' to the front of `file-name-handler-alist'. * net/tramp.el (tramp-shell-prompt-pattern): Allow a prompt to start right after a ^M. (tramp-root-regexp, tramp-completion-file-name-regexp-unified) (tramp-completion-file-name-regexp-separate) (tramp-completion-file-name-regexp-url): Use \\` and \\'. (tramp-handle-file-attributes, tramp-set-file-uid-gid): Don't modify last-coding-system-used by accident. (tramp-completion-file-name-handler): Apply the checks here, instead during registration. (tramp-register-file-name-handlers) Renamed from `tramp-register-file-name-handler'. Register both `tramp-file-name-handler' and `tramp-completion-file-name-handler'. (tramp-register-completion-file-name-handler): Removed.
-rw-r--r--lisp/ChangeLog24
-rw-r--r--lisp/net/tramp.el365
2 files changed, 203 insertions, 186 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 1195dcf732f..9ef8712df1b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,27 @@
12009-08-28 Michael Albinus <michael.albinus@gmx.de>
2
3 * net/tramp.el (all): Replace "'(lambda" by "(lambda".
4 (tramp-handle-file-local-copy): Unset `file-name-handler-alist'
5 when writing the temp file. Otherwise, epa-file gets confused.
6 (tramp-register-file-name-handlers): Make it a defun. Move also
7 `epa-file-handler' to the front of `file-name-handler-alist'.
8
92009-08-28 Stefan Monnier <monnier@iro.umontreal.ca>
10
11 * net/tramp.el (tramp-shell-prompt-pattern): Allow a prompt to
12 start right after a ^M.
13 (tramp-root-regexp, tramp-completion-file-name-regexp-unified)
14 (tramp-completion-file-name-regexp-separate)
15 (tramp-completion-file-name-regexp-url): Use \\` and \\'.
16 (tramp-handle-file-attributes, tramp-set-file-uid-gid): Don't
17 modify last-coding-system-used by accident.
18 (tramp-completion-file-name-handler): Apply the checks here,
19 instead during registration.
20 (tramp-register-file-name-handlers) Renamed from
21 `tramp-register-file-name-handler'. Register both
22 `tramp-file-name-handler' and `tramp-completion-file-name-handler'.
23 (tramp-register-completion-file-name-handler): Removed.
24
12009-08-28 Nick Roberts <nickrob@snap.net.nz> 252009-08-28 Nick Roberts <nickrob@snap.net.nz>
2 26
3 * progmodes/gdb-mi.el (gdb-use-separate-io-buffer): Remove 27 * progmodes/gdb-mi.el (gdb-use-separate-io-buffer): Remove
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 8453f678acc..1b389422296 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -69,15 +69,15 @@
69;; The Tramp version number and bug report address, as prepared by configure. 69;; The Tramp version number and bug report address, as prepared by configure.
70(require 'trampver) 70(require 'trampver)
71(add-hook 'tramp-unload-hook 71(add-hook 'tramp-unload-hook
72 '(lambda () 72 (lambda ()
73 (when (featurep 'trampver) 73 (when (featurep 'trampver)
74 (unload-feature 'trampver 'force)))) 74 (unload-feature 'trampver 'force))))
75 75
76(require 'tramp-compat) 76(require 'tramp-compat)
77(add-hook 'tramp-unload-hook 77(add-hook 'tramp-unload-hook
78 '(lambda () 78 (lambda ()
79 (when (featurep 'tramp-compat) 79 (when (featurep 'tramp-compat)
80 (unload-feature 'tramp-compat 'force)))) 80 (unload-feature 'tramp-compat 'force))))
81 81
82(require 'format-spec) ; from Gnus 5.8, also in tar ball 82(require 'format-spec) ; from Gnus 5.8, also in tar ball
83;; As long as password.el is not part of (X)Emacs, it shouldn't 83;; As long as password.el is not part of (X)Emacs, it shouldn't
@@ -105,16 +105,16 @@
105(autoload 'tramp-flush-connection-property "tramp-cache") 105(autoload 'tramp-flush-connection-property "tramp-cache")
106(autoload 'tramp-parse-connection-properties "tramp-cache") 106(autoload 'tramp-parse-connection-properties "tramp-cache")
107(add-hook 'tramp-unload-hook 107(add-hook 'tramp-unload-hook
108 '(lambda () 108 (lambda ()
109 (when (featurep 'tramp-cache) 109 (when (featurep 'tramp-cache)
110 (unload-feature 'tramp-cache 'force)))) 110 (unload-feature 'tramp-cache 'force))))
111 111
112(autoload 'tramp-uuencode-region "tramp-uu" 112(autoload 'tramp-uuencode-region "tramp-uu"
113 "Implementation of `uuencode' in Lisp.") 113 "Implementation of `uuencode' in Lisp.")
114(add-hook 'tramp-unload-hook 114(add-hook 'tramp-unload-hook
115 '(lambda () 115 (lambda ()
116 (when (featurep 'tramp-uu) 116 (when (featurep 'tramp-uu)
117 (unload-feature 'tramp-uu 'force)))) 117 (unload-feature 'tramp-uu 'force))))
118 118
119(autoload 'uudecode-decode-region "uudecode") 119(autoload 'uudecode-decode-region "uudecode")
120 120
@@ -1004,7 +1004,9 @@ Sometimes the prompt is reported to look like \"login as:\"."
1004 :type 'regexp) 1004 :type 'regexp)
1005 1005
1006(defcustom tramp-shell-prompt-pattern 1006(defcustom tramp-shell-prompt-pattern
1007 "^[^#$%>\n]*[#$%>] *\\(\e\\[[0-9;]*[a-zA-Z] *\\)*" 1007 ;; Allow a prompt to start right after a ^M since it indeed would be
1008 ;; displayed at the beginning of the line (and Zsh uses it).
1009 "\\(?:^\\| \\)[^#$%>\n]*[#$%>] *\\(\e\\[[0-9;]*[a-zA-Z] *\\)*"
1008 "Regexp to match prompts from remote shell. 1010 "Regexp to match prompts from remote shell.
1009Normally, Tramp expects you to configure `shell-prompt-pattern' 1011Normally, Tramp expects you to configure `shell-prompt-pattern'
1010correctly, but sometimes it happens that you are connecting to a 1012correctly, but sometimes it happens that you are connecting to a
@@ -1386,29 +1388,29 @@ Also see `tramp-file-name-structure'.")
1386;;;###autoload 1388;;;###autoload
1387(defconst tramp-root-regexp 1389(defconst tramp-root-regexp
1388 (if (memq system-type '(cygwin windows-nt)) 1390 (if (memq system-type '(cygwin windows-nt))
1389 "^\\([a-zA-Z]:\\)?/" 1391 "\\`\\([a-zA-Z]:\\)?/"
1390 "^/") 1392 "\\`/")
1391 "Beginning of an incomplete Tramp file name. 1393 "Beginning of an incomplete Tramp file name.
1392Usually, it is just \"^/\". On W32 systems, there might be a 1394Usually, it is just \"\\\\`/\". On W32 systems, there might be a
1393volume letter, which will be removed by `tramp-drop-volume-letter'.") 1395volume letter, which will be removed by `tramp-drop-volume-letter'.")
1394 1396
1395;;;###autoload 1397;;;###autoload
1396(defconst tramp-completion-file-name-regexp-unified 1398(defconst tramp-completion-file-name-regexp-unified
1397 (concat tramp-root-regexp "[^/]*$") 1399 (concat tramp-root-regexp "[^/]*\\'")
1398 "Value for `tramp-completion-file-name-regexp' for unified remoting. 1400 "Value for `tramp-completion-file-name-regexp' for unified remoting.
1399GNU Emacs uses a unified filename syntax for Tramp and Ange-FTP. 1401GNU Emacs uses a unified filename syntax for Tramp and Ange-FTP.
1400See `tramp-file-name-structure' for more explanations.") 1402See `tramp-file-name-structure' for more explanations.")
1401 1403
1402;;;###autoload 1404;;;###autoload
1403(defconst tramp-completion-file-name-regexp-separate 1405(defconst tramp-completion-file-name-regexp-separate
1404 (concat tramp-root-regexp "\\([[][^]]*\\)?$") 1406 (concat tramp-root-regexp "\\([[][^]]*\\)?\\'")
1405 "Value for `tramp-completion-file-name-regexp' for separate remoting. 1407 "Value for `tramp-completion-file-name-regexp' for separate remoting.
1406XEmacs uses a separate filename syntax for Tramp and EFS. 1408XEmacs uses a separate filename syntax for Tramp and EFS.
1407See `tramp-file-name-structure' for more explanations.") 1409See `tramp-file-name-structure' for more explanations.")
1408 1410
1409;;;###autoload 1411;;;###autoload
1410(defconst tramp-completion-file-name-regexp-url 1412(defconst tramp-completion-file-name-regexp-url
1411 (concat tramp-root-regexp "[^/:]+\\(:\\(/\\(/[^/]*\\)?\\)?\\)?$") 1413 (concat tramp-root-regexp "[^/:]+\\(:\\(/\\(/[^/]*\\)?\\)?\\)?\\'")
1412 "Value for `tramp-completion-file-name-regexp' for URL-like remoting. 1414 "Value for `tramp-completion-file-name-regexp' for URL-like remoting.
1413See `tramp-file-name-structure' for more explanations.") 1415See `tramp-file-name-structure' for more explanations.")
1414 1416
@@ -2240,9 +2242,9 @@ special handling of `substitute-in-file-name'."
2240 (add-hook 'rfn-eshadow-setup-minibuffer-hook 2242 (add-hook 'rfn-eshadow-setup-minibuffer-hook
2241 'tramp-rfn-eshadow-setup-minibuffer) 2243 'tramp-rfn-eshadow-setup-minibuffer)
2242 (add-hook 'tramp-unload-hook 2244 (add-hook 'tramp-unload-hook
2243 '(lambda () 2245 (lambda ()
2244 (remove-hook 'rfn-eshadow-setup-minibuffer-hook 2246 (remove-hook 'rfn-eshadow-setup-minibuffer-hook
2245 'tramp-rfn-eshadow-setup-minibuffer)))) 2247 'tramp-rfn-eshadow-setup-minibuffer))))
2246 2248
2247(defconst tramp-rfn-eshadow-update-overlay-regexp 2249(defconst tramp-rfn-eshadow-update-overlay-regexp
2248 (format "[^%s/~]*\\(/\\|~\\)" tramp-postfix-host-format)) 2250 (format "[^%s/~]*\\(/\\|~\\)" tramp-postfix-host-format))
@@ -2498,19 +2500,23 @@ target of the symlink differ."
2498(defun tramp-handle-file-attributes (filename &optional id-format) 2500(defun tramp-handle-file-attributes (filename &optional id-format)
2499 "Like `file-attributes' for Tramp files." 2501 "Like `file-attributes' for Tramp files."
2500 (unless id-format (setq id-format 'integer)) 2502 (unless id-format (setq id-format 'integer))
2501 (with-parsed-tramp-file-name (expand-file-name filename) nil 2503 ;; Don't modify `last-coding-system-used' by accident.
2502 (with-file-property v localname (format "file-attributes-%s" id-format) 2504 (let ((last-coding-system-used last-coding-system-used))
2503 (when (file-exists-p filename) 2505 (with-parsed-tramp-file-name (expand-file-name filename) nil
2504 ;; file exists, find out stuff 2506 (with-file-property v localname (format "file-attributes-%s" id-format)
2505 (save-excursion 2507 (when (file-exists-p filename)
2506 (tramp-convert-file-attributes 2508 ;; file exists, find out stuff
2507 v 2509 (save-excursion
2508 (if (tramp-get-remote-stat v) 2510 (tramp-convert-file-attributes
2509 (tramp-handle-file-attributes-with-stat v localname id-format) 2511 v
2510 (if (tramp-get-remote-perl v) 2512 (if (tramp-get-remote-stat v)
2511 (tramp-handle-file-attributes-with-perl v localname id-format) 2513 (tramp-handle-file-attributes-with-stat
2512 (tramp-handle-file-attributes-with-ls 2514 v localname id-format)
2513 v localname id-format))))))))) 2515 (if (tramp-get-remote-perl v)
2516 (tramp-handle-file-attributes-with-perl
2517 v localname id-format)
2518 (tramp-handle-file-attributes-with-ls
2519 v localname id-format))))))))))
2514 2520
2515(defun tramp-handle-file-attributes-with-ls (vec localname &optional id-format) 2521(defun tramp-handle-file-attributes-with-ls (vec localname &optional id-format)
2516 "Implement `file-attributes' for Tramp files using the ls(1) command." 2522 "Implement `file-attributes' for Tramp files using the ls(1) command."
@@ -2763,27 +2769,29 @@ and gid of the corresponding user is taken. Both parameters must be integers."
2763 ;; another implementation, see `dired-do-chown'. OTOH, it is mostly 2769 ;; another implementation, see `dired-do-chown'. OTOH, it is mostly
2764 ;; working with su(do)? when it is needed, so it shall succeed in 2770 ;; working with su(do)? when it is needed, so it shall succeed in
2765 ;; the majority of cases. 2771 ;; the majority of cases.
2766 (if (file-remote-p filename) 2772 ;; Don't modify `last-coding-system-used' by accident.
2767 (with-parsed-tramp-file-name filename nil 2773 (let ((last-coding-system-used last-coding-system-used))
2768 (if (and (zerop (user-uid)) (tramp-local-host-p v)) 2774 (if (file-remote-p filename)
2769 ;; If we are root on the local host, we can do it directly. 2775 (with-parsed-tramp-file-name filename nil
2770 (tramp-set-file-uid-gid localname uid gid) 2776 (if (and (zerop (user-uid)) (tramp-local-host-p v))
2771 (let ((uid (or (and (integerp uid) uid) 2777 ;; If we are root on the local host, we can do it directly.
2772 (tramp-get-remote-uid v 'integer))) 2778 (tramp-set-file-uid-gid localname uid gid)
2773 (gid (or (and (integerp gid) gid) 2779 (let ((uid (or (and (integerp uid) uid)
2774 (tramp-get-remote-gid v 'integer)))) 2780 (tramp-get-remote-uid v 'integer)))
2775 (tramp-send-command 2781 (gid (or (and (integerp gid) gid)
2776 v (format 2782 (tramp-get-remote-gid v 'integer))))
2777 "chown %d:%d %s" uid gid 2783 (tramp-send-command
2778 (tramp-shell-quote-argument localname)))))) 2784 v (format
2779 2785 "chown %d:%d %s" uid gid
2780 ;; We handle also the local part, because there doesn't exist 2786 (tramp-shell-quote-argument localname))))))
2781 ;; `set-file-uid-gid'. On W32 "chown" might not work. 2787
2782 (let ((uid (or (and (integerp uid) uid) (tramp-get-local-uid 'integer))) 2788 ;; We handle also the local part, because there doesn't exist
2783 (gid (or (and (integerp gid) gid) (tramp-get-local-gid 'integer)))) 2789 ;; `set-file-uid-gid'. On W32 "chown" might not work.
2784 (tramp-local-call-process 2790 (let ((uid (or (and (integerp uid) uid) (tramp-get-local-uid 'integer)))
2785 "chown" nil nil nil 2791 (gid (or (and (integerp gid) gid) (tramp-get-local-gid 'integer))))
2786 (format "%d:%d" uid gid) (tramp-shell-quote-argument filename))))) 2792 (tramp-local-call-process
2793 "chown" nil nil nil
2794 (format "%d:%d" uid gid) (tramp-shell-quote-argument filename))))))
2787 2795
2788;; Simple functions using the `test' command. 2796;; Simple functions using the `test' command.
2789 2797
@@ -2957,9 +2965,9 @@ value of `default-file-modes', without execute permissions."
2957 (format "directory-files-and-attributes-%s" id-format) 2965 (format "directory-files-and-attributes-%s" id-format)
2958 (save-excursion 2966 (save-excursion
2959 (mapcar 2967 (mapcar
2960 '(lambda (x) 2968 (lambda (x)
2961 (cons (car x) 2969 (cons (car x)
2962 (tramp-convert-file-attributes v (cdr x)))) 2970 (tramp-convert-file-attributes v (cdr x))))
2963 (if (tramp-get-remote-stat v) 2971 (if (tramp-get-remote-stat v)
2964 (tramp-handle-directory-files-and-attributes-with-stat 2972 (tramp-handle-directory-files-and-attributes-with-stat
2965 v localname id-format) 2973 v localname id-format)
@@ -3484,20 +3492,20 @@ The method used must be an out-of-band method."
3484 (delq 3492 (delq
3485 nil 3493 nil
3486 (mapcar 3494 (mapcar
3487 '(lambda (x) 3495 (lambda (x)
3488 (setq 3496 (setq
3489 x 3497 x
3490 ;; " " is indication for keep-date argument. 3498 ;; " " is indication for keep-date argument.
3491 (delete " " (mapcar '(lambda (y) (format-spec y spec)) x))) 3499 (delete " " (mapcar (lambda (y) (format-spec y spec)) x)))
3492 (unless (member "" x) (mapconcat 'identity x " "))) 3500 (unless (member "" x) (mapconcat 'identity x " ")))
3493 (tramp-get-method-parameter method 'tramp-copy-args))) 3501 (tramp-get-method-parameter method 'tramp-copy-args)))
3494 copy-env 3502 copy-env
3495 (delq 3503 (delq
3496 nil 3504 nil
3497 (mapcar 3505 (mapcar
3498 '(lambda (x) 3506 (lambda (x)
3499 (setq x (mapcar '(lambda (y) (format-spec y spec)) x)) 3507 (setq x (mapcar (lambda (y) (format-spec y spec)) x))
3500 (unless (member "" x) (mapconcat 'identity x " "))) 3508 (unless (member "" x) (mapconcat 'identity x " ")))
3501 (tramp-get-method-parameter method 'tramp-copy-env)))) 3509 (tramp-get-method-parameter method 'tramp-copy-env))))
3502 3510
3503 ;; Check for program. 3511 ;; Check for program.
@@ -3632,10 +3640,10 @@ This is like `dired-recursive-delete-directory' for Tramp files."
3632 ;; XEmacs has `dired-compression-method-alist', which is 3640 ;; XEmacs has `dired-compression-method-alist', which is
3633 ;; transformed into `dired-compress-file-suffixes' structure. 3641 ;; transformed into `dired-compress-file-suffixes' structure.
3634 (mapcar 3642 (mapcar
3635 '(lambda (x) 3643 (lambda (x)
3636 (list (concat (regexp-quote (nth 1 x)) "\\'") 3644 (list (concat (regexp-quote (nth 1 x)) "\\'")
3637 nil 3645 nil
3638 (mapconcat 'identity (nth 3 x) " "))) 3646 (mapconcat 'identity (nth 3 x) " ")))
3639 (symbol-value 'dired-compression-method-alist)))) 3647 (symbol-value 'dired-compression-method-alist))))
3640 suffix) 3648 suffix)
3641 ;; See if any suffix rule matches this file name. 3649 ;; See if any suffix rule matches this file name.
@@ -3896,21 +3904,21 @@ beginning of local filename are not substituted."
3896;; which calls corresponding functions (see minibuf.el). 3904;; which calls corresponding functions (see minibuf.el).
3897(when (fboundp 'minibuffer-electric-separator) 3905(when (fboundp 'minibuffer-electric-separator)
3898 (mapc 3906 (mapc
3899 '(lambda (x) 3907 (lambda (x)
3900 (eval 3908 (eval
3901 `(defadvice ,x 3909 `(defadvice ,x
3902 (around ,(intern (format "tramp-advice-%s" x)) activate) 3910 (around ,(intern (format "tramp-advice-%s" x)) activate)
3903 "Invoke `substitute-in-file-name' for Tramp files." 3911 "Invoke `substitute-in-file-name' for Tramp files."
3904 (if (and (symbol-value 'minibuffer-electric-file-name-behavior) 3912 (if (and (symbol-value 'minibuffer-electric-file-name-behavior)
3905 (tramp-tramp-file-p (buffer-substring))) 3913 (tramp-tramp-file-p (buffer-substring)))
3906 ;; We don't need to handle `last-input-event', because 3914 ;; We don't need to handle `last-input-event', because
3907 ;; due to the key map we know it must be ?/ or ?~. 3915 ;; due to the key map we know it must be ?/ or ?~.
3908 (let ((s (concat (buffer-substring (point-min) (point)) 3916 (let ((s (concat (buffer-substring (point-min) (point))
3909 (string last-command-char)))) 3917 (string last-command-char))))
3910 (delete-region (point-min) (point)) 3918 (delete-region (point-min) (point))
3911 (insert (substitute-in-file-name s)) 3919 (insert (substitute-in-file-name s))
3912 (setq ad-return-value last-command-char)) 3920 (setq ad-return-value last-command-char))
3913 ad-do-it)))) 3921 ad-do-it))))
3914 3922
3915 '(minibuffer-electric-separator 3923 '(minibuffer-electric-separator
3916 minibuffer-electric-tilde))) 3924 minibuffer-electric-tilde)))
@@ -4238,13 +4246,19 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1."
4238 v 5 "Decoding remote file %s with function %s..." 4246 v 5 "Decoding remote file %s with function %s..."
4239 filename loc-dec) 4247 filename loc-dec)
4240 (funcall loc-dec (point-min) (point-max)) 4248 (funcall loc-dec (point-min) (point-max))
4241 (let ((coding-system-for-write 'binary)) 4249 ;; Unset `file-name-handler-alist'. Otherwise,
4250 ;; epa-file gets confused.
4251 (let (file-name-handler-alist
4252 (coding-system-for-write 'binary))
4242 (write-region (point-min) (point-max) tmpfile))) 4253 (write-region (point-min) (point-max) tmpfile)))
4243 4254
4244 ;; If tramp-decoding-function is not defined for this 4255 ;; If tramp-decoding-function is not defined for this
4245 ;; method, we invoke tramp-decoding-command instead. 4256 ;; method, we invoke tramp-decoding-command instead.
4246 (let ((tmpfile2 (tramp-compat-make-temp-file filename))) 4257 (let ((tmpfile2 (tramp-compat-make-temp-file filename)))
4247 (let ((coding-system-for-write 'binary)) 4258 ;; Unset `file-name-handler-alist'. Otherwise,
4259 ;; epa-file gets confused.
4260 (let (file-name-handler-alist
4261 (coding-system-for-write 'binary))
4248 (write-region (point-min) (point-max) tmpfile2)) 4262 (write-region (point-min) (point-max) tmpfile2))
4249 (tramp-message 4263 (tramp-message
4250 v 5 "Decoding remote file %s with command %s..." 4264 v 5 "Decoding remote file %s with command %s..."
@@ -4430,14 +4444,14 @@ coding system might not be determined. This function repairs it."
4430 (when (boundp 'backup-directory-alist) 4444 (when (boundp 'backup-directory-alist)
4431 (if (symbol-value 'tramp-backup-directory-alist) 4445 (if (symbol-value 'tramp-backup-directory-alist)
4432 (mapcar 4446 (mapcar
4433 '(lambda (x) 4447 (lambda (x)
4434 (cons 4448 (cons
4435 (car x) 4449 (car x)
4436 (if (and (stringp (cdr x)) 4450 (if (and (stringp (cdr x))
4437 (file-name-absolute-p (cdr x)) 4451 (file-name-absolute-p (cdr x))
4438 (not (tramp-file-name-p (cdr x)))) 4452 (not (tramp-file-name-p (cdr x))))
4439 (tramp-make-tramp-file-name method user host (cdr x)) 4453 (tramp-make-tramp-file-name method user host (cdr x))
4440 (cdr x)))) 4454 (cdr x))))
4441 (symbol-value 'tramp-backup-directory-alist)) 4455 (symbol-value 'tramp-backup-directory-alist))
4442 (symbol-value 'backup-directory-alist)))) 4456 (symbol-value 'backup-directory-alist))))
4443 4457
@@ -4446,17 +4460,17 @@ coding system might not be determined. This function repairs it."
4446 (when (boundp 'bkup-backup-directory-info) 4460 (when (boundp 'bkup-backup-directory-info)
4447 (if (symbol-value 'tramp-bkup-backup-directory-info) 4461 (if (symbol-value 'tramp-bkup-backup-directory-info)
4448 (mapcar 4462 (mapcar
4449 '(lambda (x) 4463 (lambda (x)
4450 (nconc 4464 (nconc
4451 (list (car x)) 4465 (list (car x))
4452 (list 4466 (list
4453 (if (and (stringp (car (cdr x))) 4467 (if (and (stringp (car (cdr x)))
4454 (file-name-absolute-p (car (cdr x))) 4468 (file-name-absolute-p (car (cdr x)))
4455 (not (tramp-file-name-p (car (cdr x))))) 4469 (not (tramp-file-name-p (car (cdr x)))))
4456 (tramp-make-tramp-file-name 4470 (tramp-make-tramp-file-name
4457 method user host (car (cdr x))) 4471 method user host (car (cdr x)))
4458 (car (cdr x)))) 4472 (car (cdr x))))
4459 (cdr (cdr x)))) 4473 (cdr (cdr x))))
4460 (symbol-value 'tramp-bkup-backup-directory-info)) 4474 (symbol-value 'tramp-bkup-backup-directory-info))
4461 (symbol-value 'bkup-backup-directory-info))))) 4475 (symbol-value 'bkup-backup-directory-info)))))
4462 4476
@@ -4480,12 +4494,12 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
4480 ;; all other cases we must do it ourselves. 4494 ;; all other cases we must do it ourselves.
4481 (when (boundp 'auto-save-file-name-transforms) 4495 (when (boundp 'auto-save-file-name-transforms)
4482 (mapc 4496 (mapc
4483 '(lambda (x) 4497 (lambda (x)
4484 (when (and (string-match (car x) buffer-file-name) 4498 (when (and (string-match (car x) buffer-file-name)
4485 (not (car (cddr x)))) 4499 (not (car (cddr x))))
4486 (setq tramp-auto-save-directory 4500 (setq tramp-auto-save-directory
4487 (or tramp-auto-save-directory 4501 (or tramp-auto-save-directory
4488 (tramp-compat-temporary-file-directory))))) 4502 (tramp-compat-temporary-file-directory)))))
4489 (symbol-value 'auto-save-file-name-transforms))) 4503 (symbol-value 'auto-save-file-name-transforms)))
4490 ;; Create directory. 4504 ;; Create directory.
4491 (when tramp-auto-save-directory 4505 (when tramp-auto-save-directory
@@ -5028,73 +5042,54 @@ Falls back to normal file name handler if no Tramp file name handler exists."
5028 ;; would otherwise use backslash. 5042 ;; would otherwise use backslash.
5029 (let ((directory-sep-char ?/) 5043 (let ((directory-sep-char ?/)
5030 (fn (assoc operation tramp-completion-file-name-handler-alist))) 5044 (fn (assoc operation tramp-completion-file-name-handler-alist)))
5031 ;; When `tramp-mode' is not enabled, we don't do anything. 5045 (if (and
5032 (if (and fn tramp-mode) 5046 ;; When `tramp-mode' is not enabled, we don't do anything.
5047 fn tramp-mode
5048 ;; For other syntaxes than `sep', the regexp matches many common
5049 ;; situations where the user doesn't actually want to use Tramp.
5050 ;; So to avoid autoloading Tramp after typing just "/s", we
5051 ;; disable this part of the completion, unless the user implicitly
5052 ;; indicated his interest in using a fancier completion system.
5053 (or (eq tramp-syntax 'sep)
5054 (featurep 'tramp) ; If it's loaded, we may as well use it.
5055 (and (boundp 'partial-completion-mode) partial-completion-mode)
5056 ;; FIXME: These may have been loaded even if the user never
5057 ;; intended to use them.
5058 (featurep 'ido)
5059 (featurep 'icicles)))
5033 (save-match-data (apply (cdr fn) args)) 5060 (save-match-data (apply (cdr fn) args))
5034 (tramp-completion-run-real-handler operation args))))) 5061 (tramp-completion-run-real-handler operation args)))))
5035 5062
5036;;;###autoload 5063;;;###autoload
5037(defsubst tramp-register-file-name-handler () 5064(progn (defun tramp-register-file-name-handlers ()
5038 "Add Tramp file name handler to `file-name-handler-alist'." 5065 "Add Tramp file name handlers to `file-name-handler-alist'."
5039 ;; Remove autoloaded handler from file name handler alist. Useful, 5066 ;; Remove autoloaded handlers from file name handler alist. Useful,
5040 ;; if `tramp-syntax' has been changed. 5067 ;; if `tramp-syntax' has been changed.
5041 (let ((a1 (rassq 'tramp-file-name-handler file-name-handler-alist))) 5068 (let ((a1 (rassq 'tramp-file-name-handler file-name-handler-alist)))
5042 (setq file-name-handler-alist (delete a1 file-name-handler-alist))) 5069 (setq file-name-handler-alist (delq a1 file-name-handler-alist)))
5043 ;; Add the handler. 5070 (let ((a1 (rassq
5071 'tramp-completion-file-name-handler file-name-handler-alist)))
5072 (setq file-name-handler-alist (delq a1 file-name-handler-alist)))
5073 ;; Add the handlers.
5044 (add-to-list 'file-name-handler-alist 5074 (add-to-list 'file-name-handler-alist
5045 (cons tramp-file-name-regexp 'tramp-file-name-handler)) 5075 (cons tramp-file-name-regexp 'tramp-file-name-handler))
5046 ;; If jka-compr is already loaded, move it to the front of 5076 (add-to-list 'file-name-handler-alist
5047 ;; `file-name-handler-alist'. 5077 (cons tramp-completion-file-name-regexp
5048 (let ((jka (rassoc 'jka-compr-handler file-name-handler-alist))) 5078 'tramp-completion-file-name-handler))
5049 (when jka 5079 (put 'tramp-completion-file-name-handler 'safe-magic t)
5050 (setq file-name-handler-alist 5080 ;; If jka-compr or epa-file are already loaded, move them to the
5051 (cons jka (delete jka file-name-handler-alist)))))) 5081 ;; front of `file-name-handler-alist'.
5082 (dolist (fnh '(epa-file-handler jka-compr-handler))
5083 (let ((entry (rassoc fnh file-name-handler-alist)))
5084 (when entry
5085 (setq file-name-handler-alist
5086 (cons entry (delete entry file-name-handler-alist))))))))
5052 5087
5053;; `tramp-file-name-handler' must be registered before evaluation of 5088;; `tramp-file-name-handler' must be registered before evaluation of
5054;; site-start and init files, because there might exist remote files 5089;; site-start and init files, because there might exist remote files
5055;; already, f.e. files kept via recentf-mode. 5090;; already, f.e. files kept via recentf-mode.
5056;;;###autoload(tramp-register-file-name-handler) 5091;;;###autoload(tramp-register-file-name-handlers)
5057(tramp-register-file-name-handler) 5092(tramp-register-file-name-handlers)
5058
5059;;;###autoload
5060(defsubst tramp-register-completion-file-name-handler ()
5061 "Add Tramp completion file name handler to `file-name-handler-alist'."
5062 ;; Remove autoloaded handler from file name handler alist. Useful,
5063 ;; if `tramp-syntax' has been changed.
5064 (let ((a1 (rassq
5065 'tramp-completion-file-name-handler file-name-handler-alist)))
5066 (setq file-name-handler-alist (delete a1 file-name-handler-alist)))
5067 ;; In XEmacs, there is another Tramp syntax, so we can enable this
5068 ;; unconditionally. In GNU Emacs <= 22, method/user/host name
5069 ;; completion shall be bound to `partial-completion-mode'. Starting
5070 ;; with GNU Emacs 23, this is replaced by `completion-styles',
5071 ;; containing symbol `partial-completion'. `ido-mode' and
5072 ;; `icy-mode' are other packages which extend file name completion.
5073 (when (or (and (boundp 'partial-completion-mode)
5074 (symbol-value 'partial-completion-mode))
5075 (and (boundp 'completion-styles)
5076 (member 'partial-completion (symbol-value 'completion-styles)))
5077 (featurep 'xemacs)
5078 (featurep 'ido)
5079 (featurep 'icicles))
5080 (add-to-list 'file-name-handler-alist
5081 (cons tramp-completion-file-name-regexp
5082 'tramp-completion-file-name-handler))
5083 (put 'tramp-completion-file-name-handler 'safe-magic t))
5084 ;; If jka-compr is already loaded, move it to the front of
5085 ;; `file-name-handler-alist'.
5086 (let ((jka (rassoc 'jka-compr-handler file-name-handler-alist)))
5087 (when jka
5088 (setq file-name-handler-alist
5089 (cons jka (delete jka file-name-handler-alist))))))
5090
5091;; During autoload, it shall be checked whether
5092;; `partial-completion-mode' is active. Therefore, registering of
5093;; `tramp-completion-file-name-handler' will be delayed.
5094;;;###autoload(add-hook
5095;;;###autoload 'after-init-hook
5096;;;###autoload 'tramp-register-completion-file-name-handler)
5097(tramp-register-completion-file-name-handler)
5098 5093
5099;;;###autoload 5094;;;###autoload
5100(defun tramp-unload-file-name-handlers () 5095(defun tramp-unload-file-name-handlers ()
@@ -5708,8 +5703,8 @@ Only send the definition if it has not already been done."
5708 (auto-save-mode 1))) 5703 (auto-save-mode 1)))
5709(add-hook 'find-file-hooks 'tramp-set-auto-save t) 5704(add-hook 'find-file-hooks 'tramp-set-auto-save t)
5710(add-hook 'tramp-unload-hook 5705(add-hook 'tramp-unload-hook
5711 '(lambda () 5706 (lambda ()
5712 (remove-hook 'find-file-hooks 'tramp-set-auto-save))) 5707 (remove-hook 'find-file-hooks 'tramp-set-auto-save)))
5713 5708
5714(defun tramp-run-test (switch filename) 5709(defun tramp-run-test (switch filename)
5715 "Run `test' on the remote system, given a SWITCH and a FILENAME. 5710 "Run `test' on the remote system, given a SWITCH and a FILENAME.
@@ -6838,9 +6833,9 @@ connection if a previous connection has died for some reason."
6838 (concat 6833 (concat
6839 command " " 6834 command " "
6840 (mapconcat 6835 (mapconcat
6841 '(lambda (x) 6836 (lambda (x)
6842 (setq x (mapcar '(lambda (y) (format-spec y spec)) x)) 6837 (setq x (mapcar (lambda (y) (format-spec y spec)) x))
6843 (unless (member "" x) (mapconcat 'identity x " "))) 6838 (unless (member "" x) (mapconcat 'identity x " ")))
6844 login-args " ") 6839 login-args " ")
6845 ;; Local shell could be a Windows COMSPEC. It doesn't 6840 ;; Local shell could be a Windows COMSPEC. It doesn't
6846 ;; know the ";" syntax, but we must exit always for 6841 ;; know the ";" syntax, but we must exit always for
@@ -7683,12 +7678,12 @@ If the `tramp-methods' entry does not exist, return NIL."
7683 (file-name-handler-alist 7678 (file-name-handler-alist
7684 (list 7679 (list
7685 (cons "/" 7680 (cons "/"
7686 '(lambda (operation &rest args) 7681 (lambda (operation &rest args)
7687 "Returns OPERATION if it is the one to be checked." 7682 "Returns OPERATION if it is the one to be checked."
7688 (if (equal check-file-name-operation operation) 7683 (if (equal check-file-name-operation operation)
7689 operation 7684 operation
7690 (let ((file-name-handler-alist fnha)) 7685 (let ((file-name-handler-alist fnha))
7691 (apply operation args)))))))) 7686 (apply operation args))))))))
7692 (equal (apply operation args) operation)) 7687 (equal (apply operation args) operation))
7693 (error nil))) 7688 (error nil)))
7694 7689
@@ -7700,7 +7695,7 @@ If the `tramp-methods' entry does not exist, return NIL."
7700 (setq ad-return-value (tramp-handle-make-auto-save-file-name)) 7695 (setq ad-return-value (tramp-handle-make-auto-save-file-name))
7701 ad-do-it)) 7696 ad-do-it))
7702 (add-hook 'tramp-unload-hook 7697 (add-hook 'tramp-unload-hook
7703 '(lambda () (ad-unadvise 'make-auto-save-file-name)))) 7698 (lambda () (ad-unadvise 'make-auto-save-file-name))))
7704 7699
7705;; In Emacs < 22 and XEmacs < 21.5 autosaved remote files have 7700;; In Emacs < 22 and XEmacs < 21.5 autosaved remote files have
7706;; permission 0666 minus umask. This is a security threat. 7701;; permission 0666 minus umask. This is a security threat.
@@ -7727,8 +7722,8 @@ If the `tramp-methods' entry does not exist, return NIL."
7727 (> emacs-minor-version 4))) 7722 (> emacs-minor-version 4)))
7728 (add-hook 'auto-save-hook 'tramp-set-auto-save-file-modes) 7723 (add-hook 'auto-save-hook 'tramp-set-auto-save-file-modes)
7729 (add-hook 'tramp-unload-hook 7724 (add-hook 'tramp-unload-hook
7730 '(lambda () 7725 (lambda ()
7731 (remove-hook 'auto-save-hook 'tramp-set-auto-save-file-modes)))) 7726 (remove-hook 'auto-save-hook 'tramp-set-auto-save-file-modes))))
7732 7727
7733(defun tramp-subst-strs-in-string (alist string) 7728(defun tramp-subst-strs-in-string (alist string)
7734 "Replace all occurrences of the string FROM with TO in STRING. 7729 "Replace all occurrences of the string FROM with TO in STRING.
@@ -7937,7 +7932,7 @@ Only works for Bourne-like shells."
7937 ;; If it is not a Tramp file, just run the original function. 7932 ;; If it is not a Tramp file, just run the original function.
7938 (setq ad-return-value (or ad-do-it (list name)))))) 7933 (setq ad-return-value (or ad-do-it (list name))))))
7939 (add-hook 'tramp-unload-hook 7934 (add-hook 'tramp-unload-hook
7940 '(lambda () (ad-unadvise 'file-expand-wildcards)))) 7935 (lambda () (ad-unadvise 'file-expand-wildcards))))
7941 7936
7942;; Checklist for `tramp-unload-hook' 7937;; Checklist for `tramp-unload-hook'
7943;; - Unload all `tramp-*' packages 7938;; - Unload all `tramp-*' packages
@@ -8034,8 +8029,6 @@ Only works for Bourne-like shells."
8034;; reasonably unproblematic. And maybe trampclient should have some 8029;; reasonably unproblematic. And maybe trampclient should have some
8035;; way of passing credentials, like by using an SSL socket or 8030;; way of passing credentials, like by using an SSL socket or
8036;; something. (David Kastrup) 8031;; something. (David Kastrup)
8037;; * Could Tramp reasonably look for a prompt after ^M rather than
8038;; only after ^J ? (Stefan Monnier)
8039;; * Reconnect directly to a compliant shell without first going 8032;; * Reconnect directly to a compliant shell without first going
8040;; through the user's default shell. (Pete Forman) 8033;; through the user's default shell. (Pete Forman)
8041;; * Make `tramp-default-user' obsolete. 8034;; * Make `tramp-default-user' obsolete.