From d62c9a33c4504b7d9dca54e387c48d41ce8b4e52 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Tue, 7 Aug 2007 20:04:27 +0000 Subject: [PATCH] * net/tramp.el (tramp-handle-file-remote-p): Handle optional parameters IDENTIFICATION and CONNECTED. (tramp-handle-insert-file-contents): VISIT must be handled after insertion of the local copy. Reported by Peter Gordon . (tramp-file-name-handler): No special handling for `expand-file-name'. But for `file-name-as-directory'. (tramp-find-shell, tramp-open-connection-telnet) (tramp-open-connection-rsh, tramp-open-connection-su) (tramp-open-connection-multi) (tramp-open-connection-setup-interactive-shell): Guard against $PROMPT_COMMAND shell var. Reported by Steve Youngs . (tramp-append-tramp-buffers): Replace "sensible" by "sensitive" in the hint. * net/trampver.el: Update release number. --- lisp/ChangeLog | 20 ++++++++++++++++ lisp/net/tramp.el | 54 ++++++++++++++++++++++++++++---------------- lisp/net/trampver.el | 2 +- 3 files changed, 56 insertions(+), 20 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8d25f687b2b..381092c8e60 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,23 @@ +2007-08-07 Michael Albinus + + * net/tramp.el (tramp-handle-file-remote-p): Handle optional + parameters IDENTIFICATION and CONNECTED. + (tramp-handle-insert-file-contents): VISIT must be handled after + insertion of the local copy. Reported by Peter Gordon + . + (tramp-file-name-handler): No special handling for + `expand-file-name'. But for `file-name-as-directory'. + (tramp-find-shell, tramp-open-connection-telnet) + (tramp-open-connection-rsh, tramp-open-connection-su) + (tramp-open-connection-multi) + (tramp-open-connection-setup-interactive-shell): Guard against + $PROMPT_COMMAND shell var. Reported by Steve Youngs + . + (tramp-append-tramp-buffers): Replace "sensible" by "sensitive" in + the hint. + + * net/trampver.el: Update release number. + 2007-08-07 Tom Tromey * progmodes/tcl.el (tcl-indent-level, tcl-continued-indent-level): diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 9f665ca4707..09167d674eb 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -3868,11 +3868,20 @@ This will break if COMMAND prints a newline, followed by the value of (t (error "Wrong method specification for `%s'" method))) tmpfil))) -(defun tramp-handle-file-remote-p (filename) - "Like `file-remote-p' for tramp files." +(defun tramp-handle-file-remote-p (filename &optional identification connected) + "Like `file-remote-p' for Tramp files." (when (tramp-tramp-file-p filename) (with-parsed-tramp-file-name filename nil - (tramp-make-tramp-file-name multi-method method user host "")))) + (and (or (not connected) + (let ((p (get-buffer-process + (tramp-get-buffer multi-method method user host)))) + (and p (processp p) (memq (process-status p) '(run open))))) + (cond + ((eq identification 'method) method) + ((eq identification 'user) user) + ((eq identification 'host) host) + (t (tramp-make-tramp-file-name + multi-method method user host ""))))))) (defun tramp-handle-insert-file-contents (filename &optional visit beg end replace) @@ -3899,14 +3908,14 @@ This will break if COMMAND prints a newline, followed by the value of 'file-local-copy))) (file-local-copy filename))) coding-system-used result) - (when visit - (setq buffer-file-name filename) - (set-visited-file-modtime) - (set-buffer-modified-p nil)) (tramp-message-for-buffer multi-method method user host 9 "Inserting local temp file `%s'..." local-copy) (setq result (insert-file-contents local-copy nil beg end replace)) + (when visit + (setq buffer-file-name filename) + (set-visited-file-modtime) + (set-buffer-modified-p nil)) ;; Now `last-coding-system-used' has right value. Remember it. (when (boundp 'last-coding-system-used) (setq coding-system-used (symbol-value 'last-coding-system-used))) @@ -4354,11 +4363,12 @@ Falls back to normal file name handler if no tramp file name handler exists." (cond ;; When we are in completion mode, some operations shouldn' be ;; handled by backend. - ((and completion (memq operation '(expand-file-name))) - (tramp-run-real-handler operation args)) ((and completion (zerop (length localname)) (memq operation '(file-exists-p file-directory-p))) t) + ((and completion (zerop (length localname)) + (memq operation '(file-name-as-directory))) + filename) ;; Call the backend function. (foreign (apply foreign operation args)) ;; Nothing to do for us. @@ -5351,7 +5361,7 @@ file exists and nonzero exit status otherwise." 5 "Starting remote shell `%s' for tilde expansion..." shell) (tramp-send-command multi-method method user host - (concat "PS1='$ ' exec " shell)) ; + (concat "PROMPT_COMMAND='' PS1='$ ' exec " shell)) ; (tramp-barf-if-no-shell-prompt (get-buffer-process (current-buffer)) 60 "Couldn't find remote `%s' prompt" shell) @@ -5361,11 +5371,12 @@ file exists and nonzero exit status otherwise." ;; must use "\n" here, not tramp-rsh-end-of-line. Kai left the ;; last tramp-rsh-end-of-line, Douglas wanted to replace that, ;; as well. - (process-send-string nil (format "PS1='%s%s%s'; PS2=''; PS3=''%s" - tramp-rsh-end-of-line - tramp-end-of-output - tramp-rsh-end-of-line - tramp-rsh-end-of-line)) + (process-send-string + nil (format "PROMPT_COMMAND=''; PS1='%s%s%s'; PS2=''; PS3=''%s" + tramp-rsh-end-of-line + tramp-end-of-output + tramp-rsh-end-of-line + tramp-rsh-end-of-line)) (tramp-wait-for-output) (tramp-message 9 "Setting remote shell prompt...done") @@ -5690,6 +5701,7 @@ Maybe the different regular expressions need to be tuned. (or user (user-login-name)) host method) (let ((process-environment (copy-sequence process-environment))) (setenv "TERM" tramp-terminal-type) + (setenv "PROMPT_COMMAND") (setenv "PS1" "$ ") (let* ((default-directory (tramp-temporary-file-directory)) ;; If we omit the conditional here, then we would use @@ -5771,6 +5783,7 @@ arguments, and xx will be used as the host name to connect to. (setq login-args (cons "-p" (cons (match-string 2 host) login-args))) (setq real-host (match-string 1 host))) (setenv "TERM" tramp-terminal-type) + (setenv "PROMPT_COMMAND") (setenv "PS1" "$ ") (let* ((default-directory (tramp-temporary-file-directory)) ;; If we omit the conditional, we would use @@ -5823,6 +5836,7 @@ prompt than you do, so it is not at all unlikely that the variable (or user "") method) (let ((process-environment (copy-sequence process-environment))) (setenv "TERM" tramp-terminal-type) + (setenv "PROMPT_COMMAND") (setenv "PS1" "$ ") (let* ((default-directory (tramp-temporary-file-directory)) ;; If we omit the conditional, we use `undecided-dos' in @@ -5888,6 +5902,7 @@ log in as u2 to h2." (tramp-message 7 "Opening `%s' connection..." multi-method) (let ((process-environment (copy-sequence process-environment))) (setenv "TERM" tramp-terminal-type) + (setenv "PROMPT_COMMAND") (setenv "PS1" "$ ") (let* ((default-directory (tramp-temporary-file-directory)) ;; If we omit the conditional, we use `undecided-dos' in @@ -6127,10 +6142,11 @@ to set up. METHOD, USER and HOST specify the connection." ;; makes it work under `rc', too. We also unset the variable $ENV ;; because that is read by some sh implementations (eg, bash when ;; called as sh) on startup; this way, we avoid the startup file - ;; clobbering $PS1. + ;; clobbering $PS1. $PROMP_COMMAND is another way to set the prompt + ;; in /bin/bash, it must be discarded as well. (tramp-send-command-internal multi-method method user host - (format "exec env 'ENV=' 'PS1=$ ' %s" + (format "exec env 'ENV=' 'PROMPT_COMMAND=' 'PS1=$ ' %s" (tramp-get-method-parameter multi-method method user host 'tramp-remote-sh)) (format "remote `%s' to come up" @@ -6227,7 +6243,7 @@ to set up. METHOD, USER and HOST specify the connection." (setq tramp-last-cmd-time (current-time)) (tramp-send-command multi-method method user host - (format "PS1='%s%s%s'; PS2=''; PS3=''" + (format "PROMPT_COMMAND=''; PS1='%s%s%s'; PS2=''; PS3=''" tramp-rsh-end-of-line tramp-end-of-output tramp-rsh-end-of-line)) @@ -7713,7 +7729,7 @@ Used for non-7bit chars in strings." (kill-region start (point))))) (insert " The buffer(s) above will be appended to this message. If you don't want -to append a buffer because it contains sensible data, or because the buffer +to append a buffer because it contains sensitive data, or because the buffer is too large, you should delete the respective buffer. The buffer(s) will contain user and host names. Passwords will never be included there.") diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el index d265fa5393b..5734b5c9138 100644 --- a/lisp/net/trampver.el +++ b/lisp/net/trampver.el @@ -30,7 +30,7 @@ ;; are auto-frobbed from configure.ac, so you should edit that file and run ;; "autoconf && ./configure" to change them. -(defconst tramp-version "2.0.56" +(defconst tramp-version "2.0.57-pre" "This version of Tramp.") (defconst tramp-bug-report-address "tramp-devel@gnu.org" -- 2.39.2