Jürgen Hötzel <[email protected]> writes:

> Hi Michael,

Hi Juergen,

> Any ideas how we could handle copy-directory?

Enclosed are 2 more patches. The first one is needed due to recent
changes in Tramp 2.2.2-pre. The second patch collects some fixes
necessary for copy-directory (but the changes are more general).

> Jürgen

Best regards, Michael.

>From cf44b9d30cc3ad2e899a650f85f030f728c57600 Mon Sep 17 00:00:00 2001
From: Michael Albinus <[email protected]>
Date: Sun, 5 Jun 2011 11:57:26 +0200
Subject: [PATCH 5/6] Rename `with-progress-reporter' to `tramp-with-progress-reporter', as
 done in Tramp 2.2.2.

---
 tramp-adb.el |   17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/tramp-adb.el b/tramp-adb.el
index 010211f..4d0165d 100644
--- a/tramp-adb.el
+++ b/tramp-adb.el
@@ -35,6 +35,12 @@
 
 (require 'tramp)
 
+;; In Tramp 2.2.2, `with-progress-reporter' has been renamed to
+;; `tramp-with-progress-reporter'.  Until this version is commonly
+;; available, we declare it here.
+(unless (fboundp 'tramp-with-progress-reporter)
+  (defalias 'tramp-with-progress-reporter 'with-progress-reporter))
+
 (defcustom tramp-adb-sdk-dir "~/Android/sdk"
   "Set to the directory containing the Android SDK."
   :type 'string
@@ -446,7 +452,7 @@ Convert (\"-al\") to (\"-a\" \"-l\").  Remove arguments like \"--dired\"."
        v 'file-error
        "Cannot make local copy of non-existing file `%s'" filename))
     (let ((tmpfile (tramp-compat-make-temp-file filename)))
-      (with-progress-reporter
+      (tramp-with-progress-reporter
 	  v 3 (format "Fetching %s to tmp file %s" filename tmpfile)
 	(when (tramp-adb-execute-adb-command v "pull" localname tmpfile)
 	  (delete-file tmpfile)
@@ -485,7 +491,7 @@ Convert (\"-al\") to (\"-a\" \"-l\").  Remove arguments like \"--dired\"."
       (tramp-run-real-handler
        'write-region
        (list start end tmpfile append 'no-message lockname confirm))
-      (with-progress-reporter
+      (tramp-with-progress-reporter
 	  v 3 (format "Moving tmp file %s to %s" tmpfile filename)
 	(unwind-protect
 	    (when (tramp-adb-execute-adb-command v "push" tmpfile localname)
@@ -515,7 +521,7 @@ PRESERVE-UID-GID and PRESERVE-SELINUX-CONTEXT are completely ignored."
 
   (if (file-directory-p filename)
       (copy-directory filename newname keep-date)
-    (with-progress-reporter
+    (tramp-with-progress-reporter
 	(tramp-dissect-file-name (if (file-remote-p filename) filename newname))
 	0 (format "Copying %s to %s" filename newname)
 
@@ -559,7 +565,8 @@ PRESERVE-UID-GID and PRESERVE-SELINUX-CONTEXT are completely ignored."
 
   (with-parsed-tramp-file-name
       (if (file-remote-p filename) filename newname) nil
-    (with-progress-reporter v 0 (format "Renaming %s to %s" newname filename)
+    (tramp-with-progress-reporter
+	v 0 (format "Renaming %s to %s" newname filename)
 
       (if (and (tramp-equal-remote filename newname)
 	       (not (file-directory-p filename)))
@@ -921,7 +928,7 @@ connection if a previous connection has died for some reason."
 	(and p (processp p) (memq (process-status p) '(run open)))
       (save-match-data
 	(when (and p (processp p)) (delete-process p))
-	(with-progress-reporter vec 3 "Opening adb shell connection"
+	(tramp-with-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-file-name-host vec)
-- 
1.7.4.1

>From 5ee17f30183af7795ddada5f3db9821846b54aff Mon Sep 17 00:00:00 2001
From: Michael Albinus <[email protected]>
Date: Sun, 5 Jun 2011 12:56:23 +0200
Subject: [PATCH 6/6] Use `tramp-handle-directory-files' but `tramp-adb-handle-directory-files'.
 Move its code to `tramp-adb-handle-file-name-all-completions'.
 Use `re-search-forward' and `re-search-backward' in `tramp-adb-wait-for-output'.

---
 tramp-adb.el |   21 ++++++++-------------
 1 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/tramp-adb.el b/tramp-adb.el
index 4d0165d..d7d1915 100644
--- a/tramp-adb.el
+++ b/tramp-adb.el
@@ -92,7 +92,7 @@
     (file-modes . tramp-handle-file-modes)
     (expand-file-name . tramp-adb-handle-expand-file-name)
     (find-backup-file-name . tramp-handle-find-backup-file-name)
-    (directory-files . tramp-adb-handle-directory-files)
+    (directory-files . tramp-handle-directory-files)
     (make-directory . tramp-adb-handle-make-directory)
     (delete-directory . tramp-adb-handle-delete-directory)
     (delete-file . tramp-adb-handle-delete-file)
@@ -387,15 +387,6 @@ Convert (\"-al\") to (\"-a\" \"-l\").  Remove arguments like \"--dired\"."
     (setq posb (match-end 0))
     (string-lessp (substring a posa) (substring b posb))))
 
-(defun tramp-adb-handle-directory-files (dir &optional full match nosort files-only)
-  "Like `directory-files' for Tramp files."
-  (with-parsed-tramp-file-name dir nil
-    (tramp-adb-send-command
-     v (format "ls %s" (tramp-shell-quote-argument localname)))
-    (with-current-buffer (tramp-get-buffer v)
-      (remove-if (lambda (l) (string-match  "^[[:space:]]*$" l))
-		 (split-string (buffer-string) "\n")))))
-
 (defun tramp-adb-handle-make-directory (dir &optional parents)
   "Like `make-directory' for Tramp files."
   (setq dir (expand-file-name dir))
@@ -437,12 +428,16 @@ Convert (\"-al\") to (\"-a\" \"-l\").  Remove arguments like \"--dired\"."
    (with-parsed-tramp-file-name directory nil
      (with-file-property v localname "file-name-all-completions"
        (save-match-data
+	 (tramp-adb-send-command
+	  v (format "ls %s" (tramp-shell-quote-argument localname)))
 	 (mapcar
 	  (lambda (f)
 	    (if (file-directory-p f)
 		(file-name-as-directory f)
 	      f))
-	  (directory-files directory)))))))
+	  (with-current-buffer (tramp-get-buffer v)
+	    (remove-if (lambda (l) (string-match  "^[[:space:]]*$" l))
+		       (split-string (buffer-string) "\n")))))))))
 
 (defun tramp-adb-handle-file-local-copy (filename)
   "Like `file-local-copy' for Tramp files."
@@ -902,12 +897,12 @@ FMT and ARGS are passed to `error'."
     (if (tramp-wait-for-regexp proc timeout tramp-adb-prompt)
 	(let (buffer-read-only)
 	  (goto-char (point-min))
-	  (when (search-forward tramp-adb-prompt (point-at-eol) t)
+	  (when (re-search-forward tramp-adb-prompt (point-at-eol) t)
 	    (forward-line 1)
 	    (delete-region (point-min) (point)))
 	  ;; Delete the prompt.
 	  (goto-char (point-max))
-	  (search-backward tramp-adb-prompt nil t)
+	  (re-search-backward tramp-adb-prompt nil t)
 	  (delete-region (point) (point-max)))
       (if timeout
 	  (tramp-error
-- 
1.7.4.1

_______________________________________________
Tramp-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/tramp-devel

Reply via email to