From: "Drew Adams" <drew.adams@oracle.com>
To: "'Eli Zaretskii'" <eliz@gnu.org>
Cc: emacs-devel@gnu.org
Subject: RE: file-truename, convert-standard-filename
Date: Sat, 6 Feb 2010 12:46:02 -0800 [thread overview]
Message-ID: <07544B532C8E490F96FE0B1CF403C510@us.oracle.com> (raw)
In-Reply-To: <834oluf9c8.fsf@gnu.org>
> Let me try to step back a notch and try anew.
Thank you.
> There's a problem with file names, such as ".emacs", defined in Emacs
> Lisp code as literal strings: some filesystems don't allow such
> names. `convert-standard-filename' was introduced to take a Posix
> file name and produce from it a file name that can be used instead on
> the particular filesystem. So instead of
> (defvar foo-file
> (if (eq system-type 'foo)
> "this"
> (if (eq system-type 'bar)
> "that"
> ....
> we can now have just this:
> (defvar foo-file (convert-standard-filename "this"))
>
> So far so good?
Yes.
> Same considerations apply when a file name is constructed from
> fragments, like in (append ".emacs." (user-full-name) ".log")
OK. (But I think you meant `concat', not `append'.)
So it in fact has nothing specially to do with literal strings in source code.
That was apparently a red herring. (But you keep repeating it - e.g. see above;
so I wonder.)
This is the general rule, apparently:
> In order to get a file name that any supported platform could use, you
> need to run the result of this through `convert-standard-filename'.
> Okay?
I think so.
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.
Am I wrong about that?
That would mean that the original code I showed would be necessary, and that
using f-t alone, without c-s-f, would not be sufficient. This is the original
code:
(string= (c-s-f (f-t FILE1)) (c-s-f (f-t FILE2)))
So am I misunderstanding now, or was your advice wrong that just f-t suffices
here? I'm not trying to point fingers - I appreciate your patient efforts to
explain; I'm just trying to understand.
> 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? If I don't know which file system a user has, and I don't know
which file names are involved, then my code needs to call c-s-f for each file
name. No?
> like e.g. a literal `?' on a
> Windows disk. An arbitrary string generally needs such a treatment,
> before it can safely be used as a file name. That's why Emacs
> defcustoms use it.
>
> Any questions so far?
I think I understand now - see above.
c-s-f is needed for an arbitrary string.
Confirmation or correction is welcome.
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.
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.
You seem to be saying that it's _nearly always needed_, unless (a) you know
which file system is being used, (b) you know the file name being used, and (c)
you know that that particular file name is a valid one for that particular file
system.
I haven't analyzed the Emacs code, but I don't get the impression that (a), (b),
and (c) are true for each file-name occurrence where it doesn't call c-s-f.
Maybe adding c-s-f everywhere is an ongoing thing, and the code just hasn't yet
caught up with the rule?
Thx - Drew
next prev parent reply other threads:[~2010-02-06 20:46 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-05 17:31 file-truename, convert-standard-filename Drew Adams
2010-02-05 18:15 ` Andreas Schwab
2010-02-05 18:33 ` Lennart Borgman
2010-02-05 19:45 ` Andreas Schwab
2010-02-05 19:49 ` Lennart Borgman
2010-02-05 20:14 ` Stefan Monnier
2010-02-05 20:18 ` Lennart Borgman
2010-02-06 1:10 ` Miles Bader
2010-02-05 23:51 ` Drew Adams
2010-02-05 19:04 ` Eli Zaretskii
2010-02-05 23:51 ` Drew Adams
2010-02-06 0:17 ` Lennart Borgman
2010-02-06 8:45 ` Eli Zaretskii
2010-02-06 16:55 ` Lennart Borgman
2010-02-06 19:12 ` Eli Zaretskii
2010-02-06 19:20 ` Lennart Borgman
2010-02-06 9:01 ` Eli Zaretskii
2010-02-06 15:33 ` Drew Adams
2010-02-06 19:33 ` Eli Zaretskii
2010-02-06 20:46 ` Drew Adams [this message]
2010-02-06 21:58 ` Eli Zaretskii
2010-02-06 23:12 ` Drew Adams
2010-02-07 4:01 ` Eli Zaretskii
2010-02-08 1:38 ` Stefan Monnier
2010-02-08 2:46 ` Drew Adams
2010-02-26 18:33 ` Davis Herring
2010-02-26 19:12 ` Drew Adams
2010-02-26 19:35 ` Davis Herring
2010-02-26 20:25 ` Drew Adams
-- strict thread matches above, loose matches on Subject: below --
2010-02-06 3:52 MON KEY
2010-02-06 8:28 ` Eli Zaretskii
[not found] ` <d2afcfda1002061814nc3e178fl5d93e21ea6bae7b5@mail.gmail.com>
2010-02-07 2:16 ` MON KEY
[not found] ` <83wrypelms.fsf@gnu.org>
2010-02-07 23:26 ` MON KEY
2010-02-08 0:28 ` Andreas Schwab
2010-02-08 4:10 ` Eli Zaretskii
[not found] ` <d2afcfda1002091330y53017b24w5e6bdf3c3d131a97@mail.gmail.com>
2010-02-09 21:32 ` MON KEY
2010-02-09 21:59 ` Andreas Schwab
2010-02-09 22:32 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=07544B532C8E490F96FE0B1CF403C510@us.oracle.com \
--to=drew.adams@oracle.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).