summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog10
-rw-r--r--src/emacs.c7
-rw-r--r--src/lread.c27
-rw-r--r--src/nsterm.h2
-rw-r--r--src/nsterm.m57
5 files changed, 64 insertions, 39 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 7e3372bc90d..584d6a33947 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,13 @@
+2012-07-10 Glenn Morris <rgm@gnu.org>
+
+ Stop ns builds setting the EMACSLOADPATH environment variable.
+ * nsterm.m (ns_load_path): Rename from ns_init_paths.
+ Now it does not set EMACSLOADPATH, just returns the load-path string.
+ * nsterm.h: Update accordingly.
+ * lread.c [HAVE_NS]: Include nsterm.h.
+ (init_lread) [HAVE_NS]: Use ns_load_path.
+ * emacs.c (main) [HAVE_NS]: No longer call ns_init_paths.
+
2012-07-09 Glenn Morris <rgm@gnu.org>
* s/gnu.h (SIGNALS_VIA_CHARACTERS): No need to define it here,
diff --git a/src/emacs.c b/src/emacs.c
index 2b386bac176..2194cfead16 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -1426,13 +1426,6 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem
init_ntproc (); /* must precede init_editfns. */
#endif
-#ifdef HAVE_NS
-#ifndef CANNOT_DUMP
- if (initialized)
-#endif
- ns_init_paths ();
-#endif
-
/* Initialize and GC-protect Vinitial_environment and
Vprocess_environment before set_initial_environment fills them
in. */
diff --git a/src/lread.c b/src/lread.c
index 6b6231a8f11..c69190c37b6 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -45,6 +45,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "msdos.h"
#endif
+#ifdef HAVE_NS
+#include "nsterm.h"
+#endif
+
#include <unistd.h>
#include <math.h>
@@ -4125,8 +4129,16 @@ init_lread (void)
const char *normal;
#ifdef CANNOT_DUMP
+#ifdef HAVE_NS
+ const char *loadpath = ns_load_path ();
+#endif
+
normal = PATH_LOADSEARCH;
+#ifdef HAVE_NS
+ Vload_path = decode_env_path ("EMACSLOADPATH", loadpath ? loadpath : normal);
+#else
Vload_path = decode_env_path ("EMACSLOADPATH", normal);
+#endif
load_path_check ();
@@ -4135,7 +4147,12 @@ init_lread (void)
difference between initialized and !initialized in this case,
so we'll have to do it unconditionally when Vinstallation_directory
is non-nil. */
+#ifdef HAVE_NS
+ /* loadpath already includes the app-bundle's site-lisp. */
+ if (!no_site_lisp && !egetenv ("EMACSLOADPATH") && !loadpath)
+#else
if (!no_site_lisp && !egetenv ("EMACSLOADPATH"))
+#endif
{
Lisp_Object sitelisp;
sitelisp = decode_env_path (0, PATH_SITELOADSEARCH);
@@ -4171,7 +4188,12 @@ init_lread (void)
}
else
{
+#ifdef HAVE_NS
+ const char *loadpath = ns_load_path ();
+ Vload_path = decode_env_path (0, loadpath ? loadpath : normal);
+#else
Vload_path = decode_env_path (0, normal);
+#endif
if (!NILP (Vinstallation_directory))
{
Lisp_Object tem, tem1;
@@ -4274,7 +4296,12 @@ init_lread (void)
load_path_check ();
/* Add the site-lisp directories at the front. */
+#ifdef HAVE_NS
+ /* loadpath already includes the app-bundle's site-lisp. */
+ if (!no_site_lisp && !loadpath)
+#else
if (!no_site_lisp)
+#endif
{
Lisp_Object sitelisp;
sitelisp = decode_env_path (0, PATH_SITELOADSEARCH);
diff --git a/src/nsterm.h b/src/nsterm.h
index 939186d0d94..abfdfd4803a 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -800,7 +800,7 @@ extern void ns_run_ascript (void);
extern const char *ns_etc_directory (void);
extern const char *ns_exec_path (void);
-extern void ns_init_paths (void);
+extern const char *ns_load_path (void);
extern void syms_of_nsterm (void);
extern void syms_of_nsfns (void);
extern void syms_of_nsmenu (void);
diff --git a/src/nsterm.m b/src/nsterm.m
index 6ec9d695334..39725067ec7 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -365,12 +365,11 @@ ns_exec_path (void)
}
-void
-ns_init_paths (void)
-/* --------------------------------------------------------------------------
- Used to allow emacs to find its resources under Emacs.app
- Called from emacs.c at startup.
- -------------------------------------------------------------------------- */
+const char *
+ns_load_path (void)
+/* If running as a self-contained app bundle, return as a path string
+ the filenames of the site-lisp, lisp and leim directories.
+ Ie, site-lisp:lisp:leim. Otherwise, return nil. */
{
NSBundle *bundle = [NSBundle mainBundle];
NSString *resourceDir = [bundle resourcePath];
@@ -379,34 +378,30 @@ ns_init_paths (void)
NSString *pathSeparator = onWindows ? @";" : @":";
NSFileManager *fileManager = [NSFileManager defaultManager];
BOOL isDir;
-/*NSLog (@"ns_init_paths: '%@'\n%@\n", [[NSBundle mainBundle] bundlePath], [[NSBundle mainBundle] resourcePath]); */
+ NSArray *paths = [resourceDir stringsByAppendingPaths:
+ [NSArray arrayWithObjects:
+ @"site-lisp", @"lisp", @"leim", nil]];
+ NSEnumerator *pathEnum = [paths objectEnumerator];
+ resourcePaths = @"";
- /* the following based on Andrew Choi's init_mac_osx_environment () */
- if (!getenv ("EMACSLOADPATH"))
+ /* Hack to skip site-lisp. */
+ if (no_site_lisp) resourcePath = [pathEnum nextObject];
+
+ while (resourcePath = [pathEnum nextObject])
{
- NSArray *paths = [resourceDir stringsByAppendingPaths:
- [NSArray arrayWithObjects:
- @"site-lisp", @"lisp", @"leim", nil]];
- NSEnumerator *pathEnum = [paths objectEnumerator];
- resourcePaths = @"";
- /* Hack to skip site-lisp. */
- if (no_site_lisp) resourcePath = [pathEnum nextObject];
- while (resourcePath = [pathEnum nextObject])
- {
- if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir])
- if (isDir)
- {
- if ([resourcePaths length] > 0)
- resourcePaths
- = [resourcePaths stringByAppendingString: pathSeparator];
- resourcePaths
- = [resourcePaths stringByAppendingString: resourcePath];
- }
- }
- if ([resourcePaths length] > 0)
- setenv ("EMACSLOADPATH", [resourcePaths UTF8String], 1);
-/*NSLog (@"loadPath: '%@'\n", resourcePaths); */
+ if ([fileManager fileExistsAtPath: resourcePath isDirectory: &isDir])
+ if (isDir)
+ {
+ if ([resourcePaths length] > 0)
+ resourcePaths
+ = [resourcePaths stringByAppendingString: pathSeparator];
+ resourcePaths
+ = [resourcePaths stringByAppendingString: resourcePath];
+ }
}
+ if ([resourcePaths length] > 0) return [resourcePaths UTF8String];
+
+ return NULL;
}
static void