emacs-devel
[Top][All Lists]
Advanced

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

Re: file-truename, convert-standard-filename


From: Eli Zaretskii
Subject: Re: file-truename, convert-standard-filename
Date: Sat, 06 Feb 2010 23:58:13 +0200

> From: "Drew Adams" <address@hidden>
> Cc: <address@hidden>
> Date: Sat, 6 Feb 2010 12:46:02 -0800
> 
> That means that in order to use ANY file name (any file-name string, no matter
> where it was coded or how it is produced), you need to apply c-s-f to it, if 
> you
> don't know whether the name is supported by all platforms that might be used 
> by
> your code.

Again, the case when the string is known to be a name of an existing
file is the important exception.  For example, if it comes from
buffer-file-name, or from default-directory, or from other similar
interfaces.

> > If this part is understood, then just use `convert-standard-filename'
> > in any situation where a string to be used as a file name might not be
> > valid on the underlying filesystem, 
> 
> Which for an unknown string (e.g. the string value of a variable) means ALL
> situations, no?

It could be, unless, again, you know that a file by that name already
exists.

> BTW, I notice that prior to Emacs 23 the Emacs source code did not use c-s-f
> very much (e.g. defcustoms, such as in recentf.el); Emacs 23 uses it much 
> more.
> I suppose this means that we had more problems with this before Emacs 23.

No, it just means we made some cleanup.  The situations where this
really matters are very rare, and if you ignore the MS-DOS case, are
almost non-existent.  People rarely use characters in file names that
get you in trouble on MS-Windows.  And if the file name comes from the
user, you can almost be certain she will never use such characters,
and even if she does, she deserves the error message.

About the only real use-case is when the file name comes from the Lisp
code itself.  Which is why I mentioned literal strings so many times.

> But it does not seem like even the Emacs 23 source code calls c-s-f for all of
> the situations that I think you're describing.

It does where we are certain it matters.  See files.el for a few
examples.

> Maybe adding c-s-f everywhere is an ongoing thing, and the code just hasn't 
> yet
> caught up with the rule?

Something like that.  But again, many places will never need it.




reply via email to

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