[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: CORRECT VERSION: tramp (2.0.51); tramp and file-name-all-completion
Re: CORRECT VERSION: tramp (2.0.51); tramp and file-name-all-completions
Tue, 18 Oct 2005 10:47:00 +0200
Gnus/5.1002 (Gnus v5.10.2) Emacs/20.7 (hpux)
address@hidden (Kim F. Storm) writes:
>>> I used it in ido, and it seems to work:
>>> ;; work around bug in ange-ftp.
>>> ;; /ftp:address@hidden: => nil
>>> ;; /ftp:address@hidden:./ => ok
>>> (not (string= "/ftp:" dir))
>>> (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:address@hidden: => nil
;; /ftp:address@hidden:./ => ok
(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@")
>>> (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
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
Best regards, Michael.