emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r99407: * net/ange-ftp.el (ange-ftp-i


From: Michael Albinus
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r99407: * net/ange-ftp.el (ange-ftp-insert-directory): Handle the case,
Date: Thu, 28 Jan 2010 22:13:01 +0100
User-agent: Bazaar (2.0.2)

------------------------------------------------------------
revno: 99407
committer: Michael Albinus <address@hidden>
branch nick: trunk
timestamp: Thu 2010-01-28 22:13:01 +0100
message:
  * net/ange-ftp.el (ange-ftp-insert-directory): Handle the case,
  FILENAME is not in `default-directory'.  (Bug#5478)
  
  * net/tramp.el (tramp-handle-insert-directory): Simplify handling
  of SWITCHES.  Handle the case, FILENAME is not in
  `default-directory'.  (Bug#5478)
  (tramp-register-file-name-handlers): Add safe-magic property.
modified:
  lisp/ChangeLog
  lisp/net/ange-ftp.el
  lisp/net/tramp.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-01-28 20:06:36 +0000
+++ b/lisp/ChangeLog    2010-01-28 21:13:01 +0000
@@ -1,3 +1,13 @@
+2010-01-28  Michael Albinus  <address@hidden>
+
+       * net/ange-ftp.el (ange-ftp-insert-directory): Handle the case,
+       FILENAME is not in `default-directory'.  (Bug#5478)
+
+       * net/tramp.el (tramp-handle-insert-directory): Simplify handling
+       of SWITCHES.  Handle the case, FILENAME is not in
+       `default-directory'.  (Bug#5478)
+       (tramp-register-file-name-handlers): Add safe-magic property.
+
 2010-01-28  Chong Yidong  <address@hidden>
 
        * arc-mode.el (archive-zip-extract): Quote the argument passed to

=== modified file 'lisp/net/ange-ftp.el'
--- a/lisp/net/ange-ftp.el      2010-01-13 08:35:10 +0000
+++ b/lisp/net/ange-ftp.el      2010-01-28 21:13:01 +0000
@@ -4542,7 +4542,18 @@
          (if (string-match (concat "^.+[^ ] " (regexp-quote filename)
                                    "\\( -> .*\\)?[@/*=]?\n") dirlist)
              (match-string 0 dirlist)
-           "")))))))
+           "")))))
+
+    ;; The inserted file could be from somewhere else.
+    (when (and (not wildcard) (not full)
+              (search-backward
+               (if (zerop (length (file-name-nondirectory
+                                   (expand-file-name file))))
+                   "."
+                 (file-name-nondirectory file))
+               nil 'noerror))
+      (replace-match (file-relative-name (expand-file-name file)) t)
+      (goto-char (point-max)))))
 
 (defun ange-ftp-dired-uncache (dir)
   (if (ange-ftp-ftp-name (expand-file-name dir))

=== modified file 'lisp/net/tramp.el'
--- a/lisp/net/tramp.el 2010-01-28 06:06:41 +0000
+++ b/lisp/net/tramp.el 2010-01-28 21:13:01 +0000
@@ -4062,26 +4062,25 @@
             (not (symbol-value 'ls-lisp-use-insert-directory-program)))
        (tramp-run-real-handler
         'insert-directory (list filename switches wildcard full-directory-p))
-      (when (and (string-match "^--dired\\s-+" switches)
+      (when (stringp switches)
+        (setq switches (split-string switches)))
+      (when (and (member "--dired" switches)
                 (not (tramp-get-ls-command-with-dired v)))
-       (setq switches (replace-match "" nil t switches)))
-      (tramp-message
-       v 4 "Inserting directory `ls %s %s', wildcard %s, fulldir %s"
-       switches filename (if wildcard "yes" "no")
-       (if full-directory-p "yes" "no"))
+       (setq switches (delete "--dired" switches)))
       (when wildcard
         (setq wildcard (tramp-run-real-handler
                        'file-name-nondirectory (list localname)))
         (setq localname (tramp-run-real-handler
                         'file-name-directory (list localname))))
-      (when (listp switches)
-        (setq switches (mapconcat 'identity switches " ")))
       (unless full-directory-p
-        (setq switches (concat "-d " switches)))
+        (setq switches (add-to-list 'switches "-d" 'append)))
+      (setq switches (mapconcat 'tramp-shell-quote-argument switches " "))
       (when wildcard
-        (setq switches (concat switches " " wildcard)))
-      (when (string-match "'" switches)
-       (setq switches (replace-match "\\\\'" nil nil switches)))
+       (setq switches (concat switches " " wildcard)))
+      (tramp-message
+       v 4 "Inserting directory `ls %s %s', wildcard %s, fulldir %s"
+       switches filename (if wildcard "yes" "no")
+       (if full-directory-p "yes" "no"))
       ;; If `full-directory-p', we just say `ls -l FILENAME'.
       ;; Else we chdir to the parent directory, then say `ls -ld BASENAME'.
       (if full-directory-p
@@ -4144,6 +4143,17 @@
        (while (looking-at "//")
          (forward-line 1)
          (delete-region (match-beginning 0) (point)))
+
+       ;; The inserted file could be from somewhere else.
+       (when (and (not wildcard) (not full-directory-p))
+         (goto-char (point-max))
+         (search-backward
+          (if (zerop (length (file-name-nondirectory filename)))
+              "."
+            (file-name-nondirectory filename))
+          beg 'noerror)
+         (replace-match (file-relative-name filename) t))
+
        (goto-char (point-max))))))
 
 (defun tramp-handle-unhandled-file-name-directory (filename)
@@ -5481,6 +5491,7 @@
   ;; Add the handlers.
   (add-to-list 'file-name-handler-alist
               (cons tramp-file-name-regexp 'tramp-file-name-handler))
+  (put 'tramp-file-name-handler 'safe-magic t)
   (add-to-list 'file-name-handler-alist
               (cons tramp-completion-file-name-regexp
                     'tramp-completion-file-name-handler))


reply via email to

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