comparison lisp/net/tramp.el @ 53206:0c19f1a19b2b

(tramp-chunksize): Extend docstring. Suggested by Charles Curley <charlescurley@charlescurley.com>. (tramp-multi-connection-function-alist): Add ssht entry which adds "-e none -t -t" to the list of ssh args. Suggested by Adrian Aichner. (tramp-get-method-parameter): New function to retrieve a method parameter. This allows for omission of method parameters. Callers adjusted.
author Kai Großjohann <kgrossjo@eu.uu.net>
date Sun, 30 Nov 2003 18:15:22 +0000
parents 695cf19ef79e
children c1bfc266f10a
comparison
equal deleted inserted replaced
53205:ed27adf8b7ac 53206:0c19f1a19b2b
567 (defcustom tramp-multi-connection-function-alist 567 (defcustom tramp-multi-connection-function-alist
568 '(("telnet" tramp-multi-connect-telnet "telnet %h%n") 568 '(("telnet" tramp-multi-connect-telnet "telnet %h%n")
569 ("rsh" tramp-multi-connect-rlogin "rsh %h -l %u%n") 569 ("rsh" tramp-multi-connect-rlogin "rsh %h -l %u%n")
570 ("remsh" tramp-multi-connect-rlogin "remsh %h -l %u%n") 570 ("remsh" tramp-multi-connect-rlogin "remsh %h -l %u%n")
571 ("ssh" tramp-multi-connect-rlogin "ssh %h -l %u%n") 571 ("ssh" tramp-multi-connect-rlogin "ssh %h -l %u%n")
572 ("ssht" tramp-multi-connect-rlogin "ssh %h -e none -t -t -l %u%n")
572 ("su" tramp-multi-connect-su "su - %u%n") 573 ("su" tramp-multi-connect-su "su - %u%n")
573 ("sudo" tramp-multi-connect-su "sudo -u %u -s -p Password:%n")) 574 ("sudo" tramp-multi-connect-su "sudo -u %u -s -p Password:%n"))
574 "*List of connection functions for multi-hop methods. 575 "*List of connection functions for multi-hop methods.
575 Each list item is a list of three items (METHOD FUNCTION COMMAND), 576 Each list item is a list of three items (METHOD FUNCTION COMMAND),
576 where METHOD is the name as used in the file name, FUNCTION is the 577 where METHOD is the name as used in the file name, FUNCTION is the
1248 (accept-process-output proc 1) 1249 (accept-process-output proc 1)
1249 (goto-char (point-min)) 1250 (goto-char (point-min))
1250 (re-search-forward \"\\\\w+\") 1251 (re-search-forward \"\\\\w+\")
1251 (message \"Bytes sent: %s\\tBytes received: %s\" bytes (match-string 0)))) 1252 (message \"Bytes sent: %s\\tBytes received: %s\" bytes (match-string 0))))
1252 1253
1254 In the Emacs normally running Tramp, evaluate the above code.
1255 You can do this, for example, by pasting it into the `*scratch*'
1256 buffer and then hitting C-j with the cursor after the last
1257 closing parenthesis.
1258
1259 If your Emacs is buggy, the sent and received numbers will be
1260 different. In that case, you'll want to set this variable to
1261 some number. For those people who have needed it, the value 500
1262 seems to have worked well. There is no way to predict what value
1263 you need; maybe you could just experiment a bit.
1264
1253 Please raise a bug report via \"M-x tramp-bug\" if your system needs 1265 Please raise a bug report via \"M-x tramp-bug\" if your system needs
1254 this variable to be set as well." 1266 this variable to be set as well."
1255 :group 'tramp 1267 :group 'tramp
1256 :type '(choice (const nil) integer)) 1268 :type '(choice (const nil) integer))
1257 1269
1403 ;; unless this spits out a complete line, including the '\n' at the 1415 ;; unless this spits out a complete line, including the '\n' at the
1404 ;; end. 1416 ;; end.
1405 ;; The device number is returned as "-1", because there will be a virtual 1417 ;; The device number is returned as "-1", because there will be a virtual
1406 ;; device number set in `tramp-handle-file-attributes' 1418 ;; device number set in `tramp-handle-file-attributes'
1407 (defconst tramp-perl-file-attributes "\ 1419 (defconst tramp-perl-file-attributes "\
1408 $f = $ARGV[0]; 1420 ($f, $n) = @ARGV;
1409 @s = lstat($f); 1421 @s = lstat($f);
1410 if (($s[2] & 0170000) == 0120000) { $l = readlink($f); $l = \"\\\"$l\\\"\"; } 1422 if (($s[2] & 0170000) == 0120000) { $l = readlink($f); $l = \"\\\"$l\\\"\"; }
1411 elsif (($s[2] & 0170000) == 040000) { $l = \"t\"; } 1423 elsif (($s[2] & 0170000) == 040000) { $l = \"t\"; }
1412 else { $l = \"nil\" }; 1424 else { $l = \"nil\" };
1413 printf(\"(%s %u %d %d (%u %u) (%u %u) (%u %u) %u %u t (%u . %u) -1)\\n\", 1425 $u = ($n eq \"nil\") ? $s[4] : getpwuid($s[4]);
1414 $l, $s[3], $s[4], $s[5], $s[8] >> 16 & 0xffff, $s[8] & 0xffff, 1426 $g = ($n eq \"nil\") ? $s[5] : getgrgid($s[5]);
1427 printf(\"(%s %u %s %s (%u %u) (%u %u) (%u %u) %u %u t (%u . %u) -1)\\n\",
1428 $l, $s[3], $u, $g, $s[8] >> 16 & 0xffff, $s[8] & 0xffff,
1415 $s[9] >> 16 & 0xffff, $s[9] & 0xffff, $s[10] >> 16 & 0xffff, $s[10] & 0xffff, 1429 $s[9] >> 16 & 0xffff, $s[9] & 0xffff, $s[10] >> 16 & 0xffff, $s[10] & 0xffff,
1416 $s[7], $s[2], $s[1] >> 16 & 0xffff, $s[1] & 0xffff);" 1430 $s[7], $s[2], $s[1] >> 16 & 0xffff, $s[1] & 0xffff);"
1417 "Perl script to produce output suitable for use with `file-attributes' 1431 "Perl script to produce output suitable for use with `file-attributes'
1418 on the remote file system.") 1432 on the remote file system.")
1419 1433
1898 10 "Check %s" 1912 10 "Check %s"
1899 (mapconcat 'identity 1913 (mapconcat 'identity
1900 (append '("") (reverse result) (list thisstep)) 1914 (append '("") (reverse result) (list thisstep))
1901 "/")) 1915 "/"))
1902 (setq symlink-target 1916 (setq symlink-target
1903 (nth 0 (tramp-handle-file-attributes 1917 (nth 0 (file-attributes
1904 (tramp-make-tramp-file-name 1918 (tramp-make-tramp-file-name
1905 multi-method method user host 1919 multi-method method user host
1906 (mapconcat 'identity 1920 (mapconcat 'identity
1907 (append '("") 1921 (append '("")
1908 (reverse result) 1922 (reverse result)
1977 "Keeps virtual device numbers.") 1991 "Keeps virtual device numbers.")
1978 1992
1979 ;; CCC: This should check for an error condition and signal failure 1993 ;; CCC: This should check for an error condition and signal failure
1980 ;; when something goes wrong. 1994 ;; when something goes wrong.
1981 ;; Daniel Pittman <daniel@danann.net> 1995 ;; Daniel Pittman <daniel@danann.net>
1982 (defun tramp-handle-file-attributes (filename &optional nonnumeric) 1996 (defun tramp-handle-file-attributes (filename &optional id-format)
1983 "Like `file-attributes' for tramp files. 1997 "Like `file-attributes' for tramp files."
1984 Optional argument NONNUMERIC means return user and group name 1998 (let ((nonnumeric (and id-format (equal id-format 'string)))
1985 rather than as numbers." 1999 result)
1986 (let (result)
1987 (with-parsed-tramp-file-name filename nil 2000 (with-parsed-tramp-file-name filename nil
1988 (when (tramp-handle-file-exists-p filename) 2001 (when (tramp-handle-file-exists-p filename)
1989 ;; file exists, find out stuff 2002 ;; file exists, find out stuff
1990 (save-excursion 2003 (save-excursion
1991 (if (tramp-get-remote-perl multi-method method user host) 2004 (if (tramp-get-remote-perl multi-method method user host)
2095 "file attributes with perl: %s" 2108 "file attributes with perl: %s"
2096 (tramp-make-tramp-file-name 2109 (tramp-make-tramp-file-name
2097 multi-method method user host localname)) 2110 multi-method method user host localname))
2098 (tramp-send-command 2111 (tramp-send-command
2099 multi-method method user host 2112 multi-method method user host
2100 (format "tramp_file_attributes %s" 2113 (format "tramp_file_attributes %s %s"
2101 (tramp-shell-quote-argument localname))) 2114 (tramp-shell-quote-argument localname) nonnumeric))
2102 (tramp-wait-for-output) 2115 (tramp-wait-for-output)
2103 (let ((result (read (current-buffer)))) 2116 (let ((result (read (current-buffer))))
2104 (setcar (nthcdr 8 result) 2117 (setcar (nthcdr 8 result)
2105 (tramp-file-mode-from-int (nth 8 result))) 2118 (tramp-file-mode-from-int (nth 8 result)))
2106 result)) 2119 result))
2308 (eq ?- (aref (nth 8 (file-attributes filename)) 0))))) 2321 (eq ?- (aref (nth 8 (file-attributes filename)) 0)))))
2309 2322
2310 (defun tramp-handle-file-symlink-p (filename) 2323 (defun tramp-handle-file-symlink-p (filename)
2311 "Like `file-symlink-p' for tramp files." 2324 "Like `file-symlink-p' for tramp files."
2312 (with-parsed-tramp-file-name filename nil 2325 (with-parsed-tramp-file-name filename nil
2313 (let ((x (car (tramp-handle-file-attributes filename)))) 2326 (let ((x (car (file-attributes filename))))
2314 (when (stringp x) 2327 (when (stringp x)
2315 ;; When Tramp is running on VMS, then `file-name-absolute-p' 2328 ;; When Tramp is running on VMS, then `file-name-absolute-p'
2316 ;; might do weird things. 2329 ;; might do weird things.
2317 (if (file-name-absolute-p x) 2330 (if (file-name-absolute-p x)
2318 (tramp-make-tramp-file-name 2331 (tramp-make-tramp-file-name
3028 (defun tramp-handle-file-local-copy (filename) 3041 (defun tramp-handle-file-local-copy (filename)
3029 "Like `file-local-copy' for tramp files." 3042 "Like `file-local-copy' for tramp files."
3030 (with-parsed-tramp-file-name filename nil 3043 (with-parsed-tramp-file-name filename nil
3031 (let ((output-buf (get-buffer-create "*tramp output*")) 3044 (let ((output-buf (get-buffer-create "*tramp output*"))
3032 (tramp-buf (tramp-get-buffer multi-method method user host)) 3045 (tramp-buf (tramp-get-buffer multi-method method user host))
3033 (copy-program (tramp-get-copy-program 3046 (copy-program (tramp-get-method-parameter
3034 multi-method 3047 multi-method
3035 (tramp-find-method multi-method method user host) 3048 (tramp-find-method multi-method method user host)
3036 user host)) 3049 user host 'tramp-copy-program))
3037 (copy-args (tramp-get-copy-args 3050 (copy-args (tramp-get-method-parameter
3038 multi-method 3051 multi-method
3039 (tramp-find-method multi-method method user host) 3052 (tramp-find-method multi-method method user host)
3040 user host)) 3053 user host 'tramp-copy-args))
3041 ;; We used to bind the following as late as possible. 3054 ;; We used to bind the following as late as possible.
3042 ;; loc-enc and loc-dec were bound directly before the if 3055 ;; loc-enc and loc-dec were bound directly before the if
3043 ;; statement that checks them. But the functions 3056 ;; statement that checks them. But the functions
3044 ;; tramp-get-* might invoke the "are you awake" check in 3057 ;; tramp-get-* might invoke the "are you awake" check in
3045 ;; tramp-maybe-open-connection, which is an unfortunate time 3058 ;; tramp-maybe-open-connection, which is an unfortunate time
3210 (unless (y-or-n-p (format "File %s exists; overwrite anyway? " 3223 (unless (y-or-n-p (format "File %s exists; overwrite anyway? "
3211 filename)) 3224 filename))
3212 (error "File not overwritten"))) 3225 (error "File not overwritten")))
3213 (with-parsed-tramp-file-name filename nil 3226 (with-parsed-tramp-file-name filename nil
3214 (let ((curbuf (current-buffer)) 3227 (let ((curbuf (current-buffer))
3215 (copy-program (tramp-get-copy-program 3228 (copy-program (tramp-get-method-parameter
3216 multi-method 3229 multi-method
3217 (tramp-find-method multi-method method user host) 3230 (tramp-find-method multi-method method user host)
3218 user host)) 3231 user host 'tramp-copy-program))
3219 (copy-args (tramp-get-copy-args 3232 (copy-args (tramp-get-method-parameter
3220 multi-method 3233 multi-method
3221 (tramp-find-method multi-method method user host) 3234 (tramp-find-method multi-method method user host)
3222 user host)) 3235 user host 'tramp-copy-args))
3223 (rem-enc (tramp-get-remote-encoding multi-method method user host)) 3236 (rem-enc (tramp-get-remote-encoding multi-method method user host))
3224 (rem-dec (tramp-get-remote-decoding multi-method method user host)) 3237 (rem-dec (tramp-get-remote-decoding multi-method method user host))
3225 (loc-enc (tramp-get-local-encoding multi-method method user host)) 3238 (loc-enc (tramp-get-local-encoding multi-method method user host))
3226 (loc-dec (tramp-get-local-decoding multi-method method user host)) 3239 (loc-dec (tramp-get-local-decoding multi-method method user host))
3227 (trampbuf (get-buffer-create "*tramp output*")) 3240 (trampbuf (get-buffer-create "*tramp output*"))
4400 (tramp-wait-for-output) 4413 (tramp-wait-for-output)
4401 (tramp-message 4414 (tramp-message
4402 9 "Setting remote shell prompt...done") 4415 9 "Setting remote shell prompt...done")
4403 ) 4416 )
4404 (t (tramp-message 5 "Remote `%s' groks tilde expansion, good" 4417 (t (tramp-message 5 "Remote `%s' groks tilde expansion, good"
4405 (tramp-get-remote-sh multi-method method user host)))))) 4418 (tramp-get-method-parameter
4419 multi-method method user host 'tramp-remote-sh))))))
4406 4420
4407 (defun tramp-check-ls-command (multi-method method user host cmd) 4421 (defun tramp-check-ls-command (multi-method method user host cmd)
4408 "Checks whether the given `ls' executable groks `-n'. 4422 "Checks whether the given `ls' executable groks `-n'.
4409 METHOD, USER and HOST specify the connection, CMD (the absolute file name of) 4423 METHOD, USER and HOST specify the connection, CMD (the absolute file name of)
4410 the `ls' executable. Returns t if CMD supports the `-n' option, nil 4424 the `ls' executable. Returns t if CMD supports the `-n' option, nil
4684 (> emacs-major-version 20)) 4698 (> emacs-major-version 20))
4685 tramp-dos-coding-system)) 4699 tramp-dos-coding-system))
4686 (p (apply 'start-process 4700 (p (apply 'start-process
4687 (tramp-buffer-name multi-method method user host) 4701 (tramp-buffer-name multi-method method user host)
4688 (tramp-get-buffer multi-method method user host) 4702 (tramp-get-buffer multi-method method user host)
4689 (tramp-get-login-program 4703 (tramp-get-method-parameter
4690 multi-method 4704 multi-method
4691 (tramp-find-method multi-method method user host) 4705 (tramp-find-method multi-method method user host)
4692 user host) 4706 user host 'tramp-login-program)
4693 host 4707 host
4694 (tramp-get-login-args 4708 (tramp-get-method-parameter
4695 multi-method 4709 multi-method
4696 (tramp-find-method multi-method method user host) 4710 (tramp-find-method multi-method method user host)
4697 user host))) 4711 user host 'tramp-login-args)))
4698 (found nil) 4712 (found nil)
4699 (pw nil)) 4713 (pw nil))
4700 (process-kill-without-query p) 4714 (process-kill-without-query p)
4701 (set-buffer (tramp-get-buffer multi-method method user host)) 4715 (set-buffer (tramp-get-buffer multi-method method user host))
4702 (erase-buffer) 4716 (erase-buffer)
4741 user host method) 4755 user host method)
4742 (tramp-message 7 "Opening connection at %s using %s..." host method)) 4756 (tramp-message 7 "Opening connection at %s using %s..." host method))
4743 (let ((process-environment (copy-sequence process-environment)) 4757 (let ((process-environment (copy-sequence process-environment))
4744 (bufnam (tramp-buffer-name multi-method method user host)) 4758 (bufnam (tramp-buffer-name multi-method method user host))
4745 (buf (tramp-get-buffer multi-method method user host)) 4759 (buf (tramp-get-buffer multi-method method user host))
4746 (login-program (tramp-get-login-program 4760 (login-program (tramp-get-method-parameter
4747 multi-method 4761 multi-method
4748 (tramp-find-method multi-method method user host) 4762 (tramp-find-method multi-method method user host)
4749 user host)) 4763 user host 'tramp-login-program))
4750 (login-args (tramp-get-login-args 4764 (login-args (tramp-get-method-parameter
4751 multi-method 4765 multi-method
4752 (tramp-find-method multi-method method user host) 4766 (tramp-find-method multi-method method user host)
4753 user host))) 4767 user host 'tramp-login-args)))
4754 ;; The following should be changed. We need a more general 4768 ;; The following should be changed. We need a more general
4755 ;; mechanism to parse extra host args. 4769 ;; mechanism to parse extra host args.
4756 (when (string-match "\\([^#]*\\)#\\(.*\\)" host) 4770 (when (string-match "\\([^#]*\\)#\\(.*\\)" host)
4757 (setq login-args (cons "-p" (cons (match-string 2 host) rsh-args))) 4771 (setq login-args (cons "-p" (cons (match-string 2 host) rsh-args)))
4758 (setq host (match-string 1 host))) 4772 (setq host (match-string 1 host)))
4816 (> emacs-major-version 20)) 4830 (> emacs-major-version 20))
4817 tramp-dos-coding-system)) 4831 tramp-dos-coding-system))
4818 (p (apply 'start-process 4832 (p (apply 'start-process
4819 (tramp-buffer-name multi-method method user host) 4833 (tramp-buffer-name multi-method method user host)
4820 (tramp-get-buffer multi-method method user host) 4834 (tramp-get-buffer multi-method method user host)
4821 (tramp-get-login-program 4835 (tramp-get-method-parameter
4822 multi-method 4836 multi-method
4823 (tramp-find-method multi-method method user host) 4837 (tramp-find-method multi-method method user host)
4824 user host) 4838 user host 'tramp-login-program)
4825 (mapcar 4839 (mapcar
4826 (lambda (x) 4840 (lambda (x)
4827 (format-spec x `((?u . ,(or user "root"))))) 4841 (format-spec x `((?u . ,(or user "root")))))
4828 (tramp-get-login-args 4842 (tramp-get-method-parameter
4829 multi-method 4843 multi-method
4830 (tramp-find-method multi-method method user host) 4844 (tramp-find-method multi-method method user host)
4831 user host)))) 4845 user host 'tramp-login-args))))
4832 (found nil) 4846 (found nil)
4833 (pw nil)) 4847 (pw nil))
4834 (process-kill-without-query p) 4848 (process-kill-without-query p)
4835 (set-buffer (tramp-get-buffer multi-method method user host)) 4849 (set-buffer (tramp-get-buffer multi-method method user host))
4836 (tramp-process-actions p multi-method method user host 4850 (tramp-process-actions p multi-method method user host
5052 Uses PROMPT as a prompt and sends the password to process P." 5066 Uses PROMPT as a prompt and sends the password to process P."
5053 (let ((pw (tramp-read-passwd prompt))) 5067 (let ((pw (tramp-read-passwd prompt)))
5054 (erase-buffer) 5068 (erase-buffer)
5055 (process-send-string 5069 (process-send-string
5056 p (concat pw 5070 p (concat pw
5057 (tramp-get-password-end-of-line 5071 (or (tramp-get-method-parameter
5058 tramp-current-multi-method 5072 tramp-current-multi-method
5059 tramp-current-method 5073 tramp-current-method
5060 tramp-current-user 5074 tramp-current-user
5061 tramp-current-host))))) 5075 tramp-current-host
5076 'tramp-password-end-of-line)
5077 tramp-default-password-end-of-line)))))
5062 5078
5063 ;; HHH: Not Changed. This might handle the case where USER is not 5079 ;; HHH: Not Changed. This might handle the case where USER is not
5064 ;; given in the "File name" very poorly. Then, the local 5080 ;; given in the "File name" very poorly. Then, the local
5065 ;; variable tramp-current user will be set to nil. 5081 ;; variable tramp-current user will be set to nil.
5066 (defun tramp-pre-connection (multi-method method user host) 5082 (defun tramp-pre-connection (multi-method method user host)
5099 ;; called as sh) on startup; this way, we avoid the startup file 5115 ;; called as sh) on startup; this way, we avoid the startup file
5100 ;; clobbering $PS1. 5116 ;; clobbering $PS1.
5101 (tramp-send-command-internal 5117 (tramp-send-command-internal
5102 multi-method method user host 5118 multi-method method user host
5103 (format "exec env 'ENV=' 'PS1=$ ' %s" 5119 (format "exec env 'ENV=' 'PS1=$ ' %s"
5104 (tramp-get-remote-sh multi-method method user host)) 5120 (tramp-get-method-parameter
5121 multi-method method user host 'tramp-remote-sh))
5105 (format "remote `%s' to come up" 5122 (format "remote `%s' to come up"
5106 (tramp-get-remote-sh multi-method method user host))) 5123 (tramp-get-method-parameter
5124 multi-method method user host 'tramp-remote-sh)))
5107 (tramp-barf-if-no-shell-prompt 5125 (tramp-barf-if-no-shell-prompt
5108 p 30 5126 p 30
5109 "Remote `%s' didn't come up. See buffer `%s' for details" 5127 "Remote `%s' didn't come up. See buffer `%s' for details"
5110 (tramp-get-remote-sh multi-method method user host) 5128 (tramp-get-method-parameter multi-method method user host 'tramp-remote-sh)
5111 (buffer-name)) 5129 (buffer-name))
5112 (tramp-message 8 "Setting up remote shell environment") 5130 (tramp-message 8 "Setting up remote shell environment")
5113 (tramp-discard-garbage-erase-buffer p multi-method method user host) 5131 (tramp-discard-garbage-erase-buffer p multi-method method user host)
5114 (tramp-send-command-internal multi-method method user host 5132 (tramp-send-command-internal multi-method method user host
5115 "stty -inlcr -echo kill '^U'") 5133 "stty -inlcr -echo kill '^U'")
5285 (tramp-message 5 "Sending the Perl `file-attributes' implementation.") 5303 (tramp-message 5 "Sending the Perl `file-attributes' implementation.")
5286 (tramp-send-string 5304 (tramp-send-string
5287 multi-method method user host 5305 multi-method method user host
5288 (concat "tramp_file_attributes () {\n" 5306 (concat "tramp_file_attributes () {\n"
5289 tramp-remote-perl 5307 tramp-remote-perl
5290 " -e '" tramp-perl-file-attributes "' $1 2>/dev/null\n" 5308 " -e '" tramp-perl-file-attributes "' $1 $2 2>/dev/null\n"
5291 "}")) 5309 "}"))
5292 (tramp-wait-for-output) 5310 (tramp-wait-for-output)
5293 (unless (tramp-get-copy-program 5311 (unless (tramp-get-method-parameter
5294 multi-method 5312 multi-method
5295 (tramp-find-method multi-method method user host) 5313 (tramp-find-method multi-method method user host)
5296 user host) 5314 user host 'tramp-copy-program)
5297 (tramp-message 5 "Sending the Perl `mime-encode' implementations.") 5315 (tramp-message 5 "Sending the Perl `mime-encode' implementations.")
5298 (tramp-send-string 5316 (tramp-send-string
5299 multi-method method user host 5317 multi-method method user host
5300 (concat "tramp_encode () {\n" 5318 (concat "tramp_encode () {\n"
5301 (format tramp-perl-encode tramp-remote-perl) 5319 (format tramp-perl-encode tramp-remote-perl)
5330 "ln" tramp-remote-path nil))) 5348 "ln" tramp-remote-path nil)))
5331 (when ln 5349 (when ln
5332 (tramp-set-connection-property "ln" ln multi-method method user host))) 5350 (tramp-set-connection-property "ln" ln multi-method method user host)))
5333 (erase-buffer) 5351 (erase-buffer)
5334 ;; Find the right encoding/decoding commands to use. 5352 ;; Find the right encoding/decoding commands to use.
5335 (unless (tramp-get-copy-program 5353 (unless (tramp-get-method-parameter
5336 multi-method 5354 multi-method
5337 (tramp-find-method multi-method method user host) 5355 (tramp-find-method multi-method method user host)
5338 user host) 5356 user host 'tramp-copy-program)
5339 (tramp-find-inline-encoding multi-method method user host)) 5357 (tramp-find-inline-encoding multi-method method user host))
5340 ;; If encoding/decoding command are given, test to see if they work. 5358 ;; If encoding/decoding command are given, test to see if they work.
5341 ;; CCC: Maybe it would be useful to run the encoder both locally and 5359 ;; CCC: Maybe it would be useful to run the encoder both locally and
5342 ;; remotely to see if they produce the same result. 5360 ;; remotely to see if they produce the same result.
5343 (let ((rem-enc (tramp-get-remote-encoding multi-method method user host)) 5361 (let ((rem-enc (tramp-get-remote-encoding multi-method method user host))
5546 (setq p nil)) 5564 (setq p nil))
5547 (erase-buffer))) 5565 (erase-buffer)))
5548 (unless (and p (processp p) (memq (process-status p) '(run open))) 5566 (unless (and p (processp p) (memq (process-status p) '(run open)))
5549 (when (and p (processp p)) 5567 (when (and p (processp p))
5550 (delete-process p)) 5568 (delete-process p))
5551 (funcall (tramp-get-connection-function 5569 (funcall (tramp-get-method-parameter
5552 multi-method 5570 multi-method
5553 (tramp-find-method multi-method method user host) 5571 (tramp-find-method multi-method method user host)
5554 user host) 5572 user host 'tramp-connection-function)
5555 multi-method method user host)))) 5573 multi-method method user host))))
5556 5574
5557 (defun tramp-send-command 5575 (defun tramp-send-command
5558 (multi-method method user host command &optional noerase neveropen) 5576 (multi-method method user host command &optional noerase neveropen)
5559 "Send the COMMAND to USER at HOST (logged in using METHOD). 5577 "Send the COMMAND to USER at HOST (logged in using METHOD).
6033 6051
6034 (defun tramp-method-out-of-band-p (multi-method method user host) 6052 (defun tramp-method-out-of-band-p (multi-method method user host)
6035 "Return t if this is an out-of-band method, nil otherwise. 6053 "Return t if this is an out-of-band method, nil otherwise.
6036 It is important to check for this condition, since it is not possible 6054 It is important to check for this condition, since it is not possible
6037 to enter a password for the `tramp-copy-program'." 6055 to enter a password for the `tramp-copy-program'."
6038 (tramp-get-copy-program 6056 (tramp-get-method-parameter
6039 multi-method 6057 multi-method
6040 (tramp-find-method multi-method method user host) 6058 (tramp-find-method multi-method method user host)
6041 user host)) 6059 user host 'tramp-copy-program))
6042 6060
6043 ;; Variables local to connection. 6061 ;; Variables local to connection.
6044 6062
6045 (defun tramp-get-ls-command (multi-method method user host) 6063 (defun tramp-get-ls-command (multi-method method user host)
6046 (save-excursion 6064 (save-excursion
6115 multi-method method user host)) 6133 multi-method method user host))
6116 (defun tramp-get-local-decoding (multi-method method user host) 6134 (defun tramp-get-local-decoding (multi-method method user host)
6117 (tramp-get-connection-property "local-decoding" nil 6135 (tramp-get-connection-property "local-decoding" nil
6118 multi-method method user host)) 6136 multi-method method user host))
6119 6137
6120 6138 (defun tramp-get-method-parameter (multi-method method user host param)
6121 6139 "Return the method parameter PARAM.
6122 (defun tramp-get-connection-function (multi-method method user host) 6140 If the `tramp-methods' entry does not exist, use the variable PARAM
6123 (second (or (assoc 'tramp-connection-function 6141 as default."
6124 (assoc (tramp-find-method multi-method method user host) 6142 (unless (boundp param)
6125 tramp-methods)) 6143 (error "Non-existing method parameter `%s'" param))
6126 (error "Method `%s' didn't specify a connection function" 6144 (let ((entry (assoc param
6127 (or multi-method method)))))
6128
6129 (defun tramp-get-remote-sh (multi-method method user host)
6130 (second (or (assoc 'tramp-remote-sh
6131 (assoc (tramp-find-method multi-method method user host)
6132 tramp-methods))
6133 (error "Method `%s' didn't specify a remote shell"
6134 (or multi-method method)))))
6135
6136 (defun tramp-get-login-program (multi-method method user host)
6137 (second (or (assoc 'tramp-login-program
6138 (assoc (tramp-find-method multi-method method user host)
6139 tramp-methods))
6140 (error "Method `%s' didn't specify a login program"
6141 (or multi-method method)))))
6142
6143 (defun tramp-get-login-args (multi-method method user host)
6144 (second (or (assoc 'tramp-login-args
6145 (assoc (tramp-find-method multi-method method user host)
6146 tramp-methods))
6147 (error "Method `%s' didn't specify login args"
6148 (or multi-method method)))))
6149
6150 (defun tramp-get-copy-program (multi-method method user host)
6151 (second (or (assoc 'tramp-copy-program
6152 (assoc (tramp-find-method multi-method method user host)
6153 tramp-methods))
6154 (error "Method `%s' didn't specify a copy program"
6155 (or multi-method method)))))
6156
6157 (defun tramp-get-copy-args (multi-method method user host)
6158 (second (or (assoc 'tramp-copy-args
6159 (assoc (tramp-find-method multi-method method user host)
6160 tramp-methods))
6161 (error "Method `%s' didn't specify copy args"
6162 (or multi-method method)))))
6163
6164 (defun tramp-get-copy-keep-date-arg (multi-method method user host)
6165 (second (or (assoc 'tramp-copy-keep-date-arg
6166 (assoc (tramp-find-method multi-method method user host)
6167 tramp-methods))
6168 (error "Method `%s' didn't specify `keep-date' arg for tramp"
6169 (or multi-method method)))))
6170
6171 (defun tramp-get-password-end-of-line (multi-method method user host)
6172 (let ((entry (assoc 'tramp-password-end-of-line
6173 (assoc (tramp-find-method multi-method method user host) 6145 (assoc (tramp-find-method multi-method method user host)
6174 tramp-methods)))) 6146 tramp-methods))))
6175 (unless entry 6147 (if entry
6176 (error "Method `%s' didn't specify `password-end-of-line' arg for tramp" 6148 (second entry)
6177 (or multi-method method))) 6149 (symbol-value param))))
6178 (or (second entry) tramp-default-password-end-of-line))) 6150
6179 6151
6180 ;; Auto saving to a special directory. 6152 ;; Auto saving to a special directory.
6181 6153
6182 (defun tramp-make-auto-save-file-name (fn) 6154 (defun tramp-make-auto-save-file-name (fn)
6183 "Returns a file name in `tramp-auto-save-directory' for autosaving this file." 6155 "Returns a file name in `tramp-auto-save-directory' for autosaving this file."
6503 (eval-after-load "vc" 6475 (eval-after-load "vc"
6504 '(require 'tramp-vc)) 6476 '(require 'tramp-vc))
6505 6477
6506 ;;; TODO: 6478 ;;; TODO:
6507 6479
6480 ;; * tramp-copy-keep-date-arg is not used!
6508 ;; * Allow putting passwords in the filename. 6481 ;; * Allow putting passwords in the filename.
6509 ;; This should be implemented via a general mechanism to add 6482 ;; This should be implemented via a general mechanism to add
6510 ;; parameters in filenames. There is currently a kludge for 6483 ;; parameters in filenames. There is currently a kludge for
6511 ;; putting the port number into the filename for ssh and ftp 6484 ;; putting the port number into the filename for ssh and ftp
6512 ;; files. This could be subsumed by the new mechanism as well. 6485 ;; files. This could be subsumed by the new mechanism as well.
6624 ;; ** Decide whiche files to take for searching user/host names depending on 6597 ;; ** Decide whiche files to take for searching user/host names depending on
6625 ;; operating system (windows-nt) in `tramp-completion-function-alist'. 6598 ;; operating system (windows-nt) in `tramp-completion-function-alist'.
6626 ;; ** Enhance variables for debug. 6599 ;; ** Enhance variables for debug.
6627 ;; ** Implement "/multi:" completion. 6600 ;; ** Implement "/multi:" completion.
6628 ;; ** Add a learning mode for completion. Make results persistent. 6601 ;; ** Add a learning mode for completion. Make results persistent.
6602 ;; * Allow out-of-band methods as _last_ multi-hop.
6629 6603
6630 ;; Functions for file-name-handler-alist: 6604 ;; Functions for file-name-handler-alist:
6631 ;; diff-latest-backup-file -- in diff.el 6605 ;; diff-latest-backup-file -- in diff.el
6632 ;; dired-compress-file 6606 ;; dired-compress-file
6633 ;; dired-uncache -- this will be needed when we do insert-directory caching 6607 ;; dired-uncache -- this will be needed when we do insert-directory caching