diff options
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 11 | ||||
| -rw-r--r-- | lisp/net/tramp-adb.el | 60 |
2 files changed, 59 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2181a6dde7e..5ff36e04614 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2012-12-26 Jürgen Hötzel <juergen@archlinux.org> | ||
| 2 | |||
| 3 | * net/tramp-adb.el (tramp-adb-get-ls-command): New defun. Suppress | ||
| 4 | coloring, if possible (required for BusyBox based systems like | ||
| 5 | CynagenMod). | ||
| 6 | (tramp-adb-handle-file-attributes) | ||
| 7 | (tramp-adb-handle-insert-directory) | ||
| 8 | (tramp-adb-handle-file-name-all-completions): Use it. | ||
| 9 | (tramp-adb-get-toolbox): New defun. Check for remote shell | ||
| 10 | implementation (BusyBox or Toolbox). | ||
| 11 | |||
| 1 | 2012-12-24 Constantin Kulikov <zxnotdead@gmail.com> (tiny change) | 12 | 2012-12-24 Constantin Kulikov <zxnotdead@gmail.com> (tiny change) |
| 2 | 13 | ||
| 3 | * startup.el (initial-buffer-choice): Allow function as value | 14 | * startup.el (initial-buffer-choice): Allow function as value |
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index b500b1bba61..79de7ab07bb 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el | |||
| @@ -46,13 +46,15 @@ | |||
| 46 | (defconst tramp-adb-method "adb" | 46 | (defconst tramp-adb-method "adb" |
| 47 | "*When this method name is used, forward all calls to Android Debug Bridge.") | 47 | "*When this method name is used, forward all calls to Android Debug Bridge.") |
| 48 | 48 | ||
| 49 | (defcustom tramp-adb-prompt "^\\(?:[[:alnum:]]*@[[:alnum:]]*[^#\\$]*\\)?[#\\$][[:space:]]" | 49 | (defcustom tramp-adb-prompt |
| 50 | "^\\(?:[[:alnum:]]*@[[:alnum:]]*[^#\\$]*\\)?[#\\$][[:space:]]" | ||
| 50 | "Regexp used as prompt in almquist shell." | 51 | "Regexp used as prompt in almquist shell." |
| 51 | :type 'string | 52 | :type 'string |
| 52 | :version "24.4" | 53 | :version "24.4" |
| 53 | :group 'tramp) | 54 | :group 'tramp) |
| 54 | 55 | ||
| 55 | (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:]]") | 56 | (defconst tramp-adb-ls-date-regexp |
| 57 | "[[:space:]][0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9][[:space:]][0-9][0-9]:[0-9][0-9][[:space:]]") | ||
| 56 | 58 | ||
| 57 | ;;;###tramp-autoload | 59 | ;;;###tramp-autoload |
| 58 | (add-to-list 'tramp-methods `(,tramp-adb-method)) | 60 | (add-to-list 'tramp-methods `(,tramp-adb-method)) |
| @@ -269,16 +271,21 @@ pass to the OPERATION." | |||
| 269 | (unless id-format (setq id-format 'integer)) | 271 | (unless id-format (setq id-format 'integer)) |
| 270 | (ignore-errors | 272 | (ignore-errors |
| 271 | (with-parsed-tramp-file-name filename nil | 273 | (with-parsed-tramp-file-name filename nil |
| 272 | (with-tramp-file-property v localname (format "file-attributes-%s" id-format) | 274 | (with-tramp-file-property |
| 275 | v localname (format "file-attributes-%s" id-format) | ||
| 273 | (tramp-adb-barf-unless-okay | 276 | (tramp-adb-barf-unless-okay |
| 274 | v (format "ls -d -l %s" (tramp-shell-quote-argument localname)) "") | 277 | v (format "%s -d -l %s" |
| 278 | (tramp-adb-get-ls-command v) | ||
| 279 | (tramp-shell-quote-argument localname)) "") | ||
| 275 | (with-current-buffer (tramp-get-buffer v) | 280 | (with-current-buffer (tramp-get-buffer v) |
| 276 | (tramp-adb-sh-fix-ls-output) | 281 | (tramp-adb-sh-fix-ls-output) |
| 277 | (let* ((columns (split-string (buffer-string))) | 282 | (let* ((columns (split-string (buffer-string))) |
| 278 | (mod-string (nth 0 columns)) | 283 | (mod-string (nth 0 columns)) |
| 279 | (is-dir (eq ?d (aref mod-string 0))) | 284 | (is-dir (eq ?d (aref mod-string 0))) |
| 280 | (is-symlink (eq ?l (aref mod-string 0))) | 285 | (is-symlink (eq ?l (aref mod-string 0))) |
| 281 | (symlink-target (and is-symlink (cadr (split-string (buffer-string) "\\( -> \\|\n\\)")))) | 286 | (symlink-target |
| 287 | (and is-symlink | ||
| 288 | (cadr (split-string (buffer-string) "\\( -> \\|\n\\)")))) | ||
| 282 | (uid (nth 1 columns)) | 289 | (uid (nth 1 columns)) |
| 283 | (gid (nth 2 columns)) | 290 | (gid (nth 2 columns)) |
| 284 | (date (format "%s %s" (nth 4 columns) (nth 5 columns))) | 291 | (date (format "%s %s" (nth 4 columns) (nth 5 columns))) |
| @@ -297,6 +304,27 @@ pass to the OPERATION." | |||
| 297 | ;; fake | 304 | ;; fake |
| 298 | t 1 1))))))) | 305 | t 1 1))))))) |
| 299 | 306 | ||
| 307 | (defun tramp-adb-get-ls-command (vec) | ||
| 308 | (with-tramp-connection-property vec "ls" | ||
| 309 | (tramp-message vec 5 "Finding a suitable `ls' command") | ||
| 310 | (if (zerop (tramp-adb-command-exit-status | ||
| 311 | vec "ls --color=never -al /dev/null")) | ||
| 312 | ;; On CyanogenMod based system BusyBox is used and "ls" output | ||
| 313 | ;; coloring is enabled by default. So we try to disable it | ||
| 314 | ;; when possible. | ||
| 315 | "ls --color=never" | ||
| 316 | "ls"))) | ||
| 317 | |||
| 318 | (defun tramp-adb-get-toolbox (vec) | ||
| 319 | "Get shell toolbox implementation: `toolbox' for orginal distributions | ||
| 320 | or `busybox' for CynagenMode based distributions" | ||
| 321 | (with-tramp-connection-property vec "toolbox" | ||
| 322 | (tramp-message vec 5 "Checking shell toolbox implementation") | ||
| 323 | (cond | ||
| 324 | ((zerop (tramp-adb-command-exit-status vec "busybox")) 'busybox) | ||
| 325 | ((zerop (tramp-adb-command-exit-status vec "toolbox")) 'toolbox) | ||
| 326 | (t 'unkown)))) | ||
| 327 | |||
| 300 | (defun tramp-adb--gnu-switches-to-ash | 328 | (defun tramp-adb--gnu-switches-to-ash |
| 301 | (switches) | 329 | (switches) |
| 302 | "Almquist shell can't handle multiple arguments. | 330 | "Almquist shell can't handle multiple arguments. |
| @@ -310,7 +338,8 @@ Convert (\"-al\") to (\"-a\" \"-l\"). Remove arguments like \"--dired\"." | |||
| 310 | ;; FIXME: Warning about removed switches (long and non-dash). | 338 | ;; FIXME: Warning about removed switches (long and non-dash). |
| 311 | (delq nil | 339 | (delq nil |
| 312 | (mapcar | 340 | (mapcar |
| 313 | (lambda (s) (and (not (string-match "\\(^--\\|^[^-]\\)" s)) s)) | 341 | (lambda (s) |
| 342 | (and (not (string-match "\\(^--\\|^[^-]\\)" s)) s)) | ||
| 314 | switches)))))) | 343 | switches)))))) |
| 315 | 344 | ||
| 316 | (defun tramp-adb-handle-insert-directory | 345 | (defun tramp-adb-handle-insert-directory |
| @@ -325,14 +354,15 @@ Convert (\"-al\") to (\"-a\" \"-l\"). Remove arguments like \"--dired\"." | |||
| 325 | (switch-t (member "-t" switches)) | 354 | (switch-t (member "-t" switches)) |
| 326 | (switches (mapconcat 'identity (remove "-t" switches) " "))) | 355 | (switches (mapconcat 'identity (remove "-t" switches) " "))) |
| 327 | (tramp-adb-barf-unless-okay | 356 | (tramp-adb-barf-unless-okay |
| 328 | v (format "ls %s %s" switches name) | 357 | v (format "%s %s %s" (tramp-adb-get-ls-command v) switches name) |
| 329 | "Cannot insert directory listing: %s" filename) | 358 | "Cannot insert directory listing: %s" filename) |
| 330 | (unless switch-d | 359 | (unless switch-d |
| 331 | ;; We insert also filename/. and filename/.., because "ls" doesn't. | 360 | ;; We insert also filename/. and filename/.., because "ls" doesn't. |
| 332 | (narrow-to-region (point) (point)) | 361 | (narrow-to-region (point) (point)) |
| 333 | (ignore-errors | 362 | (ignore-errors |
| 334 | (tramp-adb-barf-unless-okay | 363 | (tramp-adb-barf-unless-okay |
| 335 | v (format "ls -d %s %s %s" | 364 | v (format "%s -d %s %s %s" |
| 365 | (tramp-adb-get-ls-command v) | ||
| 336 | switches | 366 | switches |
| 337 | (concat (file-name-as-directory name) ".") | 367 | (concat (file-name-as-directory name) ".") |
| 338 | (concat (file-name-as-directory name) "..")) | 368 | (concat (file-name-as-directory name) "..")) |
| @@ -342,11 +372,15 @@ Convert (\"-al\") to (\"-a\" \"-l\"). Remove arguments like \"--dired\"." | |||
| 342 | (insert-buffer-substring (tramp-get-buffer v)))) | 372 | (insert-buffer-substring (tramp-get-buffer v)))) |
| 343 | 373 | ||
| 344 | (defun tramp-adb-sh-fix-ls-output (&optional sort-by-time) | 374 | (defun tramp-adb-sh-fix-ls-output (&optional sort-by-time) |
| 345 | "Androids ls command doesn't insert size column for directories: Emacs dired can't find files. Insert dummy 0 in empty size columns." | 375 | "Insert dummy 0 in empty size columns. |
| 376 | Androids \"ls\" command doesn't insert size column for directories: | ||
| 377 | Emacs dired can't find files." | ||
| 346 | (save-excursion | 378 | (save-excursion |
| 347 | ;; Insert missing size. | 379 | ;; Insert missing size. |
| 348 | (goto-char (point-min)) | 380 | (goto-char (point-min)) |
| 349 | (while (search-forward-regexp "[[:space:]]\\([[:space:]][0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9][[:space:]]\\)" nil t) | 381 | (while |
| 382 | (search-forward-regexp | ||
| 383 | "[[:space:]]\\([[:space:]][0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9][[:space:]]\\)" nil t) | ||
| 350 | (replace-match "0\\1" "\\1" nil) | 384 | (replace-match "0\\1" "\\1" nil) |
| 351 | ;; Insert missing "/". | 385 | ;; Insert missing "/". |
| 352 | (when (looking-at "[0-9][0-9]:[0-9][0-9][[:space:]]+$") | 386 | (when (looking-at "[0-9][0-9]:[0-9][0-9][[:space:]]+$") |
| @@ -429,7 +463,9 @@ Convert (\"-al\") to (\"-a\" \"-l\"). Remove arguments like \"--dired\"." | |||
| 429 | (with-tramp-file-property v localname "file-name-all-completions" | 463 | (with-tramp-file-property v localname "file-name-all-completions" |
| 430 | (save-match-data | 464 | (save-match-data |
| 431 | (tramp-adb-send-command | 465 | (tramp-adb-send-command |
| 432 | v (format "ls %s" (tramp-shell-quote-argument localname))) | 466 | v (format "%s %s" |
| 467 | (tramp-adb-get-ls-command v) | ||
| 468 | (tramp-shell-quote-argument localname))) | ||
| 433 | (mapcar | 469 | (mapcar |
| 434 | (lambda (f) | 470 | (lambda (f) |
| 435 | (if (file-directory-p f) | 471 | (if (file-directory-p f) |
| @@ -787,7 +823,7 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." | |||
| 787 | (tramp-compat-funcall 'display-message-or-buffer output-buffer) | 823 | (tramp-compat-funcall 'display-message-or-buffer output-buffer) |
| 788 | (pop-to-buffer output-buffer)))))))) | 824 | (pop-to-buffer output-buffer)))))))) |
| 789 | 825 | ||
| 790 | ;; We use BUFFER also as connection buffer during setup. Because of | 826 | ;; We use BUFFER also as connection buffer during setup. Because of |
| 791 | ;; this, its original contents must be saved, and restored once | 827 | ;; this, its original contents must be saved, and restored once |
| 792 | ;; connection has been setup. | 828 | ;; connection has been setup. |
| 793 | (defun tramp-adb-handle-start-file-process (name buffer program &rest args) | 829 | (defun tramp-adb-handle-start-file-process (name buffer program &rest args) |