[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: $USERPROFILE for $HOME on W32
From: |
Stefan Monnier |
Subject: |
Re: $USERPROFILE for $HOME on W32 |
Date: |
Thu, 25 Nov 2004 11:00:39 -0500 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux) |
Here is a new patch. Could people try it out and tell me if it works?
And tell me how to fix it (I can't try it out, I wish someone could help me
out, really, because coding and debugging blindly like that isn't much fun).
Stefan
Index: src/w32.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32.c,v
retrieving revision 1.89
diff -u -r1.89 w32.c
--- src/w32.c 19 Oct 2004 19:08:58 -0000 1.89
+++ src/w32.c 25 Nov 2004 16:03:01 -0000
@@ -1,5 +1,5 @@
/* Utility and Unix shadow routines for GNU Emacs on the Microsoft W32 API.
- Copyright (C) 1994, 1995, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1994, 1995, 2000, 2001, 2004 Free Software Foundation, Inc.
This file is part of GNU Emacs.
@@ -424,7 +424,12 @@
getpwuid (int uid)
{
if (uid == the_passwd.pw_uid)
- return &the_passwd;
+ {
+ /* Set dir and shell from environment variables. */
+ strcpy (the_passwd.pw_dir, getenv ("HOME"));
+ strcpy (the_passwd.pw_shell, getenv ("SHELL"));
+ return &the_passwd;
+ }
return NULL;
}
@@ -531,16 +536,6 @@
the_passwd.pw_gid = 123;
}
- /* Ensure HOME and SHELL are defined. */
- if (getenv ("HOME") == NULL)
- abort ();
- if (getenv ("SHELL") == NULL)
- abort ();
-
- /* Set dir and shell from environment variables. */
- strcpy (the_passwd.pw_dir, getenv ("HOME"));
- strcpy (the_passwd.pw_shell, getenv ("SHELL"));
-
if (token)
CloseHandle (token);
}
@@ -949,11 +944,9 @@
char * def_value;
} env_vars[] =
{
- {"HOME", "C:/"},
{"PRELOAD_WINSOCK", NULL},
{"emacs_dir", "C:/emacs"},
{"EMACSLOADPATH",
"%emacs_dir%/site-lisp;%emacs_dir%/../site-lisp;%emacs_dir%/lisp;%emacs_dir%/leim"},
- {"SHELL", "%emacs_dir%/bin/cmdproxy.exe"},
{"EMACSDATA", "%emacs_dir%/etc"},
{"EMACSPATH", "%emacs_dir%/bin"},
/* We no longer set INFOPATH because Info-default-directory-list
Index: lisp/w32-fns.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/w32-fns.el,v
retrieving revision 1.54
diff -u -r1.54 w32-fns.el
--- lisp/w32-fns.el 30 May 2004 21:19:06 -0000 1.54
+++ lisp/w32-fns.el 25 Nov 2004 16:03:01 -0000
@@ -195,6 +195,28 @@
(goto-char (point-min)))
+
+(defun w32-early-setenv ()
+ "Setup sane default values for important environment variables."
+ (unless (getenv "HOME")
+ ;; Try to use $USERPROFILE if $HOME isn't properly set.
+ (setenv "HOME"
+ (cond
+ ((or (file-readable-p "C:/.emacs") (file-readable-p "C:/_emacs"))
+ ;; Backward compatibility with old default of "C:/".
+ "C:/")
+ ((and (getenv "USERPROFILE")
+ (file-writable-p (getenv "USERPROFILE")))
+ (getenv "USERPROFILE"))
+ ((and (getenv "HOMEPATH") (getenv "HOMEDRIVE")
+ (file-writable-p
+ (expand-file-name (getenv "HOMEPATH") (getenv
"HOMEDRIVE"))))
+ (expand-file-name (getenv "HOMEPATH") (getenv "HOMEDRIVE")))
+ (t "C:/"))))
+ (unless (getenv "SHELL")
+ ;; When is %emacs_dir% expanded? Should I do it here?
+ (setenv "SHELL" "%emacs_dir%/bin/cmdproxy.exe")))
+
;;; Setup Info-default-directory-list to include the info directory
;;; near where Emacs executable was installed. We used to set INFOPATH,
;;; but when this is set Info-default-directory-list is ignored. We
@@ -454,5 +476,5 @@
(setq interprogram-paste-function 'x-get-selection-value)
-;;; arch-tag: c49b48cc-0f4f-454f-a274-c2dc34815e14
+;; arch-tag: c49b48cc-0f4f-454f-a274-c2dc34815e14
;;; w32-fns.el ends here
Index: lisp/startup.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/startup.el,v
retrieving revision 1.333
diff -u -r1.333 startup.el
--- lisp/startup.el 17 Oct 2004 06:56:40 -0000 1.333
+++ lisp/startup.el 25 Nov 2004 16:03:01 -0000
@@ -340,6 +340,9 @@
(if command-line-processed
(message "Back to top level.")
(setq command-line-processed t)
+ (when (memq system-type '(windows-nt))
+ ;; Set HOME and SHELL if necessary.
+ (w32-early-setenv))
;; Give *Messages* the same default-directory as *scratch*,
;; just to keep things predictable.
(let ((dir default-directory))
@@ -1728,5 +1731,5 @@
(setq file (replace-match "/" t t file)))
file))
-;;; arch-tag: 7e294698-244d-4758-984b-4047f887a5db
+;; arch-tag: 7e294698-244d-4758-984b-4047f887a5db
;;; startup.el ends here
- $USERPROFILE for $HOME on W32, Stefan Monnier, 2004/11/22
- Re: $USERPROFILE for $HOME on W32, Jason Rumney, 2004/11/22
- Re: $USERPROFILE for $HOME on W32, Stefan Monnier, 2004/11/22
- Re: $USERPROFILE for $HOME on W32,
Stefan Monnier <=
- Re: $USERPROFILE for $HOME on W32, Jason Rumney, 2004/11/25
- Re: $USERPROFILE for $HOME on W32, Stefan, 2004/11/25
- Re: $USERPROFILE for $HOME on W32, Eli Zaretskii, 2004/11/25
- Re: $USERPROFILE for $HOME on W32, Jason Rumney, 2004/11/25
- Re: $USERPROFILE for $HOME on W32, Eli Zaretskii, 2004/11/26
- Re: $USERPROFILE for $HOME on W32, Andreas Schwab, 2004/11/25
- Re: $USERPROFILE for $HOME on W32, Stefan, 2004/11/25
- Re: $USERPROFILE for $HOME on W32, Andreas Schwab, 2004/11/25
- Re: $USERPROFILE for $HOME on W32, Eli Zaretskii, 2004/11/25
- Re: $USERPROFILE for $HOME on W32, Eli Zaretskii, 2004/11/26