* net/ange-ftp.el (ange-ftp-file-name-completion): Handle optional
[bpt/emacs.git] / lisp / net / tramp.el
index 6a46486..3cdcfd7 100644 (file)
@@ -2856,7 +2856,8 @@ of."
 
 
 ;; The following isn't needed for Emacs 20 but for 19.34?
-(defun tramp-handle-file-name-completion (filename directory)
+(defun tramp-handle-file-name-completion
+  (filename directory &optional predicate)
   "Like `file-name-completion' for tramp files."
   (unless (tramp-tramp-file-p directory)
     (error
@@ -2866,7 +2867,8 @@ of."
     (try-completion
      filename
      (mapcar (lambda (x) (cons x nil))
-            (file-name-all-completions filename directory)))))
+            (file-name-all-completions filename directory))
+     predicate)))
 
 ;; cp, mv and ln
 
@@ -4627,10 +4629,13 @@ Falls back to normal file name handler if no tramp file name handler exists."
 
 ;; Method, host name and user name completion for a file.
 ;;;###autoload
-(defun tramp-completion-handle-file-name-completion (filename directory)
+(defun tramp-completion-handle-file-name-completion
+  (filename directory &optional predicate)
   "Like `file-name-completion' for tramp files."
-  (try-completion filename
-   (mapcar 'list (file-name-all-completions filename directory))))
+  (try-completion
+   filename
+   (mapcar 'list (file-name-all-completions filename directory))
+   predicate))
 
 ;; I misuse a little bit the tramp-file-name structure in order to handle
 ;; completion possibilities for partial methods / user names / host names.
@@ -6965,8 +6970,8 @@ localname (file name on remote host)."
        item)
     (while choices
       (setq item (pop choices))
-      (when (and (string-match (nth 0 item) (or host ""))
-                (string-match (nth 1 item) (or user "")))
+      (when (and (string-match (or (nth 0 item) "") (or host ""))
+                (string-match (or (nth 1 item) "") (or user "")))
        (setq method (nth 2 item))
        (setq choices nil)))
     method))