Jürgen Hötzel <[email protected]> writes: > Hi Michael
Hi Juergen, > 2011/5/21 Michael Albinus <[email protected]>: >> Appended are the patches what I have done so far. > > Nice! Just committed to GitHub. I also implemented "sort-by-date". Yep. However, sort-by-date in dired is descending, the first appended patch corrects this. The other patch adds error handling in tramp-adb-handle-insert-directory. Likely, I will start next with handling several connected devices in parallel. Btw, whenever I touch a piece of code I try to format it according to the Coding Standards, like using lines not longer than 80 columns, proper docstrings, etc. > Jürgen Best regards, Michael.
>From 891f788408de3620e006ff3f2347be5383130f75 Mon Sep 17 00:00:00 2001 From: Michael Albinus <[email protected]> Date: Sat, 21 May 2011 19:06:48 +0200 Subject: [PATCH 1/2] Sort "ls" output by time, descending. --- tramp-adb.el | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/tramp-adb.el b/tramp-adb.el index bfbddb4..8d005a7 100644 --- a/tramp-adb.el +++ b/tramp-adb.el @@ -219,14 +219,16 @@ pass to the OPERATION." (insert " " (mapconcat 'identity sorted-lines "\n "))))) (defun tramp-adb-ls-output-time-less-p (a b) + "Sort \"ls\" output by time, descending." (let (time-a time-b) (string-match tramp-adb-ls-date-regexp a) (setq time-a (apply 'encode-time (parse-time-string (match-string 0 a)))) (string-match tramp-adb-ls-date-regexp b) (setq time-b (apply 'encode-time (parse-time-string (match-string 0 b)))) - (time-less-p time-a time-b))) + (time-less-p time-b time-a))) (defun tramp-adb-ls-output-name-less-p (a b) + "Sort \"ls\" output by name, ascending." (let (posa posb) (string-match dired-move-to-filename-regexp a) (setq posa (match-end 0)) -- 1.7.4.1
>From f9193f8270d1e6ce5fb2d5ee7390d9b606314605 Mon Sep 17 00:00:00 2001 From: Michael Albinus <[email protected]> Date: Sat, 21 May 2011 19:30:05 +0200 Subject: [PATCH 2/2] Add error handling in tramp-adb-handle-insert-directory. --- tramp-adb.el | 23 ++++++++++++++++------- 1 files changed, 16 insertions(+), 7 deletions(-) diff --git a/tramp-adb.el b/tramp-adb.el index 8d005a7..e357d69 100644 --- a/tramp-adb.el +++ b/tramp-adb.el @@ -44,7 +44,10 @@ (defconst tramp-adb-method "adb" "*When this method name is used, forward all calls to Android Debug Bridge.") -(defconst tramp-adb-ls-errors (regexp-opt '("No such file or directory"))) +(defconst tramp-adb-ls-errors + "Error strings returned by the \"ls\" command." + (regexp-opt '("No such file or directory" + "opendir failed, Permission denied"))) (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:]]") @@ -188,16 +191,22 @@ pass to the OPERATION." (setq switches (tramp-adb--gnu-switches-to-ash (split-string switches)))) ;; FIXME: tramp-adb-handle-expand-file-name does not handle name/. and name/.. (with-parsed-tramp-file-name (expand-file-name filename) nil - (let ((cmd (format "ls %s %%s" (mapconcat 'identity (remove "-t" switches) " "))) - (name (tramp-shell-quote-argument (file-name-as-directory localname)))) + (let ((cmd (format "ls %s " + (mapconcat 'identity (remove "-t" switches) " "))) + (name + (tramp-shell-quote-argument (file-name-as-directory localname)))) + ;; We insert also filename/. and filename/.., because "ls" doesn't. (dolist (string (list (concat "-d " name ".") (concat "-d " name "..") name)) - (tramp-adb-send-command v (format cmd string)) - (insert - (with-current-buffer (tramp-get-buffer v) - (buffer-string)))) + (tramp-adb-send-command v (concat cmd string)) + (let ((result + (with-current-buffer (tramp-get-buffer v) (buffer-string)))) + (when (string-match tramp-adb-ls-errors result) + (tramp-error + v 'file-error "%s: %s" (match-string 0 result) localname)) + (insert result))) (tramp-adb-sh-fix-ls-output (member "-t" switches))))) (defun tramp-adb-sh-fix-ls-output (&optional sort-by-time) -- 1.7.4.1
_______________________________________________ Tramp-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/tramp-devel
