From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.tramp,gmane.emacs.devel Subject: Re: CORRECT VERSION: tramp (2.0.51); tramp and file-name-all-completions Date: Tue, 18 Oct 2005 10:47:00 +0200 Message-ID: References: <87r7aklpcf.fsf@gmx.de> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1129628786 3851 80.91.229.2 (18 Oct 2005 09:46:26 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 18 Oct 2005 09:46:26 +0000 (UTC) Cc: tramp-devel@gnu.org, emacs-devel@gnu.org Original-X-From: tramp-devel-bounces+tramp=quimby.gnus.org@gnu.org Tue Oct 18 11:46:25 2005 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by ciao.gmane.org with esmtp (Exim 4.43) id 1ERo2Q-0006fu-Mc for tramp@deer.gmane.org; Tue, 18 Oct 2005 11:45:42 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1ERo2Q-0004a5-00 for ; Tue, 18 Oct 2005 11:45:42 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ERo2P-0000no-Jr for tramp@quimby.gnus.org; Tue, 18 Oct 2005 05:45:41 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ERn8B-0002dR-Lv for tramp-devel@gnu.org; Tue, 18 Oct 2005 04:47:37 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ERn7t-0002cz-R9 for tramp-devel@gnu.org; Tue, 18 Oct 2005 04:47:21 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ERn7k-0002cf-2X; Tue, 18 Oct 2005 04:47:10 -0400 Original-Received: from [194.113.59.95] (helo=mailrelay1.alcatel.de) by monty-python.gnu.org with esmtp (Exim 4.34) id 1ERn7j-0002xQ-TE; Tue, 18 Oct 2005 04:47:08 -0400 Original-Received: from slbwba.alcatel.de (slbwba.bln.sel.alcatel.de [149.204.93.70]) by mailrelay1.alcatel.de (8.12.10/8.12.10/ICT TSC MAIL 2005) with ESMTP id j9I8l0G0010731; Tue, 18 Oct 2005 10:47:00 +0200 Original-To: storm@cua.dk (Kim F. Storm) In-Reply-To: (Kim F. Storm's message of "Tue, 18 Oct 2005 01:05:37 +0200") User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/20.7 (hpux) X-Scanned-By: MIMEDefang 2.49 on 149.204.45.72 X-BeenThere: tramp-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: tramp-devel.gnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: tramp-devel-bounces+tramp=quimby.gnus.org@gnu.org Errors-To: tramp-devel-bounces+tramp=quimby.gnus.org@gnu.org Xref: news.gmane.org gmane.emacs.tramp:2883 gmane.emacs.devel:44250 Archived-At: storm@cua.dk (Kim F. Storm) writes: >>> I used it in ido, and it seems to work: >>> >>> ;; work around bug in ange-ftp. >>> ;; /ftp:user@host: => nil >>> ;; /ftp:user@host:./ => ok >>> (and >>> (not (string= "/ftp:" dir)) >>> (or >>> (string-match "\\`/ftp:.*:\\'" dir) >>> (and (string= tramp-default-method "ftp") >>> (string-match "\\`/[^/:]+:\\'" dir))) >>> (file-name-all-completions "" (concat dir "./")))))) >> >> This works for Tramp 2.0. It will work for Tramp 2.1 too, but there >> are also other means to derive a default methold. For the time being >> you might use a comment for this. > > What code will I need to be 2.1 compatible? Tramp uses internally `tramp-ftp-file-name-p' for ange-ftp and `tramp-efs-file-name-p' for efs. Both functions expect a proper Tramp file name syntax; you should check it before. Something like this: ;; work around bug in ange-ftp. ;; /ftp:user@host: => nil ;; /ftp:user@host:./ => ok (and (tramp-tramp-file-p dir) (fboundp 'tramp-ftp-file-name-p dir) (funcall 'tramp-ftp-file-name-p dir) (string-match ":\\'" dir) (file-name-all-completions "" (concat dir "./"))) This should work for both Tramp 2.0 and 2.1; there are no plans to change the interface. >>> (file-directory-p "/telnet:kfs@") >>> or >>> (file-directory-p "/telnet:kfs@:") >>> >>> tramp signals "Login failure" in both cases. >> >> I know. This problem has eaten most of the time yesterday. In fact I >> don't know a safe decision whether a file name shall be completed only >> or "applied". Therefore I've introduced a new variable >> tramp-completion-mode, which is set in >> file-name-all-completions. Sensible Tramp file name functions, which >> need to behave depending on the mode, check this variable (beside >> other checks). So you might use it as well (untested, I'm @work): >> >> (let ((tramp-completion-mode t)) >> (file-directory-p "/telnet:kfs@")) > > This still cause the "Login Failed" error... > > In any case, I don't quite understand how to use this. How can ido > know whether it makes sense to set tramp-completion-mode or not? It cannot, because my proposal was nonsense. The problem is that `file-directory-p' can give only an answer when it accesses the remote host. If it is urged to just reply nil under special circumstances, it is not worth to be called. When you're doing file name completion, the file name is not complete, and calling `file-directory-p' would try to access a host which does not exist. What we could do is to introduce an option saying "access this host only if there is already a connection". This would avoid the "Login Failed" error you've mentioned. The question is what `file-directory-p' should return in case there isn't a connection yet: nil, or a dont-know value as Richard did suggest? Best regards, Michael.