+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,
#include "msdos.h"
#endif
+#ifdef HAVE_NS
+#include "nsterm.h"
+#endif
+
#include <unistd.h>
#include <math.h>
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 ();
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);
}
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;
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);
}
-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];
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