It's annoyed me for some time that the native Windows version of XEmacs
often ends up with two (or more) buffers visiting the same file, even if
find-file-compare-truenames or find-file-use-truenames is set.
It turns out that this is because file-truename isn't working well on
Windows. XEmacs assumes that file-truename will always return the same
thing for a given file, no matter what path you use to get to the file.
This isn't true on Windows. The case in the path may vary, path components
may be short names or long names, etc.
Ffile_true calls xrealpath which makes a feeble attempt to be Windows
compatible, but largely fails (for example it assumes "/" as a directory
separator, but is only called with paths using "\"). While it would be
possible to fix this, there was already another function that did pretty
much what is needed: win32_get_long_filename which is only called by
Fwin32_long_file_name. The latter function doesn't seem to be used in any
of the C or Lisp code that I have.
The attached patch changed Ffile_truename to use win32_get_long_filename on
Windows after changing it to do something reasonable when given a path that
contains a file or directory that doesn't exist. This latter change might
cause a problem with code that used win32-long-file-name to test for the
existence of a file, but I can't find any code that uses it at all, let
alone for that purpose. I also changed xemacs.mak to remove realpath.c
from the native Windows build since it isn't needed anymore. With this
patch I haven't had any more problems with multiple buffers visiting the
same file if I set find-file-compare-truenames or find-file-use-truenames.
Let me know if you find any problems with this. I reworked it slightly
tonight and it's possible I introduced a bug into it, but I've been using a
similar patch for a week or so without problems. I'm probably not going to
have time to commit this before I go on holiday, but I'll do it when I come
back if no one objects and no one beats me to it.
src/Changelog:
2000-08-27 Mike Alexander <mta(a)arbortext.com>
* nt.c (win32_get_long_filename): Return something for
non-existant files and directories
* fileio.c: Include nt.h in Windows native build
* fileio.c (Ffile_truename): Use win32_get_long_filename in
Windows native build and use the correct directory sep character
when adding one to the end of a directory path.
nt/Changelog:
2000-08-27 Mike Alexander <mta(a)arbortext.com>
* xemacs.mak: Remove realpath.c
Show replies by date