aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2008-02-03 12:05:05 +0000
committerMichael Albinus2008-02-03 12:05:05 +0000
commitcfb5c0dbc617754b0ff7c2b68946753707758464 (patch)
tree1dafbed1cf8c44aa101ec73165ba4c98e1b23c42
parent1a0b96d35633d5950fa5af036ef49d272818eceb (diff)
downloademacs-cfb5c0dbc617754b0ff7c2b68946753707758464.tar.gz
emacs-cfb5c0dbc617754b0ff7c2b68946753707758464.zip
* net/tramp.el (tramp-process-sentinel): New defun.
(tramp-do-copy-or-rename-file-out-of-band) (tramp-maybe-open-connection): Use it as process sentinel. (tramp-handle-delete-directory): Don't use the "-f" option; it isn't portable. (tramp-handle-start-file-process): Echo `tramp-end-of-output' after the command. (tramp-handle-shell-command): Set `mode-line-process' in the asynchronous case.
-rw-r--r--lisp/net/tramp.el47
1 files changed, 33 insertions, 14 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 5829635d035..50c79638fd0 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3274,7 +3274,7 @@ be a local filename. The method used must be an out-of-band method."
3274 (append copy-args (list source target)))))) 3274 (append copy-args (list source target))))))
3275 (tramp-message 3275 (tramp-message
3276 v 6 "%s" (mapconcat 'identity (process-command p) " ")) 3276 v 6 "%s" (mapconcat 'identity (process-command p) " "))
3277 (set-process-sentinel p 'tramp-flush-connection-property) 3277 (set-process-sentinel p 'tramp-process-sentinel)
3278 (tramp-set-process-query-on-exit-flag p nil) 3278 (tramp-set-process-query-on-exit-flag p nil)
3279 (tramp-process-actions p v tramp-actions-copy-out-of-band)))) 3279 (tramp-process-actions p v tramp-actions-copy-out-of-band))))
3280 3280
@@ -3315,8 +3315,7 @@ be a local filename. The method used must be an out-of-band method."
3315 (tramp-flush-directory-property v localname) 3315 (tramp-flush-directory-property v localname)
3316 (unless (zerop (tramp-send-command-and-check 3316 (unless (zerop (tramp-send-command-and-check
3317 v 3317 v
3318 (format "rmdir -f %s" 3318 (format "rmdir %s" (tramp-shell-quote-argument localname))))
3319 (tramp-shell-quote-argument localname))))
3320 (tramp-error v 'file-error "Couldn't delete %s" directory)))) 3319 (tramp-error v 'file-error "Couldn't delete %s" directory))))
3321 3320
3322(defun tramp-handle-delete-file (filename) 3321(defun tramp-handle-delete-file (filename)
@@ -3649,9 +3648,10 @@ beginning of local filename are not substituted."
3649 ;; Send the command. 3648 ;; Send the command.
3650 (tramp-send-command 3649 (tramp-send-command
3651 v 3650 v
3652 (format "%s; exit" 3651 (format "%s; echo %s; exit"
3653 (mapconcat 'tramp-shell-quote-argument 3652 (mapconcat 'tramp-shell-quote-argument
3654 (cons program args) " ")) 3653 (cons program args) " ")
3654 (tramp-shell-quote-argument tramp-end-of-output))
3655 nil t) ; nooutput 3655 nil t) ; nooutput
3656 ;; Return process. 3656 ;; Return process.
3657 (tramp-get-connection-process v)) 3657 (tramp-get-connection-process v))
@@ -3804,13 +3804,13 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1."
3804 (with-parsed-tramp-file-name default-directory nil 3804 (with-parsed-tramp-file-name default-directory nil
3805 (list output-buffer (tramp-make-tramp-temp-file v))) 3805 (list output-buffer (tramp-make-tramp-temp-file v)))
3806 output-buffer)) 3806 output-buffer))
3807 (proc (get-buffer-process output-buffer))) 3807 (p (get-buffer-process output-buffer)))
3808 3808
3809 ;; Check whether there is another process running. Tramp does not 3809 ;; Check whether there is another process running. Tramp does not
3810 ;; support 2 (asynchronous) processes in parallel. 3810 ;; support 2 (asynchronous) processes in parallel.
3811 (when proc 3811 (when p
3812 (if (yes-or-no-p "A command is running. Kill it? ") 3812 (if (yes-or-no-p "A command is running. Kill it? ")
3813 (ignore-errors (kill-process proc)) 3813 (ignore-errors (kill-process p))
3814 (error "Shell command in progress"))) 3814 (error "Shell command in progress")))
3815 3815
3816 (with-current-buffer output-buffer 3816 (with-current-buffer output-buffer
@@ -3823,7 +3823,9 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1."
3823 ;; Run the process. 3823 ;; Run the process.
3824 (apply 'start-file-process "*Async Shell*" buffer args) 3824 (apply 'start-file-process "*Async Shell*" buffer args)
3825 ;; Display output. 3825 ;; Display output.
3826 (pop-to-buffer output-buffer)) 3826 (pop-to-buffer output-buffer)
3827 (setq mode-line-process '(":%s"))
3828 (require 'shell) (shell-mode))
3827 3829
3828 (prog1 3830 (prog1
3829 ;; Run the process. 3831 ;; Run the process.
@@ -4190,7 +4192,7 @@ Returns a file name in `tramp-auto-save-directory' for autosaving this file."
4190 ;; conditions are satisfied, it tries to write 4192 ;; conditions are satisfied, it tries to write
4191 ;; to a local file in default-directory, but 4193 ;; to a local file in default-directory, but
4192 ;; at this point, default-directory is remote. 4194 ;; at this point, default-directory is remote.
4193 ;; (CALL-PROCESS-REGION can't write to remote 4195 ;; (`call-process-region' can't write to remote
4194 ;; files, it seems.) The file in question is 4196 ;; files, it seems.) The file in question is
4195 ;; a tmp file anyway. 4197 ;; a tmp file anyway.
4196 (let ((default-directory 4198 (let ((default-directory
@@ -5305,7 +5307,9 @@ variable PATH."
5305 vec (format "PATH=%s; export PATH" 5307 vec (format "PATH=%s; export PATH"
5306 (mapconcat 'identity (tramp-get-remote-path vec) ":")))) 5308 (mapconcat 'identity (tramp-get-remote-path vec) ":"))))
5307 5309
5308;; -- communication with external shell -- 5310;; ------------------------------------------------------------
5311;; -- Communication with external shell --
5312;; ------------------------------------------------------------
5309 5313
5310(defun tramp-find-file-exists-command (vec) 5314(defun tramp-find-file-exists-command (vec)
5311 "Find a command on the remote host for checking if a file exists. 5315 "Find a command on the remote host for checking if a file exists.
@@ -5357,7 +5361,6 @@ file exists and nonzero exit status otherwise."
5357 vec 'file-error "Couldn't find command to check if file exists")) 5361 vec 'file-error "Couldn't find command to check if file exists"))
5358 result)) 5362 result))
5359 5363
5360
5361;; CCC test ksh or bash found for tilde expansion? 5364;; CCC test ksh or bash found for tilde expansion?
5362(defun tramp-find-shell (vec) 5365(defun tramp-find-shell (vec)
5363 "Opens a shell on the remote host which groks tilde expansion." 5366 "Opens a shell on the remote host which groks tilde expansion."
@@ -5644,6 +5647,20 @@ seconds. If not, it produces an error message with the given ERROR-ARGS."
5644 'tramp-password-end-of-line) 5647 'tramp-password-end-of-line)
5645 tramp-default-password-end-of-line)))) 5648 tramp-default-password-end-of-line))))
5646 5649
5650(defun tramp-process-sentinel (proc event)
5651 "Process sentinel for Tramp processes."
5652 (when (memq (process-status proc) '(stop exit signal))
5653 (tramp-flush-connection-property proc)
5654 ;; The "Connection closed" and "exit" messages disturb the output
5655 ;; for asynchronous processes. That's why we have echoed the Tramp
5656 ;; prompt at the end. Trailing messages can be removed.
5657 (with-current-buffer (process-buffer proc)
5658 (goto-char (point-max))
5659 (re-search-backward
5660 (mapconcat 'identity (split-string tramp-end-of-output "\n") "\r?\n")
5661 (line-beginning-position -8) t)
5662 (delete-region (point) (point-max)))))
5663
5647(defun tramp-open-connection-setup-interactive-shell (proc vec) 5664(defun tramp-open-connection-setup-interactive-shell (proc vec)
5648 "Set up an interactive shell. 5665 "Set up an interactive shell.
5649Mainly sets the prompt and the echo correctly. PROC is the shell 5666Mainly sets the prompt and the echo correctly. PROC is the shell
@@ -6176,7 +6193,7 @@ connection if a previous connection has died for some reason."
6176 vec 6 "%s" (mapconcat 'identity (process-command p) " ")) 6193 vec 6 "%s" (mapconcat 'identity (process-command p) " "))
6177 6194
6178 ;; Check whether process is alive. 6195 ;; Check whether process is alive.
6179 (set-process-sentinel p 'tramp-flush-connection-property) 6196 (set-process-sentinel p 'tramp-process-sentinel)
6180 (tramp-set-process-query-on-exit-flag p nil) 6197 (tramp-set-process-query-on-exit-flag p nil)
6181 (tramp-message vec 3 "Waiting 60s for local shell to come up...") 6198 (tramp-message vec 3 "Waiting 60s for local shell to come up...")
6182 (tramp-barf-if-no-shell-prompt 6199 (tramp-barf-if-no-shell-prompt
@@ -7367,7 +7384,9 @@ Only works for Bourne-like shells."
7367;; ** Try to avoid usage of `last-input-event' in `tramp-completion-mode-p'. 7384;; ** Try to avoid usage of `last-input-event' in `tramp-completion-mode-p'.
7368;; ** Unify `tramp-parse-{rhosts,shosts,sconfig,hosts,passwd,netrc}'. 7385;; ** Unify `tramp-parse-{rhosts,shosts,sconfig,hosts,passwd,netrc}'.
7369;; Code is nearly identical. 7386;; Code is nearly identical.
7370;; * Allow out-of-band methods as _last_ multi-hop. 7387;; * Allow out-of-band methods as _last_ multi-hop. Open a connection
7388;; until the last but one hop via `start-file-process'. Apply it
7389;; also for ftp and smb.
7371;; * WIBNI if we had a command "trampclient"? If I was editing in 7390;; * WIBNI if we had a command "trampclient"? If I was editing in
7372;; some shell with root priviledges, it would be nice if I could 7391;; some shell with root priviledges, it would be nice if I could
7373;; just call 7392;; just call