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: Luc Teirlinck
Subject: Re: Null filename ("") is considered to correspond to an existing, readable, and writable file?
Date: Tue, 3 Jan 2006 14:23:36 -0600 (CST)

Drew Adams wrote:

   As to why I "care so much" and the "extreme rarity" of an empty file name,
   I've already given this simple example (twice):

    (while (or (string= "" name) (not (file-readable-p name)))
      (setq name (read-file-name prompt...)))

   The example shows:

In my previous reply, I forgot that read-file-name returns "" if the
user exits with empty input (and _not_ the DEFAULT-FILENAME arg).  So
your real question is why read-file-name does that, a rather different
question from the one you asked.

Here is what the Elisp doc of find-file-name says:

     If the user types <RET> in an empty minibuffer, this function
     returns an empty string, regardless of the value of EXISTING.
     This is, for instance, how the user can make the current buffer
     visit no file using `M-x set-visited-file-name'.

This is what the docstring of set-visited-file-name says:

    FILENAME nil or an empty string means mark buffer as not visiting any
    file.  Remember to delete the initial contents of the minibuffer if
    you wish to pass an empty string as the argument.

So you could make your function do something similar if you want to.
read-file-name returns "" on empty input to allow its caller to attach
a special meaning to exiting with an empty minibuffer.

Sincerely,

Luc.





reply via email to

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