From: Juanma Barranquero <lektu@terra.es>
Cc: emacs-devel@gnu.org
Subject: Re: Bug Emacs 21.3: write-file downcasing
Date: Fri, 07 Feb 2003 16:50:11 +0100 [thread overview]
Message-ID: <20030207163850.3779.LEKTU@terra.es> (raw)
In-Reply-To: <6137-Fri07Feb2003172311+0200-eliz@is.elta.co.il>
On Fri, 07 Feb 2003 17:23:12 +0200, "Eli Zaretskii" <eliz@is.elta.co.il> wrote:
> What was the problem that caused the change in file-truename?
My e-mails to Jason were as follows:
> Hi.
>
> I'm investigating this:
>
> > 2001-11-08 Andrew.Maguire@Smallworld.co.uk (Andrew Maguire) gnu.emacs.bug
> > (file-truename "C:/temp/a_file")
> > returns "C:/temp/a_file" if the file does not exist and
> > "c:/temp/a_file" if it does.
>
> I'm not convinced this is a bug :)
>
> If the file does not exist, the argument is returned unmodified.
>
> OTOH, if the file does exist, eventually normalize_filename (in w32.c)
> gets called, which returns the path and name exactly as it exists in
> the filesystem, but purposefully downcases the drive letter, according
> to this changelog entry:
>
> > 1996-07-03 Andrew Innes <andrewi@harlequin.co.uk>
> >
> > * nt.c (normalize_filename): Always lower-case drive letters, even
> > on systems that preserve case in filenames.
>
> and this source code comment:
>
> > /* Always lower-case drive letters a-z, even if the filesystem
> > preserves case in filenames.
> > This is so filenames can be compared by string comparison
> > functions that are case-sensitive. Even case-preserving filesystems
> > do not distinguish case in drive letters. */
>
> If the return value of file-truename is used in comparisons, then
> perhaps the best answer would be unconditionally downcasing the drive
> letter (in the windows-specific part of the code) even if
> w32-long-file-name returns nil.
>
> OTOH, I'm not sure what's the canonical truename of a non-existent
> file. Doc about file-truename (in the Elisp reference) seems to assume
> the arg is the name of an existing file, but the function takes pains
> to returns a non-nil value even if the file does not exist...
Jason sent me the full user report, which said:
> (file-truename "C:/temp/a_file")
> returns "C:/temp/a_file" if the file does not exist
> and "c:/temp/a_file" if it does.
>
> This causes confusion if you do a find-file on C:/temp/a_file
> edit it and save it. Then do a find-file on c:/temp/a_file.
> You will get two different edits on the same file.
which I followed with:
> The problem is that currently there's no interface between the lisp
> level and the C functions that manipulate filenames, other than
> w32-short-file-name and w32-long-file-name, and both of these return
> nil if the file does not exist.
>
> So to be able to call normalize_filename on a non-existent filename,
> either normalize_filename is "upgraded" to be directly accesible from
> lisp, or it is made accesible through w32-{long|short}-file-name,
> perhaps by adding an additional parameter to those functions that, if
> set to t, would make them return their normalized argument if it does
> not exists as a file. That'd be backward-compatible. To support this
> idea, I don't understand why w32-long-file-name, which is somewhat
> similar in spirit to file-truename, does return nil for unexistent
> files while the later does return a "truename" even if non-existent!
>
> Barring that, the only other answer I can think of is making an ugly
> hack in the nt-specific code of file-truename to unconditionally downcase
> the drive letter.
>
> All in all, I think there's a lack of definition wrt which is the
> right behavior for w32 filenames. It is worse the reported "bug" that
> this one (assuming a_file exists and a_file2 doesn not)?
>
> ELISP> (file-truename "/temp/a_file")
> "c:/temp/a_file"
> ELISP> (file-truename "/temp/a_file2")
> "/temp/a_file2"
and then
> A posible answer, now that I've found untranslated-canonical-name does
> exactly what we needed...
>
> Index: files.el
> ===================================================================
> RCS file: /cvsroot/emacs/emacs/lisp/files.el,v
> retrieving revision 1.538
> diff -u -r1.538 files.el
> --- files.el 2001/11/21 12:00:32 1.538
> +++ files.el 2001/11/21 16:11:49
> @@ -618,7 +618,7 @@
> (setq newname filename)
> ;; If filename doesn't exist, newname will be nil.
> (setq newname (w32-long-file-name filename)))
> - (setq filename (or newname filename)))
> + (setq filename (or newname (untranslated-canonical-name filename))))
> (setq done t)))
>
> ;; If this file directly leads to a link, process that iteratively
and, finally:
> > A posible answer, now that I've found untranslated-canonical-name does
> > exactly what we needed...
>
> Except that untranslated-canonical-name calls expand-file-name, which
> produces:
>
> > ELISP> (file-truename "~")
> > "c:/usr/home"
> > ELISP>
>
> Oops.
>
> Although I'm still puzzled about *what* is the supposed behavior of
> file-truename wrt non-existent files...
/L/e/k/t/u
next prev parent reply other threads:[~2003-02-07 15:50 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-07 5:38 Bug Emacs 21.3: write-file downcasing Dhruva Krishnamurthy
2003-02-07 8:07 ` Juanma Barranquero
2003-02-07 15:23 ` Eli Zaretskii
2003-02-07 15:50 ` Juanma Barranquero [this message]
2003-02-07 17:16 ` Eli Zaretskii
2003-02-07 17:33 ` Juanma Barranquero
2003-02-07 17:57 ` Stefan Monnier
2003-02-07 18:19 ` Eli Zaretskii
2003-02-09 12:39 ` Richard Stallman
2003-02-09 15:52 ` Eli Zaretskii
2003-02-10 4:41 ` Dhruva Krishnamurthy
2003-02-10 5:46 ` Eli Zaretskii
2003-02-10 10:03 ` Dhruva Krishnamurthy
2003-02-10 8:21 ` Jason Rumney
2003-02-10 10:44 ` Juanma Barranquero
[not found] ` <m2smuxcwba.fsf@primate.xs4all.nl>
2003-02-10 22:39 ` Richard Stallman
2003-02-10 22:52 ` Andreas Schwab
2003-02-11 22:25 ` Richard Stallman
2003-02-12 8:28 ` Jason Rumney
2003-02-12 10:26 ` Kim F. Storm
2003-02-12 19:36 ` Jason Rumney
2003-02-12 17:50 ` Kevin Rodgers
2003-02-12 22:19 ` Andreas Schwab
2003-02-14 22:29 ` Kevin Rodgers
2003-02-11 14:53 ` Benjamin Riefenstahl
2003-02-11 23:02 ` Jason Rumney
2003-02-12 13:37 ` Benjamin Riefenstahl
2003-02-12 13:49 ` Andreas Schwab
2003-02-12 14:57 ` Benjamin Riefenstahl
2003-02-12 19:40 ` Jason Rumney
2003-02-07 18:18 ` Eli Zaretskii
2003-02-07 20:19 ` Juanma Barranquero
2003-02-07 23:03 ` Eli Zaretskii
2003-02-07 18:31 ` Jason Rumney
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030207163850.3779.LEKTU@terra.es \
--to=lektu@terra.es \
--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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.