diff options
| author | Michael Albinus | 2007-07-17 21:10:07 +0000 |
|---|---|---|
| committer | Michael Albinus | 2007-07-17 21:10:07 +0000 |
| commit | ce3f516fed03961e3da793f35b93fe6e9f5c0e0d (patch) | |
| tree | b12b244b3f25f91c35cc8e29a8b1bd80f3fc86e6 | |
| parent | 3bd84a2269913f7f5ee41c779a610b22d58c2d01 (diff) | |
| download | emacs-ce3f516fed03961e3da793f35b93fe6e9f5c0e0d.tar.gz emacs-ce3f516fed03961e3da793f35b93fe6e9f5c0e0d.zip | |
* net/tramp.el (tramp-handle-file-remote-p): Handle optional
parameter IDENTIFICATION.
(tramp-handle-set-file-times): New defun. Replaces `tramp-touch'.
(tramp-file-name-handler-alist, tramp-file-name-for-operation):
Add entry for `set-file-times'.
(tramp-do-copy-or-rename-file-via-buffer)
(tramp-do-copy-or-rename-file-out-of-band): Use `set-file-times'.
(tramp-handle-unhandled-file-name-directory): Rewrite.
(tramp-convert-file-attributes): Add error handling when inode is
extraordinary big.
(tramp-get-inode): Change parameter from FILE to VEC.
(tramp-handle-start-file-process ): Use (current-buffer) if BUFFER
is NIL. This is according to the specification. Goto (point-max)
when ready.
(tramp-handle-shell-command): Rewrite completely, using
`process-file' and `start-file-process'.
(tramp-methods, tramp-find-shell)
(tramp-open-connection-setup-interactive-shell)
(tramp-maybe-open-connection): Guard against $PROMPT_COMMAND shell
var. Reported by Steve Youngs <steve@sxemacs.org>.
* net/tramp-fish.el (tramp-fish-file-name-handler-alist): Add
entry for `set-file-times'. Rename `start-process' into
`start-file-process'. Remove `call-process' entry.
(tramp-fish-handle-set-file-times): New defun.
(tramp-fish-handle-executable-find): Use `process-file'.
(tramp-fish-handle-process-file): New defun. Replaces
`tramp-fish-handle-call-process'.
(tramp-fish-do-copy-or-rename-file-directly): Use
`set-file-times'.
(tramp-fish-get-file-entries): Change `tramp-get-inode' parameter.
* net/tramp-smb.el (tramp-smb-handle-file-attributes): Change
`tramp-get-inode' parameter.
| -rw-r--r-- | lisp/ChangeLog | 49 | ||||
| -rw-r--r-- | lisp/net/tramp-fish.el | 33 | ||||
| -rw-r--r-- | lisp/net/tramp-smb.el | 2 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 168 |
4 files changed, 173 insertions, 79 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 844aa761019..be77e72e924 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,52 @@ | |||
| 1 | 2007-07-17 Michael Albinus <michael.albinus@gmx.de> | ||
| 2 | |||
| 3 | * files.el (file-remote-p): Introduce optional parameter | ||
| 4 | IDENTIFICATION. | ||
| 5 | |||
| 6 | * recentf.el (recentf-keep-default-predicate): Adapt call of | ||
| 7 | `file-remote-p'. | ||
| 8 | |||
| 9 | * progmodes/grep.el (grep-probe): Use `process-file'. | ||
| 10 | (grep-compute-defaults): Handle variables host specific. | ||
| 11 | |||
| 12 | * net/ange-ftp.el: (ange-ftp-file-remote-p): Handle optional | ||
| 13 | parameter IDENTIFICATION. | ||
| 14 | |||
| 15 | * net/tramp.el (tramp-handle-file-remote-p): Handle optional | ||
| 16 | parameter IDENTIFICATION. | ||
| 17 | (tramp-handle-set-file-times): New defun. Replaces `tramp-touch'. | ||
| 18 | (tramp-file-name-handler-alist, tramp-file-name-for-operation): | ||
| 19 | Add entry for `set-file-times'. | ||
| 20 | (tramp-do-copy-or-rename-file-via-buffer) | ||
| 21 | (tramp-do-copy-or-rename-file-out-of-band): Use `set-file-times'. | ||
| 22 | (tramp-handle-unhandled-file-name-directory): Rewrite. | ||
| 23 | (tramp-convert-file-attributes): Add error handling when inode is | ||
| 24 | extraordinary big. | ||
| 25 | (tramp-get-inode): Change parameter from FILE to VEC. | ||
| 26 | (tramp-handle-start-file-process ): Use (current-buffer) if BUFFER | ||
| 27 | is NIL. This is according to the specification. Goto (point-max) | ||
| 28 | when ready. | ||
| 29 | (tramp-handle-shell-command): Rewrite completely, using | ||
| 30 | `process-file' and `start-file-process'. | ||
| 31 | (tramp-methods, tramp-find-shell) | ||
| 32 | (tramp-open-connection-setup-interactive-shell) | ||
| 33 | (tramp-maybe-open-connection): Guard against $PROMPT_COMMAND shell | ||
| 34 | var. Reported by Steve Youngs <steve@sxemacs.org>. | ||
| 35 | |||
| 36 | * net/tramp-fish.el (tramp-fish-file-name-handler-alist): Add | ||
| 37 | entry for `set-file-times'. Rename `start-process' into | ||
| 38 | `start-file-process'. Remove `call-process' entry. | ||
| 39 | (tramp-fish-handle-set-file-times): New defun. | ||
| 40 | (tramp-fish-handle-executable-find): Use `process-file'. | ||
| 41 | (tramp-fish-handle-process-file): New defun. Replaces | ||
| 42 | `tramp-fish-handle-call-process'. | ||
| 43 | (tramp-fish-do-copy-or-rename-file-directly): Use | ||
| 44 | `set-file-times'. | ||
| 45 | (tramp-fish-get-file-entries): Change `tramp-get-inode' parameter. | ||
| 46 | |||
| 47 | * net/tramp-smb.el (tramp-smb-handle-file-attributes): Change | ||
| 48 | `tramp-get-inode' parameter. | ||
| 49 | |||
| 1 | 2007-07-17 Stefan Monnier <monnier@iro.umontreal.ca> | 50 | 2007-07-17 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 51 | ||
| 3 | * vc-bzr.el (vc-bzr-version, vc-bzr-at-least-version) | 52 | * vc-bzr.el (vc-bzr-version, vc-bzr-at-least-version) |
diff --git a/lisp/net/tramp-fish.el b/lisp/net/tramp-fish.el index e370c54f902..8c650b550e9 100644 --- a/lisp/net/tramp-fish.el +++ b/lisp/net/tramp-fish.el | |||
| @@ -263,6 +263,7 @@ Used instead of analyzing error codes of commands.") | |||
| 263 | (make-symbolic-link . tramp-fish-handle-make-symbolic-link) | 263 | (make-symbolic-link . tramp-fish-handle-make-symbolic-link) |
| 264 | (rename-file . tramp-fish-handle-rename-file) | 264 | (rename-file . tramp-fish-handle-rename-file) |
| 265 | (set-file-modes . tramp-fish-handle-set-file-modes) | 265 | (set-file-modes . tramp-fish-handle-set-file-modes) |
| 266 | (set-file-times . tramp-fish-handle-set-file-times) | ||
| 266 | (set-visited-file-modtime . ignore) | 267 | (set-visited-file-modtime . ignore) |
| 267 | (shell-command . tramp-handle-shell-command) | 268 | (shell-command . tramp-handle-shell-command) |
| 268 | (substitute-in-file-name . tramp-handle-substitute-in-file-name) | 269 | (substitute-in-file-name . tramp-handle-substitute-in-file-name) |
| @@ -271,9 +272,8 @@ Used instead of analyzing error codes of commands.") | |||
| 271 | (verify-visited-file-modtime . ignore) | 272 | (verify-visited-file-modtime . ignore) |
| 272 | (write-region . tramp-fish-handle-write-region) | 273 | (write-region . tramp-fish-handle-write-region) |
| 273 | (executable-find . tramp-fish-handle-executable-find) | 274 | (executable-find . tramp-fish-handle-executable-find) |
| 274 | (start-process . ignore) | 275 | (start-file-process . ignore) |
| 275 | (call-process . tramp-fish-handle-call-process) | 276 | (process-file . tramp-fish-handle-process-file) |
| 276 | (process-file . tramp-handle-process-file) | ||
| 277 | ) | 277 | ) |
| 278 | "Alist of handler functions for Tramp FISH method. | 278 | "Alist of handler functions for Tramp FISH method. |
| 279 | Operations not mentioned here will be handled by the default Emacs primitives.") | 279 | Operations not mentioned here will be handled by the default Emacs primitives.") |
| @@ -698,6 +698,15 @@ target of the symlink differ." | |||
| 698 | (tramp-error | 698 | (tramp-error |
| 699 | v 'file-error "Error while changing file's mode %s" filename)))) | 699 | v 'file-error "Error while changing file's mode %s" filename)))) |
| 700 | 700 | ||
| 701 | (defun tramp-fish-handle-set-file-times (filename &optional time) | ||
| 702 | "Like `set-file-times' for Tramp files." | ||
| 703 | (with-parsed-tramp-file-name filename nil | ||
| 704 | (let ((time (if (or (null time) (equal time '(0 0))) (current-time) time))) | ||
| 705 | (zerop (process-file | ||
| 706 | "touch" nil nil nil "-t" | ||
| 707 | (format-time-string "%Y%m%d%H%M.%S" time) | ||
| 708 | (tramp-shell-quote-argument localname)))))) | ||
| 709 | |||
| 701 | (defun tramp-fish-handle-write-region | 710 | (defun tramp-fish-handle-write-region |
| 702 | (start end filename &optional append visit lockname confirm) | 711 | (start end filename &optional append visit lockname confirm) |
| 703 | "Like `write-region' for Tramp files." | 712 | "Like `write-region' for Tramp files." |
| @@ -731,14 +740,14 @@ target of the symlink differ." | |||
| 731 | (defun tramp-fish-handle-executable-find (command) | 740 | (defun tramp-fish-handle-executable-find (command) |
| 732 | "Like `executable-find' for Tramp files." | 741 | "Like `executable-find' for Tramp files." |
| 733 | (with-temp-buffer | 742 | (with-temp-buffer |
| 734 | (if (zerop (call-process "which" nil t nil command)) | 743 | (if (zerop (process-file "which" nil t nil command)) |
| 735 | (progn | 744 | (progn |
| 736 | (goto-char (point-min)) | 745 | (goto-char (point-min)) |
| 737 | (buffer-substring (point-min) (tramp-line-end-position)))))) | 746 | (buffer-substring (point-min) (tramp-line-end-position)))))) |
| 738 | 747 | ||
| 739 | (defun tramp-fish-handle-call-process | 748 | (defun tramp-fish-handle-process-file |
| 740 | (program &optional infile destination display &rest args) | 749 | (program &optional infile destination display &rest args) |
| 741 | "Like `call-process' for Tramp files." | 750 | "Like `process-file' for Tramp files." |
| 742 | ;; The implementation is not complete yet. | 751 | ;; The implementation is not complete yet. |
| 743 | (when (and (numberp destination) (zerop destination)) | 752 | (when (and (numberp destination) (zerop destination)) |
| 744 | (error "Implementation does not handle immediate return")) | 753 | (error "Implementation does not handle immediate return")) |
| @@ -926,11 +935,8 @@ KEEP-DATE is non-nil, preserve the time stamp when copying." | |||
| 926 | (tramp-shell-quote-argument v1-localname) | 935 | (tramp-shell-quote-argument v1-localname) |
| 927 | (tramp-shell-quote-argument v2-localname))))) | 936 | (tramp-shell-quote-argument v2-localname))))) |
| 928 | ;; KEEP-DATE handling. | 937 | ;; KEEP-DATE handling. |
| 929 | (when keep-date | 938 | (when (and keep-date (functionp 'set-file-times)) |
| 930 | (let ((modtime (nth 5 (file-attributes filename)))) | 939 | (apply 'set-file-times (list newname (nth 5 (file-attributes filename))))) |
| 931 | (when (and (not (null modtime)) | ||
| 932 | (not (equal modtime '(0 0)))) | ||
| 933 | (tramp-touch newname modtime)))) | ||
| 934 | ;; Set the mode. | 940 | ;; Set the mode. |
| 935 | (set-file-modes newname (file-modes filename))) | 941 | (set-file-modes newname (file-modes filename))) |
| 936 | 942 | ||
| @@ -942,7 +948,8 @@ Result is a list of (LOCALNAME LINK COUNT UID GID ATIME MTIME CTIME | |||
| 942 | SIZE MODE WEIRD INODE DEVICE)." | 948 | SIZE MODE WEIRD INODE DEVICE)." |
| 943 | (block nil | 949 | (block nil |
| 944 | (with-current-buffer (tramp-get-buffer vec) | 950 | (with-current-buffer (tramp-get-buffer vec) |
| 945 | ;; #LIST does not work properly with trailing "/", at least in .fishsrv.pl | 951 | ;; #LIST does not work properly with trailing "/", at least in |
| 952 | ;; .fishsrv.pl. | ||
| 946 | (when (string-match "/$" localname) | 953 | (when (string-match "/$" localname) |
| 947 | (setq localname (concat localname "."))) | 954 | (setq localname (concat localname "."))) |
| 948 | 955 | ||
| @@ -974,7 +981,7 @@ SIZE MODE WEIRD INODE DEVICE)." | |||
| 974 | ;; Add inode and device. | 981 | ;; Add inode and device. |
| 975 | (add-to-list | 982 | (add-to-list |
| 976 | 'res (append item | 983 | 'res (append item |
| 977 | (list (tramp-get-inode (car item)) | 984 | (list (tramp-get-inode vec) |
| 978 | (tramp-get-device vec)))))) | 985 | (tramp-get-device vec)))))) |
| 979 | 986 | ||
| 980 | ;; Read return code | 987 | ;; Read return code |
diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index 981073f7126..c8ea9932f96 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el | |||
| @@ -346,7 +346,7 @@ KEEP-DATE is not handled in case NEWNAME resides on an SMB server." | |||
| 346 | (assoc (file-name-nondirectory filename) entries))) | 346 | (assoc (file-name-nondirectory filename) entries))) |
| 347 | (uid (if (and id-format (equal id-format 'string)) "nobody" -1)) | 347 | (uid (if (and id-format (equal id-format 'string)) "nobody" -1)) |
| 348 | (gid (if (and id-format (equal id-format 'string)) "nogroup" -1)) | 348 | (gid (if (and id-format (equal id-format 'string)) "nogroup" -1)) |
| 349 | (inode (tramp-get-inode filename)) | 349 | (inode (tramp-get-inode v)) |
| 350 | (device (tramp-get-device v))) | 350 | (device (tramp-get-device v))) |
| 351 | 351 | ||
| 352 | ;; Check result. | 352 | ;; Check result. |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 021d3db6fac..792233925fc 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -571,8 +571,9 @@ files conditionalize this setup based on the TERM environment variable." | |||
| 571 | ("plinkx" | 571 | ("plinkx" |
| 572 | (tramp-login-program "plink") | 572 | (tramp-login-program "plink") |
| 573 | (tramp-login-args (("-load" "%h") ("-t") | 573 | (tramp-login-args (("-load" "%h") ("-t") |
| 574 | (,(format "env 'TERM=%s' 'PS1=$ '" | 574 | (,(format |
| 575 | tramp-terminal-type)) | 575 | "env 'TERM=%s' 'PROMPT_COMMAND=' 'PS1=$ '" |
| 576 | tramp-terminal-type)) | ||
| 576 | ("/bin/sh"))) | 577 | ("/bin/sh"))) |
| 577 | (tramp-remote-sh "/bin/sh") | 578 | (tramp-remote-sh "/bin/sh") |
| 578 | (tramp-copy-program nil) | 579 | (tramp-copy-program nil) |
| @@ -1772,6 +1773,7 @@ This is used to map a mode number to a permission string.") | |||
| 1772 | (copy-file . tramp-handle-copy-file) | 1773 | (copy-file . tramp-handle-copy-file) |
| 1773 | (rename-file . tramp-handle-rename-file) | 1774 | (rename-file . tramp-handle-rename-file) |
| 1774 | (set-file-modes . tramp-handle-set-file-modes) | 1775 | (set-file-modes . tramp-handle-set-file-modes) |
| 1776 | (set-file-times . tramp-handle-set-file-times) | ||
| 1775 | (make-directory . tramp-handle-make-directory) | 1777 | (make-directory . tramp-handle-make-directory) |
| 1776 | (delete-directory . tramp-handle-delete-directory) | 1778 | (delete-directory . tramp-handle-delete-directory) |
| 1777 | (delete-file . tramp-handle-delete-file) | 1779 | (delete-file . tramp-handle-delete-file) |
| @@ -2493,6 +2495,40 @@ of." | |||
| 2493 | (tramp-error | 2495 | (tramp-error |
| 2494 | v 'file-error "Error while changing file's mode %s" filename)))) | 2496 | v 'file-error "Error while changing file's mode %s" filename)))) |
| 2495 | 2497 | ||
| 2498 | (defun tramp-handle-set-file-times (filename &optional time) | ||
| 2499 | "Like `set-file-times' for Tramp files." | ||
| 2500 | (zerop | ||
| 2501 | (if (file-remote-p filename) | ||
| 2502 | (with-parsed-tramp-file-name filename nil | ||
| 2503 | (let ((time (if (or (null time) (equal time '(0 0))) | ||
| 2504 | (current-time) | ||
| 2505 | time)) | ||
| 2506 | (utc | ||
| 2507 | ;; With GNU Emacs, `format-time-string' has an | ||
| 2508 | ;; optional parameter UNIVERSAL. This is preferred, | ||
| 2509 | ;; because we could handle the case when the remote | ||
| 2510 | ;; host is located in a different time zone as the | ||
| 2511 | ;; local host. | ||
| 2512 | (and (functionp 'subr-arity) | ||
| 2513 | (subrp (symbol-function 'format-time-string)) | ||
| 2514 | (= 3 (cdr (funcall (symbol-function 'subr-arity) | ||
| 2515 | (symbol-function | ||
| 2516 | 'format-time-string))))))) | ||
| 2517 | (tramp-send-command-and-check | ||
| 2518 | v (format "%s touch -t %s %s" | ||
| 2519 | (if utc "TZ=UTC; export TZ;" "") | ||
| 2520 | (if utc | ||
| 2521 | (format-time-string "%Y%m%d%H%M.%S" time t) | ||
| 2522 | (format-time-string "%Y%m%d%H%M.%S" time)) | ||
| 2523 | (tramp-shell-quote-argument localname))))) | ||
| 2524 | ;; We handle also the local part, because in older Emacsen, | ||
| 2525 | ;; without `set-file-times', this function is an alias for this. | ||
| 2526 | ;; We are local, so we don't need the UTC settings. | ||
| 2527 | (call-process | ||
| 2528 | "touch" nil nil nil "-t" | ||
| 2529 | (format-time-string "%Y%m%d%H%M.%S" time) | ||
| 2530 | (tramp-shell-quote-argument filename))))) | ||
| 2531 | |||
| 2496 | ;; Simple functions using the `test' command. | 2532 | ;; Simple functions using the `test' command. |
| 2497 | 2533 | ||
| 2498 | (defun tramp-handle-file-executable-p (filename) | 2534 | (defun tramp-handle-file-executable-p (filename) |
| @@ -2926,10 +2962,8 @@ KEEP-DATE is non-nil if NEWNAME should have the same timestamp as FILENAME." | |||
| 2926 | (jka-compr-inhibit t)) | 2962 | (jka-compr-inhibit t)) |
| 2927 | (write-region (point-min) (point-max) newname)))) | 2963 | (write-region (point-min) (point-max) newname)))) |
| 2928 | ;; KEEP-DATE handling. | 2964 | ;; KEEP-DATE handling. |
| 2929 | (when keep-date | 2965 | (when (and keep-date (functionp 'set-file-times)) |
| 2930 | (when (and (not (null modtime)) | 2966 | (apply 'set-file-times (list newname modtime))) |
| 2931 | (not (equal modtime '(0 0)))) | ||
| 2932 | (tramp-touch newname modtime))) | ||
| 2933 | ;; Set the mode. | 2967 | ;; Set the mode. |
| 2934 | (set-file-modes newname (file-modes filename)) | 2968 | (set-file-modes newname (file-modes filename)) |
| 2935 | ;; If the operation was `rename', delete the original file. | 2969 | ;; If the operation was `rename', delete the original file. |
| @@ -3078,8 +3112,9 @@ be a local filename. The method used must be an out-of-band method." | |||
| 3078 | (tramp-message v 0 "Transferring %s to %s...done" filename newname) | 3112 | (tramp-message v 0 "Transferring %s to %s...done" filename newname) |
| 3079 | 3113 | ||
| 3080 | ;; Handle KEEP-DATE argument. | 3114 | ;; Handle KEEP-DATE argument. |
| 3081 | (when (and keep-date (not copy-keep-date)) | 3115 | (when (and keep-date (not copy-keep-date) (functionp 'set-file-times)) |
| 3082 | (set-file-times newname (nth 5 (file-attributes filename)))) | 3116 | (apply 'set-file-times |
| 3117 | (list newname (nth 5 (file-attributes filename))))) | ||
| 3083 | 3118 | ||
| 3084 | ;; Set the mode. | 3119 | ;; Set the mode. |
| 3085 | (unless (and keep-date copy-keep-date) | 3120 | (unless (and keep-date copy-keep-date) |
| @@ -3282,8 +3317,7 @@ This is like `dired-recursive-delete-directory' for Tramp files." | |||
| 3282 | ;; CCC is this the right thing to do? | 3317 | ;; CCC is this the right thing to do? |
| 3283 | (defun tramp-handle-unhandled-file-name-directory (filename) | 3318 | (defun tramp-handle-unhandled-file-name-directory (filename) |
| 3284 | "Like `unhandled-file-name-directory' for Tramp files." | 3319 | "Like `unhandled-file-name-directory' for Tramp files." |
| 3285 | (with-parsed-tramp-file-name filename nil | 3320 | (expand-file-name "~/")) |
| 3286 | (expand-file-name (tramp-make-tramp-file-name method user host "~/")))) | ||
| 3287 | 3321 | ||
| 3288 | ;; Canonicalization of file names. | 3322 | ;; Canonicalization of file names. |
| 3289 | 3323 | ||
| @@ -3446,9 +3480,8 @@ beginning of local filename are not substituted." | |||
| 3446 | (tramp-set-connection-property v "process-name" name) | 3480 | (tramp-set-connection-property v "process-name" name) |
| 3447 | (tramp-set-connection-property | 3481 | (tramp-set-connection-property |
| 3448 | v "process-buffer" | 3482 | v "process-buffer" |
| 3449 | (get-buffer-create | 3483 | ;; BUFFER can be nil. |
| 3450 | ;; BUFFER can be nil. | 3484 | (get-buffer-create (or buffer (current-buffer)))) |
| 3451 | (or buffer (generate-new-buffer-name (tramp-buffer-name v))))) | ||
| 3452 | ;; Activate narrowing in order to save BUFFER contents. | 3485 | ;; Activate narrowing in order to save BUFFER contents. |
| 3453 | (with-current-buffer (tramp-get-connection-buffer v) | 3486 | (with-current-buffer (tramp-get-connection-buffer v) |
| 3454 | (narrow-to-region (point-max) (point-max))) | 3487 | (narrow-to-region (point-max) (point-max))) |
| @@ -3466,7 +3499,9 @@ beginning of local filename are not substituted." | |||
| 3466 | ;; Return process. | 3499 | ;; Return process. |
| 3467 | (tramp-get-connection-process v)) | 3500 | (tramp-get-connection-process v)) |
| 3468 | ;; Save exit. | 3501 | ;; Save exit. |
| 3469 | (with-current-buffer (tramp-get-connection-buffer v) (widen)) | 3502 | (with-current-buffer (tramp-get-connection-buffer v) |
| 3503 | (widen) | ||
| 3504 | (goto-char (point-max))) | ||
| 3470 | (tramp-set-connection-property v "process-name" nil) | 3505 | (tramp-set-connection-property v "process-name" nil) |
| 3471 | (tramp-set-connection-property v "process-buffer" nil)))) | 3506 | (tramp-set-connection-property v "process-buffer" nil)))) |
| 3472 | 3507 | ||
| @@ -3575,12 +3610,33 @@ beginning of local filename are not substituted." | |||
| 3575 | (defun tramp-handle-shell-command | 3610 | (defun tramp-handle-shell-command |
| 3576 | (command &optional output-buffer error-buffer) | 3611 | (command &optional output-buffer error-buffer) |
| 3577 | "Like `shell-command' for Tramp files." | 3612 | "Like `shell-command' for Tramp files." |
| 3578 | (with-parsed-tramp-file-name default-directory nil | 3613 | (let* ((asynchronous (string-match "[ \t]*&[ \t]*\\'" command)) |
| 3579 | (let ((shell-file-name | 3614 | (args (split-string (substring command 0 asynchronous) " ")) |
| 3580 | (tramp-get-connection-property v "remote-shell" "/bin/sh")) | 3615 | (output-buffer |
| 3581 | (shell-command-switch "-c")) | 3616 | (or output-buffer |
| 3582 | (tramp-run-real-handler | 3617 | (if asynchronous |
| 3583 | 'shell-command (list command output-buffer error-buffer))))) | 3618 | "*Async Shell Command*" |
| 3619 | "*Shell Command Output*"))) | ||
| 3620 | (buffer | ||
| 3621 | (if (and (not asynchronous) (bufferp error-buffer)) | ||
| 3622 | (with-parsed-tramp-file-name default-directory nil | ||
| 3623 | (list output-buffer (tramp-make-tramp-temp-file v))) | ||
| 3624 | output-buffer))) | ||
| 3625 | |||
| 3626 | (prog1 | ||
| 3627 | ;; Run the process. We cannot use `process-file' and | ||
| 3628 | ;; `start-file-process', because these functions might not | ||
| 3629 | ;; exist in older Emacsen. | ||
| 3630 | (if (integerp asynchronous) | ||
| 3631 | (apply 'tramp-handle-start-file-process | ||
| 3632 | "*Async Shell*" buffer args) | ||
| 3633 | (apply 'tramp-handle-process-file | ||
| 3634 | (car args) nil buffer nil (cdr args))) | ||
| 3635 | ;; Insert error messages if they were separated. | ||
| 3636 | (when (listp buffer) | ||
| 3637 | (with-current-buffer error-buffer | ||
| 3638 | (insert-file-contents (cadr buffer))) | ||
| 3639 | (delete-file (cadr buffer)))))) | ||
| 3584 | 3640 | ||
| 3585 | ;; File Editing. | 3641 | ;; File Editing. |
| 3586 | 3642 | ||
| @@ -3657,14 +3713,18 @@ beginning of local filename are not substituted." | |||
| 3657 | (run-hooks 'tramp-handle-file-local-copy-hook) | 3713 | (run-hooks 'tramp-handle-file-local-copy-hook) |
| 3658 | tmpfil))) | 3714 | tmpfil))) |
| 3659 | 3715 | ||
| 3660 | (defun tramp-handle-file-remote-p (filename &optional connected) | 3716 | (defun tramp-handle-file-remote-p (file &optional identification connected) |
| 3661 | "Like `file-remote-p' for Tramp files." | 3717 | "Like `file-remote-p' for Tramp files." |
| 3662 | (when (tramp-tramp-file-p filename) | 3718 | (when (tramp-tramp-file-p filename) |
| 3663 | (with-parsed-tramp-file-name filename nil | 3719 | (with-parsed-tramp-file-name filename nil |
| 3664 | (and (or (not connected) | 3720 | (and (or (not connected) |
| 3665 | (let ((p (tramp-get-connection-process v))) | 3721 | (let ((p (tramp-get-connection-process v))) |
| 3666 | (and p (processp p) (memq (process-status p) '(run open))))) | 3722 | (and p (processp p) (memq (process-status p) '(run open))))) |
| 3667 | (tramp-make-tramp-file-name method user host ""))))) | 3723 | (cond |
| 3724 | ((eq identification 'method) method) | ||
| 3725 | ((eq identification 'user) user) | ||
| 3726 | ((eq identification 'host) host) | ||
| 3727 | (t (tramp-make-tramp-file-name method user host ""))))))) | ||
| 3668 | 3728 | ||
| 3669 | (defun tramp-handle-insert-file-contents | 3729 | (defun tramp-handle-insert-file-contents |
| 3670 | (filename &optional visit beg end replace) | 3730 | (filename &optional visit beg end replace) |
| @@ -4025,6 +4085,8 @@ ARGS are the arguments OPERATION has been called with." | |||
| 4025 | 'load 'make-directory 'make-directory-internal | 4085 | 'load 'make-directory 'make-directory-internal |
| 4026 | 'set-file-modes 'substitute-in-file-name | 4086 | 'set-file-modes 'substitute-in-file-name |
| 4027 | 'unhandled-file-name-directory 'vc-registered | 4087 | 'unhandled-file-name-directory 'vc-registered |
| 4088 | ; Emacs 22 only | ||
| 4089 | 'set-file-times | ||
| 4028 | ; XEmacs only | 4090 | ; XEmacs only |
| 4029 | 'abbreviate-file-name 'create-file-buffer | 4091 | 'abbreviate-file-name 'create-file-buffer |
| 4030 | 'dired-file-modtime 'dired-make-compressed-filename | 4092 | 'dired-file-modtime 'dired-make-compressed-filename |
| @@ -4886,40 +4948,6 @@ hosts, or files, disagree." | |||
| 4886 | (tramp-shell-quote-argument v1-localname) | 4948 | (tramp-shell-quote-argument v1-localname) |
| 4887 | (tramp-shell-quote-argument v2-localname)))))) | 4949 | (tramp-shell-quote-argument v2-localname)))))) |
| 4888 | 4950 | ||
| 4889 | (defun tramp-touch (file time) | ||
| 4890 | "Set the last-modified timestamp of the given file. | ||
| 4891 | TIME is an Emacs internal time value as returned by `current-time'." | ||
| 4892 | (let* ((utc | ||
| 4893 | ;; With GNU Emacs, `format-time-string' has an optional | ||
| 4894 | ;; parameter UNIVERSAL. This is preferred. | ||
| 4895 | (and (functionp 'subr-arity) | ||
| 4896 | (subrp (symbol-function 'format-time-string)) | ||
| 4897 | (= 3 (cdr (funcall (symbol-function 'subr-arity) | ||
| 4898 | (symbol-function 'format-time-string)))))) | ||
| 4899 | (touch-time | ||
| 4900 | (if utc | ||
| 4901 | (format-time-string "%Y%m%d%H%M.%S" time t) | ||
| 4902 | (format-time-string "%Y%m%d%H%M.%S" time))) | ||
| 4903 | (default-directory (file-name-directory file))) | ||
| 4904 | |||
| 4905 | (if (eq (tramp-find-foreign-file-name-handler file) | ||
| 4906 | 'tramp-sh-file-name-handler) | ||
| 4907 | (with-parsed-tramp-file-name file nil | ||
| 4908 | (tramp-send-command | ||
| 4909 | v (format "%s touch -t %s %s" | ||
| 4910 | (if utc "TZ=UTC; export TZ;" "") | ||
| 4911 | touch-time | ||
| 4912 | (tramp-shell-quote-argument localname)))) | ||
| 4913 | (with-temp-buffer | ||
| 4914 | (shell-command | ||
| 4915 | (format "%s touch -t %s %s" | ||
| 4916 | (if utc "TZ=UTC; export TZ;" "") | ||
| 4917 | touch-time | ||
| 4918 | (tramp-shell-quote-argument | ||
| 4919 | (if (tramp-tramp-file-p file) | ||
| 4920 | (with-parsed-tramp-file-name file nil localname) file))) | ||
| 4921 | (current-buffer)))))) | ||
| 4922 | |||
| 4923 | (defun tramp-buffer-name (vec) | 4951 | (defun tramp-buffer-name (vec) |
| 4924 | "A name for the connection buffer VEC." | 4952 | "A name for the connection buffer VEC." |
| 4925 | ;; We must use `tramp-file-name-real-host', because for gateway | 4953 | ;; We must use `tramp-file-name-real-host', because for gateway |
| @@ -5179,7 +5207,8 @@ file exists and nonzero exit status otherwise." | |||
| 5179 | (when extra-args (setq shell (concat shell " " extra-args)))) | 5207 | (when extra-args (setq shell (concat shell " " extra-args)))) |
| 5180 | (tramp-message | 5208 | (tramp-message |
| 5181 | vec 5 "Starting remote shell `%s' for tilde expansion..." shell) | 5209 | vec 5 "Starting remote shell `%s' for tilde expansion..." shell) |
| 5182 | (tramp-send-command-internal vec (concat "PS1='$ ' exec " shell)) | 5210 | (tramp-send-command-internal |
| 5211 | vec (concat "PROMPT_COMMAND='' PS1='$ ' exec " shell)) | ||
| 5183 | (tramp-message vec 5 "Setting remote shell prompt...") | 5212 | (tramp-message vec 5 "Setting remote shell prompt...") |
| 5184 | ;; Douglas Gray Stephens <DGrayStephens@slb.com> says that we | 5213 | ;; Douglas Gray Stephens <DGrayStephens@slb.com> says that we |
| 5185 | ;; must use "\n" here, not tramp-rsh-end-of-line. Kai left the | 5214 | ;; must use "\n" here, not tramp-rsh-end-of-line. Kai left the |
| @@ -5187,7 +5216,7 @@ file exists and nonzero exit status otherwise." | |||
| 5187 | ;; as well. | 5216 | ;; as well. |
| 5188 | (tramp-send-command | 5217 | (tramp-send-command |
| 5189 | vec | 5218 | vec |
| 5190 | (format "PS1='%s%s%s'; PS2=''; PS3=''" | 5219 | (format "PROMPT_COMMAND=''; PS1='%s%s%s'; PS2=''; PS3=''" |
| 5191 | tramp-rsh-end-of-line | 5220 | tramp-rsh-end-of-line |
| 5192 | tramp-end-of-output | 5221 | tramp-end-of-output |
| 5193 | tramp-rsh-end-of-line)) | 5222 | tramp-rsh-end-of-line)) |
| @@ -5455,10 +5484,11 @@ process to set up. VEC specifies the connection." | |||
| 5455 | ;; makes it work under `rc', too. We also unset the variable $ENV | 5484 | ;; makes it work under `rc', too. We also unset the variable $ENV |
| 5456 | ;; because that is read by some sh implementations (eg, bash when | 5485 | ;; because that is read by some sh implementations (eg, bash when |
| 5457 | ;; called as sh) on startup; this way, we avoid the startup file | 5486 | ;; called as sh) on startup; this way, we avoid the startup file |
| 5458 | ;; clobbering $PS1. | 5487 | ;; clobbering $PS1. $PROMP_COMMAND is another way to set the prompt |
| 5488 | ;; in /bin/bash, it must be discarded as well. | ||
| 5459 | (tramp-send-command-internal | 5489 | (tramp-send-command-internal |
| 5460 | vec | 5490 | vec |
| 5461 | (format "exec env 'ENV=' 'PS1=$ ' %s" | 5491 | (format "exec env 'ENV=' 'PROMPT_COMMAND=' 'PS1=$ ' %s" |
| 5462 | (tramp-get-method-parameter | 5492 | (tramp-get-method-parameter |
| 5463 | (tramp-file-name-method vec) 'tramp-remote-sh))) | 5493 | (tramp-file-name-method vec) 'tramp-remote-sh))) |
| 5464 | (tramp-message vec 5 "Setting up remote shell environment") | 5494 | (tramp-message vec 5 "Setting up remote shell environment") |
| @@ -5512,7 +5542,7 @@ process to set up. VEC specifies the connection." | |||
| 5512 | ;; send "echo are you awake". | 5542 | ;; send "echo are you awake". |
| 5513 | (tramp-send-command | 5543 | (tramp-send-command |
| 5514 | vec | 5544 | vec |
| 5515 | (format "PS1='%s%s%s'; PS2=''; PS3=''" | 5545 | (format "PROMPT_COMMAND=''; PS1='%s%s%s'; PS2=''; PS3=''" |
| 5516 | tramp-rsh-end-of-line | 5546 | tramp-rsh-end-of-line |
| 5517 | tramp-end-of-output | 5547 | tramp-end-of-output |
| 5518 | tramp-rsh-end-of-line)) | 5548 | tramp-rsh-end-of-line)) |
| @@ -5893,6 +5923,7 @@ connection if a previous connection has died for some reason." | |||
| 5893 | (when (and p (processp p)) | 5923 | (when (and p (processp p)) |
| 5894 | (delete-process p)) | 5924 | (delete-process p)) |
| 5895 | (setenv "TERM" tramp-terminal-type) | 5925 | (setenv "TERM" tramp-terminal-type) |
| 5926 | (setenv "PROMPT_COMMAND") | ||
| 5896 | (setenv "PS1" "$ ") | 5927 | (setenv "PS1" "$ ") |
| 5897 | (let* ((target-alist (tramp-compute-multi-hops vec)) | 5928 | (let* ((target-alist (tramp-compute-multi-hops vec)) |
| 5898 | (process-environment (copy-sequence process-environment)) | 5929 | (process-environment (copy-sequence process-environment)) |
| @@ -6243,17 +6274,24 @@ Return ATTR." | |||
| 6243 | ;; Convert inode. | 6274 | ;; Convert inode. |
| 6244 | (unless (listp (nth 10 attr)) | 6275 | (unless (listp (nth 10 attr)) |
| 6245 | (setcar (nthcdr 10 attr) | 6276 | (setcar (nthcdr 10 attr) |
| 6246 | (list (floor (nth 10 attr) 65536) | 6277 | (condition-case nil |
| 6247 | (floor (mod (nth 10 attr) 65536))))) | 6278 | (list (floor (nth 10 attr) 65536) |
| 6279 | (floor (mod (nth 10 attr) 65536))) | ||
| 6280 | ;; Inodes can be incredible huge. We must hide this. | ||
| 6281 | (error (tramp-get-inode vec))))) | ||
| 6248 | ;; Set virtual device number. | 6282 | ;; Set virtual device number. |
| 6249 | (setcar (nthcdr 11 attr) | 6283 | (setcar (nthcdr 11 attr) |
| 6250 | (tramp-get-device vec)) | 6284 | (tramp-get-device vec)) |
| 6251 | attr) | 6285 | attr) |
| 6252 | 6286 | ||
| 6253 | (defun tramp-get-inode (file) | 6287 | (defun tramp-get-inode (vec) |
| 6254 | "Returns the virtual inode number. | 6288 | "Returns the virtual inode number. |
| 6255 | If it doesn't exist, generate a new one." | 6289 | If it doesn't exist, generate a new one." |
| 6256 | (let ((string (directory-file-name file))) | 6290 | (let ((string (tramp-make-tramp-file-name |
| 6291 | (tramp-file-name-method vec) | ||
| 6292 | (tramp-file-name-user vec) | ||
| 6293 | (tramp-file-name-host vec) | ||
| 6294 | ""))) | ||
| 6257 | (unless (assoc string tramp-inodes) | 6295 | (unless (assoc string tramp-inodes) |
| 6258 | (add-to-list 'tramp-inodes | 6296 | (add-to-list 'tramp-inodes |
| 6259 | (list string (length tramp-inodes)))) | 6297 | (list string (length tramp-inodes)))) |