aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/w32.c39
2 files changed, 42 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 193ba688082..98799338e4c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12005-07-14 Jason Rumney <jasonr@gnu.org>
2
3 * w32.c (init_environment): Default HOME directory to user's
4 appdata directory if possible.
5
12005-07-14 Kim F. Storm <storm@cua.dk> 62005-07-14 Kim F. Storm <storm@cua.dk>
2 7
3 * .gdbinit (pitx): Fix output format. Print string charpos. 8 * .gdbinit (pitx): Fix output format. Print string charpos.
diff --git a/src/w32.c b/src/w32.c
index 77959037913..25283c3b4c6 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -20,8 +20,6 @@ Boston, MA 02110-1301, USA.
20 20
21 Geoff Voelker (voelker@cs.washington.edu) 7-29-94 21 Geoff Voelker (voelker@cs.washington.edu) 7-29-94
22*/ 22*/
23
24
25#include <stddef.h> /* for offsetof */ 23#include <stddef.h> /* for offsetof */
26#include <stdlib.h> 24#include <stdlib.h>
27#include <stdio.h> 25#include <stdio.h>
@@ -73,6 +71,7 @@ Boston, MA 02110-1301, USA.
73#define _ANONYMOUS_STRUCT 71#define _ANONYMOUS_STRUCT
74#endif 72#endif
75#include <windows.h> 73#include <windows.h>
74#include <shlobj.h>
76 75
77#ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */ 76#ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */
78#include <sys/socket.h> 77#include <sys/socket.h>
@@ -100,6 +99,9 @@ Boston, MA 02110-1301, USA.
100#include "w32heap.h" 99#include "w32heap.h"
101#include "systime.h" 100#include "systime.h"
102 101
102typedef HRESULT (WINAPI * ShGetFolderPath_fn)
103 (IN HWND, IN int, IN HANDLE, IN DWORD, OUT char *);
104
103void globals_of_w32 (); 105void globals_of_w32 ();
104 106
105extern Lisp_Object Vw32_downcase_file_names; 107extern Lisp_Object Vw32_downcase_file_names;
@@ -903,7 +905,9 @@ init_environment (char ** argv)
903 static const char * const tempdirs[] = { 905 static const char * const tempdirs[] = {
904 "$TMPDIR", "$TEMP", "$TMP", "c:/" 906 "$TMPDIR", "$TEMP", "$TMP", "c:/"
905 }; 907 };
908
906 int i; 909 int i;
910
907 const int imax = sizeof (tempdirs) / sizeof (tempdirs[0]); 911 const int imax = sizeof (tempdirs) / sizeof (tempdirs[0]);
908 912
909 /* Make sure they have a usable $TMPDIR. Many Emacs functions use 913 /* Make sure they have a usable $TMPDIR. Many Emacs functions use
@@ -942,6 +946,8 @@ init_environment (char ** argv)
942 LPBYTE lpval; 946 LPBYTE lpval;
943 DWORD dwType; 947 DWORD dwType;
944 char locale_name[32]; 948 char locale_name[32];
949 struct stat ignored;
950 char default_home[MAX_PATH];
945 951
946 static struct env_entry 952 static struct env_entry
947 { 953 {
@@ -964,6 +970,35 @@ init_environment (char ** argv)
964 {"LANG", NULL}, 970 {"LANG", NULL},
965 }; 971 };
966 972
973 /* For backwards compatibility, check if a .emacs file exists in C:/
974 If not, then we can try to default to the appdata directory under the
975 user's profile, which is more likely to be writable. */
976 if (stat ("C:/.emacs", &ignored) < 0)
977 {
978 HRESULT profile_result;
979 /* Dynamically load ShGetFolderPath, as it won't exist on versions
980 of Windows 95 and NT4 that have not been updated to include
981 MSIE 5. Also we don't link with shell32.dll by default. */
982 HMODULE shell32_dll;
983 ShGetFolderPath_fn get_folder_path;
984 shell32_dll = GetModuleHandle ("shell32.dll");
985 get_folder_path = (ShGetFolderPath_fn)
986 GetProcAddress (shell32_dll, "SHGetFolderPathA");
987
988 if (get_folder_path != NULL)
989 {
990 profile_result = get_folder_path (NULL, CSIDL_APPDATA, NULL,
991 0, default_home);
992
993 /* If we can't get the appdata dir, revert to old behaviour. */
994 if (profile_result == S_OK)
995 env_vars[0].def_value = default_home;
996 }
997
998 /* Unload shell32.dll, it is not needed anymore. */
999 FreeLibrary (shell32_dll);
1000 }
1001
967 /* Get default locale info and use it for LANG. */ 1002 /* Get default locale info and use it for LANG. */
968 if (GetLocaleInfo (LOCALE_USER_DEFAULT, 1003 if (GetLocaleInfo (LOCALE_USER_DEFAULT,
969 LOCALE_SABBREVLANGNAME | LOCALE_USE_CP_ACP, 1004 LOCALE_SABBREVLANGNAME | LOCALE_USE_CP_ACP,