emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r111433: * net/tramp.el (tramp-defaul


From: Michael Albinus
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111433: * net/tramp.el (tramp-default-host-alist): New defcustom.
Date: Mon, 07 Jan 2013 10:25:34 +0100
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111433
committer: Michael Albinus <address@hidden
branch nick: trunk
timestamp: Mon 2013-01-07 10:25:34 +0100
message:
  * 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.
modified:
  lisp/ChangeLog
  lisp/net/tramp-adb.el
  lisp/net/tramp-sh.el
  lisp/net/tramp.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2013-01-06 21:25:27 +0000
+++ b/lisp/ChangeLog    2013-01-07 09:25:34 +0000
@@ -1,3 +1,18 @@
+2013-01-07  Michael Albinus  <address@hidden>
+
+       * 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  <address@hidden>
 
        * net/tramp-adb.el (tramp-methods): Add `tramp-tmpdir' entry.
@@ -5,7 +20,7 @@
 2013-01-06  Michael Albinus  <address@hidden>
 
        * 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'.

=== modified file 'lisp/net/tramp-adb.el'
--- a/lisp/net/tramp-adb.el     2013-01-06 21:25:27 +0000
+++ b/lisp/net/tramp-adb.el     2013-01-07 09:25:34 +0000
@@ -66,8 +66,12 @@
    "[[: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
@@ -937,17 +941,10 @@
 
 ;; 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))
@@ -1048,6 +1045,7 @@
 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)))
@@ -1055,21 +1053,17 @@
        (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)))

=== modified file 'lisp/net/tramp-sh.el'
--- a/lisp/net/tramp-sh.el      2013-01-04 19:22:37 +0000
+++ b/lisp/net/tramp-sh.el      2013-01-07 09:25:34 +0000
@@ -5181,34 +5181,6 @@
         (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)))

=== modified file 'lisp/net/tramp.el'
--- a/lisp/net/tramp.el 2013-01-02 16:13:04 +0000
+++ b/lisp/net/tramp.el 2013-01-07 09:25:34 +0000
@@ -381,6 +381,22 @@
   :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
@@ -918,7 +934,7 @@
 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.
 
@@ -1163,6 +1179,15 @@
   "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)
@@ -3861,6 +3886,34 @@
                                      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'


reply via email to

[Prev in Thread] Current Thread [Next in Thread]