Charles G Waldman <cgw(a)pgt.com> writes:
(setenv "HOME" "/home/cgw")
(insert (getenv "HOME")) /home/cgw
(insert (expand-file-name "test" "~/test/")) c:\home\cgw\test\test
It would have been more convenient if your tried this with HOME !=
CWD, I think it is not adding your home directory here but just the CWD.
(setenv "HOME" "\\\\reactor\\cgwhome")
(insert (getenv "HOME")) \\reactor\cgwhome
(insert (expand-file-name "test" "~/test/")) c:\home\cgw\test\test
See, no 'reactor' at all.
I noticed something else
> if (IS_DIRECTORY_SEP (nm[1])
> || nm[1] == 0) /* ~ by itself */
> {
> if (!(newdir = (Bufbyte *) get_home_directory()))
> newdir = (Bufbyte *) "";
> nm++;
> #ifdef WINDOWSNT
> collapse_newdir = 0;
> #endif
> }
If I read correctly if nm == "~/fubar" this sets newdir = HOME and
"nm = /fubar".
However, later on it does
/* Effectively, let newdir be (expand-file-name newdir cwd).
Because of the admonition against calling expand-file-name
when we have pointers into lisp strings, we accomplish this
indirectly by prepending newdir to nm if necessary, and using
cwd (or the wd of newdir's drive) as the new newdir. */
[..]
if (!IS_DIRECTORY_SEP (nm[0]))
{
char * tmp = alloca (strlen (newdir) + strlen (nm) + 2);
file_name_as_directory (tmp, newdir);
strcat (tmp, nm);
nm = tmp;
}
newdir = alloca (MAXPATHLEN + 1);
So it only copies the newdir in front if nm[0] != '/' (because you do
want to have the default-directory in front of absolute names). After
that it throws newdir away.
However in our case the "/" is just there by accident
So try making it
if (!IS_DIRECTORY_SEP (nm[0]) || !collapse_newdir)
{
char * tmp = alloca (strlen (newdir) + strlen (nm) + 2);
and removing the "&& collapse_newdir" later on.
However I must be overseeing something is as this means setting HOME
on NT has never worked and that I really cannot believe.
Jan