[Mac-emacs-devel] Re: 'Fatal error (6).Abort' (with fix)
Brought to you by:
akochoi
|
From: Steven T. <ste...@ma...> - 2002-08-07 19:14:25
|
The problem is -nw.
I got kind of sick of the whole -nw thing causing a crash from the
command line. So here is a fix. It will only start up the windowing
system if it can find the "CFBundleIdentifier" string in the Info.plist
file. This should only happen if emacs is inside an Emacs.app bundle.
If you start it up from a shell, it won't find the Info.plist file and
will set inhibit_window_system to 1. The cool thing about this setup is
that it takes ignores symbolic links. So you can have the same file be
a windowed app in one place and a command line app in another. This
makes the Emacs application much smaller while still being portable.
Here's what I mean. Suppose you install emacs-21.3.50 in
/usr/local/bin. Then you symbolically link
Emacs.app/Contents/MacOS/Emacs to /usr/local/bin/emacs-21.3.50.
Executing /usr/local/bin/emacs-21.3.50 from a shell will startup in the
terminal.
Executing /Applications/Emacs.app/Contents/MacOS/Emacs from a shell will
startup in the dock with windows.
-Steven
Index: src/emacs.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/emacs.c,v
retrieving revision 1.312
diff -c -r1.312 emacs.c
*** src/emacs.c 15 Jul 2002 00:00:36 -0000 1.312
--- src/emacs.c 7 Aug 2002 19:07:47 -0000
***************
*** 1520,1525 ****
--- 1520,1529 ----
keys_of_window ();
}
+ #if HAVE_CARBON
+ mac_determine_bundle_status();
+ #endif
+
if (!noninteractive)
{
#ifdef VMS
Index: src/macterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macterm.c,v
retrieving revision 1.14
diff -c -r1.14 macterm.c
*** src/macterm.c 4 Aug 2002 19:29:06 -0000 1.14
--- src/macterm.c 7 Aug 2002 19:08:05 -0000
***************
*** 13610,13613 ****
--- 13833,13869 ----
command, this enables the Mac keyboard to be used to enter non-ASCII
characters directly. */);
mac_keyboard_text_encoding = kTextEncodingMacRoman;
+ }
+
+ /* Determine if the executable is not in a bundle, and if so, do not
attempt
+ to start up the window system */
+ void mac_determine_bundle_status()
+ {
+ #if MAC_OSX
+ extern int inhibit_window_system;
+ extern int noninteractive;
+ OSErr err;
+ CFBundleRef appsBundle;
+
+ /* No need to test if already -nw*/
+ if (inhibit_window_system || noninteractive)
+ return;
+
+
+ appsBundle = CFBundleGetMainBundle();
+ if (appsBundle != NULL)
+ {
+ CFStringRef cfBI = CFSTR("CFBundleIdentifier");
+ CFTypeRef res = CFBundleGetValueForInfoDictionaryKey(appsBundle,
cfBI);
+ /* We found the bundle identifier, now we know we are valid. */
+ if (res != NULL)
+ {
+ CFRelease(res);
+ return;
+ }
+ }
+
+ /* Unless we actually find the resource, set -nw */
+ inhibit_window_system = 1;
+ #endif
}
-Steven
|