[Top][All Lists]

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

Re: testing for a remote file to include file on a Windows mappeddrive

From: Michael Albinus
Subject: Re: testing for a remote file to include file on a Windows mappeddrive
Date: Sun, 03 Feb 2008 14:36:45 +0100
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

> Hmm... I see your point and now I'm not so sure about the function
> I propose.  I always thought that for process-file and
> start-file-process, the best option was always to use
> file-relative-name, but then the same argument should apply to my
> file-local-name.  So the main missing feature is to figure out whether
> that relative name will work, which depends on whether
> unhandled-file-name-directory returns something that works or not.

unhandled-file-name-directory is something that shall provide
`call-process' and `start-process' with a suitable default
directory. That's why Tramp always returns "~/", and ange-ftp does
"/tmp/". It doesn't look like it is usable in the `process-file' and
`start-file-process' cases.

file-relative-name might be sufficient in obvious cases:

  (file-relative-name "/sudo::/var/syslog/syslog.log" "/sudo::")
    => "../var/syslog/syslog.log"


  (file-relative-name "/sudo::/var/syslog/syslog.log" "/ssh::")
    => "/sudo:address@hidden:/var/syslog/syslog.log"

This is correct, but inconvenient.

> I suggest to change unhandled-file-name-directory so that it can (and
> should) return nil if the named file/directory cannot be
> directly accessed.

... from a local subprocess. It shall not be used for default
directories of `process-file' and `start-file-process'.

> And then let users of unhandled-file-name-directory
> default to "~/" if it returned nil.  Then we can define file-local-name
> as follows:
>   (defun file-local-name/unhandled-file-name (file)
>     (setq file (expand-file-name file))
>     (let ((dir (unhandled-file-name-directory file)))
>       (if file (expand-file-name (file-name-nondirectory file) dir))))
> or alternatively, we can add file-local-name/unhandled-file-name and
> drop unhandled-file-name-directory (which can be defined then as
>   (defun unhandled-file-name-directory (file)
>     (unhandled-file-name (file-name-directory (expand-file-name
>     file))))

I agree. It doesn't make sense for Tramp and ange-ftp, guessing what
might be a good default directory for `call-process' and `start-process'.
They shall simply apply `ignore'; alternatively it shall not be called
per file-name-handler.

>         Stefan

Best regards, Michael.

reply via email to

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