Mercurial > emacs
comparison lisp/net/tramp.el @ 108450:de8a1b891175
Merge from mainline.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Sun, 11 Apr 2010 10:53:01 +0000 |
parents | 02b5fe4a01fe |
children | 57532220127a |
comparison
equal
deleted
inserted
replaced
108449:0346e41d1e53 | 108450:de8a1b891175 |
---|---|
34 ;; For more detailed instructions, please see the info file. | 34 ;; For more detailed instructions, please see the info file. |
35 ;; | 35 ;; |
36 ;; Notes: | 36 ;; Notes: |
37 ;; ----- | 37 ;; ----- |
38 ;; | 38 ;; |
39 ;; This package only works for Emacs 21.1 and higher, and for XEmacs 21.4 | 39 ;; This package only works for Emacs 22.1 and higher, and for XEmacs 21.4 |
40 ;; and higher. For XEmacs 21, you need the package `fsf-compat' for | 40 ;; and higher. For XEmacs 21, you need the package `fsf-compat' for |
41 ;; the `with-timeout' macro. | 41 ;; the `with-timeout' macro. |
42 ;; | 42 ;; |
43 ;; Also see the todo list at the bottom of this file. | 43 ;; Also see the todo list at the bottom of this file. |
44 ;; | 44 ;; |
77 (add-hook 'tramp-unload-hook | 77 (add-hook 'tramp-unload-hook |
78 (lambda () | 78 (lambda () |
79 (when (featurep 'tramp-compat) | 79 (when (featurep 'tramp-compat) |
80 (unload-feature 'tramp-compat 'force)))) | 80 (unload-feature 'tramp-compat 'force)))) |
81 | 81 |
82 (require 'format-spec) ; from Gnus 5.8, also in tar ball | 82 (require 'format-spec) |
83 ;; As long as password.el is not part of (X)Emacs, it shouldn't | 83 ;; As long as password.el is not part of (X)Emacs, it shouldn't |
84 ;; be mandatory | 84 ;; be mandatory |
85 (if (featurep 'xemacs) | 85 (if (featurep 'xemacs) |
86 (load "password" 'noerror) | 86 (load "password" 'noerror) |
87 (or (require 'password-cache nil 'noerror) | 87 (or (require 'password-cache nil 'noerror) |
869 "HKEY_CURRENT_USER\\Software\\SimonTatham\\PuTTY\\Sessions")) | 869 "HKEY_CURRENT_USER\\Software\\SimonTatham\\PuTTY\\Sessions")) |
870 "Default list of (FUNCTION REGISTRY) pairs to be examined for putty methods.") | 870 "Default list of (FUNCTION REGISTRY) pairs to be examined for putty methods.") |
871 | 871 |
872 (defvar tramp-completion-function-alist nil | 872 (defvar tramp-completion-function-alist nil |
873 "*Alist of methods for remote files. | 873 "*Alist of methods for remote files. |
874 This is a list of entries of the form (NAME PAIR1 PAIR2 ...). | 874 This is a list of entries of the form \(NAME PAIR1 PAIR2 ...\). |
875 Each NAME stands for a remote access method. Each PAIR is of the form | 875 Each NAME stands for a remote access method. Each PAIR is of the form |
876 \(FUNCTION FILE). FUNCTION is responsible to extract user names and host | 876 \(FUNCTION FILE\). FUNCTION is responsible to extract user names and host |
877 names from FILE for completion. The following predefined FUNCTIONs exists: | 877 names from FILE for completion. The following predefined FUNCTIONs exists: |
878 | 878 |
879 * `tramp-parse-rhosts' for \"~/.rhosts\" like files, | 879 * `tramp-parse-rhosts' for \"~/.rhosts\" like files, |
880 * `tramp-parse-shosts' for \"~/.ssh/known_hosts\" like files, | 880 * `tramp-parse-shosts' for \"~/.ssh/known_hosts\" like files, |
881 * `tramp-parse-sconfig' for \"~/.ssh/config\" like files, | 881 * `tramp-parse-sconfig' for \"~/.ssh/config\" like files, |
1023 (const :tag "Private Directories" tramp-own-remote-path) | 1023 (const :tag "Private Directories" tramp-own-remote-path) |
1024 (string :tag "Directory")))) | 1024 (string :tag "Directory")))) |
1025 | 1025 |
1026 (defcustom tramp-remote-process-environment | 1026 (defcustom tramp-remote-process-environment |
1027 `("HISTFILE=$HOME/.tramp_history" "HISTSIZE=1" "LC_ALL=C" | 1027 `("HISTFILE=$HOME/.tramp_history" "HISTSIZE=1" "LC_ALL=C" |
1028 ,(concat "TERM=" tramp-terminal-type) | 1028 ,(format "TERM=%s" tramp-terminal-type) |
1029 "EMACS=t" ;; Deprecated. | 1029 "EMACS=t" ;; Deprecated. |
1030 ,(format "INSIDE_EMACS=%s,tramp:%s" emacs-version tramp-version) | 1030 ,(format "INSIDE_EMACS=%s,tramp:%s" emacs-version tramp-version) |
1031 "CDPATH=" "HISTORY=" "MAIL=" "MAILCHECK=" "MAILPATH=" | 1031 "CDPATH=" "HISTORY=" "MAIL=" "MAILCHECK=" "MAILPATH=" |
1032 "autocorrect=" "correct=") | 1032 "autocorrect=" "correct=") |
1033 | 1033 |
1427 ((equal tramp-syntax 'sep) tramp-file-name-regexp-separate) | 1427 ((equal tramp-syntax 'sep) tramp-file-name-regexp-separate) |
1428 ((equal tramp-syntax 'url) tramp-file-name-regexp-url) | 1428 ((equal tramp-syntax 'url) tramp-file-name-regexp-url) |
1429 (t (error "Wrong `tramp-syntax' defined"))) | 1429 (t (error "Wrong `tramp-syntax' defined"))) |
1430 "*Regular expression matching file names handled by Tramp. | 1430 "*Regular expression matching file names handled by Tramp. |
1431 This regexp should match Tramp file names but no other file names. | 1431 This regexp should match Tramp file names but no other file names. |
1432 \(When tramp.el is loaded, this regular expression is prepended to | 1432 When tramp.el is loaded, this regular expression is prepended to |
1433 `file-name-handler-alist', and that is searched sequentially. Thus, | 1433 `file-name-handler-alist', and that is searched sequentially. Thus, |
1434 if the Tramp entry appears rather early in the `file-name-handler-alist' | 1434 if the Tramp entry appears rather early in the `file-name-handler-alist' |
1435 and is a bit too general, then some files might be considered Tramp | 1435 and is a bit too general, then some files might be considered Tramp |
1436 files which are not really Tramp files. | 1436 files which are not really Tramp files. |
1437 | 1437 |
1438 Please note that the entry in `file-name-handler-alist' is made when | 1438 Please note that the entry in `file-name-handler-alist' is made when |
1439 this file (tramp.el) is loaded. This means that this variable must be set | 1439 this file \(tramp.el\) is loaded. This means that this variable must be set |
1440 before loading tramp.el. Alternatively, `file-name-handler-alist' can be | 1440 before loading tramp.el. Alternatively, `file-name-handler-alist' can be |
1441 updated after changing this variable. | 1441 updated after changing this variable. |
1442 | 1442 |
1443 Also see `tramp-file-name-structure'.") | 1443 Also see `tramp-file-name-structure'.") |
1444 | 1444 |
1564 (display-buffer (current-buffer)) | 1564 (display-buffer (current-buffer)) |
1565 (sit-for 30)))) | 1565 (sit-for 30)))) |
1566 | 1566 |
1567 In the Emacs normally running Tramp, evaluate the above code | 1567 In the Emacs normally running Tramp, evaluate the above code |
1568 \(replace \"xxx\" and \"yyy\" by the remote user and host name, | 1568 \(replace \"xxx\" and \"yyy\" by the remote user and host name, |
1569 respectively). You can do this, for example, by pasting it into | 1569 respectively\). You can do this, for example, by pasting it into |
1570 the `*scratch*' buffer and then hitting C-j with the cursor after the | 1570 the `*scratch*' buffer and then hitting C-j with the cursor after the |
1571 last closing parenthesis. Note that it works only if you have configured | 1571 last closing parenthesis. Note that it works only if you have configured |
1572 \"ssh\" to run without password query, see ssh-agent(1). | 1572 \"ssh\" to run without password query, see ssh-agent\(1\). |
1573 | 1573 |
1574 You will see the number of bytes sent successfully to the remote host. | 1574 You will see the number of bytes sent successfully to the remote host. |
1575 If that number exceeds 1000, you can stop the execution by hitting | 1575 If that number exceeds 1000, you can stop the execution by hitting |
1576 C-g, because your Emacs is likely clean. | 1576 C-g, because your Emacs is likely clean. |
1577 | 1577 |
1578 When it is necessary to set `tramp-chunksize', you might consider to | 1578 When it is necessary to set `tramp-chunksize', you might consider to |
1579 use an out-of-the-band method (like \"scp\") instead of an internal one | 1579 use an out-of-the-band method \(like \"scp\"\) instead of an internal one |
1580 \(like \"ssh\"), because setting `tramp-chunksize' to non-nil decreases | 1580 \(like \"ssh\"\), because setting `tramp-chunksize' to non-nil decreases |
1581 performance. | 1581 performance. |
1582 | 1582 |
1583 If your Emacs is buggy, the code stops and gives you an indication | 1583 If your Emacs is buggy, the code stops and gives you an indication |
1584 about the value `tramp-chunksize' should be set. Maybe you could just | 1584 about the value `tramp-chunksize' should be set. Maybe you could just |
1585 experiment a bit, e.g. changing the values of `init' and `step' | 1585 experiment a bit, e.g. changing the values of `init' and `step' |
3164 "Like `directory-files-and-attributes' for Tramp files." | 3164 "Like `directory-files-and-attributes' for Tramp files." |
3165 (unless id-format (setq id-format 'integer)) | 3165 (unless id-format (setq id-format 'integer)) |
3166 (when (file-directory-p directory) | 3166 (when (file-directory-p directory) |
3167 (setq directory (expand-file-name directory)) | 3167 (setq directory (expand-file-name directory)) |
3168 (let* ((temp | 3168 (let* ((temp |
3169 (tramp-compat-copy-tree | 3169 (copy-tree |
3170 (with-parsed-tramp-file-name directory nil | 3170 (with-parsed-tramp-file-name directory nil |
3171 (with-file-property | 3171 (with-file-property |
3172 v localname | 3172 v localname |
3173 (format "directory-files-and-attributes-%s" id-format) | 3173 (format "directory-files-and-attributes-%s" id-format) |
3174 (save-excursion | 3174 (save-excursion |
3295 "tramp_perl_file_name_all_completions") | 3295 "tramp_perl_file_name_all_completions") |
3296 (format "tramp_perl_file_name_all_completions %s %s %d" | 3296 (format "tramp_perl_file_name_all_completions %s %s %d" |
3297 (tramp-shell-quote-argument localname) | 3297 (tramp-shell-quote-argument localname) |
3298 (tramp-shell-quote-argument filename) | 3298 (tramp-shell-quote-argument filename) |
3299 (if (symbol-value | 3299 (if (symbol-value |
3300 'read-file-name-completion-ignore-case) | 3300 ;; `read-file-name-completion-ignore-case' |
3301 ;; is introduced with Emacs 22.1. | |
3302 (if (boundp | |
3303 'read-file-name-completion-ignore-case) | |
3304 'read-file-name-completion-ignore-case | |
3305 'completion-ignore-case)) | |
3301 1 0))) | 3306 1 0))) |
3302 | 3307 |
3303 (format (concat | 3308 (format (concat |
3304 "(\\cd %s 2>&1 && (%s %s -a 2>/dev/null" | 3309 "(\\cd %s 2>&1 && (%s %s -a 2>/dev/null" |
3305 ;; `ls' with wildcard might fail with `Argument | 3310 ;; `ls' with wildcard might fail with `Argument |
3380 (tramp-set-file-property | 3385 (tramp-set-file-property |
3381 v (concat localname filename) | 3386 v (concat localname filename) |
3382 "file-name-all-completions" | 3387 "file-name-all-completions" |
3383 result)))))))) | 3388 result)))))))) |
3384 | 3389 |
3385 ;; The following isn't needed for Emacs 20 but for 19.34? | |
3386 (defun tramp-handle-file-name-completion | 3390 (defun tramp-handle-file-name-completion |
3387 (filename directory &optional predicate) | 3391 (filename directory &optional predicate) |
3388 "Like `file-name-completion' for Tramp files." | 3392 "Like `file-name-completion' for Tramp files." |
3389 (unless (tramp-tramp-file-p directory) | 3393 (unless (tramp-tramp-file-p directory) |
3390 (error | 3394 (error |
3518 `tramp-handle-rename-file'. It is an error if OP is neither of `copy' | 3522 `tramp-handle-rename-file'. It is an error if OP is neither of `copy' |
3519 and `rename'. FILENAME and NEWNAME must be absolute file names." | 3523 and `rename'. FILENAME and NEWNAME must be absolute file names." |
3520 (unless (memq op '(copy rename)) | 3524 (unless (memq op '(copy rename)) |
3521 (error "Unknown operation `%s', must be `copy' or `rename'" op)) | 3525 (error "Unknown operation `%s', must be `copy' or `rename'" op)) |
3522 (let ((t1 (tramp-tramp-file-p filename)) | 3526 (let ((t1 (tramp-tramp-file-p filename)) |
3523 (t2 (tramp-tramp-file-p newname))) | 3527 (t2 (tramp-tramp-file-p newname)) |
3528 pr tm) | |
3524 | 3529 |
3525 (when (and (not ok-if-already-exists) (file-exists-p newname)) | 3530 (when (and (not ok-if-already-exists) (file-exists-p newname)) |
3526 (with-parsed-tramp-file-name (if t1 filename newname) nil | 3531 (with-parsed-tramp-file-name (if t1 filename newname) nil |
3527 (tramp-error | 3532 (tramp-error |
3528 v 'file-already-exists "File %s already exists" newname))) | 3533 v 'file-already-exists "File %s already exists" newname))) |
3529 | 3534 |
3530 (with-parsed-tramp-file-name (if t1 filename newname) nil | 3535 (with-parsed-tramp-file-name (if t1 filename newname) nil |
3531 (tramp-message v 0 "Transferring %s to %s..." filename newname)) | 3536 (tramp-message v 0 "Transferring %s to %s..." filename newname)) |
3532 | 3537 |
3533 (prog1 | 3538 ;; We start a pulsing progress reporter. Introduced in Emacs 24.1. |
3539 (when (> (nth 7 (file-attributes filename)) tramp-copy-size-limit) | |
3540 (condition-case nil | |
3541 (setq pr (funcall | |
3542 'make-progress-reporter | |
3543 (format "Transferring %s to %s..." filename newname)) | |
3544 tm (run-at-time 0 0.1 'progress-reporter-update pr)) | |
3545 (error nil))) | |
3546 | |
3547 (unwind-protect | |
3534 (cond | 3548 (cond |
3535 ;; Both are Tramp files. | 3549 ;; Both are Tramp files. |
3536 ((and t1 t2) | 3550 ((and t1 t2) |
3537 (with-parsed-tramp-file-name filename v1 | 3551 (with-parsed-tramp-file-name filename v1 |
3538 (with-parsed-tramp-file-name newname v2 | 3552 (with-parsed-tramp-file-name newname v2 |
3598 (when t2 | 3612 (when t2 |
3599 (with-parsed-tramp-file-name newname nil | 3613 (with-parsed-tramp-file-name newname nil |
3600 (tramp-flush-file-property v (file-name-directory localname)) | 3614 (tramp-flush-file-property v (file-name-directory localname)) |
3601 (tramp-flush-file-property v localname))) | 3615 (tramp-flush-file-property v localname))) |
3602 | 3616 |
3617 ;; Stop progress reporter. | |
3618 (if tm (cancel-timer tm)) | |
3603 (with-parsed-tramp-file-name (if t1 filename newname) nil | 3619 (with-parsed-tramp-file-name (if t1 filename newname) nil |
3604 (tramp-message v 0 "Transferring %s to %s...done" filename newname))))) | 3620 (tramp-message v 0 "Transferring %s to %s...done" filename newname))))) |
3605 | 3621 |
3606 (defun tramp-do-copy-or-rename-file-via-buffer (op filename newname keep-date) | 3622 (defun tramp-do-copy-or-rename-file-via-buffer (op filename newname keep-date) |
3607 "Use an Emacs buffer to copy or rename a file. | 3623 "Use an Emacs buffer to copy or rename a file. |
3648 (t (tramp-error | 3664 (t (tramp-error |
3649 v 'file-error | 3665 v 'file-error |
3650 "Unknown operation `%s', must be `copy' or `rename'" | 3666 "Unknown operation `%s', must be `copy' or `rename'" |
3651 op)))) | 3667 op)))) |
3652 (localname1 | 3668 (localname1 |
3653 (if t1 (tramp-handle-file-remote-p filename 'localname) filename)) | 3669 (if t1 |
3670 (tramp-file-name-handler 'file-remote-p filename 'localname) | |
3671 filename)) | |
3654 (localname2 | 3672 (localname2 |
3655 (if t2 (tramp-handle-file-remote-p newname 'localname) newname)) | 3673 (if t2 |
3674 (tramp-file-name-handler 'file-remote-p newname 'localname) | |
3675 newname)) | |
3656 (prefix (file-remote-p (if t1 filename newname))) | 3676 (prefix (file-remote-p (if t1 filename newname))) |
3657 cmd-result) | 3677 cmd-result) |
3658 | 3678 |
3659 (cond | 3679 (cond |
3660 ;; Both files are on a remote host, with same user. | 3680 ;; Both files are on a remote host, with same user. |
3812 (tramp-do-copy-or-rename-file-out-of-band | 3832 (tramp-do-copy-or-rename-file-out-of-band |
3813 'rename tmpfile newname keep-date)) | 3833 'rename tmpfile newname keep-date)) |
3814 ;; Save exit. | 3834 ;; Save exit. |
3815 (condition-case nil | 3835 (condition-case nil |
3816 (if dir-flag | 3836 (if dir-flag |
3817 (delete-directory | 3837 (tramp-compat-delete-directory |
3818 (expand-file-name ".." tmpfile) 'recursive) | 3838 (expand-file-name ".." tmpfile) 'recursive) |
3819 (delete-file tmpfile)) | 3839 (delete-file tmpfile)) |
3820 (error)))) | 3840 (error)))) |
3821 | 3841 |
3822 ;; Expand hops. Might be necessary for gateway methods. | 3842 ;; Expand hops. Might be necessary for gateway methods. |
3839 (setq host (tramp-file-name-real-host v) | 3859 (setq host (tramp-file-name-real-host v) |
3840 port (tramp-file-name-port v) | 3860 port (tramp-file-name-port v) |
3841 port (or (and port (number-to-string port)) "")) | 3861 port (or (and port (number-to-string port)) "")) |
3842 | 3862 |
3843 ;; Compose copy command. | 3863 ;; Compose copy command. |
3844 (setq spec `((?h . ,host) (?u . ,user) (?p . ,port) | 3864 (setq spec (format-spec-make |
3845 (?t . ,(tramp-get-connection-property | 3865 ?h host ?u user ?p port |
3846 (tramp-get-connection-process v) "temp-file" "")) | 3866 ?t (tramp-get-connection-property |
3847 (?k . ,(if keep-date " " ""))) | 3867 (tramp-get-connection-process v) "temp-file" "") |
3868 ?k (if keep-date " " "")) | |
3848 copy-program (tramp-get-method-parameter | 3869 copy-program (tramp-get-method-parameter |
3849 method 'tramp-copy-program) | 3870 method 'tramp-copy-program) |
3850 copy-keep-date (tramp-get-method-parameter | 3871 copy-keep-date (tramp-get-method-parameter |
3851 method 'tramp-copy-keep-date) | 3872 method 'tramp-copy-keep-date) |
3852 copy-args | 3873 copy-args |
3932 | 3953 |
3933 ;; If the operation was `rename', delete the original file. | 3954 ;; If the operation was `rename', delete the original file. |
3934 (unless (eq op 'copy) | 3955 (unless (eq op 'copy) |
3935 (if (file-regular-p filename) | 3956 (if (file-regular-p filename) |
3936 (delete-file filename) | 3957 (delete-file filename) |
3937 (delete-directory filename 'recursive)))))) | 3958 (tramp-compat-delete-directory filename 'recursive)))))) |
3938 | 3959 |
3939 (defun tramp-handle-make-directory (dir &optional parents) | 3960 (defun tramp-handle-make-directory (dir &optional parents) |
3940 "Like `make-directory' for Tramp files." | 3961 "Like `make-directory' for Tramp files." |
3941 (setq dir (expand-file-name dir)) | 3962 (setq dir (expand-file-name dir)) |
3942 (with-parsed-tramp-file-name dir nil | 3963 (with-parsed-tramp-file-name dir nil |
4861 | 4882 |
4862 (defun tramp-handle-find-backup-file-name (filename) | 4883 (defun tramp-handle-find-backup-file-name (filename) |
4863 "Like `find-backup-file-name' for Tramp files." | 4884 "Like `find-backup-file-name' for Tramp files." |
4864 (with-parsed-tramp-file-name filename nil | 4885 (with-parsed-tramp-file-name filename nil |
4865 ;; We set both variables. It doesn't matter whether it is | 4886 ;; We set both variables. It doesn't matter whether it is |
4866 ;; Emacs or XEmacs | 4887 ;; Emacs or XEmacs. |
4867 (let ((backup-directory-alist | 4888 (let ((backup-directory-alist |
4868 ;; Emacs case | 4889 ;; Emacs case. |
4869 (when (boundp 'backup-directory-alist) | 4890 (when (boundp 'backup-directory-alist) |
4870 (if (symbol-value 'tramp-backup-directory-alist) | 4891 (if (symbol-value 'tramp-backup-directory-alist) |
4871 (mapcar | 4892 (mapcar |
4872 (lambda (x) | 4893 (lambda (x) |
4873 (cons | 4894 (cons |
4879 (cdr x)))) | 4900 (cdr x)))) |
4880 (symbol-value 'tramp-backup-directory-alist)) | 4901 (symbol-value 'tramp-backup-directory-alist)) |
4881 (symbol-value 'backup-directory-alist)))) | 4902 (symbol-value 'backup-directory-alist)))) |
4882 | 4903 |
4883 (bkup-backup-directory-info | 4904 (bkup-backup-directory-info |
4884 ;; XEmacs case | 4905 ;; XEmacs case. |
4885 (when (boundp 'bkup-backup-directory-info) | 4906 (when (boundp 'bkup-backup-directory-info) |
4886 (if (symbol-value 'tramp-bkup-backup-directory-info) | 4907 (if (symbol-value 'tramp-bkup-backup-directory-info) |
4887 (mapcar | 4908 (mapcar |
4888 (lambda (x) | 4909 (lambda (x) |
4889 (nconc | 4910 (nconc |
5293 ;; function as well but regexp only. | 5314 ;; function as well but regexp only. |
5294 (defun tramp-file-name-for-operation (operation &rest args) | 5315 (defun tramp-file-name-for-operation (operation &rest args) |
5295 "Return file name related to OPERATION file primitive. | 5316 "Return file name related to OPERATION file primitive. |
5296 ARGS are the arguments OPERATION has been called with." | 5317 ARGS are the arguments OPERATION has been called with." |
5297 (cond | 5318 (cond |
5298 ; FILE resp DIRECTORY | 5319 ;; FILE resp DIRECTORY. |
5299 ((member operation | 5320 ((member operation |
5300 (list 'access-file 'byte-compiler-base-file-name 'delete-directory | 5321 (list 'access-file 'byte-compiler-base-file-name 'delete-directory |
5301 'delete-file 'diff-latest-backup-file 'directory-file-name | 5322 'delete-file 'diff-latest-backup-file 'directory-file-name |
5302 'directory-files 'directory-files-and-attributes | 5323 'directory-files 'directory-files-and-attributes |
5303 'dired-compress-file 'dired-uncache | 5324 'dired-compress-file 'dired-uncache |
5311 'file-writable-p 'find-backup-file-name 'find-file-noselect | 5332 'file-writable-p 'find-backup-file-name 'find-file-noselect |
5312 'get-file-buffer 'insert-directory 'insert-file-contents | 5333 'get-file-buffer 'insert-directory 'insert-file-contents |
5313 'load 'make-directory 'make-directory-internal | 5334 'load 'make-directory 'make-directory-internal |
5314 'set-file-modes 'substitute-in-file-name | 5335 'set-file-modes 'substitute-in-file-name |
5315 'unhandled-file-name-directory 'vc-registered | 5336 'unhandled-file-name-directory 'vc-registered |
5316 ; Emacs 22 only | 5337 ;; Emacs 22+ only. |
5317 'set-file-times | 5338 'set-file-times |
5318 ; XEmacs only | 5339 ;; XEmacs only. |
5319 'abbreviate-file-name 'create-file-buffer | 5340 'abbreviate-file-name 'create-file-buffer |
5320 'dired-file-modtime 'dired-make-compressed-filename | 5341 'dired-file-modtime 'dired-make-compressed-filename |
5321 'dired-recursive-delete-directory 'dired-set-file-modtime | 5342 'dired-recursive-delete-directory 'dired-set-file-modtime |
5322 'dired-shell-unhandle-file-name 'dired-uucode-file | 5343 'dired-shell-unhandle-file-name 'dired-uucode-file |
5323 'insert-file-contents-literally 'make-temp-name 'recover-file | 5344 'insert-file-contents-literally 'make-temp-name 'recover-file |
5324 'vm-imap-check-mail 'vm-pop-check-mail 'vm-spool-check-mail)) | 5345 'vm-imap-check-mail 'vm-pop-check-mail 'vm-spool-check-mail)) |
5325 (if (file-name-absolute-p (nth 0 args)) | 5346 (if (file-name-absolute-p (nth 0 args)) |
5326 (nth 0 args) | 5347 (nth 0 args) |
5327 (expand-file-name (nth 0 args)))) | 5348 (expand-file-name (nth 0 args)))) |
5328 ; FILE DIRECTORY resp FILE1 FILE2 | 5349 ;; FILE DIRECTORY resp FILE1 FILE2. |
5329 ((member operation | 5350 ((member operation |
5330 (list 'add-name-to-file 'copy-file 'expand-file-name | 5351 (list 'add-name-to-file 'copy-file 'expand-file-name |
5331 'file-name-all-completions 'file-name-completion | 5352 'file-name-all-completions 'file-name-completion |
5332 'file-newer-than-file-p 'make-symbolic-link 'rename-file | 5353 'file-newer-than-file-p 'make-symbolic-link 'rename-file |
5333 ; Emacs 23 only | 5354 ;; Emacs 23+ only. |
5334 'copy-directory | 5355 'copy-directory |
5335 ; XEmacs only | 5356 ;; XEmacs only. |
5336 'dired-make-relative-symlink | 5357 'dired-make-relative-symlink |
5337 'vm-imap-move-mail 'vm-pop-move-mail 'vm-spool-move-mail)) | 5358 'vm-imap-move-mail 'vm-pop-move-mail 'vm-spool-move-mail)) |
5338 (save-match-data | 5359 (save-match-data |
5339 (cond | 5360 (cond |
5340 ((string-match tramp-file-name-regexp (nth 0 args)) (nth 0 args)) | 5361 ((string-match tramp-file-name-regexp (nth 0 args)) (nth 0 args)) |
5341 ((string-match tramp-file-name-regexp (nth 1 args)) (nth 1 args)) | 5362 ((string-match tramp-file-name-regexp (nth 1 args)) (nth 1 args)) |
5342 (t (buffer-file-name (current-buffer)))))) | 5363 (t (buffer-file-name (current-buffer)))))) |
5343 ; START END FILE | 5364 ;; START END FILE. |
5344 ((eq operation 'write-region) | 5365 ((eq operation 'write-region) |
5345 (nth 2 args)) | 5366 (nth 2 args)) |
5346 ; BUF | 5367 ;; BUFFER. |
5347 ((member operation | 5368 ((member operation |
5348 (list 'set-visited-file-modtime 'verify-visited-file-modtime | 5369 (list 'set-visited-file-modtime 'verify-visited-file-modtime |
5349 ; since Emacs 22 only | 5370 ;; Emacs 22+ only. |
5350 'make-auto-save-file-name | 5371 'make-auto-save-file-name |
5351 ; XEmacs only | 5372 ;; XEmacs only. |
5352 'backup-buffer)) | 5373 'backup-buffer)) |
5353 (buffer-file-name | 5374 (buffer-file-name |
5354 (if (bufferp (nth 0 args)) (nth 0 args) (current-buffer)))) | 5375 (if (bufferp (nth 0 args)) (nth 0 args) (current-buffer)))) |
5355 ; COMMAND | 5376 ;; COMMAND. |
5356 ((member operation | 5377 ((member operation |
5357 (list ; not in Emacs 23 | 5378 (list ;; not in Emacs 23+. |
5358 'dired-call-process | 5379 'dired-call-process |
5359 ; Emacs only | 5380 ;; Emacs only. |
5360 'shell-command | 5381 'shell-command |
5361 ; since Emacs 22 only | 5382 ;; Emacs 22+ only. |
5362 'process-file | 5383 'process-file |
5363 ; since Emacs 23 only | 5384 ;; Emacs 23+ only. |
5364 'start-file-process | 5385 'start-file-process |
5365 ; XEmacs only | 5386 ;; XEmacs only. |
5366 'dired-print-file 'dired-shell-call-process | 5387 'dired-print-file 'dired-shell-call-process |
5367 ; nowhere yet | 5388 ;; nowhere yet. |
5368 'executable-find 'start-process 'call-process)) | 5389 'executable-find 'start-process 'call-process)) |
5369 default-directory) | 5390 default-directory) |
5370 ; unknown file primitive | 5391 ;; Unknown file primitive. |
5371 (t (error "unknown file I/O primitive: %s" operation)))) | 5392 (t (error "unknown file I/O primitive: %s" operation)))) |
5372 | 5393 |
5373 (defun tramp-find-foreign-file-name-handler (filename) | 5394 (defun tramp-find-foreign-file-name-handler (filename) |
5374 "Return foreign file name handler if exists." | 5395 "Return foreign file name handler if exists." |
5375 (when (and (stringp filename) (tramp-tramp-file-p filename)) | 5396 (when (tramp-tramp-file-p filename) |
5376 (let ((v (tramp-dissect-file-name filename t)) | 5397 (let ((v (tramp-dissect-file-name filename t)) |
5377 (handler tramp-foreign-file-name-handler-alist) | 5398 (handler tramp-foreign-file-name-handler-alist) |
5378 elt res) | 5399 elt res) |
5379 ;; When we are not fully sure that filename completion is safe, | 5400 ;; When we are not fully sure that filename completion is safe, |
5380 ;; we should not return a handler. | 5401 ;; we should not return a handler. |
6255 (host (tramp-file-name-real-host vec))) | 6276 (host (tramp-file-name-real-host vec))) |
6256 (if (not (zerop (length user))) | 6277 (if (not (zerop (length user))) |
6257 (format "*debug tramp/%s %s@%s*" method user host) | 6278 (format "*debug tramp/%s %s@%s*" method user host) |
6258 (format "*debug tramp/%s %s*" method host)))) | 6279 (format "*debug tramp/%s %s*" method host)))) |
6259 | 6280 |
6281 (defconst tramp-debug-outline-regexp | |
6282 "[0-9]+:[0-9]+:[0-9]+\\.[0-9]+ [a-z0-9-]+ (\\([0-9]+\\)) #") | |
6283 | |
6260 (defun tramp-get-debug-buffer (vec) | 6284 (defun tramp-get-debug-buffer (vec) |
6261 "Get the debug buffer for VEC." | 6285 "Get the debug buffer for VEC." |
6262 (with-current-buffer | 6286 (with-current-buffer |
6263 (get-buffer-create (tramp-debug-buffer-name vec)) | 6287 (get-buffer-create (tramp-debug-buffer-name vec)) |
6264 (when (bobp) | 6288 (when (bobp) |
6265 (setq buffer-undo-list t) | 6289 (setq buffer-undo-list t) |
6266 ;; Activate outline-mode. This runs `text-mode-hook' and | 6290 ;; Activate `outline-mode'. This runs `text-mode-hook' and |
6267 ;; `outline-mode-hook'. We must prevent that local processes | 6291 ;; `outline-mode-hook'. We must prevent that local processes |
6268 ;; die. Yes: I've seen `flyspell-mode', which starts "ispell" | 6292 ;; die. Yes: I've seen `flyspell-mode', which starts "ispell". |
6269 ;; ... | 6293 ;; Furthermore, `outline-regexp' must have the correct value |
6270 (let ((default-directory (tramp-compat-temporary-file-directory))) | 6294 ;; already, because it is used by `font-lock-compile-keywords'. |
6295 (let ((default-directory (tramp-compat-temporary-file-directory)) | |
6296 (outline-regexp tramp-debug-outline-regexp)) | |
6271 (outline-mode)) | 6297 (outline-mode)) |
6272 (set (make-local-variable 'outline-regexp) | 6298 (set (make-local-variable 'outline-regexp) tramp-debug-outline-regexp) |
6273 "[0-9]+:[0-9]+:[0-9]+\\.[0-9]+ [a-z0-9-]+ (\\([0-9]+\\)) #") | |
6274 ; (set (make-local-variable 'outline-regexp) | |
6275 ; "[a-z.-]+:[0-9]+: [a-z0-9-]+ (\\([0-9]+\\)) #") | |
6276 (set (make-local-variable 'outline-level) 'tramp-outline-level)) | 6299 (set (make-local-variable 'outline-level) 'tramp-outline-level)) |
6277 (current-buffer))) | 6300 (current-buffer))) |
6278 | 6301 |
6279 (defun tramp-outline-level () | 6302 (defun tramp-outline-level () |
6280 "Return the depth to which a statement is nested in the outline. | 6303 "Return the depth to which a statement is nested in the outline. |
6305 (goto-char (point-min)) | 6328 (goto-char (point-min)) |
6306 (if (looking-at "^\\s-*1$") | 6329 (if (looking-at "^\\s-*1$") |
6307 (setq result (concat "\\" progname)))) | 6330 (setq result (concat "\\" progname)))) |
6308 (unless result | 6331 (unless result |
6309 (when ignore-tilde | 6332 (when ignore-tilde |
6310 ;; Remove all ~/foo directories from dirlist. In Emacs 20, | 6333 ;; Remove all ~/foo directories from dirlist. In XEmacs, |
6311 ;; `remove' is in CL, and we want to avoid CL dependencies. | 6334 ;; `remove' is in CL, and we want to avoid CL dependencies. |
6312 (let (newdl d) | 6335 (let (newdl d) |
6313 (while dirlist | 6336 (while dirlist |
6314 (setq d (car dirlist)) | 6337 (setq d (car dirlist)) |
6315 (setq dirlist (cdr dirlist)) | 6338 (setq dirlist (cdr dirlist)) |
6622 (let ((begin (match-beginning 0))) | 6645 (let ((begin (match-beginning 0))) |
6623 (when (re-search-forward tramp-echoed-echo-mark-regexp nil t) | 6646 (when (re-search-forward tramp-echoed-echo-mark-regexp nil t) |
6624 ;; Discard echo from remote output. | 6647 ;; Discard echo from remote output. |
6625 (tramp-set-connection-property proc "check-remote-echo" nil) | 6648 (tramp-set-connection-property proc "check-remote-echo" nil) |
6626 (tramp-message proc 5 "echo-mark found") | 6649 (tramp-message proc 5 "echo-mark found") |
6627 (forward-line) | 6650 (forward-line 1) |
6628 (delete-region begin (point)) | 6651 (delete-region begin (point)) |
6629 (goto-char (point-min))))) | 6652 (goto-char (point-min))))) |
6630 | 6653 |
6631 (when (or (not (tramp-get-connection-property proc "check-remote-echo" nil)) | 6654 (when (or (not (tramp-get-connection-property proc "check-remote-echo" nil)) |
6632 ;; Sometimes, the echo string is suppressed on the remote side. | 6655 ;; Sometimes, the echo string is suppressed on the remote side. |
6893 "perl -e 'binmode STDIN; binmode STDOUT; print pack(q{u*}, join q{}, <>)'" | 6916 "perl -e 'binmode STDIN; binmode STDOUT; print pack(q{u*}, join q{}, <>)'" |
6894 "perl -e 'binmode STDIN; binmode STDOUT; print unpack(q{u*}, join q{}, <>)'")) | 6917 "perl -e 'binmode STDIN; binmode STDOUT; print unpack(q{u*}, join q{}, <>)'")) |
6895 "List of local coding commands for inline transfer. | 6918 "List of local coding commands for inline transfer. |
6896 Each item is a list that looks like this: | 6919 Each item is a list that looks like this: |
6897 | 6920 |
6898 \(FORMAT ENCODING DECODING) | 6921 \(FORMAT ENCODING DECODING\) |
6899 | 6922 |
6900 FORMAT is symbol describing the encoding/decoding format. It can be | 6923 FORMAT is symbol describing the encoding/decoding format. It can be |
6901 `b64' for base64 encoding, `uu' for uu encoding, or `pack' for simple packing. | 6924 `b64' for base64 encoding, `uu' for uu encoding, or `pack' for simple packing. |
6902 | 6925 |
6903 ENCODING and DECODING can be strings, giving commands, or symbols, | 6926 ENCODING and DECODING can be strings, giving commands, or symbols, |
6926 "perl -e 'binmode STDIN; binmode STDOUT; print pack(q{u*}, join q{}, <>)'" | 6949 "perl -e 'binmode STDIN; binmode STDOUT; print pack(q{u*}, join q{}, <>)'" |
6927 "perl -e 'binmode STDIN; binmode STDOUT; print unpack(q{u*}, join q{}, <>)'")) | 6950 "perl -e 'binmode STDIN; binmode STDOUT; print unpack(q{u*}, join q{}, <>)'")) |
6928 "List of remote coding commands for inline transfer. | 6951 "List of remote coding commands for inline transfer. |
6929 Each item is a list that looks like this: | 6952 Each item is a list that looks like this: |
6930 | 6953 |
6931 \(FORMAT ENCODING DECODING) | 6954 \(FORMAT ENCODING DECODING\) |
6932 | 6955 |
6933 FORMAT is symbol describing the encoding/decoding format. It can be | 6956 FORMAT is symbol describing the encoding/decoding format. It can be |
6934 `b64' for base64 encoding, `uu' for uu encoding, or `pack' for simple packing. | 6957 `b64' for base64 encoding, `uu' for uu encoding, or `pack' for simple packing. |
6935 | 6958 |
6936 ENCODING and DECODING can be strings, giving commands, or symbols, | 6959 ENCODING and DECODING can be strings, giving commands, or symbols, |
7087 (setq choices nil) | 7110 (setq choices nil) |
7088 ;; Replace placeholders. | 7111 ;; Replace placeholders. |
7089 (setq proxy | 7112 (setq proxy |
7090 (format-spec | 7113 (format-spec |
7091 proxy | 7114 proxy |
7092 `((?u . ,(or (tramp-file-name-user (car target-alist)) "")) | 7115 (format-spec-make |
7093 (?h . ,(or (tramp-file-name-host (car target-alist)) ""))))) | 7116 ?u (or (tramp-file-name-user (car target-alist)) "") |
7117 ?h (or (tramp-file-name-host (car target-alist)) "")))) | |
7094 (with-parsed-tramp-file-name proxy l | 7118 (with-parsed-tramp-file-name proxy l |
7095 ;; Add the hop. | 7119 ;; Add the hop. |
7096 (add-to-list 'target-alist l) | 7120 (add-to-list 'target-alist l) |
7097 ;; Start next search. | 7121 ;; Start next search. |
7098 (setq choices tramp-default-proxies-alist))))) | 7122 (setq choices tramp-default-proxies-alist))))) |
7306 ;; Replace login-args place holders. | 7330 ;; Replace login-args place holders. |
7307 (setq | 7331 (setq |
7308 l-host (or l-host "") | 7332 l-host (or l-host "") |
7309 l-user (or l-user "") | 7333 l-user (or l-user "") |
7310 l-port (or l-port "") | 7334 l-port (or l-port "") |
7311 spec `((?h . ,l-host) (?u . ,l-user) (?p . ,l-port) | 7335 spec (format-spec-make ?h l-host ?u l-user ?p l-port ?t tmpfile) |
7312 (?t . ,tmpfile)) | |
7313 command | 7336 command |
7314 (concat | 7337 (concat |
7315 ;; We do not want to see the trailing local prompt in | 7338 ;; We do not want to see the trailing local prompt in |
7316 ;; `start-file-process'. | 7339 ;; `start-file-process'. |
7317 (unless (memq system-type '(windows-nt)) "exec ") | 7340 (unless (memq system-type '(windows-nt)) "exec ") |
7979 ;; is cached persistently. | 8002 ;; is cached persistently. |
7980 (if (memq 'tramp-own-remote-path tramp-remote-path) | 8003 (if (memq 'tramp-own-remote-path tramp-remote-path) |
7981 (tramp-get-connection-process vec) | 8004 (tramp-get-connection-process vec) |
7982 vec) | 8005 vec) |
7983 "remote-path" | 8006 "remote-path" |
7984 (let* ((remote-path (tramp-compat-copy-tree tramp-remote-path)) | 8007 (let* ((remote-path (copy-tree tramp-remote-path)) |
7985 (elt1 (memq 'tramp-default-remote-path remote-path)) | 8008 (elt1 (memq 'tramp-default-remote-path remote-path)) |
7986 (elt2 (memq 'tramp-own-remote-path remote-path)) | 8009 (elt2 (memq 'tramp-own-remote-path remote-path)) |
7987 (default-remote-path | 8010 (default-remote-path |
7988 (when elt1 | 8011 (when elt1 |
7989 (condition-case nil | 8012 (condition-case nil |
8278 | 8301 |
8279 (unless (tramp-exists-file-name-handler 'make-auto-save-file-name) | 8302 (unless (tramp-exists-file-name-handler 'make-auto-save-file-name) |
8280 (defadvice make-auto-save-file-name | 8303 (defadvice make-auto-save-file-name |
8281 (around tramp-advice-make-auto-save-file-name () activate) | 8304 (around tramp-advice-make-auto-save-file-name () activate) |
8282 "Invoke `tramp-handle-make-auto-save-file-name' for Tramp files." | 8305 "Invoke `tramp-handle-make-auto-save-file-name' for Tramp files." |
8283 (if (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))) | 8306 (if (tramp-tramp-file-p (buffer-file-name)) |
8284 ;; We cannot call `tramp-handle-make-auto-save-file-name' | 8307 ;; We cannot call `tramp-handle-make-auto-save-file-name' |
8285 ;; directly, because this would bypass the locking mechanism. | 8308 ;; directly, because this would bypass the locking mechanism. |
8286 (setq ad-return-value | 8309 (setq ad-return-value |
8287 (tramp-file-name-handler 'make-auto-save-file-name)) | 8310 (tramp-file-name-handler 'make-auto-save-file-name)) |
8288 ad-do-it)) | 8311 ad-do-it)) |
8292 (ad-remove-advice | 8315 (ad-remove-advice |
8293 'make-auto-save-file-name | 8316 'make-auto-save-file-name |
8294 'around 'tramp-advice-make-auto-save-file-name) | 8317 'around 'tramp-advice-make-auto-save-file-name) |
8295 (ad-activate 'make-auto-save-file-name)))) | 8318 (ad-activate 'make-auto-save-file-name)))) |
8296 | 8319 |
8297 ;; In Emacs < 22 and XEmacs < 21.5 autosaved remote files have | 8320 ;; In XEmacs < 21.5, autosaved remote files have permission 0666 minus |
8298 ;; permission 0666 minus umask. This is a security threat. | 8321 ;; umask. This is a security threat. |
8299 | 8322 |
8300 (defun tramp-set-auto-save-file-modes () | 8323 (defun tramp-set-auto-save-file-modes () |
8301 "Set permissions of autosaved remote files to the original permissions." | 8324 "Set permissions of autosaved remote files to the original permissions." |
8302 (let ((bfn (buffer-file-name))) | 8325 (let ((bfn (buffer-file-name))) |
8303 (when (and (stringp bfn) | 8326 (when (and (tramp-tramp-file-p bfn) |
8304 (tramp-tramp-file-p bfn) | |
8305 (buffer-modified-p) | 8327 (buffer-modified-p) |
8306 (stringp buffer-auto-save-file-name) | 8328 (stringp buffer-auto-save-file-name) |
8307 (not (equal bfn buffer-auto-save-file-name))) | 8329 (not (equal bfn buffer-auto-save-file-name))) |
8308 (unless (file-exists-p buffer-auto-save-file-name) | 8330 (unless (file-exists-p buffer-auto-save-file-name) |
8309 (write-region "" nil buffer-auto-save-file-name)) | 8331 (write-region "" nil buffer-auto-save-file-name)) |
8311 ;; auto-saved file belonging to another original file. This could | 8333 ;; auto-saved file belonging to another original file. This could |
8312 ;; be a security threat. | 8334 ;; be a security threat. |
8313 (set-file-modes buffer-auto-save-file-name | 8335 (set-file-modes buffer-auto-save-file-name |
8314 (or (file-modes bfn) (tramp-octal-to-decimal "0600")))))) | 8336 (or (file-modes bfn) (tramp-octal-to-decimal "0600")))))) |
8315 | 8337 |
8316 (unless (or (> emacs-major-version 21) | 8338 (unless (and (featurep 'xemacs) |
8317 (and (featurep 'xemacs) | 8339 (= emacs-major-version 21) |
8318 (= emacs-major-version 21) | 8340 (> emacs-minor-version 4)) |
8319 (> emacs-minor-version 4))) | |
8320 (add-hook 'auto-save-hook 'tramp-set-auto-save-file-modes) | 8341 (add-hook 'auto-save-hook 'tramp-set-auto-save-file-modes) |
8321 (add-hook 'tramp-unload-hook | 8342 (add-hook 'tramp-unload-hook |
8322 (lambda () | 8343 (lambda () |
8323 (remove-hook 'auto-save-hook 'tramp-set-auto-save-file-modes)))) | 8344 (remove-hook 'auto-save-hook 'tramp-set-auto-save-file-modes)))) |
8324 | 8345 |
8558 ;; strange when doing zerop, we should kill the process and start | 8579 ;; strange when doing zerop, we should kill the process and start |
8559 ;; again. (Greg Stark) | 8580 ;; again. (Greg Stark) |
8560 ;; * Remove unneeded parameters from methods. | 8581 ;; * Remove unneeded parameters from methods. |
8561 ;; * Make it work for different encodings, and for different file name | 8582 ;; * Make it work for different encodings, and for different file name |
8562 ;; encodings, too. (Daniel Pittman) | 8583 ;; encodings, too. (Daniel Pittman) |
8563 ;; * Progress reports while copying files. (Michael Kifer) | |
8564 ;; * Don't search for perl5 and perl. Instead, only search for perl and | 8584 ;; * Don't search for perl5 and perl. Instead, only search for perl and |
8565 ;; then look if it's the right version (with `perl -v'). | 8585 ;; then look if it's the right version (with `perl -v'). |
8566 ;; * When editing a remote CVS controlled file as a different user, VC | 8586 ;; * When editing a remote CVS controlled file as a different user, VC |
8567 ;; gets confused about the file locking status. Try to find out why | 8587 ;; gets confused about the file locking status. Try to find out why |
8568 ;; the workaround doesn't work. | 8588 ;; the workaround doesn't work. |
8623 ;; improve Tramp to set LC_ALL to "C" only for commands where Tramp | 8643 ;; improve Tramp to set LC_ALL to "C" only for commands where Tramp |
8624 ;; expects English? Or just to set LC_MESSAGES to "C" if Tramp | 8644 ;; expects English? Or just to set LC_MESSAGES to "C" if Tramp |
8625 ;; expects only English messages? (Juri Linkov) | 8645 ;; expects only English messages? (Juri Linkov) |
8626 ;; * Make shadowfile.el grok Tramp filenames. (Bug#4526, Bug#4846) | 8646 ;; * Make shadowfile.el grok Tramp filenames. (Bug#4526, Bug#4846) |
8627 ;; * Do not handle files with drive letter as remote. (Bug#5447) | 8647 ;; * Do not handle files with drive letter as remote. (Bug#5447) |
8628 ;; * Load Tramp subpackages only when needed. (Bug#1529, Bug#5448) | 8648 ;; * Load Tramp subpackages only when needed. (Bug#1529, Bug#5448, Bug#5705) |
8629 ;; * Try telnet+curl as new method. It might be useful for busybox, | 8649 ;; * Try telnet+curl as new method. It might be useful for busybox, |
8630 ;; without built-in uuencode/uudecode. | 8650 ;; without built-in uuencode/uudecode. |
8631 ;; * Let `shell-dynamic-complete-*' and `comint-dynamic-complete' work | 8651 ;; * Let `shell-dynamic-complete-*' and `comint-dynamic-complete' work |
8632 ;; on remote hosts. | 8652 ;; on remote hosts. |
8633 ;; * Use secrets.el for password handling. | 8653 ;; * Use secrets.el for password handling. |