aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2013-01-07 10:25:34 +0100
committerMichael Albinus2013-01-07 10:25:34 +0100
commitb49eebcc079d00ea9f428a786e57988195f154a6 (patch)
treed6ded908264762d57659401bf8d4b1cbc72436ec
parent38eba8dfc489f91d5d02291cea7b4155461f730d (diff)
downloademacs-b49eebcc079d00ea9f428a786e57988195f154a6.tar.gz
emacs-b49eebcc079d00ea9f428a786e57988195f154a6.zip
* net/tramp.el (tramp-default-host-alist): New defcustom.
(tramp-find-host): Use it. (tramp-eshell-directory-change): Moved from tramp-sh.el. Add to `eshell-directory-change-hook'. * net/tramp-adb.el (top): Add adb specific entry in `tramp-default-host-alist'. (tramp-adb-file-name-host): Remove function. (tramp-adb-execute-adb-command, tramp-adb-maybe-open-connection): Use `tramp-file-name-host' instead of `tramp-adb-file-name-host'. * net/tramp-sh.el : Move eshell integration code to tramp.el.
-rw-r--r--lisp/ChangeLog17
-rw-r--r--lisp/net/tramp-adb.el34
-rw-r--r--lisp/net/tramp-sh.el28
-rw-r--r--lisp/net/tramp.el55
4 files changed, 84 insertions, 50 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9425ca5cdc2..03b83277010 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,18 @@
12013-01-07 Michael Albinus <michael.albinus@gmx.de>
2
3 * net/tramp.el (tramp-default-host-alist): New defcustom.
4 (tramp-find-host): Use it.
5 (tramp-eshell-directory-change): Moved from tramp-sh.el. Add to
6 `eshell-directory-change-hook'.
7
8 * net/tramp-adb.el (top): Add adb specific entry in
9 `tramp-default-host-alist'.
10 (tramp-adb-file-name-host): Remove function.
11 (tramp-adb-execute-adb-command, tramp-adb-maybe-open-connection):
12 Use `tramp-file-name-host' instead of `tramp-adb-file-name-host'.
13
14 * net/tramp-sh.el : Move eshell integration code to tramp.el.
15
12013-01-06 Jürgen Hötzel <juergen@archlinux.org> 162013-01-06 Jürgen Hötzel <juergen@archlinux.org>
2 17
3 * net/tramp-adb.el (tramp-methods): Add `tramp-tmpdir' entry. 18 * net/tramp-adb.el (tramp-methods): Add `tramp-tmpdir' entry.
@@ -5,7 +20,7 @@
52013-01-06 Michael Albinus <michael.albinus@gmx.de> 202013-01-06 Michael Albinus <michael.albinus@gmx.de>
6 21
7 * net/tramp-adb.el (tramp-adb-ls-toolbox-regexp): The file size can 22 * net/tramp-adb.el (tramp-adb-ls-toolbox-regexp): The file size can
8 consist of mor than one digit. 23 consist of more than one digit.
9 (tramp-adb-file-name-handler-alist): Use 24 (tramp-adb-file-name-handler-alist): Use
10 `tramp-handle-file-exists-p' consistently. 25 `tramp-handle-file-exists-p' consistently.
11 (tramp-adb-file-name-handler): Don't tweak `tramp-default-host'. 26 (tramp-adb-file-name-handler): Don't tweak `tramp-default-host'.
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index bb9ff015ac3..c6aec52bd07 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
@@ -937,17 +941,10 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
937 941
938;; Helper functions. 942;; Helper functions.
939 943
940(defun tramp-adb-file-name-host (vec)
941 "Return host component of VEC.
942If 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) 944(defun tramp-adb-execute-adb-command (vec &rest args)
948 "Returns nil on success error-output on failure." 945 "Returns nil on success error-output on failure."
949 (when (tramp-adb-file-name-host vec) 946 (when (> (length (tramp-file-name-host vec)) 0)
950 (setq args (append (list "-s" (tramp-adb-file-name-host vec)) args))) 947 (setq args (append (list "-s" (tramp-file-name-host vec)) args)))
951 (with-temp-buffer 948 (with-temp-buffer
952 (prog1 949 (prog1
953 (unless (zerop (apply 'call-process (tramp-adb-program) nil t nil args)) 950 (unless (zerop (apply 'call-process (tramp-adb-program) nil t nil args))
@@ -1048,6 +1045,7 @@ Does not do anything if a connection is already open, but re-opens the
1048connection if a previous connection has died for some reason." 1045connection if a previous connection has died for some reason."
1049 (let* ((buf (tramp-get-connection-buffer vec)) 1046 (let* ((buf (tramp-get-connection-buffer vec))
1050 (p (get-buffer-process buf)) 1047 (p (get-buffer-process buf))
1048 (host (tramp-file-name-host vec))
1051 (devices (mapcar 'cadr (tramp-adb-parse-device-names nil)))) 1049 (devices (mapcar 'cadr (tramp-adb-parse-device-names nil))))
1052 (unless 1050 (unless
1053 (and p (processp p) (memq (process-status p) '(run open))) 1051 (and p (processp p) (memq (process-status p) '(run open)))
@@ -1055,21 +1053,17 @@ connection if a previous connection has died for some reason."
1055 (when (and p (processp p)) (delete-process p)) 1053 (when (and p (processp p)) (delete-process p))
1056 (if (not devices) 1054 (if (not devices)
1057 (tramp-error vec 'file-error "No device connected")) 1055 (tramp-error vec 'file-error "No device connected"))
1058 (if (and (tramp-adb-file-name-host vec) 1056 (if (and (> (length host) 0) (not (member host devices)))
1059 (not (member (tramp-adb-file-name-host vec) devices))) 1057 (tramp-error vec 'file-error "Device %s not connected" host))
1060 (tramp-error 1058 (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 1059 (tramp-error
1066 vec 'file-error 1060 vec 'file-error
1067 "Multiple Devices connected: No Host/Device specified")) 1061 "Multiple Devices connected: No Host/Device specified"))
1068 (with-tramp-progress-reporter vec 3 "Opening adb shell connection" 1062 (with-tramp-progress-reporter vec 3 "Opening adb shell connection"
1069 (let* ((coding-system-for-read 'utf-8-dos) ;is this correct? 1063 (let* ((coding-system-for-read 'utf-8-dos) ;is this correct?
1070 (process-connection-type tramp-process-connection-type) 1064 (process-connection-type tramp-process-connection-type)
1071 (args (if (tramp-adb-file-name-host vec) 1065 (args (if (> (length host) 0)
1072 (list "-s" (tramp-adb-file-name-host vec) "shell") 1066 (list "-s" host "shell")
1073 (list "shell"))) 1067 (list "shell")))
1074 (p (let ((default-directory 1068 (p (let ((default-directory
1075 (tramp-compat-temporary-file-directory))) 1069 (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.
387This is an alist of items (METHOD USER HOST). The first matching item
388specifies the host to use for a file name which does not specify a
389host. METHOD and HOST are regular expressions or nil, which is
390interpreted as a regular expression which always matches. If no entry
391matches, the variable `tramp-default-host' takes effect.
392
393If the file name does not specify the method, lookup is done using the
394empty 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.
386This is an alist of items (HOST USER PROXY). The first matching 402This is an alist of items (HOST USER PROXY). The first matching
@@ -918,7 +934,7 @@ See `tramp-file-name-structure' for more explanations.")
918This regexp should match partial Tramp file names only. 934This regexp should match partial Tramp file names only.
919 935
920Please note that the entry in `file-name-handler-alist' is made when 936Please note that the entry in `file-name-handler-alist' is made when
921this file (tramp.el) is loaded. This means that this variable must be set 937this file \(tramp.el\) is loaded. This means that this variable must be set
922before loading tramp.el. Alternatively, `file-name-handler-alist' can be 938before loading tramp.el. Alternatively, `file-name-handler-alist' can be
923updated after changing this variable. 939updated 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.
1164This is HOST, if non-nil. Otherwise, it is `tramp-default-host'." 1180This 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'