Mercurial > emacs
comparison lisp/net/tramp.el @ 55420:c44f9de543e3
2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Version 2.0.40 of Tramp released.
* net/tramp.el (tramp-completion-mode, tramp-md5-function): Use
symbol-function to invoke functions only known on some Emacs
flavors. This avoids byte-compiler warnings. Reported by Kevin
Scaldeferri <kevin@scaldeferri.com>.
(tramp-do-copy-or-rename-file-via-buffer): Renamed from
tramp-do-copy-or-rename-via-buffer (without `file'), to make it
consistent with the other tramp-do-* functions.
(tramp-do-copy-or-rename-file): Calls adjusted.
(tramp-process-initial-commands): Avoid liveness check on shell --
we know that it must be alive since we're opening a connection at
this moment.
(tramp-last-cmd): New internal variable.
(tramp-process-echoes): New tunable.
(tramp-send-command): Set tramp-last-cmd.
(tramp-wait-for-output): Delete echo, if applicable.
(tramp-read-passwd): Construct the key for the password cache in a
way that works for multi methods, too.
(tramp-bug): Add backup-directory-alist and
bkup-backup-directory-info to bug reports, with Tramp
counterparts.
2004-05-01 Michael Albinus <michael.albinus@gmx.de>
* net/tramp*.el: Suppress byte-compiler warnings where possible.
* net/tramp.el (tramp-out-of-band-prompt-regexp)
(tramp-actions-copy-out-of-band): New defcustoms.
(tramp-do-copy-or-rename-file-out-of-band): Asynchronous process
used instead of a synchronous one. Allows password entering.
(tramp-action-out-of-band): New defun.
(tramp-open-connection-rsh, tramp-method-out-of-band-p): Remove
restriction with password from doc string.
(tramp-bug): Add variables `tramp-terminal-prompt-regexp',
`tramp-out-of-band-prompt-regexp',
`tramp-actions-copy-out-of-band', `password-cache' and
`password-cache-expiry'.
(toplevel): Remove todo item wrt ssh-agent. Obsolete due to
password caching.
(tramp-touch): FILE can be a local file, too.
(TODO): Remove items done.
(tramp-handle-insert-directory): Properly quote file name also if
not full-directory-p. Handle wildcard case. Reported by Andreas
Schwab <schwab@suse.de>.
(tramp-do-copy-or-rename-file-via-buffer): Set permissions of the
new file.
(tramp-handle-file-local-copy, tramp-handle-write-region): The
permissions of the temporary file are set if filename exists.
Reported by Ted Stern <stern@cray.com>.
(tramp-backup-directory-alist)
(tramp-bkup-backup-directory-info): New defcustoms.
(tramp-file-name-handler-alist): Add entry for
`find-backup-file-name'.
(tramp-handle-find-backup-file-name): New function. Implements
Tramp's find-backup-file-name.
* net/tramp-smb.el (tramp-smb-file-name-handler-alist): Add entry
for `find-backup-file-name'.
* net/tramp-vc.el (tramp-vc-workfile-unchanged-p): Correct typo
("file" -> "filename"). Reported by Kim F. Storm <storm@cua.dk>.
author | Kai Großjohann <kgrossjo@eu.uu.net> |
---|---|
date | Fri, 07 May 2004 21:20:10 +0000 |
parents | c1bfc266f10a |
children | 4bc6cb45c326 |
comparison
equal
deleted
inserted
replaced
55419:738233cdd3b0 | 55420:c44f9de543e3 |
---|---|
133 (load "cl-seq"))) | 133 (load "cl-seq"))) |
134 | 134 |
135 (unless (boundp 'custom-print-functions) | 135 (unless (boundp 'custom-print-functions) |
136 (defvar custom-print-functions nil)) ; not autoloaded before Emacs 20.4 | 136 (defvar custom-print-functions nil)) ; not autoloaded before Emacs 20.4 |
137 | 137 |
138 ;; Avoid bytecompiler warnings if the byte-compiler supports this. | 138 ;; Avoid byte-compiler warnings if the byte-compiler supports this. |
139 ;; Currently, XEmacs supports this. | 139 ;; Currently, XEmacs supports this. |
140 (eval-when-compile | 140 (eval-when-compile |
141 (when (fboundp 'byte-compiler-options) | 141 (when (fboundp 'byte-compiler-options) |
142 (byte-compiler-options (warnings (- unused-vars))))) | 142 (let (unused-vars) ; Pacify Emacs byte-compiler |
143 (defalias 'warnings 'identity) ; Pacify Emacs byte-compiler | |
144 (byte-compiler-options (warnings (- unused-vars)))))) | |
145 | |
146 ;; `directory-sep-char' is an obsolete variable in Emacs. But it is | |
147 ;; used in XEmacs, so we set it here and there. The following is needed | |
148 ;; to pacify Emacs byte-compiler. | |
149 (eval-when-compile | |
150 (when (boundp 'byte-compile-not-obsolete-var) | |
151 (setq byte-compile-not-obsolete-var 'directory-sep-char))) | |
152 | |
153 ;; XEmacs byte-compiler raises warning abouts `last-coding-system-used'. | |
154 (eval-when-compile | |
155 (unless (boundp 'last-coding-system-used) | |
156 (defvar last-coding-system-used nil))) | |
143 | 157 |
144 ;;; User Customizable Internal Variables: | 158 ;;; User Customizable Internal Variables: |
145 | 159 |
146 (defgroup tramp nil | 160 (defgroup tramp nil |
147 "Edit remote files with a combination of rsh and rcp or similar programs." | 161 "Edit remote files with a combination of rsh and rcp or similar programs." |
154 | 168 |
155 (defcustom tramp-debug-buffer nil | 169 (defcustom tramp-debug-buffer nil |
156 "*Whether to send all commands and responses to a debug buffer." | 170 "*Whether to send all commands and responses to a debug buffer." |
157 :group 'tramp | 171 :group 'tramp |
158 :type 'boolean) | 172 :type 'boolean) |
173 | |
174 ;; Emacs case | |
175 (eval-and-compile | |
176 (when (boundp 'backup-directory-alist) | |
177 (defcustom tramp-backup-directory-alist nil | |
178 "Alist of filename patterns and backup directory names. | |
179 Each element looks like (REGEXP . DIRECTORY), with the same meaning like | |
180 in `backup-directory-alist'. If a Tramp file is backed up, and DIRECTORY | |
181 is a local file name, the backup directory is prepended with Tramp file | |
182 name prefix \(multi-method, method, user, host\) of file. | |
183 | |
184 \(setq tramp-backup-directory-alist backup-directory-alist\) | |
185 | |
186 gives the same backup policy for Tramp files on their hosts like the | |
187 policy for local files." | |
188 :group 'tramp | |
189 :type '(repeat (cons (regexp :tag "Regexp matching filename") | |
190 (directory :tag "Backup directory name")))))) | |
191 | |
192 ;; XEmacs case. We cannot check for `bkup-backup-directory-info', because | |
193 ;; the package "backup-dir" might not be loaded yet. | |
194 (eval-and-compile | |
195 (when (featurep 'xemacs) | |
196 (defcustom tramp-bkup-backup-directory-info nil | |
197 "*Alist of (FILE-REGEXP BACKUP-DIR OPTIONS ...)) | |
198 It has the same meaning like `bkup-backup-directory-info' from package | |
199 `backup-dir'. If a Tramp file is backed up, and BACKUP-DIR is a local | |
200 file name, the backup directory is prepended with Tramp file name prefix | |
201 \(multi-method, method, user, host\) of file. | |
202 | |
203 \(setq tramp-bkup-backup-directory-info bkup-backup-directory-info\) | |
204 | |
205 gives the same backup policy for Tramp files on their hosts like the | |
206 policy for local files." | |
207 :type '(repeat | |
208 (list (regexp :tag "File regexp") | |
209 (string :tag "Backup Dir") | |
210 (set :inline t | |
211 (const ok-create) | |
212 (const full-path) | |
213 (const prepend-name) | |
214 (const search-upward)))) | |
215 :group 'tramp))) | |
159 | 216 |
160 (defcustom tramp-auto-save-directory nil | 217 (defcustom tramp-auto-save-directory nil |
161 "*Put auto-save files in this directory, if set. | 218 "*Put auto-save files in this directory, if set. |
162 The idea is to use a local directory so that auto-saving is faster." | 219 The idea is to use a local directory so that auto-saving is faster." |
163 :group 'tramp | 220 :group 'tramp |
852 The regexp should match at end of buffer. | 909 The regexp should match at end of buffer. |
853 The answer will be provided by `tramp-action-terminal', which see." | 910 The answer will be provided by `tramp-action-terminal', which see." |
854 :group 'tramp | 911 :group 'tramp |
855 :type 'regexp) | 912 :type 'regexp) |
856 | 913 |
914 (defcustom tramp-out-of-band-prompt-regexp | |
915 "" | |
916 "Regular expression indicating an out-of-band copy has finished. | |
917 In fact this expression is empty by intention, it will be used only to | |
918 check regularly the status of the associated process. | |
919 The answer will be provided by `tramp-action-out-of-band', which see." | |
920 :group 'tramp | |
921 :type 'regexp) | |
922 | |
857 (defcustom tramp-temp-name-prefix "tramp." | 923 (defcustom tramp-temp-name-prefix "tramp." |
858 "*Prefix to use for temporary files. | 924 "*Prefix to use for temporary files. |
859 If this is a relative file name (such as \"tramp.\"), it is considered | 925 If this is a relative file name (such as \"tramp.\"), it is considered |
860 relative to the directory name returned by the function | 926 relative to the directory name returned by the function |
861 `tramp-temporary-file-directory' (which see). It may also be an | 927 `tramp-temporary-file-directory' (which see). It may also be an |
1235 The ACTION should also be a symbol, but a function. When the | 1301 The ACTION should also be a symbol, but a function. When the |
1236 corresponding PATTERN matches, the ACTION function is called." | 1302 corresponding PATTERN matches, the ACTION function is called." |
1237 :group 'tramp | 1303 :group 'tramp |
1238 :type '(repeat (list variable function))) | 1304 :type '(repeat (list variable function))) |
1239 | 1305 |
1306 (defcustom tramp-actions-copy-out-of-band | |
1307 '((tramp-password-prompt-regexp tramp-action-password) | |
1308 (tramp-wrong-passwd-regexp tramp-action-permission-denied) | |
1309 (tramp-out-of-band-prompt-regexp tramp-action-out-of-band)) | |
1310 "List of pattern/action pairs. | |
1311 This list is used for copying/renaming with out-of-band methods. | |
1312 See `tramp-actions-before-shell' for more info." | |
1313 :group 'tramp | |
1314 :type '(repeat (list variable function))) | |
1315 | |
1240 (defcustom tramp-multi-actions | 1316 (defcustom tramp-multi-actions |
1241 '((tramp-password-prompt-regexp tramp-multi-action-password) | 1317 '((tramp-password-prompt-regexp tramp-multi-action-password) |
1242 (tramp-login-prompt-regexp tramp-multi-action-login) | 1318 (tramp-login-prompt-regexp tramp-multi-action-login) |
1243 (shell-prompt-pattern tramp-multi-action-succeed) | 1319 (shell-prompt-pattern tramp-multi-action-succeed) |
1244 (tramp-shell-prompt-pattern tramp-multi-action-succeed) | 1320 (tramp-shell-prompt-pattern tramp-multi-action-succeed) |
1324 (make-variable-buffer-local 'tramp-buffer-file-attributes) | 1400 (make-variable-buffer-local 'tramp-buffer-file-attributes) |
1325 | 1401 |
1326 (defvar tramp-md5-function | 1402 (defvar tramp-md5-function |
1327 (cond ((and (require 'md5) (fboundp 'md5)) 'md5) | 1403 (cond ((and (require 'md5) (fboundp 'md5)) 'md5) |
1328 ((fboundp 'md5-encode) | 1404 ((fboundp 'md5-encode) |
1329 (lambda (x) (base64-encode-string (md5-encode x)))) | 1405 (lambda (x) (base64-encode-string |
1406 (funcall (symbol-function 'md5-encode) x)))) | |
1330 (t (error "Coulnd't find an `md5' function"))) | 1407 (t (error "Coulnd't find an `md5' function"))) |
1331 "Function to call for running the MD5 algorithm.") | 1408 "Function to call for running the MD5 algorithm.") |
1332 | 1409 |
1333 (defvar tramp-end-of-output | 1410 (defvar tramp-end-of-output |
1334 (concat "///" | 1411 (concat "///" |
1462 ;; unless this spits out a complete line, including the '\n' at the | 1539 ;; unless this spits out a complete line, including the '\n' at the |
1463 ;; end. | 1540 ;; end. |
1464 ;; The device number is returned as "-1", because there will be a virtual | 1541 ;; The device number is returned as "-1", because there will be a virtual |
1465 ;; device number set in `tramp-handle-file-attributes' | 1542 ;; device number set in `tramp-handle-file-attributes' |
1466 (defconst tramp-perl-file-attributes "\ | 1543 (defconst tramp-perl-file-attributes "\ |
1467 ($f, $n) = @ARGV; | 1544 \($f, $n) = @ARGV; |
1468 @s = lstat($f); | 1545 @s = lstat($f); |
1469 if (($s[2] & 0170000) == 0120000) { $l = readlink($f); $l = \"\\\"$l\\\"\"; } | 1546 if (($s[2] & 0170000) == 0120000) { $l = readlink($f); $l = \"\\\"$l\\\"\"; } |
1470 elsif (($s[2] & 0170000) == 040000) { $l = \"t\"; } | 1547 elsif (($s[2] & 0170000) == 040000) { $l = \"t\"; } |
1471 else { $l = \"nil\" }; | 1548 else { $l = \"nil\" }; |
1472 $u = ($n eq \"nil\") ? $s[4] : getpwuid($s[4]); | 1549 $u = ($n eq \"nil\") ? $s[4] : getpwuid($s[4]); |
1626 (funcall 'coding-system-p '(dos))) | 1703 (funcall 'coding-system-p '(dos))) |
1627 'dos | 1704 'dos |
1628 'undecided-dos) | 1705 'undecided-dos) |
1629 "Some Emacsen know the `dos' coding system, others need `undecided-dos'.") | 1706 "Some Emacsen know the `dos' coding system, others need `undecided-dos'.") |
1630 | 1707 |
1708 (defvar tramp-last-cmd nil | |
1709 "Internal Tramp variable recording the last command sent. | |
1710 This variable is buffer-local in every buffer.") | |
1711 (make-variable-buffer-local 'tramp-last-cmd) | |
1712 | |
1713 (defvar tramp-process-echoes nil | |
1714 "Whether to process echoes from the remote shell.") | |
1715 | |
1631 (defvar tramp-last-cmd-time nil | 1716 (defvar tramp-last-cmd-time nil |
1632 "Internal Tramp variable recording the time when the last cmd was sent. | 1717 "Internal Tramp variable recording the time when the last cmd was sent. |
1633 This variable is buffer-local in every buffer.") | 1718 This variable is buffer-local in every buffer.") |
1634 (make-variable-buffer-local 'tramp-last-cmd-time) | 1719 (make-variable-buffer-local 'tramp-last-cmd-time) |
1635 | 1720 |
1636 ;; This variable does not have the right value in XEmacs. What should | 1721 ;; This variable does not have the right value in XEmacs. What should |
1637 ;; I use instead of find-operation-coding-system in XEmacs? | 1722 ;; I use instead of find-operation-coding-system in XEmacs? |
1638 (defvar tramp-feature-write-region-fix | 1723 (defvar tramp-feature-write-region-fix |
1639 (when (fboundp 'find-operation-coding-system) | 1724 (when (fboundp 'find-operation-coding-system) |
1640 (let ((file-coding-system-alist '(("test" emacs-mule)))) | 1725 (let ((file-coding-system-alist '(("test" emacs-mule)))) |
1641 (find-operation-coding-system 'write-region 0 0 "" nil "test"))) | 1726 (funcall (symbol-function 'find-operation-coding-system) |
1727 'write-region 0 0 "" nil "test"))) | |
1642 "Internal variable to say if `write-region' chooses the right coding. | 1728 "Internal variable to say if `write-region' chooses the right coding. |
1643 Older versions of Emacs chose the coding system for `write-region' based | 1729 Older versions of Emacs chose the coding system for `write-region' based |
1644 on the FILENAME argument, even if VISIT was a string.") | 1730 on the FILENAME argument, even if VISIT was a string.") |
1645 | 1731 |
1646 ;; New handlers should be added here. The following operations can be | 1732 ;; New handlers should be added here. The following operations can be |
1682 (insert-directory . tramp-handle-insert-directory) | 1768 (insert-directory . tramp-handle-insert-directory) |
1683 (expand-file-name . tramp-handle-expand-file-name) | 1769 (expand-file-name . tramp-handle-expand-file-name) |
1684 (file-local-copy . tramp-handle-file-local-copy) | 1770 (file-local-copy . tramp-handle-file-local-copy) |
1685 (insert-file-contents . tramp-handle-insert-file-contents) | 1771 (insert-file-contents . tramp-handle-insert-file-contents) |
1686 (write-region . tramp-handle-write-region) | 1772 (write-region . tramp-handle-write-region) |
1773 (find-backup-file-name . tramp-handle-find-backup-file-name) | |
1687 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory) | 1774 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory) |
1688 (dired-compress-file . tramp-handle-dired-compress-file) | 1775 (dired-compress-file . tramp-handle-dired-compress-file) |
1689 (dired-call-process . tramp-handle-dired-call-process) | 1776 (dired-call-process . tramp-handle-dired-call-process) |
1690 (dired-recursive-delete-directory | 1777 (dired-recursive-delete-directory |
1691 . tramp-handle-dired-recursive-delete-directory) | 1778 . tramp-handle-dired-recursive-delete-directory) |
1754 (defsubst tramp-line-end-position nil | 1841 (defsubst tramp-line-end-position nil |
1755 "Return point at end of line. | 1842 "Return point at end of line. |
1756 Calls `line-end-position' or `point-at-eol' if defined, else | 1843 Calls `line-end-position' or `point-at-eol' if defined, else |
1757 own implementation." | 1844 own implementation." |
1758 (cond | 1845 (cond |
1759 ((fboundp 'line-end-position) (funcall 'line-end-position)) | 1846 ((fboundp 'line-end-position) (funcall (symbol-function 'line-end-position))) |
1760 ((fboundp 'point-at-eol) (funcall 'point-at-eol)) | 1847 ((fboundp 'point-at-eol) (funcall (symbol-function 'point-at-eol))) |
1761 (t (save-excursion (end-of-line) (point))))) | 1848 (t (save-excursion (end-of-line) (point))))) |
1762 | 1849 |
1763 (defmacro with-parsed-tramp-file-name (filename var &rest body) | 1850 (defmacro with-parsed-tramp-file-name (filename var &rest body) |
1764 "Parse a Tramp filename and make components available in the body. | 1851 "Parse a Tramp filename and make components available in the body. |
1765 | 1852 |
1788 (,(if var (intern (concat (symbol-name var) "-localname")) 'localname) | 1875 (,(if var (intern (concat (symbol-name var) "-localname")) 'localname) |
1789 (tramp-file-name-localname ,(or var 'v)))) | 1876 (tramp-file-name-localname ,(or var 'v)))) |
1790 ,@body)) | 1877 ,@body)) |
1791 | 1878 |
1792 (put 'with-parsed-tramp-file-name 'lisp-indent-function 2) | 1879 (put 'with-parsed-tramp-file-name 'lisp-indent-function 2) |
1880 ;; To be activated for debugging containing this macro | |
1881 (def-edebug-spec with-parsed-tramp-file-name t) | |
1793 | 1882 |
1794 ;;; Config Manipulation Functions: | 1883 ;;; Config Manipulation Functions: |
1795 | 1884 |
1796 (defun tramp-set-completion-function (method function-list) | 1885 (defun tramp-set-completion-function (method function-list) |
1797 "Sets the list of completion functions for METHOD. | 1886 "Sets the list of completion functions for METHOD. |
2709 ;; source file into it, then write out the buffer to | 2798 ;; source file into it, then write out the buffer to |
2710 ;; the target file. The advantage is that it doesn't | 2799 ;; the target file. The advantage is that it doesn't |
2711 ;; matter which filename handlers are used for the | 2800 ;; matter which filename handlers are used for the |
2712 ;; source and target file. | 2801 ;; source and target file. |
2713 (t | 2802 (t |
2714 (tramp-do-copy-or-rename-via-buffer | 2803 (tramp-do-copy-or-rename-file-via-buffer |
2715 op filename newname keep-date)))) | 2804 op filename newname keep-date)))) |
2716 | 2805 |
2717 ;; One file is a Tramp file, the other one is local. | 2806 ;; One file is a Tramp file, the other one is local. |
2718 ((or t1 t2) | 2807 ((or t1 t2) |
2719 ;; If the Tramp file has an out-of-band method, the corresponding | 2808 ;; If the Tramp file has an out-of-band method, the corresponding |
2725 (tramp-method-out-of-band-p | 2814 (tramp-method-out-of-band-p |
2726 v2-multi-method v2-method v2-user v2-host))) | 2815 v2-multi-method v2-method v2-user v2-host))) |
2727 (tramp-do-copy-or-rename-file-out-of-band | 2816 (tramp-do-copy-or-rename-file-out-of-band |
2728 op filename newname keep-date) | 2817 op filename newname keep-date) |
2729 ;; Use the generic method via a Tramp buffer. | 2818 ;; Use the generic method via a Tramp buffer. |
2730 (tramp-do-copy-or-rename-via-buffer op filename newname keep-date))) | 2819 (tramp-do-copy-or-rename-file-via-buffer |
2820 op filename newname keep-date))) | |
2731 | 2821 |
2732 (t | 2822 (t |
2733 ;; One of them must be a Tramp file. | 2823 ;; One of them must be a Tramp file. |
2734 (error "Tramp implementation says this cannot happen"))))) | 2824 (error "Tramp implementation says this cannot happen"))))) |
2735 | 2825 |
2736 ;; CCC: implement keep-date if possible -- via touch? | 2826 (defun tramp-do-copy-or-rename-file-via-buffer (op filename newname keep-date) |
2737 (defun tramp-do-copy-or-rename-via-buffer (op filename newname keep-date) | |
2738 "Use an Emacs buffer to copy or rename a file. | 2827 "Use an Emacs buffer to copy or rename a file. |
2739 First arg OP is either `copy' or `rename' and indicates the operation. | 2828 First arg OP is either `copy' or `rename' and indicates the operation. |
2740 FILENAME is the source file, NEWNAME the target file. | 2829 FILENAME is the source file, NEWNAME the target file. |
2741 KEEP-DATE is non-nil if NEWNAME should have the same timestamp as FILENAME." | 2830 KEEP-DATE is non-nil if NEWNAME should have the same timestamp as FILENAME." |
2742 (let ((trampbuf (get-buffer-create "*tramp output*")) | 2831 (let ((trampbuf (get-buffer-create "*tramp output*")) |
2752 ;; `jka-compr-inhibit' to t. | 2841 ;; `jka-compr-inhibit' to t. |
2753 (let ((coding-system-for-write 'binary) | 2842 (let ((coding-system-for-write 'binary) |
2754 (jka-compr-inhibit t)) | 2843 (jka-compr-inhibit t)) |
2755 (write-region (point-min) (point-max) newname)) | 2844 (write-region (point-min) (point-max) newname)) |
2756 ;; KEEP-DATE handling. | 2845 ;; KEEP-DATE handling. |
2757 (when (and keep-date | 2846 (when keep-date |
2758 (not (null modtime)) | 2847 (when (and (not (null modtime)) |
2759 (not (equal modtime '(0 0)))) | 2848 (not (equal modtime '(0 0)))) |
2760 (tramp-touch newname modtime))) | 2849 (tramp-touch newname modtime)) |
2850 (set-file-modes newname (file-modes filename)))) | |
2761 ;; If the operation was `rename', delete the original file. | 2851 ;; If the operation was `rename', delete the original file. |
2762 (unless (eq op 'copy) | 2852 (unless (eq op 'copy) |
2763 (delete-file filename)))) | 2853 (delete-file filename)))) |
2764 | 2854 |
2765 (defun tramp-do-copy-or-rename-file-directly | 2855 (defun tramp-do-copy-or-rename-file-directly |
2789 | 2879 |
2790 (defun tramp-do-copy-or-rename-file-out-of-band (op filename newname keep-date) | 2880 (defun tramp-do-copy-or-rename-file-out-of-band (op filename newname keep-date) |
2791 "Invoke rcp program to copy. | 2881 "Invoke rcp program to copy. |
2792 One of FILENAME and NEWNAME must be a Tramp name, the other must | 2882 One of FILENAME and NEWNAME must be a Tramp name, the other must |
2793 be a local filename. The method used must be an out-of-band method." | 2883 be a local filename. The method used must be an out-of-band method." |
2794 (let ((trampbuf (get-buffer-create "*tramp output*")) | 2884 (let ((t1 (tramp-tramp-file-p filename)) |
2795 (t1 (tramp-tramp-file-p filename)) | |
2796 (t2 (tramp-tramp-file-p newname)) | 2885 (t2 (tramp-tramp-file-p newname)) |
2797 v1-multi-method v1-method v1-user v1-host v1-localname | 2886 v1-multi-method v1-method v1-user v1-host v1-localname |
2798 v2-multi-method v2-method v2-user v2-host v2-localname | 2887 v2-multi-method v2-method v2-user v2-host v2-localname |
2799 method copy-program copy-args source target) | 2888 multi-method method user host copy-program copy-args |
2889 source target trampbuf) | |
2800 | 2890 |
2801 ;; Check which ones of source and target are Tramp files. | 2891 ;; Check which ones of source and target are Tramp files. |
2802 ;; We cannot invoke `with-parsed-tramp-file-name'; | 2892 ;; We cannot invoke `with-parsed-tramp-file-name'; |
2803 ;; it fails if the file isn't a Tramp file name. | 2893 ;; it fails if the file isn't a Tramp file name. |
2804 (if t1 | 2894 (if t1 |
2806 (setq v1-multi-method l-multi-method | 2896 (setq v1-multi-method l-multi-method |
2807 v1-method l-method | 2897 v1-method l-method |
2808 v1-user l-user | 2898 v1-user l-user |
2809 v1-host l-host | 2899 v1-host l-host |
2810 v1-localname l-localname | 2900 v1-localname l-localname |
2901 multi-method l-multi-method | |
2811 method (tramp-find-method | 2902 method (tramp-find-method |
2812 v1-multi-method v1-method v1-user v1-host) | 2903 v1-multi-method v1-method v1-user v1-host) |
2904 user l-user | |
2905 host l-host | |
2813 copy-program (tramp-get-method-parameter | 2906 copy-program (tramp-get-method-parameter |
2814 v1-multi-method method | 2907 v1-multi-method method |
2815 v1-user v1-host 'tramp-copy-program) | 2908 v1-user v1-host 'tramp-copy-program) |
2816 copy-args (tramp-get-method-parameter | 2909 copy-args (tramp-get-method-parameter |
2817 v1-multi-method method | 2910 v1-multi-method method |
2823 (setq v2-multi-method l-multi-method | 2916 (setq v2-multi-method l-multi-method |
2824 v2-method l-method | 2917 v2-method l-method |
2825 v2-user l-user | 2918 v2-user l-user |
2826 v2-host l-host | 2919 v2-host l-host |
2827 v2-localname l-localname | 2920 v2-localname l-localname |
2921 multi-method l-multi-method | |
2828 method (tramp-find-method | 2922 method (tramp-find-method |
2829 v2-multi-method v2-method v2-user v2-host) | 2923 v2-multi-method v2-method v2-user v2-host) |
2924 user l-user | |
2925 host l-host | |
2830 copy-program (tramp-get-method-parameter | 2926 copy-program (tramp-get-method-parameter |
2831 v2-multi-method method | 2927 v2-multi-method method |
2832 v2-user v2-host 'tramp-copy-program) | 2928 v2-user v2-host 'tramp-copy-program) |
2833 copy-args (tramp-get-method-parameter | 2929 copy-args (tramp-get-method-parameter |
2834 v2-multi-method method | 2930 v2-multi-method method |
2869 (cons (tramp-get-method-parameter | 2965 (cons (tramp-get-method-parameter |
2870 v2-multi-method method | 2966 v2-multi-method method |
2871 v2-user v2-host 'tramp-copy-keep-date-arg) | 2967 v2-user v2-host 'tramp-copy-keep-date-arg) |
2872 copy-args)))) | 2968 copy-args)))) |
2873 | 2969 |
2874 (setq copy-args (append copy-args (list source target))) | 2970 (setq copy-args (append copy-args (list source target)) |
2875 | 2971 trampbuf (generate-new-buffer |
2876 ;; Use rcp-like program for file transfer. | 2972 (tramp-buffer-name multi-method method user host))) |
2877 (tramp-message | 2973 |
2878 5 "Transferring %s to file %s..." filename newname) | 2974 ;; Use an asynchronous process. By this, password can be handled. |
2879 (save-excursion (set-buffer trampbuf) (erase-buffer)) | 2975 (save-excursion |
2880 (unless (equal | 2976 (set-buffer trampbuf) |
2881 0 | 2977 (setq tramp-current-multi-method multi-method |
2882 (apply #'call-process copy-program | 2978 tramp-current-method method |
2883 nil trampbuf nil copy-args)) | 2979 tramp-current-user user |
2884 (pop-to-buffer trampbuf) | 2980 tramp-current-host host) |
2885 (error | 2981 (tramp-message |
2886 (concat | 2982 5 "Transferring %s to file %s..." filename newname) |
2887 "tramp-do-copy-or-rename-file-out-of-band: `%s' didn't work, " | 2983 |
2888 "see buffer `%s' for details") | 2984 ;; Use rcp-like program for file transfer. |
2889 copy-program trampbuf)) | 2985 (let ((p (apply 'start-process (buffer-name trampbuf) trampbuf |
2890 (tramp-message | 2986 copy-program copy-args))) |
2891 5 "Transferring %s to file %s...done" filename newname) | 2987 (process-kill-without-query p) |
2988 (tramp-process-actions p multi-method method user host | |
2989 tramp-actions-copy-out-of-band)) | |
2990 (kill-buffer trampbuf) | |
2991 (tramp-message | |
2992 5 "Transferring %s to file %s...done" filename newname)) | |
2892 | 2993 |
2893 ;; If the operation was `rename', delete the original file. | 2994 ;; If the operation was `rename', delete the original file. |
2894 (unless (eq op 'copy) | 2995 (unless (eq op 'copy) |
2895 (delete-file filename)))) | 2996 (delete-file filename)))) |
2896 | 2997 |
3010 (message "Uncompressing %s..." file) | 3111 (message "Uncompressing %s..." file) |
3011 (when (zerop (tramp-send-command-and-check | 3112 (when (zerop (tramp-send-command-and-check |
3012 multi-method method user host | 3113 multi-method method user host |
3013 (concat (nth 2 suffix) " " localname))) | 3114 (concat (nth 2 suffix) " " localname))) |
3014 (message "Uncompressing %s...done" file) | 3115 (message "Uncompressing %s...done" file) |
3015 (dired-remove-file file) | 3116 ;; `dired-remove-file' is not defined in XEmacs |
3117 (funcall (symbol-function 'dired-remove-file) file) | |
3016 (string-match (car suffix) file) | 3118 (string-match (car suffix) file) |
3017 (concat (substring file 0 (match-beginning 0))))) | 3119 (concat (substring file 0 (match-beginning 0))))) |
3018 (t | 3120 (t |
3019 ;; We don't recognize the file as compressed, so compress it. | 3121 ;; We don't recognize the file as compressed, so compress it. |
3020 ;; Try gzip. | 3122 ;; Try gzip. |
3021 (message "Compressing %s..." file) | 3123 (message "Compressing %s..." file) |
3022 (when (zerop (tramp-send-command-and-check | 3124 (when (zerop (tramp-send-command-and-check |
3023 multi-method method user host | 3125 multi-method method user host |
3024 (concat "gzip -f " localname))) | 3126 (concat "gzip -f " localname))) |
3025 (message "Compressing %s...done" file) | 3127 (message "Compressing %s...done" file) |
3026 (dired-remove-file file) | 3128 ;; `dired-remove-file' is not defined in XEmacs |
3129 (funcall (symbol-function 'dired-remove-file) file) | |
3027 (cond ((file-exists-p (concat file ".gz")) | 3130 (cond ((file-exists-p (concat file ".gz")) |
3028 (concat file ".gz")) | 3131 (concat file ".gz")) |
3029 ((file-exists-p (concat file ".z")) | 3132 ((file-exists-p (concat file ".z")) |
3030 (concat file ".z")) | 3133 (concat file ".z")) |
3031 (t nil))))))))) | 3134 (t nil))))))))) |
3089 (tramp-send-command | 3192 (tramp-send-command |
3090 multi-method method user host | 3193 multi-method method user host |
3091 (format "%s %s %s" | 3194 (format "%s %s %s" |
3092 (tramp-get-ls-command multi-method method user host) | 3195 (tramp-get-ls-command multi-method method user host) |
3093 switches | 3196 switches |
3094 (if full-directory-p | 3197 (if wildcard |
3095 ;; Add "/." to make sure we got complete dir | 3198 localname |
3096 ;; listing for symlinks, too. | 3199 (tramp-shell-quote-argument |
3097 (concat (file-name-as-directory | 3200 (file-name-nondirectory localname)))))) |
3098 (file-name-nondirectory localname)) ".") | |
3099 (file-name-nondirectory localname))))) | |
3100 (sit-for 1) ;needed for rsh but not ssh? | 3201 (sit-for 1) ;needed for rsh but not ssh? |
3101 (tramp-wait-for-output)) | 3202 (tramp-wait-for-output)) |
3102 ;; The following let-binding is used by code that's commented | 3203 ;; The following let-binding is used by code that's commented |
3103 ;; out. Let's leave the let-binding in for a while to see | 3204 ;; out. Let's leave the let-binding in for a while to see |
3104 ;; that the commented-out code is really not needed. Commenting-out | 3205 ;; that the commented-out code is really not needed. Commenting-out |
3359 (unless (file-exists-p filename) | 3460 (unless (file-exists-p filename) |
3360 (error "Cannot make local copy of non-existing file `%s'" | 3461 (error "Cannot make local copy of non-existing file `%s'" |
3361 filename)) | 3462 filename)) |
3362 (setq tmpfil (tramp-make-temp-file)) | 3463 (setq tmpfil (tramp-make-temp-file)) |
3363 | 3464 |
3364 | |
3365 (cond ((tramp-method-out-of-band-p multi-method method user host) | 3465 (cond ((tramp-method-out-of-band-p multi-method method user host) |
3366 ;; `copy-file' handles out-of-band methods | 3466 ;; `copy-file' handles out-of-band methods |
3367 (copy-file filename tmpfil t t)) | 3467 (copy-file filename tmpfil t t)) |
3368 | 3468 |
3369 ((and rem-enc rem-dec) | 3469 ((and rem-enc rem-dec) |
3416 (tramp-call-local-coding-command | 3516 (tramp-call-local-coding-command |
3417 loc-dec tmpfil2 tmpfil) | 3517 loc-dec tmpfil2 tmpfil) |
3418 (delete-file tmpfil2))) | 3518 (delete-file tmpfil2))) |
3419 (tramp-message-for-buffer | 3519 (tramp-message-for-buffer |
3420 multi-method method user host | 3520 multi-method method user host |
3421 5 "Decoding remote file %s...done" filename))) | 3521 5 "Decoding remote file %s...done" filename) |
3522 ;; Set proper permissions. | |
3523 (set-file-modes tmpfil (file-modes filename)))) | |
3422 | 3524 |
3423 (t (error "Wrong method specification for `%s'" method))) | 3525 (t (error "Wrong method specification for `%s'" method))) |
3424 tmpfil))) | 3526 tmpfil))) |
3425 | 3527 |
3426 | 3528 |
3468 (when (boundp 'last-coding-system-used) | 3570 (when (boundp 'last-coding-system-used) |
3469 (setq last-coding-system-used coding-system-used)) | 3571 (setq last-coding-system-used coding-system-used)) |
3470 (list (expand-file-name filename) | 3572 (list (expand-file-name filename) |
3471 (second result)))))) | 3573 (second result)))))) |
3472 | 3574 |
3575 | |
3576 (defun tramp-handle-find-backup-file-name (filename) | |
3577 "Like `find-backup-file-name' for tramp files." | |
3578 | |
3579 (if (or (and (not (featurep 'xemacs)) | |
3580 (not (boundp 'tramp-backup-directory-alist))) | |
3581 (and (featurep 'xemacs) | |
3582 (not (boundp 'tramp-bkup-backup-directory-info)))) | |
3583 | |
3584 ;; No tramp backup directory alist defined, or nil | |
3585 (tramp-run-real-handler 'find-backup-file-name (list filename)) | |
3586 | |
3587 (with-parsed-tramp-file-name filename nil | |
3588 (let* ((backup-var | |
3589 (copy-tree | |
3590 (if (featurep 'xemacs) | |
3591 ;; XEmacs case | |
3592 (symbol-value 'tramp-bkup-backup-directory-info) | |
3593 ;; Emacs case | |
3594 (symbol-value 'tramp-backup-directory-alist)))) | |
3595 | |
3596 ;; We set both variables. It doesn't matter whether it is | |
3597 ;; Emacs or XEmacs | |
3598 (backup-directory-alist backup-var) | |
3599 (bkup-backup-directory-info backup-var)) | |
3600 | |
3601 (mapcar | |
3602 '(lambda (x) | |
3603 (let ((dir (if (consp (cdr x)) (car (cdr x)) (cdr x)))) | |
3604 (when (and (stringp dir) | |
3605 (file-name-absolute-p dir) | |
3606 (not (tramp-file-name-p dir))) | |
3607 ;; Prepend absolute directory names with tramp prefix | |
3608 (if (consp (cdr x)) | |
3609 (setcar (cdr x) | |
3610 (tramp-make-tramp-file-name | |
3611 multi-method method user host dir)) | |
3612 (setcdr x (tramp-make-tramp-file-name | |
3613 multi-method method user host dir)))))) | |
3614 backup-var) | |
3615 | |
3616 (tramp-run-real-handler 'find-backup-file-name (list filename)))))) | |
3617 | |
3473 ;; CCC grok APPEND, LOCKNAME, CONFIRM | 3618 ;; CCC grok APPEND, LOCKNAME, CONFIRM |
3474 (defun tramp-handle-write-region | 3619 (defun tramp-handle-write-region |
3475 (start end filename &optional append visit lockname confirm) | 3620 (start end filename &optional append visit lockname confirm) |
3476 "Like `write-region' for tramp files." | 3621 "Like `write-region' for tramp files." |
3477 (unless (eq append nil) | 3622 (unless (eq append nil) |
3497 (rem-enc (tramp-get-remote-encoding multi-method method user host)) | 3642 (rem-enc (tramp-get-remote-encoding multi-method method user host)) |
3498 (rem-dec (tramp-get-remote-decoding multi-method method user host)) | 3643 (rem-dec (tramp-get-remote-decoding multi-method method user host)) |
3499 (loc-enc (tramp-get-local-encoding multi-method method user host)) | 3644 (loc-enc (tramp-get-local-encoding multi-method method user host)) |
3500 (loc-dec (tramp-get-local-decoding multi-method method user host)) | 3645 (loc-dec (tramp-get-local-decoding multi-method method user host)) |
3501 (trampbuf (get-buffer-create "*tramp output*")) | 3646 (trampbuf (get-buffer-create "*tramp output*")) |
3647 (modes (file-modes filename)) | |
3502 ;; We use this to save the value of `last-coding-system-used' | 3648 ;; We use this to save the value of `last-coding-system-used' |
3503 ;; after writing the tmp file. At the end of the function, | 3649 ;; after writing the tmp file. At the end of the function, |
3504 ;; we set `last-coding-system-used' to this saved value. | 3650 ;; we set `last-coding-system-used' to this saved value. |
3505 ;; This way, any intermediary coding systems used while | 3651 ;; This way, any intermediary coding systems used while |
3506 ;; talking to the remote shell or suchlike won't hose this | 3652 ;; talking to the remote shell or suchlike won't hose this |
3517 (tramp-run-real-handler | 3663 (tramp-run-real-handler |
3518 'write-region | 3664 'write-region |
3519 (if confirm ; don't pass this arg unless defined for backward compat. | 3665 (if confirm ; don't pass this arg unless defined for backward compat. |
3520 (list start end tmpfil append 'no-message lockname confirm) | 3666 (list start end tmpfil append 'no-message lockname confirm) |
3521 (list start end tmpfil append 'no-message lockname))) | 3667 (list start end tmpfil append 'no-message lockname))) |
3668 ;; The permissions of the temporary file should be set. If | |
3669 ;; filename does not exist (eq modes nil) it has been renamed to | |
3670 ;; the backup file. This case `save-buffer' handles | |
3671 ;; permissions. | |
3672 (when modes (set-file-modes tmpfil modes)) | |
3522 ;; Now, `last-coding-system-used' has the right value. Remember it. | 3673 ;; Now, `last-coding-system-used' has the right value. Remember it. |
3523 (when (boundp 'last-coding-system-used) | 3674 (when (boundp 'last-coding-system-used) |
3524 (setq coding-system-used last-coding-system-used)) | 3675 (setq coding-system-used last-coding-system-used)) |
3525 ;; This is a bit lengthy due to the different methods possible for | 3676 ;; This is a bit lengthy due to the different methods possible for |
3526 ;; file transfer. First, we check whether the method uses an rcp | 3677 ;; file transfer. First, we check whether the method uses an rcp |
3883 user host x))) | 4034 user host x))) |
3884 (read (current-buffer)))))) | 4035 (read (current-buffer)))))) |
3885 (list (tramp-handle-expand-file-name name)))))) | 4036 (list (tramp-handle-expand-file-name name)))))) |
3886 | 4037 |
3887 ;; Check for complete.el and override PC-expand-many-files if appropriate. | 4038 ;; Check for complete.el and override PC-expand-many-files if appropriate. |
3888 (eval-when-compile | 4039 (eval-and-compile |
3889 (defun tramp-save-PC-expand-many-files (name))); avoid compiler warning | 4040 (defun tramp-save-PC-expand-many-files (name))); avoid compiler warning |
3890 | 4041 |
3891 (defun tramp-setup-complete () | 4042 (defun tramp-setup-complete () |
3892 (fset 'tramp-save-PC-expand-many-files | 4043 (fset 'tramp-save-PC-expand-many-files |
3893 (symbol-function 'PC-expand-many-files)) | 4044 (symbol-function 'PC-expand-many-files)) |
3934 (char-equal last-input-event ?\ ))) | 4085 (char-equal last-input-event ?\ ))) |
3935 ;; XEmacs | 4086 ;; XEmacs |
3936 (and (featurep 'xemacs) | 4087 (and (featurep 'xemacs) |
3937 (not (event-modifiers last-input-event)) | 4088 (not (event-modifiers last-input-event)) |
3938 (or (char-equal | 4089 (or (char-equal |
3939 (funcall 'event-to-character last-input-event) ?\?) | 4090 (funcall (symbol-function 'event-to-character) |
4091 last-input-event) ?\?) | |
3940 (char-equal | 4092 (char-equal |
3941 (funcall 'event-to-character last-input-event) ?\t) | 4093 (funcall (symbol-function 'event-to-character) |
4094 last-input-event) ?\t) | |
3942 (char-equal | 4095 (char-equal |
3943 (funcall 'event-to-character last-input-event) ?\ )))) | 4096 (funcall (symbol-function 'event-to-character) |
4097 last-input-event) ?\ )))) | |
3944 t))) | 4098 t))) |
3945 | 4099 |
3946 (defun tramp-completion-handle-file-exists-p (filename) | 4100 (defun tramp-completion-handle-file-exists-p (filename) |
3947 "Like `file-exists-p' for tramp files." | 4101 "Like `file-exists-p' for tramp files." |
3948 (if (tramp-completion-mode filename) | 4102 (if (tramp-completion-mode filename) |
4476 | 4630 |
4477 (defun tramp-touch (file time) | 4631 (defun tramp-touch (file time) |
4478 "Set the last-modified timestamp of the given file. | 4632 "Set the last-modified timestamp of the given file. |
4479 TIME is an Emacs internal time value as returned by `current-time'." | 4633 TIME is an Emacs internal time value as returned by `current-time'." |
4480 (let ((touch-time (format-time-string "%Y%m%d%H%M.%S" time))) | 4634 (let ((touch-time (format-time-string "%Y%m%d%H%M.%S" time))) |
4481 (with-parsed-tramp-file-name file nil | 4635 (if (tramp-tramp-file-p file) |
4482 (let ((buf (tramp-get-buffer multi-method method user host))) | 4636 (with-parsed-tramp-file-name file nil |
4483 (unless (zerop (tramp-send-command-and-check | 4637 (let ((buf (tramp-get-buffer multi-method method user host))) |
4484 multi-method method user host | 4638 (unless (zerop (tramp-send-command-and-check |
4485 (format "touch -t %s %s" | 4639 multi-method method user host |
4486 touch-time | 4640 (format "touch -t %s %s" |
4487 localname))) | 4641 touch-time |
4488 (pop-to-buffer buf) | 4642 localname))) |
4489 (error "tramp-touch: touch failed, see buffer `%s' for details" | 4643 (pop-to-buffer buf) |
4490 buf)))))) | 4644 (error "tramp-touch: touch failed, see buffer `%s' for details" |
4491 | 4645 buf)))) |
4646 ;; It's a local file | |
4647 (with-temp-buffer | |
4648 (unless (zerop (call-process | |
4649 "touch" nil (current-buffer) nil "-t" touch-time file)) | |
4650 (pop-to-buffer (current-buffer)) | |
4651 (error "tramp-touch: touch failed")))))) | |
4652 | |
4492 (defun tramp-buffer-name (multi-method method user host) | 4653 (defun tramp-buffer-name (multi-method method user host) |
4493 "A name for the connection buffer for USER at HOST using METHOD." | 4654 "A name for the connection buffer for USER at HOST using METHOD." |
4494 (if multi-method | 4655 (if multi-method |
4495 (tramp-buffer-name-multi-method "tramp" multi-method method user host) | 4656 (tramp-buffer-name-multi-method "tramp" multi-method method user host) |
4496 (let ((method (tramp-find-method multi-method method user host))) | 4657 (let ((method (tramp-find-method multi-method method user host))) |
4813 tramp-terminal-type) | 4974 tramp-terminal-type) |
4814 (erase-buffer) | 4975 (erase-buffer) |
4815 (process-send-string nil (concat tramp-terminal-type | 4976 (process-send-string nil (concat tramp-terminal-type |
4816 tramp-rsh-end-of-line))) | 4977 tramp-rsh-end-of-line))) |
4817 | 4978 |
4979 (defun tramp-action-out-of-band (p multi-method method user host) | |
4980 "Check whether an out-of-band copy has finished." | |
4981 (cond ((and (memq (process-status p) '(stop exit)) | |
4982 (zerop (process-exit-status p))) | |
4983 (tramp-message 9 "Process has finished.") | |
4984 (throw 'tramp-action 'ok)) | |
4985 ((or (and (memq (process-status p) '(stop exit)) | |
4986 (not (zerop (process-exit-status p)))) | |
4987 (memq (process-status p) '(signal))) | |
4988 (tramp-message 9 "Process has died.") | |
4989 (throw 'tramp-action 'process-died)) | |
4990 (t nil))) | |
4991 | |
4818 ;; The following functions are specifically for multi connections. | 4992 ;; The following functions are specifically for multi connections. |
4819 | 4993 |
4820 (defun tramp-multi-action-login (p method user host) | 4994 (defun tramp-multi-action-login (p method user host) |
4821 "Send the login name." | 4995 "Send the login name." |
4822 (tramp-message 9 "Sending login name `%s'" user) | 4996 (tramp-message 9 "Sending login name `%s'" user) |
4929 (while commands | 5103 (while commands |
4930 (setq cmd (pop commands)) | 5104 (setq cmd (pop commands)) |
4931 (erase-buffer) | 5105 (erase-buffer) |
4932 (tramp-message 10 "Sending command to remote shell: %s" | 5106 (tramp-message 10 "Sending command to remote shell: %s" |
4933 cmd) | 5107 cmd) |
4934 (tramp-send-command multi-method method user host cmd) | 5108 (tramp-send-command multi-method method user host cmd nil t) |
4935 (tramp-barf-if-no-shell-prompt | 5109 (tramp-barf-if-no-shell-prompt |
4936 p 60 "Remote shell command failed: %s" cmd)) | 5110 p 60 "Remote shell command failed: %s" cmd)) |
4937 (erase-buffer))) | 5111 (erase-buffer))) |
4938 | 5112 |
4939 ;; The actual functions for opening connections. | 5113 ;; The actual functions for opening connections. |
5011 If USER is nil, start the command `rsh HOST'[*] instead | 5185 If USER is nil, start the command `rsh HOST'[*] instead |
5012 | 5186 |
5013 Recognition of the remote shell prompt is based on the variables | 5187 Recognition of the remote shell prompt is based on the variables |
5014 `shell-prompt-pattern' and `tramp-shell-prompt-pattern' which must be | 5188 `shell-prompt-pattern' and `tramp-shell-prompt-pattern' which must be |
5015 set up correctly. | 5189 set up correctly. |
5016 | |
5017 Please note that it is NOT possible to use this connection method with | |
5018 an out-of-band transfer method if this function asks the user for a | |
5019 password! You must use an inline transfer method in this case. | |
5020 Sadly, the transfer method cannot be switched on the fly, instead you | |
5021 must specify the right method in the file name. | |
5022 | 5190 |
5023 Kludgy feature: if HOST has the form \"xx#yy\", then yy is assumed to | 5191 Kludgy feature: if HOST has the form \"xx#yy\", then yy is assumed to |
5024 be a port number for ssh, and \"-p yy\" will be added to the list of | 5192 be a port number for ssh, and \"-p yy\" will be added to the list of |
5025 arguments, and xx will be used as the host name to connect to. | 5193 arguments, and xx will be used as the host name to connect to. |
5026 | 5194 |
5409 (buffer-name)) | 5577 (buffer-name)) |
5410 (tramp-message 8 "Setting up remote shell environment") | 5578 (tramp-message 8 "Setting up remote shell environment") |
5411 (tramp-discard-garbage-erase-buffer p multi-method method user host) | 5579 (tramp-discard-garbage-erase-buffer p multi-method method user host) |
5412 (tramp-send-command-internal multi-method method user host | 5580 (tramp-send-command-internal multi-method method user host |
5413 "stty -inlcr -echo kill '^U'") | 5581 "stty -inlcr -echo kill '^U'") |
5582 (erase-buffer) | |
5583 ;; Ignore garbage after stty command. | |
5584 (tramp-send-command-internal multi-method method user host | |
5585 "echo foo") | |
5414 (erase-buffer) | 5586 (erase-buffer) |
5415 (tramp-send-command-internal multi-method method user host | 5587 (tramp-send-command-internal multi-method method user host |
5416 "TERM=dumb; export TERM") | 5588 "TERM=dumb; export TERM") |
5417 ;; Try to set up the coding system correctly. | 5589 ;; Try to set up the coding system correctly. |
5418 ;; CCC this can't be the right way to do it. Hm. | 5590 ;; CCC this can't be the right way to do it. Hm. |
5856 connection. This is meant to be used from | 6028 connection. This is meant to be used from |
5857 `tramp-maybe-open-connection' only." | 6029 `tramp-maybe-open-connection' only." |
5858 (or neveropen | 6030 (or neveropen |
5859 (tramp-maybe-open-connection multi-method method user host)) | 6031 (tramp-maybe-open-connection multi-method method user host)) |
5860 (setq tramp-last-cmd-time (current-time)) | 6032 (setq tramp-last-cmd-time (current-time)) |
6033 (setq tramp-last-cmd command) | |
5861 (when tramp-debug-buffer | 6034 (when tramp-debug-buffer |
5862 (save-excursion | 6035 (save-excursion |
5863 (set-buffer (tramp-get-debug-buffer multi-method method user host)) | 6036 (set-buffer (tramp-get-debug-buffer multi-method method user host)) |
5864 (goto-char (point-max)) | 6037 (goto-char (point-max)) |
5865 (tramp-insert-with-face 'bold (format "$ %s\n" command)))) | 6038 (tramp-insert-with-face 'bold (format "$ %s\n" command)))) |
5884 (defun tramp-wait-for-output (&optional timeout) | 6057 (defun tramp-wait-for-output (&optional timeout) |
5885 "Wait for output from remote rsh command." | 6058 "Wait for output from remote rsh command." |
5886 (let ((proc (get-buffer-process (current-buffer))) | 6059 (let ((proc (get-buffer-process (current-buffer))) |
5887 (found nil) | 6060 (found nil) |
5888 (start-time (current-time)) | 6061 (start-time (current-time)) |
6062 (start-point (point)) | |
5889 (end-of-output (concat "^" | 6063 (end-of-output (concat "^" |
5890 (regexp-quote tramp-end-of-output) | 6064 (regexp-quote tramp-end-of-output) |
5891 "\r?$"))) | 6065 "\r?$"))) |
5892 ;; Algorithm: get waiting output. See if last line contains | 6066 ;; Algorithm: get waiting output. See if last line contains |
5893 ;; end-of-output sentinel. If not, wait a bit and again get | 6067 ;; end-of-output sentinel. If not, wait a bit and again get |
5918 ;; the end-of-output sentinel. | 6092 ;; the end-of-output sentinel. |
5919 (when found | 6093 (when found |
5920 (goto-char (point-max)) | 6094 (goto-char (point-max)) |
5921 (forward-line -2) | 6095 (forward-line -2) |
5922 (delete-region (point) (point-max))) | 6096 (delete-region (point) (point-max))) |
6097 ;; If processing echoes, look for it in the first line and delete. | |
6098 (when tramp-process-echoes | |
6099 (save-excursion | |
6100 (goto-char start-point) | |
6101 (when (looking-at (regexp-quote tramp-last-cmd)) | |
6102 (delete-region (point) (forward-line 1))))) | |
5923 ;; Add output to debug buffer if appropriate. | 6103 ;; Add output to debug buffer if appropriate. |
5924 (when tramp-debug-buffer | 6104 (when tramp-debug-buffer |
5925 (append-to-buffer | 6105 (append-to-buffer |
5926 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method | 6106 (tramp-get-debug-buffer tramp-current-multi-method tramp-current-method |
5927 tramp-current-user tramp-current-host) | 6107 tramp-current-user tramp-current-host) |
6323 (if user | 6503 (if user |
6324 (format "%s@%s:%s" user host localname) | 6504 (format "%s@%s:%s" user host localname) |
6325 (format "%s:%s" host localname))) | 6505 (format "%s:%s" host localname))) |
6326 | 6506 |
6327 (defun tramp-method-out-of-band-p (multi-method method user host) | 6507 (defun tramp-method-out-of-band-p (multi-method method user host) |
6328 "Return t if this is an out-of-band method, nil otherwise. | 6508 "Return t if this is an out-of-band method, nil otherwise." |
6329 It is important to check for this condition, since it is not possible | |
6330 to enter a password for the `tramp-copy-program'." | |
6331 (tramp-get-method-parameter | 6509 (tramp-get-method-parameter |
6332 multi-method | 6510 multi-method |
6333 (tramp-find-method multi-method method user host) | 6511 (tramp-find-method multi-method method user host) |
6334 user host 'tramp-copy-program)) | 6512 user host 'tramp-copy-program)) |
6335 | 6513 |
6500 "Read a password from user (compat function). | 6678 "Read a password from user (compat function). |
6501 Invokes `password-read' if available, `read-passwd' else." | 6679 Invokes `password-read' if available, `read-passwd' else." |
6502 (if (functionp 'password-read) | 6680 (if (functionp 'password-read) |
6503 (let* ((user (or tramp-current-user (user-login-name))) | 6681 (let* ((user (or tramp-current-user (user-login-name))) |
6504 (host (or tramp-current-host (system-name))) | 6682 (host (or tramp-current-host (system-name))) |
6505 (key (concat user "@" host)) | 6683 (key (if (and (stringp user) (stringp host)) |
6684 (concat user "@" host) | |
6685 (concat "[" (mapconcat 'identity user "/") "]@[" | |
6686 (mapconcat 'identity host "/") "]"))) | |
6506 (password (apply #'password-read (list prompt key)))) | 6687 (password (apply #'password-read (list prompt key)))) |
6507 (apply #'password-cache-add (list key password)) | 6688 (apply #'password-cache-add (list key password)) |
6508 password) | 6689 password) |
6509 (read-passwd prompt))) | 6690 (read-passwd prompt))) |
6510 | 6691 |
6712 tramp-login-prompt-regexp | 6893 tramp-login-prompt-regexp |
6713 tramp-password-prompt-regexp | 6894 tramp-password-prompt-regexp |
6714 tramp-wrong-passwd-regexp | 6895 tramp-wrong-passwd-regexp |
6715 tramp-yesno-prompt-regexp | 6896 tramp-yesno-prompt-regexp |
6716 tramp-yn-prompt-regexp | 6897 tramp-yn-prompt-regexp |
6898 tramp-terminal-prompt-regexp | |
6899 tramp-out-of-band-prompt-regexp | |
6717 tramp-temp-name-prefix | 6900 tramp-temp-name-prefix |
6718 tramp-file-name-structure | 6901 tramp-file-name-structure |
6719 tramp-file-name-regexp | 6902 tramp-file-name-regexp |
6720 tramp-multi-file-name-structure | 6903 tramp-multi-file-name-structure |
6721 tramp-multi-file-name-hop-structure | 6904 tramp-multi-file-name-hop-structure |
6723 tramp-multi-connection-function-alist | 6906 tramp-multi-connection-function-alist |
6724 tramp-methods | 6907 tramp-methods |
6725 tramp-end-of-output | 6908 tramp-end-of-output |
6726 tramp-coding-commands | 6909 tramp-coding-commands |
6727 tramp-actions-before-shell | 6910 tramp-actions-before-shell |
6911 tramp-actions-copy-out-of-band | |
6728 tramp-multi-actions | 6912 tramp-multi-actions |
6729 tramp-terminal-type | 6913 tramp-terminal-type |
6730 tramp-shell-prompt-pattern | 6914 tramp-shell-prompt-pattern |
6731 tramp-chunksize | 6915 tramp-chunksize |
6916 ,(when (boundp 'tramp-backup-directory-alist) | |
6917 'tramp-backup-directory-alist) | |
6918 ,(when (boundp 'tramp-bkup-backup-directory-info) | |
6919 'tramp-bkup-backup-directory-info) | |
6732 | 6920 |
6733 ;; Non-tramp variables of interest | 6921 ;; Non-tramp variables of interest |
6734 shell-prompt-pattern | 6922 shell-prompt-pattern |
6735 backup-by-copying | 6923 backup-by-copying |
6736 backup-by-copying-when-linked | 6924 backup-by-copying-when-linked |
6737 backup-by-copying-when-mismatch | 6925 backup-by-copying-when-mismatch |
6738 ,(when (boundp 'backup-by-copying-when-privileged-mismatch) | 6926 ,(when (boundp 'backup-by-copying-when-privileged-mismatch) |
6739 'backup-by-copying-when-privileged-mismatch) | 6927 'backup-by-copying-when-privileged-mismatch) |
6928 ,(when (boundp 'password-cache) | |
6929 'password-cache) | |
6930 ,(when (boundp 'password-cache-expiry) | |
6931 'password-cache-expiry) | |
6932 ,(when (boundp 'backup-directory-alist) | |
6933 'backup-directory-alist) | |
6934 ,(when (boundp 'bkup-backup-directory-info) | |
6935 'bkup-backup-directory-info) | |
6740 file-name-handler-alist) | 6936 file-name-handler-alist) |
6741 nil ; pre-hook | 6937 nil ; pre-hook |
6742 nil ; post-hook | 6938 nil ; post-hook |
6743 "\ | 6939 "\ |
6744 Enter your bug report in this message, including as much detail as you | 6940 Enter your bug report in this message, including as much detail as you |
6797 ;; * Cooperate with PCL-CVS. It uses start-process, which doesn't | 6993 ;; * Cooperate with PCL-CVS. It uses start-process, which doesn't |
6798 ;; work for remote files. | 6994 ;; work for remote files. |
6799 ;; * Rewrite `tramp-shell-quote-argument' to abstain from using | 6995 ;; * Rewrite `tramp-shell-quote-argument' to abstain from using |
6800 ;; `shell-quote-argument'. | 6996 ;; `shell-quote-argument'. |
6801 ;; * Completion gets confused when you leave out the method name. | 6997 ;; * Completion gets confused when you leave out the method name. |
6802 ;; * Support `dired-compress-file' filename handler. | |
6803 ;; * In Emacs 21, `insert-directory' shows total number of bytes used | 6998 ;; * In Emacs 21, `insert-directory' shows total number of bytes used |
6804 ;; by the files in that directory. Add this here. | 6999 ;; by the files in that directory. Add this here. |
6805 ;; * Avoid screen blanking when hitting `g' in dired. (Eli Tziperman) | 7000 ;; * Avoid screen blanking when hitting `g' in dired. (Eli Tziperman) |
6806 ;; * Make ffap.el grok Tramp filenames. (Eli Tziperman) | 7001 ;; * Make ffap.el grok Tramp filenames. (Eli Tziperman) |
6807 ;; * When logging in, keep looking for questions according to an alist | 7002 ;; * When logging in, keep looking for questions according to an alist |
6818 ;; do the right thing. | 7013 ;; do the right thing. |
6819 ;; * `vc-directory' does not work. It never displays any files, even | 7014 ;; * `vc-directory' does not work. It never displays any files, even |
6820 ;; if it does show files when run locally. | 7015 ;; if it does show files when run locally. |
6821 ;; * Allow correction of passwords, if the remote end allows this. | 7016 ;; * Allow correction of passwords, if the remote end allows this. |
6822 ;; (Mark Hershberger) | 7017 ;; (Mark Hershberger) |
6823 ;; * Make sure permissions of tmp file are good. | |
6824 ;; (Nelson Minar <nelson@media.mit.edu>) | |
6825 ;; * Grok passwd prompts with scp? (David Winter | |
6826 ;; <winter@nevis1.nevis.columbia.edu>). Maybe just do `ssh -l user | |
6827 ;; host', then wait a while for the passwd or passphrase prompt. If | |
6828 ;; there is one, remember the passwd/phrase. | |
6829 ;; * How to deal with MULE in `insert-file-contents' and `write-region'? | 7018 ;; * How to deal with MULE in `insert-file-contents' and `write-region'? |
6830 ;; * Do asynchronous `shell-command's. | 7019 ;; * Do asynchronous `shell-command's. |
6831 ;; * Grok `append' parameter for `write-region'. | 7020 ;; * Grok `append' parameter for `write-region'. |
6832 ;; * Test remote ksh or bash for tilde expansion in `tramp-find-shell'? | 7021 ;; * Test remote ksh or bash for tilde expansion in `tramp-find-shell'? |
6833 ;; * abbreviate-file-name | 7022 ;; * abbreviate-file-name |
6834 ;; * grok ~ in tramp-remote-path (Henrik Holm <henrikh@tele.ntnu.no>) | 7023 ;; * grok ~ in tramp-remote-path (Henrik Holm <henrikh@tele.ntnu.no>) |
6835 ;; * `C' in dired gives error `not tramp file name'. | |
6836 ;; * Also allow to omit user names when doing multi-hop. Not sure yet | 7024 ;; * Also allow to omit user names when doing multi-hop. Not sure yet |
6837 ;; what the user names should default to, though. | 7025 ;; what the user names should default to, though. |
6838 ;; * better error checking. At least whenever we see something | 7026 ;; * better error checking. At least whenever we see something |
6839 ;; strange when doing zerop, we should kill the process and start | 7027 ;; strange when doing zerop, we should kill the process and start |
6840 ;; again. (Greg Stark) | 7028 ;; again. (Greg Stark) |
6846 ;; * Remove unneeded parameters from methods. | 7034 ;; * Remove unneeded parameters from methods. |
6847 ;; * Invoke rsync once for copying a whole directory hierarchy. | 7035 ;; * Invoke rsync once for copying a whole directory hierarchy. |
6848 ;; (Francesco Potort,Al(B) | 7036 ;; (Francesco Potort,Al(B) |
6849 ;; * Should we set PATH ourselves or should we rely on the remote end | 7037 ;; * Should we set PATH ourselves or should we rely on the remote end |
6850 ;; to do it? | 7038 ;; to do it? |
6851 ;; * Do the autoconf thing. | |
6852 ;; * Make it work for XEmacs 20, which is missing `with-timeout'. | 7039 ;; * Make it work for XEmacs 20, which is missing `with-timeout'. |
6853 ;; * Allow non-Unix remote systems. (More a long-term thing.) | |
6854 ;; * Make it work for different encodings, and for different file name | 7040 ;; * Make it work for different encodings, and for different file name |
6855 ;; encodings, too. (Daniel Pittman) | 7041 ;; encodings, too. (Daniel Pittman) |
6856 ;; * Change applicable functions to pass a struct tramp-file-name rather | 7042 ;; * Change applicable functions to pass a struct tramp-file-name rather |
6857 ;; than the individual items MULTI-METHOD, METHOD, USER, HOST, LOCALNAME. | 7043 ;; than the individual items MULTI-METHOD, METHOD, USER, HOST, LOCALNAME. |
6858 ;; * Implement asynchronous shell commands. | 7044 ;; * Implement asynchronous shell commands. |
6863 ;; * Don't search for perl5 and perl. Instead, only search for perl and | 7049 ;; * Don't search for perl5 and perl. Instead, only search for perl and |
6864 ;; then look if it's the right version (with `perl -v'). | 7050 ;; then look if it's the right version (with `perl -v'). |
6865 ;; * When editing a remote CVS controlled file as a different user, VC | 7051 ;; * When editing a remote CVS controlled file as a different user, VC |
6866 ;; gets confused about the file locking status. Try to find out why | 7052 ;; gets confused about the file locking status. Try to find out why |
6867 ;; the workaround doesn't work. | 7053 ;; the workaround doesn't work. |
6868 ;; * When user is running ssh-agent, it would be useful to add the | |
6869 ;; passwords typed by the user to that agent. This way, the next time | |
6870 ;; round, the users don't have to type all this in again. | |
6871 ;; This would be especially useful for start-process, I think. | |
6872 ;; An easy way to implement start-process is to open a second shell | |
6873 ;; connection which is inconvenient if the user has to reenter | |
6874 ;; passwords. | |
6875 ;; * Change `copy-file' to grok the case where the filename handler | 7054 ;; * Change `copy-file' to grok the case where the filename handler |
6876 ;; for the source and the target file are different. Right now, | 7055 ;; for the source and the target file are different. Right now, |
6877 ;; it looks at the source file and then calls that handler, if | 7056 ;; it looks at the source file and then calls that handler, if |
6878 ;; there is one. But since ange-ftp, for instance, does not know | 7057 ;; there is one. But since ange-ftp, for instance, does not know |
6879 ;; about Tramp, it does not do the right thing if the target file | 7058 ;; about Tramp, it does not do the right thing if the target file |
6893 ;; ** Add a learning mode for completion. Make results persistent. | 7072 ;; ** Add a learning mode for completion. Make results persistent. |
6894 ;; * Allow out-of-band methods as _last_ multi-hop. | 7073 ;; * Allow out-of-band methods as _last_ multi-hop. |
6895 | 7074 |
6896 ;; Functions for file-name-handler-alist: | 7075 ;; Functions for file-name-handler-alist: |
6897 ;; diff-latest-backup-file -- in diff.el | 7076 ;; diff-latest-backup-file -- in diff.el |
6898 ;; dired-compress-file | |
6899 ;; dired-uncache -- this will be needed when we do insert-directory caching | 7077 ;; dired-uncache -- this will be needed when we do insert-directory caching |
6900 ;; file-name-as-directory -- use primitive? | 7078 ;; file-name-as-directory -- use primitive? |
6901 ;; file-name-directory -- use primitive? | |
6902 ;; file-name-nondirectory -- use primitive? | |
6903 ;; file-name-sans-versions -- use primitive? | 7079 ;; file-name-sans-versions -- use primitive? |
6904 ;; file-newer-than-file-p | |
6905 ;; find-backup-file-name | |
6906 ;; get-file-buffer -- use primitive | 7080 ;; get-file-buffer -- use primitive |
6907 ;; load | |
6908 ;; unhandled-file-name-directory | |
6909 ;; vc-registered | 7081 ;; vc-registered |
6910 | 7082 |
6911 ;;; arch-tag: 3a21a994-182b-48fa-b0cd-c1d9fede424a | 7083 ;;; arch-tag: 3a21a994-182b-48fa-b0cd-c1d9fede424a |
6912 ;;; tramp.el ends here | 7084 ;;; tramp.el ends here |