[Top][All Lists]

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

bug#10319: 24.0.92; doc string of `file-remote-p'

From: Michael Albinus
Subject: bug#10319: 24.0.92; doc string of `file-remote-p'
Date: Mon, 19 Dec 2011 19:26:31 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

"Drew Adams" <address@hidden> writes:

>> > If so, let's just say that: It never opens a new remote
>> > connection.  It can only reuse a connection that is
>> > already open.
>> Sounds OK to me.
> Let's do that then.  IMO, that will avoid some misunderstanding.
>> It is also an implementation hint. Any handler that provides an own
>> implementation of `file-remote-p' shall behave like this.
>> `tramp-handle-file-remote-p' and `ange-ftp-file-remote-p' do so.
> I doubt that trying to hint that in the doc string will help more than
> hurt user understanding.  IMO we would either need to spell that out
> clearly or put it in comments in the code.

I didn't intend to include it as such. It is an implicit implementation

> I think the latter is preferable.  The doc string should be aimed
> mainly at users of the function, not at implementors of substitute
> definitions of it.  But all of that kind of thing can be stated
> clearly in the source file for those to whom it is useful.


>> As a consequence, the result might differ whether a connection is
>> already open, or not. If the connection is not established yet, we get
>> (file-remote-p "/ssh::" 'localname) => ""
>> If there is an established connection, we see
>> (file-remote-p "/ssh::" 'localname) => "/home/albinus"
> That might be worth pointing out in the doc string.  It might be
> useful to users of the function.  Perhaps you could just add text like
> this:
>   "The return value can differ depending on whether there
>    is an existing connection."

We shall mention that the return value is still a string. And the
difference happens only for localname parts.

> Do we want to say more than that?  Is there some rule about this?
> E.g., if no existing connection is the return value _always_ ""?  If
> no rule, then just adding that sentence (or similar) should be enough.

I wouldn't give a rule. There are other cases, like (file-remote-p
"/ssh::" 'localname), which returns "~" when there is no connection, and
"/home/albinus" otherwise.

Combining your proposals, the docstring could be

  "Test whether FILE specifies a location on a remote system.  Returns
   nil or a string identifying the remote connection (ideally a prefix
   of FILE).  For example, the remote identification for filename
   "/address@hidden:/foo" could be "/address@hidden:".  A file is considered
   "remote" if accessing it is likely to be slower or less reliable than
   accessing local files.  Furthermore, relative file names do not work
   across remote connections.

   IDENTIFICATION specifies which part of the identification shall be
   returned as string.  IDENTIFICATION can be the symbol `method',
   `user', `host' or `localname'; any other value is handled like nil
   and means to return the complete identification string.  The string
   returned for IDENTIFICATION `localname' can differ depending on
   whether there is an existing connection."

   If CONNECTED is non-nil, the function returns an identification only
   if FILE is located on a remote system, and a connection is
   established to that remote system.

  `file-remote-p' never opens a new remote connection.  It can only
   reuse a connection that is already open."

> Thx - Drew

Best regards, Michael.

reply via email to

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