diff options
| author | Joakim Verona | 2013-01-08 00:03:39 +0100 |
|---|---|---|
| committer | Joakim Verona | 2013-01-08 00:03:39 +0100 |
| commit | 1c05adeed60d0afbe9439bcc995bcd4b9e40a53b (patch) | |
| tree | 2b7791b68de6eb6f716c08077d872ce7bcf828ef /lisp/net | |
| parent | be73be611d160876f9df633ff3a2d86eb78f65c7 (diff) | |
| parent | acfe10b71c260718f72445cd984327c1d96063ab (diff) | |
| download | emacs-1c05adeed60d0afbe9439bcc995bcd4b9e40a53b.tar.gz emacs-1c05adeed60d0afbe9439bcc995bcd4b9e40a53b.zip | |
auto upstream
Diffstat (limited to 'lisp/net')
| -rw-r--r-- | lisp/net/tramp-adb.el | 53 | ||||
| -rw-r--r-- | lisp/net/tramp-sh.el | 28 | ||||
| -rw-r--r-- | lisp/net/tramp.el | 55 |
3 files changed, 85 insertions, 51 deletions
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index bb9ff015ac3..f5aadd591d6 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el | |||
| @@ -66,8 +66,12 @@ | |||
| 66 | "[[:space:]]+\\(.*\\)$")) ; \6 filename | 66 | "[[:space:]]+\\(.*\\)$")) ; \6 filename |
| 67 | 67 | ||
| 68 | ;;;###tramp-autoload | 68 | ;;;###tramp-autoload |
| 69 | (add-to-list 'tramp-methods `(,tramp-adb-method | 69 | (add-to-list 'tramp-methods |
| 70 | (tramp-tmpdir "/data/local/tmp"))) | 70 | `(,tramp-adb-method |
| 71 | (tramp-tmpdir "/data/local/tmp"))) | ||
| 72 | |||
| 73 | ;;;###tramp-autoload | ||
| 74 | (add-to-list 'tramp-default-host-alist `(,tramp-adb-method nil "")) | ||
| 71 | 75 | ||
| 72 | ;;;###tramp-autoload | 76 | ;;;###tramp-autoload |
| 73 | (eval-after-load 'tramp | 77 | (eval-after-load 'tramp |
| @@ -119,7 +123,7 @@ | |||
| 119 | (vc-registered . ignore) ;no vc control files on Android devices | 123 | (vc-registered . ignore) ;no vc control files on Android devices |
| 120 | (write-region . tramp-adb-handle-write-region) | 124 | (write-region . tramp-adb-handle-write-region) |
| 121 | (set-file-modes . tramp-adb-handle-set-file-modes) | 125 | (set-file-modes . tramp-adb-handle-set-file-modes) |
| 122 | (set-file-times . ignore) | 126 | (set-file-times . tramp-adb-handle-set-file-times) |
| 123 | (copy-file . tramp-adb-handle-copy-file) | 127 | (copy-file . tramp-adb-handle-copy-file) |
| 124 | (rename-file . tramp-adb-handle-rename-file) | 128 | (rename-file . tramp-adb-handle-rename-file) |
| 125 | (process-file . tramp-adb-handle-process-file) | 129 | (process-file . tramp-adb-handle-process-file) |
| @@ -307,7 +311,9 @@ pass to the OPERATION." | |||
| 307 | (and is-symlink | 311 | (and is-symlink |
| 308 | (cadr (split-string name "\\( -> \\|\n\\)"))))) | 312 | (cadr (split-string name "\\( -> \\|\n\\)"))))) |
| 309 | (push (list | 313 | (push (list |
| 310 | name | 314 | (if is-symlink |
| 315 | (car (split-string name "\\( -> \\|\n\\)")) | ||
| 316 | name) | ||
| 311 | (or is-dir symlink-target) | 317 | (or is-dir symlink-target) |
| 312 | 1 ;link-count | 318 | 1 ;link-count |
| 313 | ;; no way to handle numeric ids in Androids ash | 319 | ;; no way to handle numeric ids in Androids ash |
| @@ -611,6 +617,19 @@ But handle the case, if the \"test\" command is not available." | |||
| 611 | v (format "chmod %s %s" (tramp-compat-decimal-to-octal mode) localname) | 617 | v (format "chmod %s %s" (tramp-compat-decimal-to-octal mode) localname) |
| 612 | "Error while changing file's mode %s" filename))) | 618 | "Error while changing file's mode %s" filename))) |
| 613 | 619 | ||
| 620 | (defun tramp-adb-handle-set-file-times (filename &optional time) | ||
| 621 | "Like `set-file-times' for Tramp files." | ||
| 622 | (with-parsed-tramp-file-name filename nil | ||
| 623 | (tramp-flush-file-property v localname) | ||
| 624 | (let ((time (if (or (null time) (equal time '(0 0))) | ||
| 625 | (current-time) | ||
| 626 | time))) | ||
| 627 | (tramp-adb-command-exit-status | ||
| 628 | ;; use shell arithmetic because of Emacs integer size limit | ||
| 629 | v (format "touch -t $(( %d * 65536 + %d )) %s" | ||
| 630 | (car time) (cadr time) | ||
| 631 | (tramp-shell-quote-argument localname)))))) | ||
| 632 | |||
| 614 | (defun tramp-adb-handle-copy-file | 633 | (defun tramp-adb-handle-copy-file |
| 615 | (filename newname &optional ok-if-already-exists keep-date | 634 | (filename newname &optional ok-if-already-exists keep-date |
| 616 | preserve-uid-gid preserve-extended-attributes) | 635 | preserve-uid-gid preserve-extended-attributes) |
| @@ -937,17 +956,10 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." | |||
| 937 | 956 | ||
| 938 | ;; Helper functions. | 957 | ;; Helper functions. |
| 939 | 958 | ||
| 940 | (defun tramp-adb-file-name-host (vec) | ||
| 941 | "Return host component of VEC. | ||
| 942 | If it is equal to the default value of `tramp-default-host', `nil' is returned." | ||
| 943 | (let ((host (tramp-file-name-host vec))) | ||
| 944 | (unless (equal host (eval (car (get 'tramp-default-host 'standard-value)))) | ||
| 945 | host))) | ||
| 946 | |||
| 947 | (defun tramp-adb-execute-adb-command (vec &rest args) | 959 | (defun tramp-adb-execute-adb-command (vec &rest args) |
| 948 | "Returns nil on success error-output on failure." | 960 | "Returns nil on success error-output on failure." |
| 949 | (when (tramp-adb-file-name-host vec) | 961 | (when (> (length (tramp-file-name-host vec)) 0) |
| 950 | (setq args (append (list "-s" (tramp-adb-file-name-host vec)) args))) | 962 | (setq args (append (list "-s" (tramp-file-name-host vec)) args))) |
| 951 | (with-temp-buffer | 963 | (with-temp-buffer |
| 952 | (prog1 | 964 | (prog1 |
| 953 | (unless (zerop (apply 'call-process (tramp-adb-program) nil t nil args)) | 965 | (unless (zerop (apply 'call-process (tramp-adb-program) nil t nil args)) |
| @@ -1048,6 +1060,7 @@ Does not do anything if a connection is already open, but re-opens the | |||
| 1048 | connection if a previous connection has died for some reason." | 1060 | connection if a previous connection has died for some reason." |
| 1049 | (let* ((buf (tramp-get-connection-buffer vec)) | 1061 | (let* ((buf (tramp-get-connection-buffer vec)) |
| 1050 | (p (get-buffer-process buf)) | 1062 | (p (get-buffer-process buf)) |
| 1063 | (host (tramp-file-name-host vec)) | ||
| 1051 | (devices (mapcar 'cadr (tramp-adb-parse-device-names nil)))) | 1064 | (devices (mapcar 'cadr (tramp-adb-parse-device-names nil)))) |
| 1052 | (unless | 1065 | (unless |
| 1053 | (and p (processp p) (memq (process-status p) '(run open))) | 1066 | (and p (processp p) (memq (process-status p) '(run open))) |
| @@ -1055,21 +1068,17 @@ connection if a previous connection has died for some reason." | |||
| 1055 | (when (and p (processp p)) (delete-process p)) | 1068 | (when (and p (processp p)) (delete-process p)) |
| 1056 | (if (not devices) | 1069 | (if (not devices) |
| 1057 | (tramp-error vec 'file-error "No device connected")) | 1070 | (tramp-error vec 'file-error "No device connected")) |
| 1058 | (if (and (tramp-adb-file-name-host vec) | 1071 | (if (and (> (length host) 0) (not (member host devices))) |
| 1059 | (not (member (tramp-adb-file-name-host vec) devices))) | 1072 | (tramp-error vec 'file-error "Device %s not connected" host)) |
| 1060 | (tramp-error | 1073 | (if (and (> (length devices) 1) (zerop (length host))) |
| 1061 | vec 'file-error | ||
| 1062 | "Device %s not connected" (tramp-adb-file-name-host vec))) | ||
| 1063 | (if (and (not (eq (length devices) 1)) | ||
| 1064 | (not (tramp-adb-file-name-host vec))) | ||
| 1065 | (tramp-error | 1074 | (tramp-error |
| 1066 | vec 'file-error | 1075 | vec 'file-error |
| 1067 | "Multiple Devices connected: No Host/Device specified")) | 1076 | "Multiple Devices connected: No Host/Device specified")) |
| 1068 | (with-tramp-progress-reporter vec 3 "Opening adb shell connection" | 1077 | (with-tramp-progress-reporter vec 3 "Opening adb shell connection" |
| 1069 | (let* ((coding-system-for-read 'utf-8-dos) ;is this correct? | 1078 | (let* ((coding-system-for-read 'utf-8-dos) ;is this correct? |
| 1070 | (process-connection-type tramp-process-connection-type) | 1079 | (process-connection-type tramp-process-connection-type) |
| 1071 | (args (if (tramp-adb-file-name-host vec) | 1080 | (args (if (> (length host) 0) |
| 1072 | (list "-s" (tramp-adb-file-name-host vec) "shell") | 1081 | (list "-s" host "shell") |
| 1073 | (list "shell"))) | 1082 | (list "shell"))) |
| 1074 | (p (let ((default-directory | 1083 | (p (let ((default-directory |
| 1075 | (tramp-compat-temporary-file-directory))) | 1084 | (tramp-compat-temporary-file-directory))) |
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 79f8d82b02b..d83599a6662 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -5181,34 +5181,6 @@ function cell is returned to be applied on a buffer." | |||
| 5181 | (t | 5181 | (t |
| 5182 | (format "%s <%%s" coding))))))) | 5182 | (format "%s <%%s" coding))))))) |
| 5183 | 5183 | ||
| 5184 | ;;; Integration of eshell.el: | ||
| 5185 | |||
| 5186 | (eval-when-compile | ||
| 5187 | (defvar eshell-path-env)) | ||
| 5188 | |||
| 5189 | ;; eshell.el keeps the path in `eshell-path-env'. We must change it | ||
| 5190 | ;; when `default-directory' points to another host. | ||
| 5191 | (defun tramp-eshell-directory-change () | ||
| 5192 | "Set `eshell-path-env' to $PATH of the host related to `default-directory'." | ||
| 5193 | (setq eshell-path-env | ||
| 5194 | (if (file-remote-p default-directory) | ||
| 5195 | (with-parsed-tramp-file-name default-directory nil | ||
| 5196 | (mapconcat | ||
| 5197 | 'identity | ||
| 5198 | (tramp-get-remote-path v) | ||
| 5199 | ":")) | ||
| 5200 | (getenv "PATH")))) | ||
| 5201 | |||
| 5202 | (eval-after-load "esh-util" | ||
| 5203 | '(progn | ||
| 5204 | (tramp-eshell-directory-change) | ||
| 5205 | (add-hook 'eshell-directory-change-hook | ||
| 5206 | 'tramp-eshell-directory-change) | ||
| 5207 | (add-hook 'tramp-unload-hook | ||
| 5208 | (lambda () | ||
| 5209 | (remove-hook 'eshell-directory-change-hook | ||
| 5210 | 'tramp-eshell-directory-change))))) | ||
| 5211 | |||
| 5212 | (add-hook 'tramp-unload-hook | 5184 | (add-hook 'tramp-unload-hook |
| 5213 | (lambda () | 5185 | (lambda () |
| 5214 | (unload-feature 'tramp-sh 'force))) | 5186 | (unload-feature 'tramp-sh 'force))) |
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 7c393622ffc..4c346799dcf 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el | |||
| @@ -381,6 +381,22 @@ Useful for su and sudo methods mostly." | |||
| 381 | :group 'tramp | 381 | :group 'tramp |
| 382 | :type 'string) | 382 | :type 'string) |
| 383 | 383 | ||
| 384 | ;;;###tramp-autoload | ||
| 385 | (defcustom tramp-default-host-alist nil | ||
| 386 | "Default host to use for specific method/user pairs. | ||
| 387 | This is an alist of items (METHOD USER HOST). The first matching item | ||
| 388 | specifies the host to use for a file name which does not specify a | ||
| 389 | host. METHOD and HOST are regular expressions or nil, which is | ||
| 390 | interpreted as a regular expression which always matches. If no entry | ||
| 391 | matches, the variable `tramp-default-host' takes effect. | ||
| 392 | |||
| 393 | If the file name does not specify the method, lookup is done using the | ||
| 394 | empty string for the method name." | ||
| 395 | :group 'tramp | ||
| 396 | :type '(repeat (list (choice :tag "Method regexp" regexp sexp) | ||
| 397 | (choice :tag " User regexp" regexp sexp) | ||
| 398 | (choice :tag " Host name" string (const nil))))) | ||
| 399 | |||
| 384 | (defcustom tramp-default-proxies-alist nil | 400 | (defcustom tramp-default-proxies-alist nil |
| 385 | "Route to be followed for specific host/user pairs. | 401 | "Route to be followed for specific host/user pairs. |
| 386 | This is an alist of items (HOST USER PROXY). The first matching | 402 | This is an alist of items (HOST USER PROXY). The first matching |
| @@ -918,7 +934,7 @@ See `tramp-file-name-structure' for more explanations.") | |||
| 918 | This regexp should match partial Tramp file names only. | 934 | This regexp should match partial Tramp file names only. |
| 919 | 935 | ||
| 920 | Please note that the entry in `file-name-handler-alist' is made when | 936 | Please note that the entry in `file-name-handler-alist' is made when |
| 921 | this file (tramp.el) is loaded. This means that this variable must be set | 937 | this file \(tramp.el\) is loaded. This means that this variable must be set |
| 922 | before loading tramp.el. Alternatively, `file-name-handler-alist' can be | 938 | before loading tramp.el. Alternatively, `file-name-handler-alist' can be |
| 923 | updated after changing this variable. | 939 | updated after changing this variable. |
| 924 | 940 | ||
| @@ -1163,6 +1179,15 @@ This is USER, if non-nil. Otherwise, do a lookup in | |||
| 1163 | "Return the right host string to use. | 1179 | "Return the right host string to use. |
| 1164 | This is HOST, if non-nil. Otherwise, it is `tramp-default-host'." | 1180 | This is HOST, if non-nil. Otherwise, it is `tramp-default-host'." |
| 1165 | (or (and (> (length host) 0) host) | 1181 | (or (and (> (length host) 0) host) |
| 1182 | (let ((choices tramp-default-host-alist) | ||
| 1183 | lhost item) | ||
| 1184 | (while choices | ||
| 1185 | (setq item (pop choices)) | ||
| 1186 | (when (and (string-match (or (nth 0 item) "") (or method "")) | ||
| 1187 | (string-match (or (nth 1 item) "") (or user ""))) | ||
| 1188 | (setq lhost (nth 2 item)) | ||
| 1189 | (setq choices nil))) | ||
| 1190 | lhost) | ||
| 1166 | tramp-default-host)) | 1191 | tramp-default-host)) |
| 1167 | 1192 | ||
| 1168 | (defun tramp-dissect-file-name (name &optional nodefault) | 1193 | (defun tramp-dissect-file-name (name &optional nodefault) |
| @@ -3861,6 +3886,34 @@ Only works for Bourne-like shells." | |||
| 3861 | t t result))) | 3886 | t t result))) |
| 3862 | result)))) | 3887 | result)))) |
| 3863 | 3888 | ||
| 3889 | ;;; Integration of eshell.el: | ||
| 3890 | |||
| 3891 | (eval-when-compile | ||
| 3892 | (defvar eshell-path-env)) | ||
| 3893 | |||
| 3894 | ;; eshell.el keeps the path in `eshell-path-env'. We must change it | ||
| 3895 | ;; when `default-directory' points to another host. | ||
| 3896 | (defun tramp-eshell-directory-change () | ||
| 3897 | "Set `eshell-path-env' to $PATH of the host related to `default-directory'." | ||
| 3898 | (setq eshell-path-env | ||
| 3899 | (if (file-remote-p default-directory) | ||
| 3900 | (with-parsed-tramp-file-name default-directory nil | ||
| 3901 | (mapconcat | ||
| 3902 | 'identity | ||
| 3903 | (tramp-get-connection-property v "remote-path" nil) | ||
| 3904 | ":")) | ||
| 3905 | (getenv "PATH")))) | ||
| 3906 | |||
| 3907 | (eval-after-load "esh-util" | ||
| 3908 | '(progn | ||
| 3909 | (tramp-eshell-directory-change) | ||
| 3910 | (add-hook 'eshell-directory-change-hook | ||
| 3911 | 'tramp-eshell-directory-change) | ||
| 3912 | (add-hook 'tramp-unload-hook | ||
| 3913 | (lambda () | ||
| 3914 | (remove-hook 'eshell-directory-change-hook | ||
| 3915 | 'tramp-eshell-directory-change))))) | ||
| 3916 | |||
| 3864 | ;; Checklist for `tramp-unload-hook' | 3917 | ;; Checklist for `tramp-unload-hook' |
| 3865 | ;; - Unload all `tramp-*' packages | 3918 | ;; - Unload all `tramp-*' packages |
| 3866 | ;; - Reset `file-name-handler-alist' | 3919 | ;; - Reset `file-name-handler-alist' |