aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2010-04-22 14:07:37 +0200
committerMichael Albinus2010-04-22 14:07:37 +0200
commita94d821ff748cef9307ecbf7b68a699a86d9cc5d (patch)
tree652d0d75b2568f14026656c1cbdebe800c55db53
parenta92375d91a09ba71abd7d9d4668e7a96fd8d61fa (diff)
downloademacs-a94d821ff748cef9307ecbf7b68a699a86d9cc5d.tar.gz
emacs-a94d821ff748cef9307ecbf7b68a699a86d9cc5d.zip
Synchronize with Tramp repository.
* net/tramp.el (with-connection-property, tramp-completion-mode-p) (tramp-action-process-alive, tramp-action-out-of-band) (tramp-check-for-regexp, tramp-file-name-p, tramp-equal-remote) (tramp-exists-file-name-handler): Fix docstring. (with-progress-reporter): New defmacro. (tramp-do-copy-or-rename-file, tramp-handle-dired-compress-file) (tramp-maybe-open-connection): Use it.
-rwxr-xr-xlisp/ChangeLog12
-rwxr-xr-xlisp/net/tramp.el247
2 files changed, 139 insertions, 120 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index dd14ff9e77c..a6fabbf70a9 100755
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,15 @@
12010-04-22 Michael Albinus <michael.albinus@gmx.de>
2
3 Synchronize with Tramp repository.
4
5 * net/tramp.el (with-connection-property, tramp-completion-mode-p)
6 (tramp-action-process-alive, tramp-action-out-of-band)
7 (tramp-check-for-regexp, tramp-file-name-p, tramp-equal-remote)
8 (tramp-exists-file-name-handler): Fix docstring.
9 (with-progress-reporter): New defmacro.
10 (tramp-do-copy-or-rename-file, tramp-handle-dired-compress-file)
11 (tramp-maybe-open-connection): Use it.
12
12010-04-22 Noah Lavine <noah549@gmail.com> (tiny change) 132010-04-22 Noah Lavine <noah549@gmail.com> (tiny change)
2 14
3 Detect ssh 'ControlMaster' argument automatically in some cases. 15 Detect ssh 'ControlMaster' argument automatically in some cases.
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index af5d526bfc6..a17c113bbe7 100755
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -2240,7 +2240,7 @@ FILE must be a local file name on a connection identified via VEC."
2240(font-lock-add-keywords 'emacs-lisp-mode '("\\<with-file-property\\>")) 2240(font-lock-add-keywords 'emacs-lisp-mode '("\\<with-file-property\\>"))
2241 2241
2242(defmacro with-connection-property (key property &rest body) 2242(defmacro with-connection-property (key property &rest body)
2243 "Checks in Tramp for property PROPERTY, otherwise executes BODY and set." 2243 "Check in Tramp for property PROPERTY, otherwise executes BODY and set."
2244 `(let ((value (tramp-get-connection-property ,key ,property 'undef))) 2244 `(let ((value (tramp-get-connection-property ,key ,property 'undef)))
2245 (when (eq value 'undef) 2245 (when (eq value 'undef)
2246 ;; We cannot pass ,@body as parameter to 2246 ;; We cannot pass ,@body as parameter to
@@ -2254,7 +2254,29 @@ FILE must be a local file name on a connection identified via VEC."
2254(put 'with-connection-property 'edebug-form-spec t) 2254(put 'with-connection-property 'edebug-form-spec t)
2255(font-lock-add-keywords 'emacs-lisp-mode '("\\<with-connection-property\\>")) 2255(font-lock-add-keywords 'emacs-lisp-mode '("\\<with-connection-property\\>"))
2256 2256
2257(eval-and-compile ; silence compiler 2257(defmacro with-progress-reporter (vec level message &rest body)
2258 "Executes BODY, spinning a progress reporter with MESSAGE."
2259 `(let (pr tm)
2260 (tramp-message ,vec ,level "%s..." ,message)
2261 ;; We start a pulsing progress reporter after 3 seconds. Feature
2262 ;; introduced in Emacs 24.1.
2263 (when (<= ,level tramp-verbose)
2264 (condition-case nil
2265 (setq pr (funcall 'make-progress-reporter ,message)
2266 tm (run-at-time 3 0.1 'progress-reporter-update pr))
2267 (error nil)))
2268 (unwind-protect
2269 ;; Execute the body.
2270 (progn ,@body)
2271 ;; Stop progress reporter.
2272 (if tm (cancel-timer tm))
2273 (tramp-message ,vec ,level "%s...done" ,message))))
2274
2275(put 'with-progress-reporter 'lisp-indent-function 3)
2276(put 'with-progress-reporter 'edebug-form-spec t)
2277(font-lock-add-keywords 'emacs-lisp-mode '("\\<with-progress-reporter\\>"))
2278
2279(eval-and-compile ;; Silence compiler.
2258 (if (memq system-type '(cygwin windows-nt)) 2280 (if (memq system-type '(cygwin windows-nt))
2259 (defun tramp-drop-volume-letter (name) 2281 (defun tramp-drop-volume-letter (name)
2260 "Cut off unnecessary drive letter from file NAME. 2282 "Cut off unnecessary drive letter from file NAME.
@@ -3547,91 +3569,76 @@ and `rename'. FILENAME and NEWNAME must be absolute file names."
3547 v 'file-already-exists "File %s already exists" newname))) 3569 v 'file-already-exists "File %s already exists" newname)))
3548 3570
3549 (with-parsed-tramp-file-name (if t1 filename newname) nil 3571 (with-parsed-tramp-file-name (if t1 filename newname) nil
3550 (tramp-message v 0 "Transferring %s to %s..." filename newname)) 3572 (with-progress-reporter
3573 v 0 (format "Transferring %s to %s" filename newname)
3551 3574
3552 ;; We start a pulsing progress reporter. Introduced in Emacs 24.1. 3575 (cond
3553 (when (> (nth 7 (file-attributes filename)) tramp-copy-size-limit) 3576 ;; Both are Tramp files.
3554 (condition-case nil 3577 ((and t1 t2)
3555 (setq pr (funcall 3578 (with-parsed-tramp-file-name filename v1
3556 'make-progress-reporter 3579 (with-parsed-tramp-file-name newname v2
3557 (format "Transferring %s to %s..." filename newname)) 3580 (cond
3558 tm (run-at-time 0 0.1 'progress-reporter-update pr)) 3581 ;; Shortcut: if method, host, user are the same for both
3559 (error nil))) 3582 ;; files, we invoke `cp' or `mv' on the remote host
3560 3583 ;; directly.
3561 (unwind-protect 3584 ((tramp-equal-remote filename newname)
3562 (cond 3585 (tramp-do-copy-or-rename-file-directly
3563 ;; Both are Tramp files. 3586 op filename newname
3564 ((and t1 t2) 3587 ok-if-already-exists keep-date preserve-uid-gid))
3565 (with-parsed-tramp-file-name filename v1 3588
3566 (with-parsed-tramp-file-name newname v2 3589 ;; Try out-of-band operation.
3567 (cond 3590 ((tramp-method-out-of-band-p
3568 ;; Shortcut: if method, host, user are the same for both 3591 v1 (nth 7 (file-attributes filename)))
3569 ;; files, we invoke `cp' or `mv' on the remote host 3592 (tramp-do-copy-or-rename-file-out-of-band
3570 ;; directly. 3593 op filename newname keep-date))
3571 ((tramp-equal-remote filename newname) 3594
3572 (tramp-do-copy-or-rename-file-directly 3595 ;; No shortcut was possible. So we copy the
3573 op filename newname 3596 ;; file first. If the operation was `rename', we go
3574 ok-if-already-exists keep-date preserve-uid-gid)) 3597 ;; back and delete the original file (if the copy was
3575 3598 ;; successful). The approach is simple-minded: we
3576 ;; Try out-of-band operation. 3599 ;; create a new buffer, insert the contents of the
3577 ((tramp-method-out-of-band-p 3600 ;; source file into it, then write out the buffer to
3578 v1 (nth 7 (file-attributes filename))) 3601 ;; the target file. The advantage is that it doesn't
3579 (tramp-do-copy-or-rename-file-out-of-band 3602 ;; matter which filename handlers are used for the
3580 op filename newname keep-date)) 3603 ;; source and target file.
3581 3604 (t
3582 ;; No shortcut was possible. So we copy the 3605 (tramp-do-copy-or-rename-file-via-buffer
3583 ;; file first. If the operation was `rename', we go 3606 op filename newname keep-date))))))
3584 ;; back and delete the original file (if the copy was 3607
3585 ;; successful). The approach is simple-minded: we 3608 ;; One file is a Tramp file, the other one is local.
3586 ;; create a new buffer, insert the contents of the 3609 ((or t1 t2)
3587 ;; source file into it, then write out the buffer to 3610 (cond
3588 ;; the target file. The advantage is that it doesn't 3611 ;; Fast track on local machine.
3589 ;; matter which filename handlers are used for the 3612 ((tramp-local-host-p v)
3590 ;; source and target file. 3613 (tramp-do-copy-or-rename-file-directly
3591 (t 3614 op filename newname
3592 (tramp-do-copy-or-rename-file-via-buffer 3615 ok-if-already-exists keep-date preserve-uid-gid))
3593 op filename newname keep-date)))))) 3616
3594 3617 ;; If the Tramp file has an out-of-band method, the corresponding
3595 ;; One file is a Tramp file, the other one is local. 3618 ;; copy-program can be invoked.
3596 ((or t1 t2) 3619 ((tramp-method-out-of-band-p v (nth 7 (file-attributes filename)))
3597 (with-parsed-tramp-file-name (if t1 filename newname) nil 3620 (tramp-do-copy-or-rename-file-out-of-band
3598 (cond 3621 op filename newname keep-date))
3599 ;; Fast track on local machine. 3622
3600 ((tramp-local-host-p v) 3623 ;; Use the inline method via a Tramp buffer.
3601 (tramp-do-copy-or-rename-file-directly 3624 (t (tramp-do-copy-or-rename-file-via-buffer
3602 op filename newname 3625 op filename newname keep-date))))
3603 ok-if-already-exists keep-date preserve-uid-gid)) 3626
3604 3627 (t
3605 ;; If the Tramp file has an out-of-band method, the corresponding 3628 ;; One of them must be a Tramp file.
3606 ;; copy-program can be invoked. 3629 (error "Tramp implementation says this cannot happen")))
3607 ((tramp-method-out-of-band-p v (nth 7 (file-attributes filename))) 3630
3608 (tramp-do-copy-or-rename-file-out-of-band 3631 ;; In case of `rename', we must flush the cache of the source file.
3609 op filename newname keep-date)) 3632 (when (and t1 (eq op 'rename))
3610 3633 (with-parsed-tramp-file-name filename v1
3611 ;; Use the inline method via a Tramp buffer. 3634 (tramp-flush-file-property v1 (file-name-directory localname))
3612 (t (tramp-do-copy-or-rename-file-via-buffer 3635 (tramp-flush-file-property v1 localname)))
3613 op filename newname keep-date))))) 3636
3614 3637 ;; When newname did exist, we have wrong cached values.
3615 (t 3638 (when t2
3616 ;; One of them must be a Tramp file. 3639 (with-parsed-tramp-file-name newname v2
3617 (error "Tramp implementation says this cannot happen"))) 3640 (tramp-flush-file-property v2 (file-name-directory localname))
3618 3641 (tramp-flush-file-property v2 localname)))))))
3619 ;; In case of `rename', we must flush the cache of the source file.
3620 (when (and t1 (eq op 'rename))
3621 (with-parsed-tramp-file-name filename nil
3622 (tramp-flush-file-property v (file-name-directory localname))
3623 (tramp-flush-file-property v localname)))
3624
3625 ;; When newname did exist, we have wrong cached values.
3626 (when t2
3627 (with-parsed-tramp-file-name newname nil
3628 (tramp-flush-file-property v (file-name-directory localname))
3629 (tramp-flush-file-property v localname)))
3630
3631 ;; Stop progress reporter.
3632 (if tm (cancel-timer tm))
3633 (with-parsed-tramp-file-name (if t1 filename newname) nil
3634 (tramp-message v 0 "Transferring %s to %s...done" filename newname)))))
3635 3642
3636(defun tramp-do-copy-or-rename-file-via-buffer (op filename newname keep-date) 3643(defun tramp-do-copy-or-rename-file-via-buffer (op filename newname keep-date)
3637 "Use an Emacs buffer to copy or rename a file. 3644 "Use an Emacs buffer to copy or rename a file.
@@ -4069,30 +4076,30 @@ This is like `dired-recursive-delete-directory' for Tramp files."
4069 nil) 4076 nil)
4070 ((and suffix (nth 2 suffix)) 4077 ((and suffix (nth 2 suffix))
4071 ;; We found an uncompression rule. 4078 ;; We found an uncompression rule.
4072 (tramp-message v 0 "Uncompressing %s..." file) 4079 (with-progress-reporter v 0 (format "Uncompressing %s..." file)
4073 (when (zerop (tramp-send-command-and-check 4080 (when (zerop
4074 v (concat (nth 2 suffix) " " 4081 (tramp-send-command-and-check
4075 (tramp-shell-quote-argument localname)))) 4082 v (concat (nth 2 suffix) " "
4076 (tramp-message v 0 "Uncompressing %s...done" file) 4083 (tramp-shell-quote-argument localname))))
4077 ;; `dired-remove-file' is not defined in XEmacs 4084 ;; `dired-remove-file' is not defined in XEmacs
4078 (funcall (symbol-function 'dired-remove-file) file) 4085 (funcall (symbol-function 'dired-remove-file) file)
4079 (string-match (car suffix) file) 4086 (string-match (car suffix) file)
4080 (concat (substring file 0 (match-beginning 0))))) 4087 (concat (substring file 0 (match-beginning 0))))))
4081 (t 4088 (t
4082 ;; We don't recognize the file as compressed, so compress it. 4089 ;; We don't recognize the file as compressed, so compress it.
4083 ;; Try gzip. 4090 ;; Try gzip.
4084 (tramp-message v 0 "Compressing %s..." file) 4091 (with-progress-reporter v 0 (format "Compressing %s..." file)
4085 (when (zerop (tramp-send-command-and-check 4092 (when (zerop
4086 v (concat "gzip -f " 4093 (tramp-send-command-and-check
4087 (tramp-shell-quote-argument localname)))) 4094 v (concat "gzip -f "
4088 (tramp-message v 0 "Compressing %s...done" file) 4095 (tramp-shell-quote-argument localname))))
4089 ;; `dired-remove-file' is not defined in XEmacs 4096 ;; `dired-remove-file' is not defined in XEmacs
4090 (funcall (symbol-function 'dired-remove-file) file) 4097 (funcall (symbol-function 'dired-remove-file) file)
4091 (cond ((file-exists-p (concat file ".gz")) 4098 (cond ((file-exists-p (concat file ".gz"))
4092 (concat file ".gz")) 4099 (concat file ".gz"))
4093 ((file-exists-p (concat file ".z")) 4100 ((file-exists-p (concat file ".z"))
4094 (concat file ".z")) 4101 (concat file ".z"))
4095 (t nil))))))))) 4102 (t nil))))))))))
4096 4103
4097(defun tramp-handle-dired-uncache (dir &optional dir-p) 4104(defun tramp-handle-dired-uncache (dir &optional dir-p)
4098 "Like `dired-uncache' for Tramp files." 4105 "Like `dired-uncache' for Tramp files."
@@ -5552,9 +5559,9 @@ Falls back to normal file name handler if no Tramp file name handler exists."
5552 ;; disable this part of the completion, unless the user implicitly 5559 ;; disable this part of the completion, unless the user implicitly
5553 ;; indicated his interest in using a fancier completion system. 5560 ;; indicated his interest in using a fancier completion system.
5554 (or (eq tramp-syntax 'sep) 5561 (or (eq tramp-syntax 'sep)
5555 (featurep 'tramp) ;; If it's loaded, we may as well use 5562 (featurep 'tramp) ;; If it's loaded, we may as well use it.
5556 ;; it. `partial-completion-mode' does not exist in 5563 ;; `partial-completion-mode' does not exist in XEmacs.
5557 ;; XEmacs. It is obsoleted with Emacs 24.1. 5564 ;; It is obsoleted with Emacs 24.1.
5558 (and (boundp 'partial-completion-mode) partial-completion-mode) 5565 (and (boundp 'partial-completion-mode) partial-completion-mode)
5559 ;; FIXME: These may have been loaded even if the user never 5566 ;; FIXME: These may have been loaded even if the user never
5560 ;; intended to use them. 5567 ;; intended to use them.
@@ -5628,7 +5635,7 @@ should never be set globally, the intention is to let-bind it.")
5628;; overwriting this check in such cases. Or we change Tramp file name 5635;; overwriting this check in such cases. Or we change Tramp file name
5629;; syntax in order to avoid ambiguities, like in XEmacs ... 5636;; syntax in order to avoid ambiguities, like in XEmacs ...
5630(defun tramp-completion-mode-p () 5637(defun tramp-completion-mode-p ()
5631 "Checks whether method / user name / host name completion is active." 5638 "Check, whether method / user name / host name completion is active."
5632 (or 5639 (or
5633 ;; Signal from outside. `non-essential' has been introduced in Emacs 24. 5640 ;; Signal from outside. `non-essential' has been introduced in Emacs 24.
5634 (and (boundp 'non-essential) (symbol-value 'non-essential)) 5641 (and (boundp 'non-essential) (symbol-value 'non-essential))
@@ -6587,12 +6594,12 @@ The terminal type can be configured with `tramp-terminal-type'."
6587 (tramp-send-string vec tramp-terminal-type)) 6594 (tramp-send-string vec tramp-terminal-type))
6588 6595
6589(defun tramp-action-process-alive (proc vec) 6596(defun tramp-action-process-alive (proc vec)
6590 "Check whether a process has finished." 6597 "Check, whether a process has finished."
6591 (unless (memq (process-status proc) '(run open)) 6598 (unless (memq (process-status proc) '(run open))
6592 (throw 'tramp-action 'process-died))) 6599 (throw 'tramp-action 'process-died)))
6593 6600
6594(defun tramp-action-out-of-band (proc vec) 6601(defun tramp-action-out-of-band (proc vec)
6595 "Check whether an out-of-band copy has finished." 6602 "Check, whether an out-of-band copy has finished."
6596 (cond ((and (memq (process-status proc) '(stop exit)) 6603 (cond ((and (memq (process-status proc) '(stop exit))
6597 (zerop (process-exit-status proc))) 6604 (zerop (process-exit-status proc)))
6598 (tramp-message vec 3 "Process has finished.") 6605 (tramp-message vec 3 "Process has finished.")
@@ -6674,7 +6681,7 @@ for process communication also."
6674 (tramp-message proc 10 "\n%s" (buffer-string)))) 6681 (tramp-message proc 10 "\n%s" (buffer-string))))
6675 6682
6676(defun tramp-check-for-regexp (proc regexp) 6683(defun tramp-check-for-regexp (proc regexp)
6677 "Check whether REGEXP is contained in process buffer of PROC. 6684 "Check, whether REGEXP is contained in process buffer of PROC.
6678Erase echoed commands if exists." 6685Erase echoed commands if exists."
6679 (with-current-buffer (process-buffer proc) 6686 (with-current-buffer (process-buffer proc)
6680 (goto-char (point-min)) 6687 (goto-char (point-min))
@@ -7315,9 +7322,9 @@ connection if a previous connection has died for some reason."
7315 7322
7316 ;; Check whether process is alive. 7323 ;; Check whether process is alive.
7317 (tramp-set-process-query-on-exit-flag p nil) 7324 (tramp-set-process-query-on-exit-flag p nil)
7318 (tramp-message vec 3 "Waiting 60s for local shell to come up...") 7325 (with-progress-reporter vec 3 "Waiting 60s for local shell to come up"
7319 (tramp-barf-if-no-shell-prompt 7326 (tramp-barf-if-no-shell-prompt
7320 p 60 "Couldn't find local shell prompt %s" tramp-encoding-shell) 7327 p 60 "Couldn't find local shell prompt %s" tramp-encoding-shell))
7321 7328
7322 ;; Now do all the connections as specified. 7329 ;; Now do all the connections as specified.
7323 (while target-alist 7330 (while target-alist
@@ -7810,7 +7817,7 @@ Not actually used. Use `(format \"%o\" i)' instead?"
7810;; data structure. 7817;; data structure.
7811 7818
7812(defun tramp-file-name-p (vec) 7819(defun tramp-file-name-p (vec)
7813 "Check whether VEC is a Tramp object." 7820 "Check, whether VEC is a Tramp object."
7814 (and (vectorp vec) (= 4 (length vec)))) 7821 (and (vectorp vec) (= 4 (length vec))))
7815 7822
7816(defun tramp-file-name-method (vec) 7823(defun tramp-file-name-method (vec)
@@ -7941,7 +7948,7 @@ values."
7941 localname)))))) 7948 localname))))))
7942 7949
7943(defun tramp-equal-remote (file1 file2) 7950(defun tramp-equal-remote (file1 file2)
7944 "Checks, whether the remote parts of FILE1 and FILE2 are identical. 7951 "Check, whether the remote parts of FILE1 and FILE2 are identical.
7945The check depends on method, user and host name of the files. If 7952The check depends on method, user and host name of the files. If
7946one of the components is missing, the default values are used. 7953one of the components is missing, the default values are used.
7947The local file name parts of FILE1 and FILE2 are not taken into 7954The local file name parts of FILE1 and FILE2 are not taken into
@@ -8319,7 +8326,7 @@ If the `tramp-methods' entry does not exist, return NIL."
8319;; Auto saving to a special directory. 8326;; Auto saving to a special directory.
8320 8327
8321(defun tramp-exists-file-name-handler (operation &rest args) 8328(defun tramp-exists-file-name-handler (operation &rest args)
8322 "Checks whether OPERATION runs a file name handler." 8329 "Check, whether OPERATION runs a file name handler."
8323 ;; The file name handler is determined on base of either an 8330 ;; The file name handler is determined on base of either an
8324 ;; argument, `buffer-file-name', or `default-directory'. 8331 ;; argument, `buffer-file-name', or `default-directory'.
8325 (condition-case nil 8332 (condition-case nil