/* Lisp parsing and input streams.
-Copyright (C) 1985-1989, 1993-1995, 1997-2013 Free Software Foundation,
-Inc.
+Copyright (C) 1985-1989, 1993-1995, 1997-2013 Free Software Foundation, Inc.
This file is part of GNU Emacs.
SET_SYMBOL_FWD (XSYMBOL (sym), (union Lisp_Fwd *)ko_fwd);
}
\f
-/* Check that the elements of Vload_path exist. */
+/* Check that the elements of lpath exist. */
static void
-load_path_check (void)
+load_path_check (Lisp_Object lpath)
{
Lisp_Object path_tail;
/* The only elements that might not exist are those from
PATH_LOADSEARCH, EMACSLOADPATH. Anything else is only added if
it exists. */
- for (path_tail = Vload_path; !NILP (path_tail); path_tail = XCDR (path_tail))
+ for (path_tail = lpath; !NILP (path_tail); path_tail = XCDR (path_tail))
{
Lisp_Object dirfile;
dirfile = Fcar (path_tail);
so we can see if the site changed it later during dumping. */
static Lisp_Object dump_path;
-/* Compute the default Vload_path, with the following logic:
- If CANNOT_DUMP:
- use EMACSLOADPATH env-var if set; otherwise use PATH_LOADSEARCH,
- prepending PATH_SITELOADSEARCH unless --no-site-lisp.
+/* Return the default load-path, to be used if EMACSLOADPATH is unset.
+ This does not include the standard site-lisp directories
+ under the installation prefix (i.e., PATH_SITELOADSEARCH),
+ but it does (unless no_site_lisp is set) include site-lisp
+ directories in the source/build directories if those exist and we
+ are running uninstalled.
+
+ Uses the following logic:
+ If CANNOT_DUMP: Use PATH_LOADSEARCH.
The remainder is what happens when dumping works:
If purify-flag (ie dumping) just use PATH_DUMPLOADSEARCH.
- Otherwise use EMACSLOADPATH if set, else PATH_LOADSEARCH.
+ Otherwise use PATH_LOADSEARCH.
- If !initialized, then just set both Vload_path and dump_path.
- If initialized, then if Vload_path != dump_path, do nothing.
+ If !initialized, then just set dump_path and return PATH_DUMPLOADSEARCH.
+ If initialized, then if Vload_path != dump_path, return just Vload_path.
(Presumably the load-path has already been changed by something.
- This can only be from a site-load file during dumping,
- or because EMACSLOADPATH is set.)
+ This can only be from a site-load file during dumping.)
If Vinstallation_directory is not nil (ie, running uninstalled):
If installation-dir/lisp exists and not already a member,
we must be running uninstalled. Reset the load-path
install-dir/src/Makefile.in does NOT exist (this is a sanity
check), then repeat the above steps for source-dir/lisp,
leim and site-lisp.
- Finally, add the site-lisp directories at the front (if !no_site_lisp).
*/
-
-void
-init_lread (void)
+Lisp_Object
+load_path_default (bool ignore_existing)
{
+ Lisp_Object lpath = Qnil;
const char *normal;
#ifdef CANNOT_DUMP
normal = PATH_LOADSEARCH;
#ifdef HAVE_NS
- Vload_path = decode_env_path ("EMACSLOADPATH", loadpath ? loadpath : normal);
+ lpath = decode_env_path (0, loadpath ? loadpath : normal, 0);
#else
- Vload_path = decode_env_path ("EMACSLOADPATH", normal);
+ lpath = decode_env_path (0, normal, 0);
#endif
- load_path_check ();
-
- /* FIXME CANNOT_DUMP platforms should get source-dir/lisp etc added
- to their load-path too, AFAICS. I don't think we can tell the
- difference between initialized and !initialized in this case,
- so we'll have to do it unconditionally when Vinstallation_directory
- is non-nil. */
- if (!no_site_lisp && !egetenv ("EMACSLOADPATH"))
- {
- Lisp_Object sitelisp;
- sitelisp = decode_env_path (0, PATH_SITELOADSEARCH);
- if (! NILP (sitelisp)) Vload_path = nconc2 (sitelisp, Vload_path);
- }
#else /* !CANNOT_DUMP */
- if (NILP (Vpurify_flag))
- {
- normal = PATH_LOADSEARCH;
- /* If the EMACSLOADPATH environment variable is set, use its value.
- This doesn't apply if we're dumping. */
- if (egetenv ("EMACSLOADPATH"))
- Vload_path = decode_env_path ("EMACSLOADPATH", normal);
- }
- else
- normal = PATH_DUMPLOADSEARCH;
+
+ normal = NILP (Vpurify_flag) ? PATH_LOADSEARCH : PATH_DUMPLOADSEARCH;
/* In a dumped Emacs, we normally reset the value of Vload_path using
PATH_LOADSEARCH, since the value that was dumped uses lisp/ in
site-lisp files that were processed during dumping. */
if (initialized)
{
- if (NILP (Fequal (dump_path, Vload_path)))
+ if (!ignore_existing && NILP (Fequal (dump_path, Vload_path)))
{
- /* Do not make any changes, just check the elements exist. */
- /* Note: --no-site-lisp is ignored.
- I don't know what to do about this. */
- load_path_check ();
+ /* Do not make any changes. */
+ return Vload_path;
}
else
- {
+ {
#ifdef HAVE_NS
- const char *loadpath = ns_load_path ();
- Vload_path = decode_env_path (0, loadpath ? loadpath : normal);
+ const char *loadpath = ns_load_path ();
+ lpath = decode_env_path (0, loadpath ? loadpath : normal, 0);
#else
- Vload_path = decode_env_path (0, normal);
+ lpath = decode_env_path (0, normal, 0);
#endif
- if (!NILP (Vinstallation_directory))
- {
- Lisp_Object tem, tem1;
+ if (!NILP (Vinstallation_directory))
+ {
+ Lisp_Object tem, tem1;
/* Add to the path the lisp subdir of the installation
dir, if it is accessible. Note: in out-of-tree builds,
tem1 = Ffile_accessible_directory_p (tem);
if (!NILP (tem1))
{
- if (NILP (Fmember (tem, Vload_path)))
+ if (NILP (Fmember (tem, lpath)))
{
/* We are running uninstalled. The default load-path
points to the eventual installed lisp, leim
directories. We should not use those now, even
if they exist, so start over from a clean slate. */
- Vload_path = list1 (tem);
+ lpath = list1 (tem);
}
}
else
/* That dir doesn't exist, so add the build-time
Lisp dirs instead. */
- Vload_path = nconc2 (Vload_path, dump_path);
+ lpath = nconc2 (lpath, dump_path);
/* Add leim under the installation dir, if it is accessible. */
tem = Fexpand_file_name (build_string ("leim"),
tem1 = Ffile_accessible_directory_p (tem);
if (!NILP (tem1))
{
- if (NILP (Fmember (tem, Vload_path)))
- Vload_path = Fcons (tem, Vload_path);
+ if (NILP (Fmember (tem, lpath)))
+ lpath = Fcons (tem, lpath);
}
/* Add site-lisp under the installation dir, if it exists. */
tem1 = Ffile_accessible_directory_p (tem);
if (!NILP (tem1))
{
- if (NILP (Fmember (tem, Vload_path)))
- Vload_path = Fcons (tem, Vload_path);
+ if (NILP (Fmember (tem, lpath)))
+ lpath = Fcons (tem, lpath);
}
}
tem = Fexpand_file_name (build_string ("lisp"),
Vsource_directory);
- if (NILP (Fmember (tem, Vload_path)))
- Vload_path = Fcons (tem, Vload_path);
+ if (NILP (Fmember (tem, lpath)))
+ lpath = Fcons (tem, lpath);
tem = Fexpand_file_name (build_string ("leim"),
Vsource_directory);
- if (NILP (Fmember (tem, Vload_path)))
- Vload_path = Fcons (tem, Vload_path);
+ if (NILP (Fmember (tem, lpath)))
+ lpath = Fcons (tem, lpath);
if (!no_site_lisp)
{
tem1 = Ffile_accessible_directory_p (tem);
if (!NILP (tem1))
{
- if (NILP (Fmember (tem, Vload_path)))
- Vload_path = Fcons (tem, Vload_path);
+ if (NILP (Fmember (tem, lpath)))
+ lpath = Fcons (tem, lpath);
}
}
}
} /* Vinstallation_directory != Vsource_directory */
- } /* if Vinstallation_directory */
-
- /* Check before adding the site-lisp directories.
- The install should have created them, but they are not
- required, so no need to warn if they are absent.
- Or we might be running before installation. */
- load_path_check ();
+ } /* if Vinstallation_directory */
- /* Add the site-lisp directories at the front. */
- if (!no_site_lisp)
- {
- Lisp_Object sitelisp;
- sitelisp = decode_env_path (0, PATH_SITELOADSEARCH);
- if (! NILP (sitelisp)) Vload_path = nconc2 (sitelisp, Vload_path);
- }
- } /* if dump_path == Vload_path */
+ } /* if dump_path == Vload_path */
}
else /* !initialized */
{
/* NORMAL refers to PATH_DUMPLOADSEARCH, ie the lisp dir in the
source directory. We used to add ../lisp (ie the lisp dir in
the build directory) at the front here, but that caused trouble
- because it was copied from dump_path into Vload_path, above,
- when Vinstallation_directory was non-nil. It should not be
+ because it was copied from dump_path into Vload_path, above,
+ when Vinstallation_directory was non-nil. It should not be
necessary, since in out of tree builds lisp/ is empty, save
for Makefile. */
- Vload_path = decode_env_path (0, normal);
- dump_path = Vload_path;
- /* No point calling load_path_check; load-path only contains essential
- elements from the source directory at this point. They cannot
- be missing unless something went extremely (and improbably)
- wrong, in which case the build will fail in obvious ways. */
+ lpath = decode_env_path (0, normal, 0);
+ dump_path = lpath;
}
-#endif /* !CANNOT_DUMP */
+#endif /* !CANNOT_DUMP */
+
+ return lpath;
+}
+
+void
+init_lread (void)
+{
+ /* First, set Vload_path. */
+
+ /* We explicitly ignore EMACSLOADPATH when dumping. */
+ if (NILP (Vpurify_flag) && egetenv ("EMACSLOADPATH"))
+ {
+ Vload_path = decode_env_path ("EMACSLOADPATH", 0, 1);
+
+ /* Check (non-nil) user-supplied elements. */
+ load_path_check (Vload_path);
+
+ /* Replace any nil elements from the environment with the default. */
+ if (Fmemq (Qnil, Vload_path))
+ {
+ Lisp_Object lpath = Vload_path;
+ Lisp_Object elem, default_lpath = load_path_default (1);
+
+ /* Check defaults, before adding site-lisp. */
+ load_path_check (default_lpath);
+
+ /* Add the site-lisp directories to the front of the default. */
+ if (!no_site_lisp)
+ {
+ Lisp_Object sitelisp;
+ sitelisp = decode_env_path (0, PATH_SITELOADSEARCH, 0);
+ if (! NILP (sitelisp))
+ default_lpath = nconc2 (sitelisp, default_lpath);
+ }
+
+ Vload_path = Qnil;
+
+ /* Replace nils from EMACSLOADPATH by default. */
+ while (CONSP (lpath))
+ {
+ Lisp_Object arg[2];
+ elem = XCAR (lpath);
+ lpath = XCDR (lpath);
+ arg[0] = Vload_path;
+ arg[1] = NILP (elem) ? default_lpath : Fcons (elem, Qnil);
+ Vload_path = Fappend (2, arg);
+ }
+ } /* Fmemq (Qnil, Vload_path) */
+ }
+ else /* Vpurify_flag || !EMACSLOADPATH */
+ {
+ Vload_path = load_path_default (0);
+
+ /* Check before adding site-lisp directories.
+ The install should have created them, but they are not
+ required, so no need to warn if they are absent.
+ Or we might be running before installation. */
+ load_path_check (Vload_path);
+
+ /* Add the site-lisp directories at the front, unless the
+ load-path has somehow already been changed (this can only be
+ from a site-load file during dumping?) from the dumped value.
+ FIXME? Should we ignore any dump_path changes? */
+ if (initialized && !no_site_lisp &&
+ ! NILP (Fequal (dump_path, Vload_path)))
+ {
+ Lisp_Object sitelisp;
+ sitelisp = decode_env_path (0, PATH_SITELOADSEARCH, 0);
+ if (! NILP (sitelisp)) Vload_path = nconc2 (sitelisp, Vload_path);
+ }
+ } /* !Vpurify_flag && EMACSLOADPATH */
Vvalues = Qnil;
DEFVAR_LISP ("load-path", Vload_path,
doc: /* List of directories to search for files to load.
-Each element is a string (directory name) or nil (try default directory).
-Initialized based on EMACSLOADPATH environment variable, if any,
-otherwise to default specified by file `epaths.h' when Emacs was built. */);
+Each element is a string (directory name) or nil (meaning `default-directory').
+Initialized during startup as described in Info node `(elisp)Library Search'. */);
DEFVAR_LISP ("load-suffixes", Vload_suffixes,
doc: /* List of suffixes for (compiled or source) Emacs Lisp files.
You cannot count on them to still be there! */);
Vsource_directory
= Fexpand_file_name (build_string ("../"),
- Fcar (decode_env_path (0, PATH_DUMPLOADSEARCH)));
+ 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). */);