[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lisp/net/tramp.el,v
From: |
Michael Albinus |
Subject: |
[Emacs-diffs] Changes to emacs/lisp/net/tramp.el,v |
Date: |
Tue, 17 Jul 2007 21:10:09 +0000 |
CVSROOT: /cvsroot/emacs
Module name: emacs
Changes by: Michael Albinus <albinus> 07/07/17 21:10:08
Index: net/tramp.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/net/tramp.el,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -b -r1.126 -r1.127
--- net/tramp.el 8 Jul 2007 18:03:19 -0000 1.126
+++ net/tramp.el 17 Jul 2007 21:10:07 -0000 1.127
@@ -571,7 +571,8 @@
("plinkx"
(tramp-login-program "plink")
(tramp-login-args (("-load" "%h") ("-t")
- (,(format "env 'TERM=%s' 'PS1=$ '"
+ (,(format
+ "env 'TERM=%s' 'PROMPT_COMMAND='
'PS1=$ '"
tramp-terminal-type))
("/bin/sh")))
(tramp-remote-sh "/bin/sh")
@@ -1772,6 +1773,7 @@
(copy-file . tramp-handle-copy-file)
(rename-file . tramp-handle-rename-file)
(set-file-modes . tramp-handle-set-file-modes)
+ (set-file-times . tramp-handle-set-file-times)
(make-directory . tramp-handle-make-directory)
(delete-directory . tramp-handle-delete-directory)
(delete-file . tramp-handle-delete-file)
@@ -2493,6 +2495,40 @@
(tramp-error
v 'file-error "Error while changing file's mode %s" filename))))
+(defun tramp-handle-set-file-times (filename &optional time)
+ "Like `set-file-times' for Tramp files."
+ (zerop
+ (if (file-remote-p filename)
+ (with-parsed-tramp-file-name filename nil
+ (let ((time (if (or (null time) (equal time '(0 0)))
+ (current-time)
+ time))
+ (utc
+ ;; With GNU Emacs, `format-time-string' has an
+ ;; optional parameter UNIVERSAL. This is preferred,
+ ;; because we could handle the case when the remote
+ ;; host is located in a different time zone as the
+ ;; local host.
+ (and (functionp 'subr-arity)
+ (subrp (symbol-function 'format-time-string))
+ (= 3 (cdr (funcall (symbol-function 'subr-arity)
+ (symbol-function
+ 'format-time-string)))))))
+ (tramp-send-command-and-check
+ v (format "%s touch -t %s %s"
+ (if utc "TZ=UTC; export TZ;" "")
+ (if utc
+ (format-time-string "%Y%m%d%H%M.%S" time t)
+ (format-time-string "%Y%m%d%H%M.%S" time))
+ (tramp-shell-quote-argument localname)))))
+ ;; We handle also the local part, because in older Emacsen,
+ ;; without `set-file-times', this function is an alias for this.
+ ;; We are local, so we don't need the UTC settings.
+ (call-process
+ "touch" nil nil nil "-t"
+ (format-time-string "%Y%m%d%H%M.%S" time)
+ (tramp-shell-quote-argument filename)))))
+
;; Simple functions using the `test' command.
(defun tramp-handle-file-executable-p (filename)
@@ -2926,10 +2962,8 @@
(jka-compr-inhibit t))
(write-region (point-min) (point-max) newname))))
;; KEEP-DATE handling.
- (when keep-date
- (when (and (not (null modtime))
- (not (equal modtime '(0 0))))
- (tramp-touch newname modtime)))
+ (when (and keep-date (functionp 'set-file-times))
+ (apply 'set-file-times (list newname modtime)))
;; Set the mode.
(set-file-modes newname (file-modes filename))
;; If the operation was `rename', delete the original file.
@@ -3078,8 +3112,9 @@
(tramp-message v 0 "Transferring %s to %s...done" filename newname)
;; Handle KEEP-DATE argument.
- (when (and keep-date (not copy-keep-date))
- (set-file-times newname (nth 5 (file-attributes filename))))
+ (when (and keep-date (not copy-keep-date) (functionp 'set-file-times))
+ (apply 'set-file-times
+ (list newname (nth 5 (file-attributes filename)))))
;; Set the mode.
(unless (and keep-date copy-keep-date)
@@ -3282,8 +3317,7 @@
;; CCC is this the right thing to do?
(defun tramp-handle-unhandled-file-name-directory (filename)
"Like `unhandled-file-name-directory' for Tramp files."
- (with-parsed-tramp-file-name filename nil
- (expand-file-name (tramp-make-tramp-file-name method user host "~/"))))
+ (expand-file-name "~/"))
;; Canonicalization of file names.
@@ -3446,9 +3480,8 @@
(tramp-set-connection-property v "process-name" name)
(tramp-set-connection-property
v "process-buffer"
- (get-buffer-create
;; BUFFER can be nil.
- (or buffer (generate-new-buffer-name (tramp-buffer-name v)))))
+ (get-buffer-create (or buffer (current-buffer))))
;; Activate narrowing in order to save BUFFER contents.
(with-current-buffer (tramp-get-connection-buffer v)
(narrow-to-region (point-max) (point-max)))
@@ -3466,7 +3499,9 @@
;; Return process.
(tramp-get-connection-process v))
;; Save exit.
- (with-current-buffer (tramp-get-connection-buffer v) (widen))
+ (with-current-buffer (tramp-get-connection-buffer v)
+ (widen)
+ (goto-char (point-max)))
(tramp-set-connection-property v "process-name" nil)
(tramp-set-connection-property v "process-buffer" nil))))
@@ -3575,12 +3610,33 @@
(defun tramp-handle-shell-command
(command &optional output-buffer error-buffer)
"Like `shell-command' for Tramp files."
+ (let* ((asynchronous (string-match "[ \t]*&[ \t]*\\'" command))
+ (args (split-string (substring command 0 asynchronous) " "))
+ (output-buffer
+ (or output-buffer
+ (if asynchronous
+ "*Async Shell Command*"
+ "*Shell Command Output*")))
+ (buffer
+ (if (and (not asynchronous) (bufferp error-buffer))
(with-parsed-tramp-file-name default-directory nil
- (let ((shell-file-name
- (tramp-get-connection-property v "remote-shell" "/bin/sh"))
- (shell-command-switch "-c"))
- (tramp-run-real-handler
- 'shell-command (list command output-buffer error-buffer)))))
+ (list output-buffer (tramp-make-tramp-temp-file v)))
+ output-buffer)))
+
+ (prog1
+ ;; Run the process. We cannot use `process-file' and
+ ;; `start-file-process', because these functions might not
+ ;; exist in older Emacsen.
+ (if (integerp asynchronous)
+ (apply 'tramp-handle-start-file-process
+ "*Async Shell*" buffer args)
+ (apply 'tramp-handle-process-file
+ (car args) nil buffer nil (cdr args)))
+ ;; Insert error messages if they were separated.
+ (when (listp buffer)
+ (with-current-buffer error-buffer
+ (insert-file-contents (cadr buffer)))
+ (delete-file (cadr buffer))))))
;; File Editing.
@@ -3657,14 +3713,18 @@
(run-hooks 'tramp-handle-file-local-copy-hook)
tmpfil)))
-(defun tramp-handle-file-remote-p (filename &optional connected)
+(defun tramp-handle-file-remote-p (file &optional identification connected)
"Like `file-remote-p' for Tramp files."
(when (tramp-tramp-file-p filename)
(with-parsed-tramp-file-name filename nil
(and (or (not connected)
(let ((p (tramp-get-connection-process v)))
(and p (processp p) (memq (process-status p) '(run open)))))
- (tramp-make-tramp-file-name method user host "")))))
+ (cond
+ ((eq identification 'method) method)
+ ((eq identification 'user) user)
+ ((eq identification 'host) host)
+ (t (tramp-make-tramp-file-name method user host "")))))))
(defun tramp-handle-insert-file-contents
(filename &optional visit beg end replace)
@@ -4025,6 +4085,8 @@
'load 'make-directory 'make-directory-internal
'set-file-modes 'substitute-in-file-name
'unhandled-file-name-directory 'vc-registered
+ ; Emacs 22 only
+ 'set-file-times
; XEmacs only
'abbreviate-file-name 'create-file-buffer
'dired-file-modtime 'dired-make-compressed-filename
@@ -4886,40 +4948,6 @@
(tramp-shell-quote-argument v1-localname)
(tramp-shell-quote-argument v2-localname))))))
-(defun tramp-touch (file time)
- "Set the last-modified timestamp of the given file.
-TIME is an Emacs internal time value as returned by `current-time'."
- (let* ((utc
- ;; With GNU Emacs, `format-time-string' has an optional
- ;; parameter UNIVERSAL. This is preferred.
- (and (functionp 'subr-arity)
- (subrp (symbol-function 'format-time-string))
- (= 3 (cdr (funcall (symbol-function 'subr-arity)
- (symbol-function 'format-time-string))))))
- (touch-time
- (if utc
- (format-time-string "%Y%m%d%H%M.%S" time t)
- (format-time-string "%Y%m%d%H%M.%S" time)))
- (default-directory (file-name-directory file)))
-
- (if (eq (tramp-find-foreign-file-name-handler file)
- 'tramp-sh-file-name-handler)
- (with-parsed-tramp-file-name file nil
- (tramp-send-command
- v (format "%s touch -t %s %s"
- (if utc "TZ=UTC; export TZ;" "")
- touch-time
- (tramp-shell-quote-argument localname))))
- (with-temp-buffer
- (shell-command
- (format "%s touch -t %s %s"
- (if utc "TZ=UTC; export TZ;" "")
- touch-time
- (tramp-shell-quote-argument
- (if (tramp-tramp-file-p file)
- (with-parsed-tramp-file-name file nil localname) file)))
- (current-buffer))))))
-
(defun tramp-buffer-name (vec)
"A name for the connection buffer VEC."
;; We must use `tramp-file-name-real-host', because for gateway
@@ -5179,7 +5207,8 @@
(when extra-args (setq shell (concat shell " " extra-args))))
(tramp-message
vec 5 "Starting remote shell `%s' for tilde expansion..." shell)
- (tramp-send-command-internal vec (concat "PS1='$ ' exec " shell))
+ (tramp-send-command-internal
+ vec (concat "PROMPT_COMMAND='' PS1='$ ' exec " shell))
(tramp-message vec 5 "Setting remote shell prompt...")
;; Douglas Gray Stephens <address@hidden> says that we
;; must use "\n" here, not tramp-rsh-end-of-line. Kai left the
@@ -5187,7 +5216,7 @@
;; as well.
(tramp-send-command
vec
- (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))
@@ -5455,10 +5484,11 @@
;; 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
vec
- (format "exec env 'ENV=' 'PS1=$ ' %s"
+ (format "exec env 'ENV=' 'PROMPT_COMMAND=' 'PS1=$ ' %s"
(tramp-get-method-parameter
(tramp-file-name-method vec) 'tramp-remote-sh)))
(tramp-message vec 5 "Setting up remote shell environment")
@@ -5512,7 +5542,7 @@
;; send "echo are you awake".
(tramp-send-command
vec
- (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))
@@ -5893,6 +5923,7 @@
(when (and p (processp p))
(delete-process p))
(setenv "TERM" tramp-terminal-type)
+ (setenv "PROMPT_COMMAND")
(setenv "PS1" "$ ")
(let* ((target-alist (tramp-compute-multi-hops vec))
(process-environment (copy-sequence process-environment))
@@ -6243,17 +6274,24 @@
;; Convert inode.
(unless (listp (nth 10 attr))
(setcar (nthcdr 10 attr)
+ (condition-case nil
(list (floor (nth 10 attr) 65536)
- (floor (mod (nth 10 attr) 65536)))))
+ (floor (mod (nth 10 attr) 65536)))
+ ;; Inodes can be incredible huge. We must hide this.
+ (error (tramp-get-inode vec)))))
;; Set virtual device number.
(setcar (nthcdr 11 attr)
(tramp-get-device vec))
attr)
-(defun tramp-get-inode (file)
+(defun tramp-get-inode (vec)
"Returns the virtual inode number.
If it doesn't exist, generate a new one."
- (let ((string (directory-file-name file)))
+ (let ((string (tramp-make-tramp-file-name
+ (tramp-file-name-method vec)
+ (tramp-file-name-user vec)
+ (tramp-file-name-host vec)
+ "")))
(unless (assoc string tramp-inodes)
(add-to-list 'tramp-inodes
(list string (length tramp-inodes))))
- [Emacs-diffs] Changes to emacs/lisp/net/tramp.el,v, Michael Albinus, 2007/07/08
- [Emacs-diffs] Changes to emacs/lisp/net/tramp.el,v,
Michael Albinus <=
- [Emacs-diffs] Changes to emacs/lisp/net/tramp.el,v, Michael Albinus, 2007/07/22
- [Emacs-diffs] Changes to emacs/lisp/net/tramp.el,v, Michael Albinus, 2007/07/23
- [Emacs-diffs] Changes to emacs/lisp/net/tramp.el,v, Miles Bader, 2007/07/26
- [Emacs-diffs] Changes to emacs/lisp/net/tramp.el,v, Michael Albinus, 2007/07/29