Re: [Mac-emacs-devel] Re: 'Fatal error (6).Abort' (with fix)
Brought to you by:
akochoi
|
From: Andrew C. <ak...@sh...> - 2002-08-09 01:42:38
|
> 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.
>
> [...]
>
> -Steven
>
> [...]
Hi Steven,
I believe the long-term solution is to install the application bundle
at one place (say /Applications/ or some other location specified by
the user) and have the executable in $prefix/bin/ invoked from the
command line start a GUI or terminal version depending on whether the
-nw switch was used.
For that to work, we need a fix for invoking a GUI version from the
command line. So here it is: the patch at the end of this message
allows a GUI Emacs to be started at the command line, with options
passed to it and all! A pathname to the executable in the bundle must
be typed to the shell for the application to find its resources, of
course. There's still a bit of a problem since input becomes sluggish
when subprocesses are started (say an ftp process). I'll try to find
a fix for this (everyone is welcome to help).
When this works, all we need to do is install something like the
following script as the file /usr/local/bin/emacs.
#!/bin/sh
/Applications/Emacs.app/Contents/MacOS/Emacs $*
Before I work out the changes to the makefiles and so on, I'd like to
make sure everything works (and fix the above bug). Therefore I
invite everyone to test this patch. Thanks.
Andrew.
-----
Index: src/mac.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/mac.c,v
retrieving revision 1.7
diff -u -r1.7 mac.c
--- src/mac.c 2 Aug 2002 20:34:38 -0000 1.7
+++ src/mac.c 9 Aug 2002 00:48:13 -0000
@@ -2745,6 +2745,31 @@
return Qnil;
}
+#ifdef MAC_OSX
+#undef select
+
+extern int inhibit_window_system;
+
+int
+sys_select (n, rfds, wfds, efds, timeout)
+ int n;
+ SELECT_TYPE *rfds;
+ SELECT_TYPE *wfds;
+ SELECT_TYPE *efds;
+ struct timeval *timeout;
+{
+ EventRecord e;
+
+ if (!inhibit_window_system && n == 1 && rfds && FD_ISSET (0, rfds))
+ return 1;
+
+ if (!inhibit_window_system && rfds && FD_ISSET (0, rfds)
+ && EventAvail (everyEvent, &e))
+ return 1;
+
+ return select (n, rfds, wfds, efds, timeout);
+}
+#endif /* MAC_OSX */
void
syms_of_mac ()
Index: src/macterm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/macterm.c,v
retrieving revision 1.14
diff -u -r1.14 macterm.c
--- src/macterm.c 4 Aug 2002 19:29:06 -0000 1.14
+++ src/macterm.c 9 Aug 2002 00:48:19 -0000
@@ -366,6 +366,7 @@
extern Lisp_Object x_icon_type P_ ((struct frame *));
+extern int inhibit_window_system;
#if __MRC__
QDGlobals qd; /* QuickDraw global information structure. */
@@ -13405,6 +13433,18 @@
return dpyinfo;
}
+#ifdef MAC_OSX
+void MakeMeTheFrontProcess ()
+{
+ ProcessSerialNumber psn;
+ OSErr err;
+
+ err = GetCurrentProcess (&psn);
+ if (err == noErr)
+ (void) SetFrontProcess (&psn);
+}
+#endif /* MAC_OSX */
+
/* Set up use of X before we make the first connection. */
static struct redisplay_interface x_redisplay_interface =
@@ -13514,6 +13554,9 @@
#endif
DisableMenuCommand (NULL, kHICommandQuit);
+
+ if (!inhibit_window_system)
+ MakeMeTheFrontProcess ();
#endif
}
Index: src/s/darwin.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/s/darwin.h,v
retrieving revision 1.4
diff -u -r1.4 darwin.h
--- src/s/darwin.h 1 Aug 2002 03:33:20 -0000 1.4
+++ src/s/darwin.h 9 Aug 2002 00:48:20 -0000
@@ -308,3 +308,7 @@
#define realloc unexec_realloc
#define free unexec_free
#endif
+
+#if defined (emacs) || defined (temacs)
+#define select sys_select
+#endif
|