From 41120e0f595b16387eebfbf731fff70481de1b4b Mon Sep 17 00:00:00 2001 From: Robin Templeton Date: Tue, 12 May 2015 19:10:41 -0400 Subject: [PATCH] better load-path defaults --- src/emacs.c | 3 ++- src/lread.c | 32 +++++++++++++------------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/emacs.c b/src/emacs.c index 4777044215..1f910efe56 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -2533,7 +2533,8 @@ both `lib-src' (on MS-DOS, `info') and `etc' directories are found within the variable `invocation-directory' or its parent. For example, this is the case when running an uninstalled Emacs executable from its build directory. */); - Vinstallation_directory = Qnil; + if (!Vinstallation_directory) + Vinstallation_directory = Qnil; DEFVAR_LISP ("system-messages-locale", Vsystem_messages_locale, doc: /* System locale for messages. */); diff --git a/src/lread.c b/src/lread.c index 5628ee5e2d..0d910d54dd 100644 --- a/src/lread.c +++ b/src/lread.c @@ -4139,24 +4139,17 @@ load_path_default (void) { Lisp_Object lpath = Qnil; const char *normal; + bool initialized_or_cannot_dump; #ifdef CANNOT_DUMP -#ifdef HAVE_NS - const char *loadpath = ns_load_path (); -#endif - - normal = PATH_DUMPLOADSEARCH; -#ifdef HAVE_NS - lpath = decode_env_path (0, loadpath ? loadpath : normal, 0); + initialized_or_cannot_dump = true; + normal = PATH_LOADSEARCH; #else - lpath = decode_env_path (0, normal, 0); -#endif - -#else /* !CANNOT_DUMP */ - + initialized_or_cannot_dump = initialized; normal = NILP (Vpurify_flag) ? PATH_LOADSEARCH : PATH_DUMPLOADSEARCH; +#endif - if (initialized) + if (initialized_or_cannot_dump) { #ifdef HAVE_NS const char *loadpath = ns_load_path (); @@ -4250,7 +4243,7 @@ load_path_default (void) } /* if Vinstallation_directory */ } - else /* !initialized */ + else /* !initialized_or_cannot_dump */ { /* NORMAL refers to PATH_DUMPLOADSEARCH, ie the lisp dir in the source directory. We used to add ../lisp (ie the lisp dir in @@ -4259,7 +4252,6 @@ load_path_default (void) for Makefile. */ lpath = decode_env_path (0, normal, 0); } -#endif /* !CANNOT_DUMP */ return lpath; } @@ -4267,7 +4259,12 @@ load_path_default (void) void init_lread (void) { - /* First, set Vload_path. */ + /* Set Vsource_directory before calling load_path_default. */ + Vsource_directory + = Fexpand_file_name (build_string ("../"), + Fcar (decode_env_path (0, PATH_DUMPLOADSEARCH, 0))); + + /* Set Vload_path. */ /* Ignore EMACSLOADPATH when dumping. */ #ifdef CANNOT_DUMP @@ -4540,9 +4537,6 @@ and is not meant for users to change. */); DEFVAR_LISP ("source-directory", Vsource_directory, doc: /* Directory in which Emacs sources were found when Emacs was built. You cannot count on them to still be there! */); - Vsource_directory - = Fexpand_file_name (build_string ("../"), - Fcar (decode_env_path (0, PATH_DUMPLOADSEARCH, 0))); DEFVAR_LISP ("preloaded-file-list", Vpreloaded_file_list, doc: /* List of files that were preloaded (when dumping Emacs). */); -- 2.20.1