(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.
+2013-01-07 Michael Albinus <michael.albinus@gmx.de>
+
+ * 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.
+
2013-01-06 Jürgen Hötzel <juergen@archlinux.org>
* net/tramp-adb.el (tramp-methods): Add `tramp-tmpdir' entry.
2013-01-06 Michael Albinus <michael.albinus@gmx.de>
* net/tramp-adb.el (tramp-adb-ls-toolbox-regexp): The file size can
- consist of mor than one digit.
+ consist of more than one digit.
(tramp-adb-file-name-handler-alist): Use
`tramp-handle-file-exists-p' consistently.
(tramp-adb-file-name-handler): Don't tweak `tramp-default-host'.
"[[:space:]]+\\(.*\\)$")) ; \6 filename
;;;###tramp-autoload
-(add-to-list 'tramp-methods `(,tramp-adb-method
- (tramp-tmpdir "/data/local/tmp")))
+(add-to-list 'tramp-methods
+ `(,tramp-adb-method
+ (tramp-tmpdir "/data/local/tmp")))
+
+;;;###tramp-autoload
+(add-to-list 'tramp-default-host-alist `(,tramp-adb-method nil ""))
;;;###tramp-autoload
(eval-after-load 'tramp
;; Helper functions.
-(defun tramp-adb-file-name-host (vec)
- "Return host component of VEC.
-If it is equal to the default value of `tramp-default-host', `nil' is returned."
- (let ((host (tramp-file-name-host vec)))
- (unless (equal host (eval (car (get 'tramp-default-host 'standard-value))))
- host)))
-
(defun tramp-adb-execute-adb-command (vec &rest args)
"Returns nil on success error-output on failure."
- (when (tramp-adb-file-name-host vec)
- (setq args (append (list "-s" (tramp-adb-file-name-host vec)) args)))
+ (when (> (length (tramp-file-name-host vec)) 0)
+ (setq args (append (list "-s" (tramp-file-name-host vec)) args)))
(with-temp-buffer
(prog1
(unless (zerop (apply 'call-process (tramp-adb-program) nil t nil args))
connection if a previous connection has died for some reason."
(let* ((buf (tramp-get-connection-buffer vec))
(p (get-buffer-process buf))
+ (host (tramp-file-name-host vec))
(devices (mapcar 'cadr (tramp-adb-parse-device-names nil))))
(unless
(and p (processp p) (memq (process-status p) '(run open)))
(when (and p (processp p)) (delete-process p))
(if (not devices)
(tramp-error vec 'file-error "No device connected"))
- (if (and (tramp-adb-file-name-host vec)
- (not (member (tramp-adb-file-name-host vec) devices)))
- (tramp-error
- vec 'file-error
- "Device %s not connected" (tramp-adb-file-name-host vec)))
- (if (and (not (eq (length devices) 1))
- (not (tramp-adb-file-name-host vec)))
+ (if (and (> (length host) 0) (not (member host devices)))
+ (tramp-error vec 'file-error "Device %s not connected" host))
+ (if (and (> (length devices) 1) (zerop (length host)))
(tramp-error
vec 'file-error
"Multiple Devices connected: No Host/Device specified"))
(with-tramp-progress-reporter vec 3 "Opening adb shell connection"
(let* ((coding-system-for-read 'utf-8-dos) ;is this correct?
(process-connection-type tramp-process-connection-type)
- (args (if (tramp-adb-file-name-host vec)
- (list "-s" (tramp-adb-file-name-host vec) "shell")
+ (args (if (> (length host) 0)
+ (list "-s" host "shell")
(list "shell")))
(p (let ((default-directory
(tramp-compat-temporary-file-directory)))
(t
(format "%s <%%s" coding)))))))
-;;; Integration of eshell.el:
-
-(eval-when-compile
- (defvar eshell-path-env))
-
-;; eshell.el keeps the path in `eshell-path-env'. We must change it
-;; when `default-directory' points to another host.
-(defun tramp-eshell-directory-change ()
- "Set `eshell-path-env' to $PATH of the host related to `default-directory'."
- (setq eshell-path-env
- (if (file-remote-p default-directory)
- (with-parsed-tramp-file-name default-directory nil
- (mapconcat
- 'identity
- (tramp-get-remote-path v)
- ":"))
- (getenv "PATH"))))
-
-(eval-after-load "esh-util"
- '(progn
- (tramp-eshell-directory-change)
- (add-hook 'eshell-directory-change-hook
- 'tramp-eshell-directory-change)
- (add-hook 'tramp-unload-hook
- (lambda ()
- (remove-hook 'eshell-directory-change-hook
- 'tramp-eshell-directory-change)))))
-
(add-hook 'tramp-unload-hook
(lambda ()
(unload-feature 'tramp-sh 'force)))
:group 'tramp
:type 'string)
+;;;###tramp-autoload
+(defcustom tramp-default-host-alist nil
+ "Default host to use for specific method/user pairs.
+This is an alist of items (METHOD USER HOST). The first matching item
+specifies the host to use for a file name which does not specify a
+host. METHOD and HOST are regular expressions or nil, which is
+interpreted as a regular expression which always matches. If no entry
+matches, the variable `tramp-default-host' takes effect.
+
+If the file name does not specify the method, lookup is done using the
+empty string for the method name."
+ :group 'tramp
+ :type '(repeat (list (choice :tag "Method regexp" regexp sexp)
+ (choice :tag " User regexp" regexp sexp)
+ (choice :tag " Host name" string (const nil)))))
+
(defcustom tramp-default-proxies-alist nil
"Route to be followed for specific host/user pairs.
This is an alist of items (HOST USER PROXY). The first matching
This regexp should match partial Tramp file names only.
Please note that the entry in `file-name-handler-alist' is made when
-this file (tramp.el) is loaded. This means that this variable must be set
+this file \(tramp.el\) is loaded. This means that this variable must be set
before loading tramp.el. Alternatively, `file-name-handler-alist' can be
updated after changing this variable.
"Return the right host string to use.
This is HOST, if non-nil. Otherwise, it is `tramp-default-host'."
(or (and (> (length host) 0) host)
+ (let ((choices tramp-default-host-alist)
+ lhost item)
+ (while choices
+ (setq item (pop choices))
+ (when (and (string-match (or (nth 0 item) "") (or method ""))
+ (string-match (or (nth 1 item) "") (or user "")))
+ (setq lhost (nth 2 item))
+ (setq choices nil)))
+ lhost)
tramp-default-host))
(defun tramp-dissect-file-name (name &optional nodefault)
t t result)))
result))))
+;;; Integration of eshell.el:
+
+(eval-when-compile
+ (defvar eshell-path-env))
+
+;; eshell.el keeps the path in `eshell-path-env'. We must change it
+;; when `default-directory' points to another host.
+(defun tramp-eshell-directory-change ()
+ "Set `eshell-path-env' to $PATH of the host related to `default-directory'."
+ (setq eshell-path-env
+ (if (file-remote-p default-directory)
+ (with-parsed-tramp-file-name default-directory nil
+ (mapconcat
+ 'identity
+ (tramp-get-connection-property v "remote-path" nil)
+ ":"))
+ (getenv "PATH"))))
+
+(eval-after-load "esh-util"
+ '(progn
+ (tramp-eshell-directory-change)
+ (add-hook 'eshell-directory-change-hook
+ 'tramp-eshell-directory-change)
+ (add-hook 'tramp-unload-hook
+ (lambda ()
+ (remove-hook 'eshell-directory-change-hook
+ 'tramp-eshell-directory-change)))))
+
;; Checklist for `tramp-unload-hook'
;; - Unload all `tramp-*' packages
;; - Reset `file-name-handler-alist'