>From a80d4c04255fe8b4972cc3dcf8f62a7b5b573ffb Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Fri, 27 May 2011 23:38:51 +0200 Subject: [PATCH 6/6] Implement host name completion. --- tramp-adb.el | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/tramp-adb.el b/tramp-adb.el index fd7dba2..bdbd6d2 100644 --- a/tramp-adb.el +++ b/tramp-adb.el @@ -54,6 +54,10 @@ ;;;###tramp-autoload (add-to-list 'tramp-methods `(,tramp-adb-method)) +(eval-after-load 'tramp + '(tramp-set-completion-function + tramp-adb-method '((tramp-adb-parse-device-names "")))) + ;;;###tramp-autoload (add-to-list 'tramp-foreign-file-name-handler-alist (cons 'tramp-adb-file-name-p 'tramp-adb-file-name-handler)) @@ -121,6 +125,16 @@ pass to the OPERATION." "The Android Debug Bridge." (expand-file-name "platform-tools/adb" tramp-adb-sdk-dir)) +(defun tramp-adb-parse-device-names (ignore) + "Return a list of (nil host) tuples allowed to access." + (with-temp-buffer + (when (zerop (call-process (tramp-adb-program) nil t nil "devices")) + (let (result) + (goto-char (point-min)) + (while (search-forward-regexp "^\\(\\S-+\\)[[:space:]]+device$" nil t) + (add-to-list 'result (list nil (match-string 1)))) + result)))) + (defun tramp-adb-handle-expand-file-name (name &optional dir) "Like `expand-file-name' for Tramp files." ;; If DIR is not given, use DEFAULT-DIRECTORY or "/". -- 1.7.4.1