emacs-devel
[Top][All Lists]
Advanced

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

Re: Null filename ("") is considered to correspond to an existing, read


From: Eli Zaretskii
Subject: Re: Null filename ("") is considered to correspond to an existing, readable, and writable file?
Date: Tue, 03 Jan 2006 07:32:24 +0200

> From: "Drew Adams" <address@hidden>
> Date: Mon, 2 Jan 2006 19:27:56 -0800
> 
> Besides, where is the section of the manual that says that, unless stated
> otherwise, all file-name arguments to functions are relative

This is a basic notion of every filesystem: every file is relative to
the current directory, unless it begins with the root directory
string.  I don't thing the Emacs manual should teach such basics.

> and they are all relative to the `default-directory'?

In Emacs, `default-directory' is the variable that stores the current
directory that is in effect when you are in that file's buffer.  The
Emacs manual says in the node "File Names":

       Each buffer has a default directory which is normally the same as the
    directory of the file visited in that buffer.  When you enter a file
    name without a directory, the default directory is used.  If you specify
    a directory in a relative fashion, with a name that does not start with
    a slash, it is interpreted with respect to the default directory.  The
    default directory is kept in the variable `default-directory', which
    has a separate value in every buffer.

Clear enough?

> Beyond the doc, wouldn't you expect functions with these names to return nil
> for a "" argument? What's the purpose of not checking this case, correctly
> applying the meaning of the function's name and returning nil?
> 
> Is it so that you can use (file-exists-p "") to test the existence of
> directory `default-directory'? What's the advantage of such a "feature"?
> There are other, more readable ways to test that: (file-exists-p
> default-directory), for instance.
> 
> Sorry, I still don't get it. Why is the design like this?

This was discussed here some months ago, although I couldn't find that
thread in the few minutes I had to look for it.




reply via email to

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