unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
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 07:33:17 -0800	[thread overview]
Message-ID: <E219F4EDC14E4F3589BFE10A33478CBB@us.oracle.com> (raw)
In-Reply-To: <83bpg2g2l8.fsf@gnu.org>

> Even after reading the ELisp node where it is documented?  Could you
> tell what else is missing?

Uh, no, because, as I said, I still don't understand it. When I do, you'll
understand better what is missing or could be stated better.

> > What do you mean by "embedded literal string" in the source 
> > code? If the Emacs source code has (defcustom foo ".emacs"...),
> > do I need to apply c-s-f to foo in order to compare its value?
> 
> Only if the other string is a name of a file that already exists in
> the filesystem.

I'm comparing arbitrary, unknown file names. I don't know the names ahead of
time, and I don't know whether they name existing files.

From what you just said, I will always need to use c-s-f, since one of the files
might be ".emacs" (assuming it appears in Emacs source code as an embedded
literal) and the other might be an existing file.

That's different from your first statement that probably just f-t would be
sufficient. I used (c-s-f (f-t FILE)), but you suggested that (f-t FILE) would
be sufficient.

But I've probably got this all wrong, because I still don't understand it. I
still haven't heard (or haven't understood, if in fact you've said it) what
c-s-f is _for_: what use cases. Perhaps you can give some useful examples of
calling it and why it's needed for those calls - what can go wrong if it's not
called in those cases.

> > And does "Emacs sources" apply only to code distributed with Emacs
> > or to any Emacs-Lisp source code?
> 
> The latter, of course.

So any occurrence of a literal string in any Emacs-Lisp (or C?) code? If that
particular name is used as a file name, then one needs to wrap c-s-f around it
when it is so used? That's hard to believe.

> > And you seem to say two things: a "file name embedded as a 
> > literal string" and "a name of a file mentioned in Emacs sources".
> > Is c-s-f needed for certain file names (e.g. those "mentioned" in
> > Emacs sources) or for certain strings (e.g. literal strings in
> > distributed source code) that name files?
> 
> ``Literal string'' is the main issue here.  That's why this function
> was introduced in the first place: to seamlessly take care of all the
> places in Emacs Lisp sources where there's a literal string serving as
> a file name, and that string might be an invalid file name on some
> filesystems.

I'm beginning to understand, I think.

It sounds like c-s-f is something to use at the point where the literal string
is introduced into the code - and only then. If code is written so that any
literal string that might be used as a file name is first wrapped with c-s-f
before being bound our assigned to a variable, and there are no other literal
occurrences of it, then one should be OK. Is that it?

What about a literal string that is not in code, but is provided by a user
interactively or constructed dynamically (e.g. (concat ".em" "acs"))? If a
prompt asks a user where to save his blahs, and he answers ".emacs.blah", does
code that handles that filename then need to wrap it with c-s-f? And does it
matter whether the file in question already exists (as was stated before)?

I'm guessing that the answers here are no and no, that it applies only to
strings in code and it has nothing to do with whether the files named already
exist. But please let me know.

> > IOW, is it about the name or the actual string object?
> 
> It's about the names that are valid on some systems, but not on
> others.

So it is _not_ the string that's important. So it is also not the fact that a
literal string is in code (as opposed to being entered or created dynamically).
(concat ".e" "macs") is just as problematic as ".emacs", and needs to be wrapped
with c-s-f. Is that it?

Very sorry, but as you can see, this is still not clear at all to me. You say
its the presence of a literal string that's problematic, then you say it's the
name itself that is problematic, since a file with that name might not be
possible on some system.

Every statement you make makes me think I understand a bit, until I reach the
next statement, which seems to say something different. I'm sure that once I
understand then all of the statements will make sense together, but so far they
do not, for me.

> > Does it matter whether it's (string= (file-truename 
> > ".emacs") (file-truename bar)) or (string= (file-truename foo)
> > (file-truename bar)), where foo's value is
> > ".emacs"? Is c-s-f needed in the former case but not the latter?
> 
> It is needed in the first case, if `bar' is the name of a file already
> existing in the filesystem, because on MS-DOS, `bar' could be "_emacs"
> instead.

But .emacs and _emacs could be two different files on MS-DOC, no? I'm not
familiar with MS-DOS - is a file named ".emacs" impossible (unlike Windows)?

> It _may_ be needed in the second case if one of `foo' or
> `bar' is a string whose value is ".emacs", while the other is the name
> of a file already existing in the filesystem.  It is _not_ needed if
> both `foo' and `bar' hold names of files already existing on
> filesystems of the same type.
> 
> > Obviously, I'm not yet understanding what this is about. 
> > Does it have something
> > to do with strings that are defined before Emacs gets dumped?
> 
> No, Emacs dumping is not the issue here, at least not directly.  For
> defcustoms, it's not an issue because a defcustom is evaluated again
> when a dumped Emacs starts.  So if the filesystem where it was dumped
> is different from the one where it starts, the name will be
> recomputed anew.

Hm. But there _are_ lots of defcustoms that use c-s-f. (I was mistaken about
defcustoms with f-t, but not c-s-f.)

I think that with just a little more help, especially some examples, I might get
it. But I'm not there yet. Some examples without it that are problematic, and
just what the problems are (bad consequences). And the same examples fixed to
use c-s-f. Thx.






  reply	other threads:[~2010-02-06 15:33 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 [this message]
2010-02-06 19:33         ` Eli Zaretskii
2010-02-06 20:46           ` Drew Adams
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=E219F4EDC14E4F3589BFE10A33478CBB@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).