[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Stefan Monnier
Subject: Re: $USERPROFILE for $HOME on W32
Date: Fri, 26 Nov 2004 09:47:50 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux)

>> > Lisp means, e.g., that temacs will have different ideas about HOME
>> > etc. than the dumped Emacs, which I think might confuse someone some
>> Huh?  Of course HOME is different before and after the dump.
>> How could it be otherwise?

> We are emulating a Posix system where HOME's value is something
> determined outside Emacs.  If you set HOME in init_environment, it
> will be the same before and after dumping, as it is on a Posix system,
> since init_environment is called unconditionally in the W32 port, and
> called very early in the initialization process, way before the Lisp
> interpreter is started and any application-level code runs.

Obviously I don't understand what you mean by "before" and "after" dumping.
When I build on my GNU/Linux system, before dump HOME=/u/monnier, and after
dump HOME=/u/fernanda, /u/monnier/, /u/root, /u/guest, ...

> The way you suggested to do it, not only will it be different before
> and after the dumping, but it also changes its value in the middle of
> loadup, because startup.el is loaded after many other Lisp files.

Huh?  The code is not run when startup.el is loaded.  It's run when we call

> Such a change is unexpected by any reasonable Emacs hacker, and could
> cost someone several hours of useless ``debugging'', or even real bugs
> if some preloaded Lisp file references HOME's value.

That would screw up anyone who runs an Emacs he hasn't built himself.
I.e. 99% of the users.  I think we'd know about it by now.

> Why insist on doing that when there's a cleaner way?  For that matter, is
> there any reason at all to favor doing this in Lisp?  I don't think I've
> heard even a single reason in favor; did I miss something?

I find it much easier to write (file-writable-p "~/.emacs").  And I know it
will not dump a core, even if I mess up badly.

>> > This change means that we run this code every time getpwuid is called.
>> Right.  Just as we do it on Unix (except on Unix we only do it for HOME
>> and not for SHELL).
> Unix is a different matter.  The W32 port emulates a single user, so
> the values are guaranteed to be constant.  The right way to impement
> such emulations is to use static variables initialized only once.

This has nothing to do with single-user or not.  On Unix we are also
guaranteed that the uid will not change under us while running Emacs.
And yet, everytime we do getpwnam, we rebuilt its value to obey the current
value of $HOME, in case the user changed it with (setenv "HOME" foo).
Read the source.
And BTW, W32 is not very different w.r.t single or multi user.  The GUI
makes it difficult to have more than one person logged in at the same time,
but other than that it's basically just the same.

> It's just one of several minor reasons.  I never said your suggestion
> was a catastrophe, only that there's a slightly better way.  But if
> what I said, and the fact that Jason also preferred doing that in C,
> don't convince you, then probably nothing will; I give up.

My opinion is that something should be done in C only if it can't be done in
elisp, or if it's inconvenient to do it in elisp, or if doing it in elisp is
too costly performancewise.
I don't think any of those 3 cases applies here.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]