diff options
| author | Michael Albinus | 2007-08-24 05:27:22 +0000 |
|---|---|---|
| committer | Michael Albinus | 2007-08-24 05:27:22 +0000 |
| commit | 0f205eeefa5af8c4a61fd26c58ff3c4af9106728 (patch) | |
| tree | 7c952c7485c566e2c6d780b8d0cba4c1c6b5b270 | |
| parent | bb1f0d92c29e2465d1d18eaf3a7bbfcf8a8f0d6b (diff) | |
| download | emacs-0f205eeefa5af8c4a61fd26c58ff3c4af9106728.tar.gz emacs-0f205eeefa5af8c4a61fd26c58ff3c4af9106728.zip | |
* net/tramp.el (tramp-local-host-p): New defun.
(tramp-handle-file-local-copy, tramp-handle-write-region):
Implement fast track when being on the local host.
(tramp-file-name-handler): Don't set "started" property. It shall
be reserved for the "ftp" method.
(tramp-make-copy-program-file-name): Use `tramp-file-name-real-host'.
* net/tramp-ftp.el (top): Autoload `tramp-set-connection-property'.
(tramp-ftp-file-name-handler): Set "started" property.
| -rw-r--r-- | lisp/ChangeLog | 14 | ||||
| -rw-r--r-- | lisp/net/tramp-ftp.el | 31 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 150 |
3 files changed, 114 insertions, 81 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cac2d1c269f..e6d8ec1b3e1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 1 | 2007-08-24 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * net/tramp.el (tramp-local-host-p): New defun. | ||
| 4 | (tramp-handle-file-local-copy, tramp-handle-write-region): | ||
| 5 | Implement fast track when being on the local host. | ||
| 6 | (tramp-file-name-handler): Don't set "started" property. It shall | ||
| 7 | be reserved for the "ftp" method. | ||
| 8 | (tramp-make-copy-program-file-name): Use `tramp-file-name-real-host'. | ||
| 9 | |||
| 10 | * net/tramp-ftp.el (top): Autoload `tramp-set-connection-property'. | ||
| 11 | (tramp-ftp-file-name-handler): Set "started" property. | ||
| 12 | |||
| 1 | 2007-08-24 Ulrich Mueller <ulm@gentoo.org> (tiny change) | 13 | 2007-08-24 Ulrich Mueller <ulm@gentoo.org> (tiny change) |
| 2 | 14 | ||
| 3 | * files.el (backup-buffer-copy): Don't wrap delete in | 15 | * files.el (backup-buffer-copy): Don't wrap delete in |
| @@ -1630,7 +1642,7 @@ | |||
| 1630 | 1642 | ||
| 1631 | Sync with Tramp 2.1.10. | 1643 | Sync with Tramp 2.1.10. |
| 1632 | 1644 | ||
| 1633 | * net/tramp.el (tramp-get-ls-command): Fyx typo. | 1645 | * net/tramp.el (tramp-get-ls-command): Fix typo. |
| 1634 | 1646 | ||
| 1635 | * net/trampver.el: Update release number. | 1647 | * net/trampver.el: Update release number. |
| 1636 | 1648 | ||
diff --git a/lisp/net/tramp-ftp.el b/lisp/net/tramp-ftp.el index f3d7a3aadf1..6fe069636f7 100644 --- a/lisp/net/tramp-ftp.el +++ b/lisp/net/tramp-ftp.el | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | ;;; Code: | 30 | ;;; Code: |
| 31 | 31 | ||
| 32 | (require 'tramp) | 32 | (require 'tramp) |
| 33 | (autoload 'tramp-set-connection-property "tramp-cache") | ||
| 33 | 34 | ||
| 34 | (eval-when-compile (require 'custom)) | 35 | (eval-when-compile (require 'custom)) |
| 35 | 36 | ||
| @@ -137,19 +138,25 @@ pass to the OPERATION." | |||
| 137 | (ange-ftp-ftp-name-arg "") | 138 | (ange-ftp-ftp-name-arg "") |
| 138 | (ange-ftp-ftp-name-res nil)) | 139 | (ange-ftp-ftp-name-res nil)) |
| 139 | (cond | 140 | (cond |
| 140 | ;; If argument is a symlink, `file-directory-p' and `file-exists-p' | 141 | ;; If argument is a symlink, `file-directory-p' and |
| 141 | ;; call the traversed file recursively. So we cannot disable the | 142 | ;; `file-exists-p' call the traversed file recursively. So we |
| 142 | ;; file-name-handler this case. | 143 | ;; cannot disable the file-name-handler this case. We set the |
| 144 | ;; connection property "started" in order to put the remote | ||
| 145 | ;; location into the cache, which is helpful for further | ||
| 146 | ;; completion. | ||
| 143 | ((memq operation '(file-directory-p file-exists-p)) | 147 | ((memq operation '(file-directory-p file-exists-p)) |
| 144 | (apply 'ange-ftp-hook-function operation args)) | 148 | (if (apply 'ange-ftp-hook-function operation args) |
| 145 | ;; Normally, the handlers must be discarded | 149 | (with-parsed-tramp-file-name (car args) nil |
| 146 | (t (let* ((inhibit-file-name-handlers | 150 | (tramp-set-connection-property v "started" t)) |
| 147 | (list 'tramp-file-name-handler | 151 | nil)) |
| 148 | 'tramp-completion-file-name-handler | 152 | ;; Normally, the handlers must be discarded. |
| 149 | (and (eq inhibit-file-name-operation operation) | 153 | (t (let* ((inhibit-file-name-handlers |
| 150 | inhibit-file-name-handlers))) | 154 | (list 'tramp-file-name-handler |
| 151 | (inhibit-file-name-operation operation)) | 155 | 'tramp-completion-file-name-handler |
| 152 | (apply 'ange-ftp-hook-function operation args))))))) | 156 | (and (eq inhibit-file-name-operation operation) |
| 157 | inhibit-file-name-handlers))) | ||
| 158 | (inhibit-file-name-operation operation)) | ||
| 159 | (apply 'ange-ftp-hook-function operation args))))))) | ||
| 153 | 160 | ||
| 154 | (defun tramp-ftp-file-name-p (filename) | 161 | (defun tramp-ftp-file-name-p (filename) |
| 155 | "Check if it's a filename that should be forwarded to Ange-FTP." | 162 | "Check if it's a filename that should be forwarded to Ange-FTP." |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 9f326800f0e..85f9287fca8 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -3665,14 +3665,9 @@ beginning of local filename are not substituted." | |||
| 3665 | 3665 | ||
| 3666 | (defun tramp-handle-file-local-copy (filename) | 3666 | (defun tramp-handle-file-local-copy (filename) |
| 3667 | "Like `file-local-copy' for Tramp files." | 3667 | "Like `file-local-copy' for Tramp files." |
| 3668 | |||
| 3668 | (with-parsed-tramp-file-name filename nil | 3669 | (with-parsed-tramp-file-name filename nil |
| 3669 | (let (;; We used to bind the following as late as possible. | 3670 | (let ((rem-enc (tramp-get-remote-coding v "remote-encoding")) |
| 3670 | ;; loc-dec was bound directly before the if statement that | ||
| 3671 | ;; checks them. But the functions tramp-get-* might invoke | ||
| 3672 | ;; the "are you awake" check in `tramp-maybe-open-connection', | ||
| 3673 | ;; which is an unfortunate time since we rely on the buffer | ||
| 3674 | ;; contents at that spot. | ||
| 3675 | (rem-enc (tramp-get-remote-coding v "remote-encoding")) | ||
| 3676 | (loc-dec (tramp-get-local-coding v "local-decoding")) | 3671 | (loc-dec (tramp-get-local-coding v "local-decoding")) |
| 3677 | tmpfil) | 3672 | tmpfil) |
| 3678 | (unless (file-exists-p filename) | 3673 | (unless (file-exists-p filename) |
| @@ -3681,55 +3676,59 @@ beginning of local filename are not substituted." | |||
| 3681 | "Cannot make local copy of non-existing file `%s'" filename)) | 3676 | "Cannot make local copy of non-existing file `%s'" filename)) |
| 3682 | (setq tmpfil (tramp-make-temp-file filename)) | 3677 | (setq tmpfil (tramp-make-temp-file filename)) |
| 3683 | 3678 | ||
| 3684 | (cond ((and (tramp-method-out-of-band-p v) | 3679 | (cond |
| 3685 | (> (nth 7 (file-attributes filename)) | 3680 | ;; Fast track on local machine. |
| 3686 | tramp-copy-size-limit)) | 3681 | ((tramp-local-host-p v) |
| 3687 | ;; `copy-file' handles out-of-band methods | 3682 | (tramp-do-copy-or-rename-file-directly 'copy v localname tmpfil t) |
| 3688 | (copy-file filename tmpfil t t)) | 3683 | (tramp-send-command v (format "chown %s %s" (user-login-name) tmpfil))) |
| 3689 | 3684 | ||
| 3690 | (rem-enc | 3685 | ;; `copy-file' handles out-of-band methods. |
| 3691 | ;; Use inline encoding for file transfer. | 3686 | ((and (tramp-method-out-of-band-p v) |
| 3692 | (save-excursion | 3687 | (> (nth 7 (file-attributes filename)) tramp-copy-size-limit)) |
| 3693 | (tramp-message v 5 "Encoding remote file %s..." filename) | 3688 | (copy-file filename tmpfil t t)) |
| 3694 | (tramp-barf-unless-okay | 3689 | |
| 3695 | v | 3690 | ;; Use inline encoding for file transfer. |
| 3696 | (concat rem-enc " < " (tramp-shell-quote-argument localname)) | 3691 | (rem-enc |
| 3697 | "Encoding remote file failed") | 3692 | (save-excursion |
| 3698 | 3693 | (tramp-message v 5 "Encoding remote file %s..." filename) | |
| 3699 | (tramp-message v 5 "Decoding remote file %s..." filename) | 3694 | (tramp-barf-unless-okay |
| 3700 | ;; Here is where loc-dec used to be let-bound. | 3695 | v (format "%s < %s" rem-enc (tramp-shell-quote-argument localname)) |
| 3701 | (if (and (symbolp loc-dec) (fboundp loc-dec)) | 3696 | "Encoding remote file failed") |
| 3702 | ;; If local decoding is a function, we call it. We | 3697 | (tramp-message v 5 "Encoding remote file %s...done" filename) |
| 3703 | ;; must disable multibyte, because | 3698 | |
| 3704 | ;; `uudecode-decode-region' doesn't handle it | 3699 | (tramp-message v 5 "Decoding remote file %s..." filename) |
| 3705 | ;; correctly. | 3700 | (if (and (symbolp loc-dec) (fboundp loc-dec)) |
| 3706 | (unwind-protect | 3701 | ;; If local decoding is a function, we call it. We must |
| 3707 | (with-temp-buffer | 3702 | ;; disable multibyte, because `uudecode-decode-region' |
| 3708 | (set-buffer-multibyte nil) | 3703 | ;; doesn't handle it correctly. |
| 3709 | (insert-buffer-substring (tramp-get-buffer v)) | 3704 | (unwind-protect |
| 3710 | (tramp-message | 3705 | (with-temp-buffer |
| 3711 | v 5 "Decoding remote file %s with function %s..." | 3706 | (set-buffer-multibyte nil) |
| 3712 | filename loc-dec) | 3707 | (insert-buffer-substring (tramp-get-buffer v)) |
| 3713 | (funcall loc-dec (point-min) (point-max)) | 3708 | (tramp-message |
| 3714 | (let ((coding-system-for-write 'binary)) | 3709 | v 5 "Decoding remote file %s with function %s..." |
| 3715 | (write-region (point-min) (point-max) tmpfil)))) | 3710 | filename loc-dec) |
| 3716 | ;; If tramp-decoding-function is not defined for this | 3711 | (funcall loc-dec (point-min) (point-max)) |
| 3717 | ;; method, we invoke tramp-decoding-command instead. | 3712 | (let ((coding-system-for-write 'binary)) |
| 3718 | (let ((tmpfil2 (tramp-make-temp-file filename))) | 3713 | (write-region (point-min) (point-max) tmpfil)))) |
| 3719 | (let ((coding-system-for-write 'binary)) | 3714 | ;; If tramp-decoding-function is not defined for this |
| 3720 | (write-region (point-min) (point-max) tmpfil2)) | 3715 | ;; method, we invoke tramp-decoding-command instead. |
| 3721 | (tramp-message | 3716 | (let ((tmpfil2 (tramp-make-temp-file filename))) |
| 3722 | v 5 "Decoding remote file %s with command %s..." | 3717 | (let ((coding-system-for-write 'binary)) |
| 3723 | filename loc-dec) | 3718 | (write-region (point-min) (point-max) tmpfil2)) |
| 3724 | (tramp-call-local-coding-command | 3719 | (tramp-message |
| 3725 | loc-dec tmpfil2 tmpfil) | 3720 | v 5 "Decoding remote file %s with command %s..." |
| 3726 | (delete-file tmpfil2))) | 3721 | filename loc-dec) |
| 3727 | (tramp-message v 5 "Decoding remote file %s...done" filename) | 3722 | (tramp-call-local-coding-command loc-dec tmpfil2 tmpfil) |
| 3728 | ;; Set proper permissions. | 3723 | (delete-file tmpfil2))) |
| 3729 | (set-file-modes tmpfil (file-modes filename)))) | 3724 | (tramp-message v 5 "Decoding remote file %s...done" filename) |
| 3730 | 3725 | ;; Set proper permissions. | |
| 3731 | (t (tramp-error | 3726 | (set-file-modes tmpfil (file-modes filename)))) |
| 3732 | v 'file-error "Wrong method specification for `%s'" method))) | 3727 | |
| 3728 | ;; Oops, I don't know what to do. | ||
| 3729 | (t (tramp-error | ||
| 3730 | v 'file-error "Wrong method specification for `%s'" method))) | ||
| 3731 | |||
| 3733 | (run-hooks 'tramp-handle-file-local-copy-hook) | 3732 | (run-hooks 'tramp-handle-file-local-copy-hook) |
| 3734 | tmpfil))) | 3733 | tmpfil))) |
| 3735 | 3734 | ||
| @@ -3927,20 +3926,26 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file." | |||
| 3927 | ;; the backup file. This case `save-buffer' handles | 3926 | ;; the backup file. This case `save-buffer' handles |
| 3928 | ;; permissions. | 3927 | ;; permissions. |
| 3929 | (when modes (set-file-modes tmpfil modes)) | 3928 | (when modes (set-file-modes tmpfil modes)) |
| 3929 | |||
| 3930 | ;; This is a bit lengthy due to the different methods possible for | 3930 | ;; This is a bit lengthy due to the different methods possible for |
| 3931 | ;; file transfer. First, we check whether the method uses an rcp | 3931 | ;; file transfer. First, we check whether the method uses an rcp |
| 3932 | ;; program. If so, we call it. Otherwise, both encoding and | 3932 | ;; program. If so, we call it. Otherwise, both encoding and |
| 3933 | ;; decoding command must be specified. However, if the method | 3933 | ;; decoding command must be specified. However, if the method |
| 3934 | ;; _also_ specifies an encoding function, then that is used for | 3934 | ;; _also_ specifies an encoding function, then that is used for |
| 3935 | ;; encoding the contents of the tmp file. | 3935 | ;; encoding the contents of the tmp file. |
| 3936 | (cond ((and (tramp-method-out-of-band-p v) | 3936 | (cond ;; Fast track on local machine. |
| 3937 | ((tramp-local-host-p v) | ||
| 3938 | (tramp-do-copy-or-rename-file-directly | ||
| 3939 | 'rename v tmpfil localname t)) | ||
| 3940 | |||
| 3941 | ;; `copy-file' handles out-of-band methods | ||
| 3942 | ((and (tramp-method-out-of-band-p v) | ||
| 3937 | (integerp start) | 3943 | (integerp start) |
| 3938 | (> (- end start) tramp-copy-size-limit)) | 3944 | (> (- end start) tramp-copy-size-limit)) |
| 3939 | ;; `copy-file' handles out-of-band methods | 3945 | (rename-file tmpfil filename t)) |
| 3940 | (copy-file tmpfil filename t t)) | ||
| 3941 | 3946 | ||
| 3947 | ;; Use inline file transfer | ||
| 3942 | (rem-dec | 3948 | (rem-dec |
| 3943 | ;; Use inline file transfer | ||
| 3944 | ;; Encode tmpfil | 3949 | ;; Encode tmpfil |
| 3945 | (tramp-message v 5 "Encoding region...") | 3950 | (tramp-message v 5 "Encoding region...") |
| 3946 | (unwind-protect | 3951 | (unwind-protect |
| @@ -4025,14 +4030,19 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file." | |||
| 4025 | filename rem-dec))) | 4030 | filename rem-dec))) |
| 4026 | (tramp-message | 4031 | (tramp-message |
| 4027 | v 5 "Decoding region into remote file %s...done" filename) | 4032 | v 5 "Decoding region into remote file %s...done" filename) |
| 4028 | (tramp-flush-file-property v localname)))) | 4033 | (tramp-flush-file-property v localname)) |
| 4034 | |||
| 4035 | ;; Save exit. | ||
| 4036 | (delete-file tmpfil))) | ||
| 4037 | |||
| 4038 | ;; That's not expected. | ||
| 4029 | (t | 4039 | (t |
| 4030 | (tramp-error | 4040 | (tramp-error |
| 4031 | v 'file-error | 4041 | v 'file-error |
| 4032 | (concat "Method `%s' should specify both encoding and " | 4042 | (concat "Method `%s' should specify both encoding and " |
| 4033 | "decoding command or an rcp program") | 4043 | "decoding command or an rcp program") |
| 4034 | method))) | 4044 | method))) |
| 4035 | (delete-file tmpfil) | 4045 | |
| 4036 | (when (or (eq visit t) (stringp visit)) | 4046 | (when (or (eq visit t) (stringp visit)) |
| 4037 | (set-visited-file-modtime | 4047 | (set-visited-file-modtime |
| 4038 | ;; We must pass modtime explicitely, because filename can be different | 4048 | ;; We must pass modtime explicitely, because filename can be different |
| @@ -4198,10 +4208,7 @@ Falls back to normal file name handler if no tramp file name handler exists." | |||
| 4198 | filename) | 4208 | filename) |
| 4199 | ;; Call the backend function. Set a connection property | 4209 | ;; Call the backend function. Set a connection property |
| 4200 | ;; first, it will be reused for user/host name completion. | 4210 | ;; first, it will be reused for user/host name completion. |
| 4201 | (foreign | 4211 | (foreign (apply foreign operation args)) |
| 4202 | (unless (zerop (length localname)) | ||
| 4203 | (tramp-set-connection-property v "started" nil)) | ||
| 4204 | (apply foreign operation args)) | ||
| 4205 | ;; Nothing to do for us. | 4212 | ;; Nothing to do for us. |
| 4206 | (t (tramp-run-real-handler operation args))))))) | 4213 | (t (tramp-run-real-handler operation args))))))) |
| 4207 | 4214 | ||
| @@ -6502,8 +6509,7 @@ necessary only. This function will be used in file name completion." | |||
| 6502 | (defun tramp-make-copy-program-file-name (vec) | 6509 | (defun tramp-make-copy-program-file-name (vec) |
| 6503 | "Create a file name suitable to be passed to `rcp' and workalikes." | 6510 | "Create a file name suitable to be passed to `rcp' and workalikes." |
| 6504 | (let ((user (tramp-file-name-user vec)) | 6511 | (let ((user (tramp-file-name-user vec)) |
| 6505 | (host (car (split-string | 6512 | (host (tramp-file-name-real-host vec)) |
| 6506 | (tramp-file-name-host vec) tramp-prefix-port-regexp))) | ||
| 6507 | (localname (tramp-shell-quote-argument | 6513 | (localname (tramp-shell-quote-argument |
| 6508 | (tramp-file-name-localname vec)))) | 6514 | (tramp-file-name-localname vec)))) |
| 6509 | (if (not (zerop (length user))) | 6515 | (if (not (zerop (length user))) |
| @@ -6514,6 +6520,14 @@ necessary only. This function will be used in file name completion." | |||
| 6514 | "Return t if this is an out-of-band method, nil otherwise." | 6520 | "Return t if this is an out-of-band method, nil otherwise." |
| 6515 | (tramp-get-method-parameter (tramp-file-name-method vec) 'tramp-copy-program)) | 6521 | (tramp-get-method-parameter (tramp-file-name-method vec) 'tramp-copy-program)) |
| 6516 | 6522 | ||
| 6523 | (defun tramp-local-host-p (vec) | ||
| 6524 | "Return t if this points to the local host, nil otherwise." | ||
| 6525 | (let ((host (tramp-file-name-real-host vec))) | ||
| 6526 | (and | ||
| 6527 | (stringp host) | ||
| 6528 | (string-match | ||
| 6529 | (concat "^" (regexp-opt (list "localhost" (system-name)) t) "$") host)))) | ||
| 6530 | |||
| 6517 | ;; Variables local to connection. | 6531 | ;; Variables local to connection. |
| 6518 | 6532 | ||
| 6519 | (defun tramp-get-remote-path (vec) | 6533 | (defun tramp-get-remote-path (vec) |