[Top][All Lists]

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

RE: file-truename, convert-standard-filename

From: Davis Herring
Subject: RE: file-truename, convert-standard-filename
Date: Fri, 26 Feb 2010 11:35:03 -0800 (PST)
User-agent: SquirrelMail/1.4.8-5.7.lanl7

> If my code gets a file name from the user, and I can't depend on it
> being valid for the given platform, why would I *not* need to call
> `convert...'? Just wondering. Seems to me this would be similar to the
> literal-file-name-string-in-code situation.

What harm comes from not calling it?  There are plenty of ways that
filenames can be useless without `convert-standard-filename' even being
able to help.  The filename might reside in a directory to which the user
has no access, or it might involve a directory that doesn't exist, or be a
file you want to open for writing on a read-only filesystem, or...  In
other words, your code already has to be capable of dealing with the
user's filename causing an error when you try to use it.  That the error
might be "invalid character" rather than "permission denied" is
irrelevant; the user has the intelligence (that literal strings lack) to
address the problem, so just report it.

The error message that Emacs receives from the system in case of an
invalid file name might be unhelpful (not tell the user what was wrong
with their filename).  Nonetheless, transparently changing (on Windows) a
user's value of "really?" to "really_" (or whatever) is Not The Right
Thing.  If it turns out that such uninformative errors are a problem, we
instead need

(defun filename-valid-p (f) (not (equal f (convert-standard-filename f))))
; or similar

that you can test when the error occurs so as to substitute a more helpful
error message.

> Anyway, thanks for the extended explanation. It was what I eventually
> had understood from the thread, but it helps in any case. If it had
> come earlier in the thread, it might have made the thread shorter. ;-)

If the thread had been shorter, I might not have gotten so far behind and
the reply might have come earlier.  ;)


This product is sold by volume, not by mass.  If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during

reply via email to

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