comparison lisp/net/tramp.el @ 85024:ef71cdab0d5c

* net/tramp.el (top): Add tramp-compat to `tramp-unload-hook'. (tramp-file-name-handler-alist): Add `tramp-handle-insert-file-contents-literally'. Neded for XEmacs. (tramp-make-temp-file): Use `make-temp-name'. `make-temp-file', used before, creates the file already, which is not desired. (tramp-do-copy-or-rename-file-directly): Simplify handling of temporary file. (tramp-handle-insert-file-contents): Assign the result in the short track case. (tramp-handle-insert-file-contents-literally): New defun. (tramp-completion-mode-p): Revert change from 2007-09-24. Checking for `return' etc as last character is not sufficient, for example in dired-mode when entering <g> (revert-buffer) or <s> (dired-sort). * net/tramp-compat.el (top): Add also compatibility code for loading appropriate timer package. (tramp-compat-copy-tree): Check for `subrp' and `symbol-file' in order to avoid autoloading problems. * net/tramp-fish.el: * net/tramp-smb.el: Move further compatibility code to tramp-compat.el. * net/tramp-ftp.el (tramp-ftp-file-name-handler): Handle the case where the second parameter of `copy-file' or `rename-file' is a remote file but not via ftp.
author Michael Albinus <michael.albinus@gmx.de>
date Wed, 03 Oct 2007 10:54:03 +0000
parents f7642749252b
children a42b8750a992
comparison
equal deleted inserted replaced
85023:0161d8024935 85024:ef71cdab0d5c
71 '(lambda () 71 '(lambda ()
72 (when (featurep 'trampver) 72 (when (featurep 'trampver)
73 (unload-feature 'trampver 'force)))) 73 (unload-feature 'trampver 'force))))
74 74
75 (require 'tramp-compat) 75 (require 'tramp-compat)
76 76 (add-hook 'tramp-unload-hook
77 ;; `directory-sep-char' is an obsolete variable in Emacs. But it is 77 '(lambda ()
78 ;; used in XEmacs, so we set it here and there. The following is needed 78 (when (featurep 'tramp-compat)
79 ;; to pacify Emacs byte-compiler. 79 (unload-feature 'tramp-compat 'force))))
80 (eval-when-compile
81 (setq byte-compile-not-obsolete-var 'directory-sep-char))
82
83 (require 'custom)
84
85 (if (featurep 'xemacs)
86 (require 'timer-funcs)
87 (require 'timer))
88 80
89 (require 'format-spec) ;from Gnus 5.8, also in tar ball 81 (require 'format-spec) ;from Gnus 5.8, also in tar ball
90 ;; As long as password.el is not part of (X)Emacs, it shouldn't 82 ;; As long as password.el is not part of (X)Emacs, it shouldn't
91 ;; be mandatory 83 ;; be mandatory
92 (if (featurep 'xemacs) 84 (if (featurep 'xemacs)
174 "Edit remote files with a combination of rsh and rcp or similar programs." 166 "Edit remote files with a combination of rsh and rcp or similar programs."
175 :group 'files 167 :group 'files
176 :version "22.1") 168 :version "22.1")
177 169
178 (defcustom tramp-verbose 3 170 (defcustom tramp-verbose 3
179 "*Verbosity level for tramp. 171 "*Verbosity level for Tramp.
180 Any level x includes messages for all levels 1 .. x-1. The levels are 172 Any level x includes messages for all levels 1 .. x-1. The levels are
181 173
182 0 silent (no tramp messages at all) 174 0 silent (no tramp messages at all)
183 1 errors 175 1 errors
184 2 warnings 176 2 warnings
1277 (defconst tramp-file-name-regexp 1269 (defconst tramp-file-name-regexp
1278 (cond ((equal tramp-syntax 'ftp) tramp-file-name-regexp-unified) 1270 (cond ((equal tramp-syntax 'ftp) tramp-file-name-regexp-unified)
1279 ((equal tramp-syntax 'sep) tramp-file-name-regexp-separate) 1271 ((equal tramp-syntax 'sep) tramp-file-name-regexp-separate)
1280 ((equal tramp-syntax 'url) tramp-file-name-regexp-url) 1272 ((equal tramp-syntax 'url) tramp-file-name-regexp-url)
1281 (t (error "Wrong `tramp-syntax' defined"))) 1273 (t (error "Wrong `tramp-syntax' defined")))
1282 "*Regular expression matching file names handled by tramp. 1274 "*Regular expression matching file names handled by Tramp.
1283 This regexp should match tramp file names but no other file names. 1275 This regexp should match tramp file names but no other file names.
1284 \(When tramp.el is loaded, this regular expression is prepended to 1276 \(When tramp.el is loaded, this regular expression is prepended to
1285 `file-name-handler-alist', and that is searched sequentially. Thus, 1277 `file-name-handler-alist', and that is searched sequentially. Thus,
1286 if the tramp entry appears rather early in the `file-name-handler-alist' 1278 if the tramp entry appears rather early in the `file-name-handler-alist'
1287 and is a bit too general, then some files might be considered tramp 1279 and is a bit too general, then some files might be considered tramp
1760 (expand-file-name . tramp-handle-expand-file-name) 1752 (expand-file-name . tramp-handle-expand-file-name)
1761 (substitute-in-file-name . tramp-handle-substitute-in-file-name) 1753 (substitute-in-file-name . tramp-handle-substitute-in-file-name)
1762 (file-local-copy . tramp-handle-file-local-copy) 1754 (file-local-copy . tramp-handle-file-local-copy)
1763 (file-remote-p . tramp-handle-file-remote-p) 1755 (file-remote-p . tramp-handle-file-remote-p)
1764 (insert-file-contents . tramp-handle-insert-file-contents) 1756 (insert-file-contents . tramp-handle-insert-file-contents)
1757 (insert-file-contents-literally
1758 . tramp-handle-insert-file-contents-literally)
1765 (write-region . tramp-handle-write-region) 1759 (write-region . tramp-handle-write-region)
1766 (find-backup-file-name . tramp-handle-find-backup-file-name) 1760 (find-backup-file-name . tramp-handle-find-backup-file-name)
1767 (make-auto-save-file-name . tramp-handle-make-auto-save-file-name) 1761 (make-auto-save-file-name . tramp-handle-make-auto-save-file-name)
1768 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory) 1762 (unhandled-file-name-directory . tramp-handle-unhandled-file-name-directory)
1769 (dired-compress-file . tramp-handle-dired-compress-file) 1763 (dired-compress-file . tramp-handle-dired-compress-file)
1980 (put 'tramp-let-maybe 'lisp-indent-function 2) 1974 (put 'tramp-let-maybe 'lisp-indent-function 2)
1981 (put 'tramp-let-maybe 'edebug-form-spec t) 1975 (put 'tramp-let-maybe 'edebug-form-spec t)
1982 1976
1983 (defsubst tramp-make-temp-file (filename) 1977 (defsubst tramp-make-temp-file (filename)
1984 (concat 1978 (concat
1985 (funcall (if (fboundp 'make-temp-file) 'make-temp-file 'make-temp-name) 1979 (make-temp-name
1986 (expand-file-name tramp-temp-name-prefix 1980 (expand-file-name
1987 (tramp-compat-temporary-file-directory))) 1981 tramp-temp-name-prefix (tramp-compat-temporary-file-directory)))
1988 (file-name-extension filename t))) 1982 (file-name-extension filename t)))
1989 1983
1990 (defsubst tramp-make-tramp-temp-file (vec) 1984 (defsubst tramp-make-tramp-temp-file (vec)
1991 (format 1985 (format
1992 "/tmp/%s%s" 1986 "/tmp/%s%s"
3157 ;; Move the temporary file to its destination. 3151 ;; Move the temporary file to its destination.
3158 (cond 3152 (cond
3159 (t2 3153 (t2
3160 (tramp-send-command 3154 (tramp-send-command
3161 v (format 3155 v (format
3162 "%s %s %s" cmd 3156 "mv -f %s %s"
3163 (tramp-shell-quote-argument tmpfile) 3157 (tramp-shell-quote-argument tmpfile)
3164 (tramp-shell-quote-argument localname2)))) 3158 (tramp-shell-quote-argument localname2))))
3165 (t1 3159 (t1
3166 (if (eq op 'copy) 3160 (rename-file tmpfile localname2 ok-if-already-exists))))))))
3167 (tramp-compat-copy-file
3168 tmpfile localname2 ok-if-already-exists
3169 keep-date preserve-uid-gid)
3170 (rename-file tmpfile localname2 ok-if-already-exists))))
3171
3172 ;; Remove temporary file.
3173 (when (eq op 'copy) (delete-file tmpfile)))))))
3174 3161
3175 ;; Set the time and mode. Mask possible errors. 3162 ;; Set the time and mode. Mask possible errors.
3176 ;; Won't be applied for 'rename. 3163 ;; Won't be applied for 'rename.
3177 (condition-case nil 3164 (condition-case nil
3178 (when (and keep-date (not preserve-uid-gid)) 3165 (when (and keep-date (not preserve-uid-gid))
3809 "Like `file-local-copy' for Tramp files." 3796 "Like `file-local-copy' for Tramp files."
3810 3797
3811 (with-parsed-tramp-file-name filename nil 3798 (with-parsed-tramp-file-name filename nil
3812 (let ((rem-enc (tramp-get-remote-coding v "remote-encoding")) 3799 (let ((rem-enc (tramp-get-remote-coding v "remote-encoding"))
3813 (loc-dec (tramp-get-local-coding v "local-decoding")) 3800 (loc-dec (tramp-get-local-coding v "local-decoding"))
3814 (tmpfil (tramp-make-temp-file filename))) 3801 (tmpfile (tramp-make-temp-file filename)))
3815 (unless (file-exists-p filename) 3802 (unless (file-exists-p filename)
3816 (tramp-error 3803 (tramp-error
3817 v 'file-error 3804 v 'file-error
3818 "Cannot make local copy of non-existing file `%s'" filename)) 3805 "Cannot make local copy of non-existing file `%s'" filename))
3819 3806
3820 (cond 3807 (cond
3821 ;; `copy-file' handles direct copy and out-of-band methods. 3808 ;; `copy-file' handles direct copy and out-of-band methods.
3822 ((or (tramp-local-host-p v) 3809 ((or (tramp-local-host-p v)
3823 (and (tramp-method-out-of-band-p v) 3810 (and (tramp-method-out-of-band-p v)
3824 (> (nth 7 (file-attributes filename)) tramp-copy-size-limit))) 3811 (> (nth 7 (file-attributes filename)) tramp-copy-size-limit)))
3825 (copy-file filename tmpfil t t)) 3812 (copy-file filename tmpfile t t))
3826 3813
3827 ;; Use inline encoding for file transfer. 3814 ;; Use inline encoding for file transfer.
3828 (rem-enc 3815 (rem-enc
3829 (save-excursion 3816 (save-excursion
3830 (tramp-message v 5 "Encoding remote file %s..." filename) 3817 (tramp-message v 5 "Encoding remote file %s..." filename)
3845 (tramp-message 3832 (tramp-message
3846 v 5 "Decoding remote file %s with function %s..." 3833 v 5 "Decoding remote file %s with function %s..."
3847 filename loc-dec) 3834 filename loc-dec)
3848 (funcall loc-dec (point-min) (point-max)) 3835 (funcall loc-dec (point-min) (point-max))
3849 (let ((coding-system-for-write 'binary)) 3836 (let ((coding-system-for-write 'binary))
3850 (write-region (point-min) (point-max) tmpfil)))) 3837 (write-region (point-min) (point-max) tmpfile))))
3851 ;; If tramp-decoding-function is not defined for this 3838 ;; If tramp-decoding-function is not defined for this
3852 ;; method, we invoke tramp-decoding-command instead. 3839 ;; method, we invoke tramp-decoding-command instead.
3853 (let ((tmpfil2 (tramp-make-temp-file filename))) 3840 (let ((tmpfile2 (tramp-make-temp-file filename)))
3854 (let ((coding-system-for-write 'binary)) 3841 (let ((coding-system-for-write 'binary))
3855 (write-region (point-min) (point-max) tmpfil2)) 3842 (write-region (point-min) (point-max) tmpfile2))
3856 (tramp-message 3843 (tramp-message
3857 v 5 "Decoding remote file %s with command %s..." 3844 v 5 "Decoding remote file %s with command %s..."
3858 filename loc-dec) 3845 filename loc-dec)
3859 (tramp-call-local-coding-command loc-dec tmpfil2 tmpfil) 3846 (tramp-call-local-coding-command loc-dec tmpfile2 tmpfile)
3860 (delete-file tmpfil2))) 3847 (delete-file tmpfile2)))
3861 (tramp-message v 5 "Decoding remote file %s...done" filename) 3848 (tramp-message v 5 "Decoding remote file %s...done" filename)
3862 ;; Set proper permissions. 3849 ;; Set proper permissions.
3863 (set-file-modes tmpfil (file-modes filename)) 3850 (set-file-modes tmpfile (file-modes filename))
3864 ;; Set local user ownership. 3851 ;; Set local user ownership.
3865 (tramp-set-file-uid-gid tmpfil))) 3852 (tramp-set-file-uid-gid tmpfile)))
3866 3853
3867 ;; Oops, I don't know what to do. 3854 ;; Oops, I don't know what to do.
3868 (t (tramp-error 3855 (t (tramp-error
3869 v 'file-error "Wrong method specification for `%s'" method))) 3856 v 'file-error "Wrong method specification for `%s'" method)))
3870 3857
3871 (run-hooks 'tramp-handle-file-local-copy-hook) 3858 (run-hooks 'tramp-handle-file-local-copy-hook)
3872 tmpfil))) 3859 tmpfile)))
3873 3860
3874 (defun tramp-handle-file-remote-p (filename &optional identification connected) 3861 (defun tramp-handle-file-remote-p (filename &optional identification connected)
3875 "Like `file-remote-p' for Tramp files." 3862 "Like `file-remote-p' for Tramp files."
3876 (when (tramp-tramp-file-p filename) 3863 (when (tramp-tramp-file-p filename)
3877 (with-parsed-tramp-file-name filename nil 3864 (with-parsed-tramp-file-name filename nil
3904 (list (expand-file-name filename) 0)) 3891 (list (expand-file-name filename) 0))
3905 3892
3906 (if (and (tramp-local-host-p v) 3893 (if (and (tramp-local-host-p v)
3907 (file-readable-p localname)) 3894 (file-readable-p localname))
3908 ;; Short track: if we are on the local host, we can run directly. 3895 ;; Short track: if we are on the local host, we can run directly.
3909 (insert-file-contents localname visit beg end replace) 3896 (setq result (insert-file-contents localname visit beg end replace))
3910 3897
3911 ;; `insert-file-contents-literally' takes care to avoid calling 3898 ;; `insert-file-contents-literally' takes care to avoid calling
3912 ;; jka-compr. By let-binding inhibit-file-name-operation, we 3899 ;; jka-compr. By let-binding inhibit-file-name-operation, we
3913 ;; propagate that care to the file-local-copy operation. 3900 ;; propagate that care to the file-local-copy operation.
3914 (let ((local-copy 3901 (let ((local-copy
3932 (setq buffer-file-name filename) 3919 (setq buffer-file-name filename)
3933 (set-visited-file-modtime) 3920 (set-visited-file-modtime)
3934 (set-buffer-modified-p nil)) 3921 (set-buffer-modified-p nil))
3935 (list (expand-file-name filename) 3922 (list (expand-file-name filename)
3936 (cadr result)))))) 3923 (cadr result))))))
3924
3925 ;; This is needed for XEmacs only. Code stolen from files.el.
3926 (defun tramp-handle-insert-file-contents-literally
3927 (filename &optional visit beg end replace)
3928 "Like `insert-file-contents-literally' for Tramp files."
3929 (let ((format-alist nil)
3930 (after-insert-file-functions nil)
3931 (coding-system-for-read 'no-conversion)
3932 (coding-system-for-write 'no-conversion)
3933 (find-buffer-file-type-function
3934 (if (fboundp 'find-buffer-file-type)
3935 (symbol-function 'find-buffer-file-type)
3936 nil))
3937 (inhibit-file-name-handlers '(jka-compr-handler image-file-handler))
3938 (inhibit-file-name-operation 'insert-file-contents))
3939 (unwind-protect
3940 (progn
3941 (fset 'find-buffer-file-type (lambda (filename) t))
3942 (insert-file-contents filename visit beg end replace))
3943 (if find-buffer-file-type-function
3944 (fset 'find-buffer-file-type find-buffer-file-type-function)
3945 (fmakunbound 'find-buffer-file-type)))))
3937 3946
3938 (defun tramp-handle-find-backup-file-name (filename) 3947 (defun tramp-handle-find-backup-file-name (filename)
3939 "Like `find-backup-file-name' for Tramp files." 3948 "Like `find-backup-file-name' for Tramp files."
3940 (with-parsed-tramp-file-name filename nil 3949 (with-parsed-tramp-file-name filename nil
3941 ;; We set both variables. It doesn't matter whether it is 3950 ;; We set both variables. It doesn't matter whether it is
4039 ;; (unless (or (eq lockname nil) 4048 ;; (unless (or (eq lockname nil)
4040 ;; (string= lockname filename)) 4049 ;; (string= lockname filename))
4041 ;; (error 4050 ;; (error
4042 ;; "tramp-handle-write-region: LOCKNAME must be nil or equal FILENAME")) 4051 ;; "tramp-handle-write-region: LOCKNAME must be nil or equal FILENAME"))
4043 4052
4044 ;; XEmacs takes a coding system as the seventh argument, not `confirm' 4053 ;; XEmacs takes a coding system as the seventh argument, not `confirm'.
4045 (when (and (not (featurep 'xemacs)) confirm (file-exists-p filename)) 4054 (when (and (not (featurep 'xemacs)) confirm (file-exists-p filename))
4046 (unless (y-or-n-p (format "File %s exists; overwrite anyway? " filename)) 4055 (unless (y-or-n-p (format "File %s exists; overwrite anyway? " filename))
4047 (tramp-error v 'file-error "File not overwritten"))) 4056 (tramp-error v 'file-error "File not overwritten")))
4048 4057
4049 (let ((rem-dec (tramp-get-remote-coding v "remote-decoding")) 4058 (let ((rem-dec (tramp-get-remote-coding v "remote-decoding"))
4057 ;; variable. This approach was snarfed from ange-ftp.el. 4066 ;; variable. This approach was snarfed from ange-ftp.el.
4058 coding-system-used 4067 coding-system-used
4059 ;; Write region into a tmp file. This isn't really needed if we 4068 ;; Write region into a tmp file. This isn't really needed if we
4060 ;; use an encoding function, but currently we use it always 4069 ;; use an encoding function, but currently we use it always
4061 ;; because this makes the logic simpler. 4070 ;; because this makes the logic simpler.
4062 (tmpfil (tramp-make-temp-file filename))) 4071 (tmpfile (tramp-make-temp-file filename)))
4063 4072
4064 (if (and (tramp-local-host-p v) 4073 (if (and (tramp-local-host-p v)
4065 (file-writable-p (file-name-directory localname))) 4074 (file-writable-p (file-name-directory localname)))
4066 ;; Short track: if we are on the local host, we can run directly. 4075 ;; Short track: if we are on the local host, we can run directly.
4067 (if confirm 4076 (if confirm
4073 ;; modtime data to be clobbered from the temp file. We call 4082 ;; modtime data to be clobbered from the temp file. We call
4074 ;; `set-visited-file-modtime' ourselves later on. 4083 ;; `set-visited-file-modtime' ourselves later on.
4075 (tramp-run-real-handler 4084 (tramp-run-real-handler
4076 'write-region 4085 'write-region
4077 (if confirm ; don't pass this arg unless defined for backward compat. 4086 (if confirm ; don't pass this arg unless defined for backward compat.
4078 (list start end tmpfil append 'no-message lockname confirm) 4087 (list start end tmpfile append 'no-message lockname confirm)
4079 (list start end tmpfil append 'no-message lockname))) 4088 (list start end tmpfile append 'no-message lockname)))
4080 ;; Now, `last-coding-system-used' has the right value. Remember it. 4089 ;; Now, `last-coding-system-used' has the right value. Remember it.
4081 (when (boundp 'last-coding-system-used) 4090 (when (boundp 'last-coding-system-used)
4082 (setq coding-system-used (symbol-value 'last-coding-system-used))) 4091 (setq coding-system-used (symbol-value 'last-coding-system-used)))
4083 ;; The permissions of the temporary file should be set. If 4092 ;; The permissions of the temporary file should be set. If
4084 ;; filename does not exist (eq modes nil) it has been renamed to 4093 ;; filename does not exist (eq modes nil) it has been renamed to
4085 ;; the backup file. This case `save-buffer' handles 4094 ;; the backup file. This case `save-buffer' handles
4086 ;; permissions. 4095 ;; permissions.
4087 (when modes (set-file-modes tmpfil modes)) 4096 (when modes (set-file-modes tmpfile modes))
4088 4097
4089 ;; This is a bit lengthy due to the different methods possible for 4098 ;; This is a bit lengthy due to the different methods possible for
4090 ;; file transfer. First, we check whether the method uses an rcp 4099 ;; file transfer. First, we check whether the method uses an rcp
4091 ;; program. If so, we call it. Otherwise, both encoding and 4100 ;; program. If so, we call it. Otherwise, both encoding and
4092 ;; decoding command must be specified. However, if the method 4101 ;; decoding command must be specified. However, if the method
4096 ;; `rename-file' handles direct copy and out-of-band methods. 4105 ;; `rename-file' handles direct copy and out-of-band methods.
4097 ((or (tramp-local-host-p v) 4106 ((or (tramp-local-host-p v)
4098 (and (tramp-method-out-of-band-p v) 4107 (and (tramp-method-out-of-band-p v)
4099 (integerp start) 4108 (integerp start)
4100 (> (- end start) tramp-copy-size-limit))) 4109 (> (- end start) tramp-copy-size-limit)))
4101 (rename-file tmpfil filename t)) 4110 (rename-file tmpfile filename t))
4102 4111
4103 ;; Use inline file transfer 4112 ;; Use inline file transfer
4104 (rem-dec 4113 (rem-dec
4105 ;; Encode tmpfil 4114 ;; Encode tmpfile
4106 (tramp-message v 5 "Encoding region...") 4115 (tramp-message v 5 "Encoding region...")
4107 (unwind-protect 4116 (unwind-protect
4108 (with-temp-buffer 4117 (with-temp-buffer
4109 ;; Use encoding function or command. 4118 ;; Use encoding function or command.
4110 (if (and (symbolp loc-enc) (fboundp loc-enc)) 4119 (if (and (symbolp loc-enc) (fboundp loc-enc))
4111 (progn 4120 (progn
4112 (tramp-message 4121 (tramp-message
4113 v 5 "Encoding region using function `%s'..." 4122 v 5 "Encoding region using function `%s'..."
4114 (symbol-name loc-enc)) 4123 (symbol-name loc-enc))
4115 (let ((coding-system-for-read 'binary)) 4124 (let ((coding-system-for-read 'binary))
4116 (insert-file-contents-literally tmpfil)) 4125 (insert-file-contents-literally tmpfile))
4117 ;; CCC. The following `let' is a workaround for 4126 ;; CCC. The following `let' is a workaround for
4118 ;; the base64.el that comes with pgnus-0.84. If 4127 ;; the base64.el that comes with pgnus-0.84. If
4119 ;; both of the following conditions are 4128 ;; both of the following conditions are
4120 ;; satisfied, it tries to write to a local file 4129 ;; satisfied, it tries to write to a local file
4121 ;; in default-directory, but at this point, 4130 ;; in default-directory, but at this point,
4128 (funcall loc-enc (point-min) (point-max)))) 4137 (funcall loc-enc (point-min) (point-max))))
4129 4138
4130 (tramp-message 4139 (tramp-message
4131 v 5 "Encoding region using command `%s'..." loc-enc) 4140 v 5 "Encoding region using command `%s'..." loc-enc)
4132 (unless (equal 0 (tramp-call-local-coding-command 4141 (unless (equal 0 (tramp-call-local-coding-command
4133 loc-enc tmpfil t)) 4142 loc-enc tmpfile t))
4134 (tramp-error 4143 (tramp-error
4135 v 'file-error 4144 v 'file-error
4136 "Cannot write to `%s', local encoding command `%s' failed" 4145 "Cannot write to `%s', local encoding command `%s' failed"
4137 filename loc-enc))) 4146 filename loc-enc)))
4138 4147
4154 v nil 4163 v nil
4155 "Couldn't write region to `%s', decode using `%s' failed" 4164 "Couldn't write region to `%s', decode using `%s' failed"
4156 filename rem-dec) 4165 filename rem-dec)
4157 ;; When `file-precious-flag' is set, the region is 4166 ;; When `file-precious-flag' is set, the region is
4158 ;; written to a temporary file. Check that the 4167 ;; written to a temporary file. Check that the
4159 ;; checksum is equal to that from the local tmpfil. 4168 ;; checksum is equal to that from the local tmpfile.
4160 (when file-precious-flag 4169 (when file-precious-flag
4161 (erase-buffer) 4170 (erase-buffer)
4162 (and 4171 (and
4163 ;; cksum runs locally 4172 ;; cksum runs locally
4164 (let ((default-directory 4173 (let ((default-directory
4165 (tramp-compat-temporary-file-directory))) 4174 (tramp-compat-temporary-file-directory)))
4166 (zerop (call-process "cksum" tmpfil t))) 4175 (zerop (call-process "cksum" tmpfile t)))
4167 ;; cksum runs remotely 4176 ;; cksum runs remotely
4168 (zerop 4177 (zerop
4169 (tramp-send-command-and-check 4178 (tramp-send-command-and-check
4170 v 4179 v
4171 (format "cksum <%s" (tramp-shell-quote-argument localname)))) 4180 (format "cksum <%s" (tramp-shell-quote-argument localname))))
4182 (tramp-message 4191 (tramp-message
4183 v 5 "Decoding region into remote file %s...done" filename) 4192 v 5 "Decoding region into remote file %s...done" filename)
4184 (tramp-flush-file-property v localname)) 4193 (tramp-flush-file-property v localname))
4185 4194
4186 ;; Save exit. 4195 ;; Save exit.
4187 (delete-file tmpfil))) 4196 (delete-file tmpfile)))
4188 4197
4189 ;; That's not expected. 4198 ;; That's not expected.
4190 (t 4199 (t
4191 (tramp-error 4200 (tramp-error
4192 v 'file-error 4201 v 'file-error
4566 ;; syntax in order to avoid ambiguities, like in XEmacs ... 4575 ;; syntax in order to avoid ambiguities, like in XEmacs ...
4567 (defun tramp-completion-mode-p () 4576 (defun tramp-completion-mode-p ()
4568 "Checks whether method / user name / host name completion is active." 4577 "Checks whether method / user name / host name completion is active."
4569 (or 4578 (or
4570 ;; Emacs 4579 ;; Emacs
4571 (not (memq last-input-event '(return newline))) 4580 (equal last-input-event 'tab)
4572 (and (natnump last-input-event) 4581 (and (natnump last-input-event)
4573 (not (char-equal last-input-event ?\n)) 4582 (or
4574 (not (char-equal last-input-event ?\r))) 4583 ;; ?\t has event-modifier 'control
4584 (char-equal last-input-event ?\t)
4585 (and (not (event-modifiers last-input-event))
4586 (or (char-equal last-input-event ?\?)
4587 (char-equal last-input-event ?\ )))))
4575 ;; XEmacs 4588 ;; XEmacs
4576 (and (featurep 'xemacs) 4589 (and (featurep 'xemacs)
4577 ;; `last-input-event' might be nil. 4590 ;; `last-input-event' might be nil.
4578 (not (null last-input-event)) 4591 (not (null last-input-event))
4579 ;; `last-input-event' may have no character approximation. 4592 ;; `last-input-event' may have no character approximation.
4580 (funcall (symbol-function 'event-to-character) last-input-event) 4593 (funcall (symbol-function 'event-to-character) last-input-event)
4581 (not (char-equal 4594 (or
4582 (funcall (symbol-function 'event-to-character) 4595 ;; ?\t has event-modifier 'control
4583 last-input-event) ?\n)) 4596 (char-equal
4584 (not (char-equal 4597 (funcall (symbol-function 'event-to-character)
4585 (funcall (symbol-function 'event-to-character) 4598 last-input-event) ?\t)
4586 last-input-event) ?\r))))) 4599 (and (not (event-modifiers last-input-event))
4600 (or (char-equal
4601 (funcall (symbol-function 'event-to-character)
4602 last-input-event) ?\?)
4603 (char-equal
4604 (funcall (symbol-function 'event-to-character)
4605 last-input-event) ?\ )))))))
4587 4606
4588 ;; Method, host name and user name completion. 4607 ;; Method, host name and user name completion.
4589 ;; `tramp-completion-dissect-file-name' returns a list of 4608 ;; `tramp-completion-dissect-file-name' returns a list of
4590 ;; tramp-file-name structures. For all of them we return possible completions. 4609 ;; tramp-file-name structures. For all of them we return possible completions.
4591 ;;;###autoload 4610 ;;;###autoload
6642 would yield `t'. On the other hand, the following check results in nil: 6661 would yield `t'. On the other hand, the following check results in nil:
6643 6662
6644 (tramp-equal-remote \"/sudo::/etc\" \"/su::/etc\")" 6663 (tramp-equal-remote \"/sudo::/etc\" \"/su::/etc\")"
6645 (and (stringp (file-remote-p file1)) 6664 (and (stringp (file-remote-p file1))
6646 (stringp (file-remote-p file2)) 6665 (stringp (file-remote-p file2))
6647 (string-equal (file-remote-p file1) 6666 (string-equal (file-remote-p file1) (file-remote-p file2))))
6648 (file-remote-p file2))))
6649 6667
6650 (defun tramp-make-tramp-file-name (method user host localname) 6668 (defun tramp-make-tramp-file-name (method user host localname)
6651 "Constructs a Tramp file name from METHOD, USER, HOST and LOCALNAME." 6669 "Constructs a Tramp file name from METHOD, USER, HOST and LOCALNAME."
6652 (concat tramp-prefix-format 6670 (concat tramp-prefix-format
6653 (when (not (zerop (length method))) 6671 (when (not (zerop (length method)))
7259 as you possibly can about the problem, what you did to cause it 7277 as you possibly can about the problem, what you did to cause it
7260 and what the local and remote machines are. 7278 and what the local and remote machines are.
7261 7279
7262 If you can give a simple set of instructions to make this bug 7280 If you can give a simple set of instructions to make this bug
7263 happen reliably, please include those. Thank you for helping 7281 happen reliably, please include those. Thank you for helping
7264 kill bugs in TRAMP. 7282 kill bugs in Tramp.
7265 7283
7266 Another useful thing to do is to put 7284 Another useful thing to do is to put
7267 7285
7268 (setq tramp-verbose 8) 7286 (setq tramp-verbose 8)
7269 7287