emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r111341: * net/tramp-adb.el (tramp-ad


From: Michael Albinus
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r111341: * net/tramp-adb.el (tramp-adb-get-ls-command): New defun. Suppress
Date: Wed, 26 Dec 2012 17:22:18 +0100
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 111341
author: Jürgen Hötzel <address@hidden>
committer: Michael Albinus <address@hidden>
branch nick: trunk
timestamp: Wed 2012-12-26 17:22:18 +0100
message:
  * net/tramp-adb.el (tramp-adb-get-ls-command): New defun.  Suppress
  coloring, if possible (required for BusyBox based systems like
  CynagenMod).
  (tramp-adb-handle-file-attributes)
  (tramp-adb-handle-insert-directory)
  (tramp-adb-handle-file-name-all-completions): Use it.
  (tramp-adb-get-toolbox): New defun.  Check for remote shell
  implementation (BusyBox or Toolbox).
modified:
  lisp/ChangeLog
  lisp/net/tramp-adb.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2012-12-26 04:20:21 +0000
+++ b/lisp/ChangeLog    2012-12-26 16:22:18 +0000
@@ -1,3 +1,14 @@
+2012-12-26  Jürgen Hötzel  <address@hidden>
+
+       * net/tramp-adb.el (tramp-adb-get-ls-command): New defun.  Suppress
+       coloring, if possible (required for BusyBox based systems like
+       CynagenMod).
+       (tramp-adb-handle-file-attributes)
+       (tramp-adb-handle-insert-directory)
+       (tramp-adb-handle-file-name-all-completions): Use it.
+       (tramp-adb-get-toolbox): New defun.  Check for remote shell
+       implementation (BusyBox or Toolbox).
+
 2012-12-24  Constantin Kulikov <address@hidden>  (tiny change)
 
        * startup.el (initial-buffer-choice): Allow function as value

=== modified file 'lisp/net/tramp-adb.el'
--- a/lisp/net/tramp-adb.el     2012-12-22 13:44:06 +0000
+++ b/lisp/net/tramp-adb.el     2012-12-26 16:22:18 +0000
@@ -46,13 +46,15 @@
 (defconst tramp-adb-method "adb"
   "*When this method name is used, forward all calls to Android Debug Bridge.")
 
-(defcustom tramp-adb-prompt 
"^\\(?:[[:alnum:address@hidden:alnum:]]*[^#\\$]*\\)?[#\\$][[:space:]]"
+(defcustom tramp-adb-prompt
+  "^\\(?:[[:alnum:address@hidden:alnum:]]*[^#\\$]*\\)?[#\\$][[:space:]]"
   "Regexp used as prompt in almquist shell."
   :type 'string
   :version "24.4"
   :group 'tramp)
 
-(defconst tramp-adb-ls-date-regexp 
"[[:space:]][0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9][[:space:]][0-9][0-9]:[0-9][0-9][[:space:]]")
+(defconst tramp-adb-ls-date-regexp
+  
"[[:space:]][0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9][[:space:]][0-9][0-9]:[0-9][0-9][[:space:]]")
 
 ;;;###tramp-autoload
 (add-to-list 'tramp-methods `(,tramp-adb-method))
@@ -269,16 +271,21 @@
   (unless id-format (setq id-format 'integer))
   (ignore-errors
     (with-parsed-tramp-file-name filename nil
-      (with-tramp-file-property v localname (format "file-attributes-%s" 
id-format)
+      (with-tramp-file-property
+         v localname (format "file-attributes-%s" id-format)
        (tramp-adb-barf-unless-okay
-        v (format "ls -d -l %s" (tramp-shell-quote-argument localname)) "")
+        v (format "%s -d -l %s"
+                  (tramp-adb-get-ls-command v)
+                  (tramp-shell-quote-argument localname)) "")
        (with-current-buffer (tramp-get-buffer v)
          (tramp-adb-sh-fix-ls-output)
          (let* ((columns (split-string (buffer-string)))
                 (mod-string (nth 0 columns))
                 (is-dir (eq ?d (aref mod-string 0)))
                 (is-symlink (eq ?l (aref mod-string 0)))
-                (symlink-target (and is-symlink (cadr (split-string 
(buffer-string) "\\( -> \\|\n\\)"))))
+                (symlink-target
+                 (and is-symlink
+                      (cadr (split-string (buffer-string) "\\( -> \\|\n\\)"))))
                 (uid (nth 1 columns))
                 (gid (nth 2 columns))
                 (date (format "%s %s" (nth 4 columns) (nth 5 columns)))
@@ -297,6 +304,27 @@
             ;; fake
             t 1 1)))))))
 
+(defun tramp-adb-get-ls-command (vec)
+  (with-tramp-connection-property vec "ls"
+    (tramp-message vec 5 "Finding a suitable `ls' command")
+    (if        (zerop (tramp-adb-command-exit-status
+               vec "ls --color=never -al /dev/null"))
+       ;; On CyanogenMod based system BusyBox is used and "ls" output
+       ;; coloring is enabled by default.  So we try to disable it
+       ;; when possible.
+       "ls --color=never"
+      "ls")))
+
+(defun tramp-adb-get-toolbox (vec)
+  "Get shell toolbox implementation: `toolbox' for orginal distributions
+or `busybox' for CynagenMode based distributions"
+  (with-tramp-connection-property vec "toolbox"
+    (tramp-message vec 5 "Checking shell toolbox implementation")
+    (cond
+     ((zerop (tramp-adb-command-exit-status vec "busybox")) 'busybox)
+     ((zerop (tramp-adb-command-exit-status vec "toolbox")) 'toolbox)
+     (t 'unkown))))
+
 (defun tramp-adb--gnu-switches-to-ash
   (switches)
   "Almquist shell can't handle multiple arguments.
@@ -310,7 +338,8 @@
                  ;; FIXME: Warning about removed switches (long and non-dash).
                  (delq nil
                        (mapcar
-                        (lambda (s) (and (not (string-match 
"\\(^--\\|^[^-]\\)" s)) s))
+                        (lambda (s)
+                          (and (not (string-match "\\(^--\\|^[^-]\\)" s)) s))
                         switches))))))
 
 (defun tramp-adb-handle-insert-directory
@@ -325,14 +354,15 @@
            (switch-t (member "-t" switches))
            (switches (mapconcat 'identity (remove "-t" switches) " ")))
        (tramp-adb-barf-unless-okay
-        v (format "ls %s %s" switches name)
+        v (format "%s %s %s" (tramp-adb-get-ls-command v) switches name)
         "Cannot insert directory listing: %s" filename)
        (unless switch-d
          ;; We insert also filename/. and filename/.., because "ls" doesn't.
          (narrow-to-region (point) (point))
          (ignore-errors
            (tramp-adb-barf-unless-okay
-            v (format "ls -d %s %s %s"
+            v (format "%s -d %s %s %s"
+                      (tramp-adb-get-ls-command v)
                       switches
                       (concat (file-name-as-directory name) ".")
                       (concat (file-name-as-directory name) ".."))
@@ -342,11 +372,15 @@
     (insert-buffer-substring (tramp-get-buffer v))))
 
 (defun tramp-adb-sh-fix-ls-output (&optional sort-by-time)
-  "Androids ls command doesn't insert size column for directories: Emacs dired 
can't find files. Insert dummy 0 in empty size columns."
+  "Insert dummy 0 in empty size columns.
+Androids \"ls\" command doesn't insert size column for directories:
+Emacs dired can't find files."
   (save-excursion
     ;; Insert missing size.
     (goto-char (point-min))
-    (while (search-forward-regexp 
"[[:space:]]\\([[:space:]][0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9][[:space:]]\\)" nil 
t)
+    (while
+       (search-forward-regexp
+        
"[[:space:]]\\([[:space:]][0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9][[:space:]]\\)" nil 
t)
       (replace-match "0\\1" "\\1" nil)
       ;; Insert missing "/".
       (when (looking-at "[0-9][0-9]:[0-9][0-9][[:space:]]+$")
@@ -429,7 +463,9 @@
      (with-tramp-file-property v localname "file-name-all-completions"
        (save-match-data
         (tramp-adb-send-command
-         v (format "ls %s" (tramp-shell-quote-argument localname)))
+         v (format "%s %s"
+                   (tramp-adb-get-ls-command v)
+                   (tramp-shell-quote-argument localname)))
         (mapcar
          (lambda (f)
            (if (file-directory-p f)
@@ -787,7 +823,7 @@
                (tramp-compat-funcall 'display-message-or-buffer output-buffer)
              (pop-to-buffer output-buffer))))))))
 
-;; We use BUFFER also as connection buffer during setup. Because of
+;; We use BUFFER also as connection buffer during setup.  Because of
 ;; this, its original contents must be saved, and restored once
 ;; connection has been setup.
 (defun tramp-adb-handle-start-file-process (name buffer program &rest args)


reply via email to

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