]> code.delx.au - gnu-emacs/blobdiff - src/emacs.c
* lisp.h:
[gnu-emacs] / src / emacs.c
index 9a520951610956043cd281407b7f7b384f613ad6..8dfdf9062a13d30a321a873d32c00c24d19bc2f2 100644 (file)
@@ -5,10 +5,10 @@
 
 This file is part of GNU Emacs.
 
-GNU Emacs is free software; you can redistribute it and/or modify
+GNU Emacs is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 3, or (at your option)
-any later version.
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -16,9 +16,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING.  If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA.  */
+along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
 #include <config.h>
@@ -100,7 +98,7 @@ int gdb_use_lsb = 1;
 #else
 int gdb_use_lsb = 0;
 #endif
-#ifdef NO_UNION_TYPE
+#ifndef USE_LISP_UNION_TYPE
 int gdb_use_union = 0;
 #else
 int gdb_use_union = 1;
@@ -326,6 +324,7 @@ Display options:\n\
 --title, -T TITLE               title for initial Emacs frame\n\
 --vertical-scroll-bars, -vb     enable vertical scroll bars\n\
 --xrm XRESOURCES                set additional X resources\n\
+--parent-id XID                 set parent window\n\
 --help                          display this help and exit\n\
 --version                       output version information and exit\n\
 \n"
@@ -353,10 +352,10 @@ int fatal_error_in_progress;
 
 void (*fatal_error_signal_hook) P_ ((void));
 
-#ifdef HAVE_GTK_AND_PTHREAD
-/* When compiled with GTK and running under Gnome, multiple threads may be
-   created.  Keep track of our main thread to make sure signals are delivered
-   to it (see syssignal.h).  */
+#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
+/* When compiled with GTK and running under Gnome, or Carbon under Mac
+   OS X, multiple threads may be created.  Keep track of our main
+   thread to make sure signals are delivered to it (see syssignal.h).  */
 
 pthread_t main_thread;
 #endif
@@ -422,11 +421,7 @@ memory_warning_signal (sig)
 
 #if ! defined (DOS_NT) && ! defined (NO_ABORT)
 
-#ifndef ABORT_RETURN_TYPE
-#define ABORT_RETURN_TYPE void
-#endif
-
-ABORT_RETURN_TYPE
+void
 abort ()
 {
   kill (getpid (), SIGABRT);
@@ -927,16 +922,6 @@ main (argc, argv
     }
 #endif
 
-#ifdef NeXT
-  {
-    extern int malloc_cookie;
-    /* This helps out unexnext.c.  */
-    if (initialized)
-      if (malloc_jumpstart (malloc_cookie) != 0)
-       printf ("malloc jumpstart failed!\n");
-  }
-#endif /* NeXT */
-
 #ifdef MAC_OSX
   /* Skip process serial number passed in the form -psn_x_y as
      command-line argument.  The WindowServer adds this option when
@@ -1037,9 +1022,9 @@ main (argc, argv
 # endif /* not SYNC_INPUT */
 #endif /* not SYSTEM_MALLOC */
 
-#ifdef HAVE_GTK_AND_PTHREAD
+#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD
   main_thread = pthread_self ();
-#endif /* HAVE_GTK_AND_PTHREAD */
+#endif /* FORWARD_SIGNAL_TO_MAIN_THREAD */
 
 #if defined (MSDOS) || defined (WINDOWSNT)
   /* We do all file input/output as binary files.  When we need to translate
@@ -1083,10 +1068,6 @@ main (argc, argv
   if (do_initial_setlocale)
     setlocale (LC_ALL, "");
 
-#ifdef EXTRA_INITIALIZE
-  EXTRA_INITIALIZE;
-#endif
-
   inhibit_window_system = 0;
 
   /* Handle the -t switch, which specifies filename to use as terminal.  */
@@ -1136,8 +1117,9 @@ main (argc, argv
   if (argmatch (argv, argc, "-script", "--script", 3, &junk, &skip_args))
     {
       noninteractive = 1;      /* Set batch mode.  */
-      /* Convert --script to --scriptload, un-skip it, and sort again
+      /* Convert --script to -scriptload, un-skip it, and sort again
         so that it will be handled in proper sequence.  */
+      /* FIXME broken for --script=FILE - is that supposed to work?  */
       argv[skip_args - 1] = "-scriptload";
       skip_args -= 2;
       sort_args (argc, argv);
@@ -1283,6 +1265,7 @@ main (argc, argv
       init_alloc_once ();
       init_obarray ();
       init_eval_once ();
+      init_character_once ();
       init_charset_once ();
       init_coding_once ();
       init_syntax_once ();     /* Create standard syntax table.  */
@@ -1307,6 +1290,38 @@ main (argc, argv
         CANNOT_DUMP is defined.  */
       syms_of_keyboard ();
 
+#ifdef MAC_OS8
+      /* init_window_once calls make_terminal_frame which on Mac OS
+         creates a full-fledge output_mac type frame.  This does not
+         work correctly before syms_of_textprop, syms_of_macfns,
+         syms_of_ccl, syms_of_fontset, syms_of_xterm, syms_of_search,
+         syms_of_frame, mac_term_init, and init_keyboard have already
+         been called.  */
+      syms_of_textprop ();
+      syms_of_macfns ();
+      syms_of_ccl ();
+      syms_of_fontset ();
+      syms_of_macterm ();
+      syms_of_macmenu ();
+      syms_of_macselect ();
+      syms_of_search ();
+      syms_of_frame ();
+
+      init_atimer ();
+      mac_term_init (build_string ("Mac"), NULL, NULL);
+      init_keyboard ();
+#endif
+      /* Called before syms_of_fileio, because it sets up Qerror_condition.  */
+      syms_of_data ();
+      syms_of_fileio ();
+      /* Before syms_of_coding to initialize Vgc_cons_threshold.  */
+      syms_of_alloc ();
+      /* Before syms_of_coding because it initializes Qcharsetp.  */
+      syms_of_charset ();
+      /* Before init_window_once, because it sets up the
+        Vcoding_system_hash_table.  */
+      syms_of_coding ();       /* This should be after syms_of_fileio.  */
+
       init_window_once ();     /* Init the window system.  */
       init_fileio_once ();     /* Must precede any path manipulation.  */
 #ifdef HAVE_WINDOW_SYSTEM
@@ -1379,12 +1394,15 @@ main (argc, argv
              Lisp_Object buffer;
 
              buffer = Fcdr (XCAR (tail));
-             /* Verify that all buffers are empty now, as they
-                ought to be.  */
-             if (BUF_Z (XBUFFER (buffer)) > BUF_BEG (XBUFFER (buffer)))
-               abort ();
-             /* It is safe to do this crudely in an empty buffer.  */
-             XBUFFER (buffer)->enable_multibyte_characters = Qnil;
+             /* Make a multibyte buffer unibyte.  */
+             if (BUF_Z_BYTE (XBUFFER (buffer)) > BUF_Z (XBUFFER (buffer)))
+               {
+                 struct buffer *current = current_buffer;
+
+                 set_buffer_temp (XBUFFER (buffer));
+                 Fset_buffer_multibyte (Qnil);
+                 set_buffer_temp (current);
+               }
            }
        }
     }
@@ -1392,7 +1410,6 @@ main (argc, argv
   no_loadup
     = argmatch (argv, argc, "-nl", "--no-loadup", 6, NULL, &skip_args);
 
-
 #ifdef HAVE_X_WINDOWS
   /* Stupid kludge to catch command-line display spec.  We can't
      handle this argument entirely in window system dependent code
@@ -1478,7 +1495,7 @@ main (argc, argv
      if this is not done.  Do it after set_global_environment so that we
      don't pollute Vglobal_environment.  */
   /* Setting LANG here will defeat the startup locale processing...  */
-#ifdef AIX3_2
+#ifdef AIX
   putenv ("LANG=C");
 #endif
 
@@ -1510,7 +1527,7 @@ main (argc, argv
         for the sake of symbols like error-message.  */
       /* Called before init_window_once for Mac OS Classic.  */
       syms_of_data ();
-      syms_of_alloc ();
+      syms_of_chartab ();
       syms_of_lread ();
       syms_of_print ();
       syms_of_eval ();
@@ -1525,7 +1542,7 @@ main (argc, argv
       syms_of_callproc ();
       syms_of_category ();
       syms_of_ccl ();
-      syms_of_charset ();
+      syms_of_character ();
       syms_of_cmds ();
 #ifndef NO_DIR_LIBRARY
       syms_of_dired ();
@@ -1534,8 +1551,6 @@ main (argc, argv
       syms_of_doc ();
       syms_of_editfns ();
       syms_of_emacs ();
-      syms_of_fileio ();
-      syms_of_coding ();       /* This should be after syms_of_fileio.  */
 #ifdef CLASH_DETECTION
       syms_of_filelock ();
 #endif /* CLASH_DETECTION */
@@ -1565,6 +1580,7 @@ main (argc, argv
 #endif /* WINDOWSNT */
       syms_of_window ();
       syms_of_xdisp ();
+      syms_of_font ();
 #ifdef HAVE_WINDOW_SYSTEM
       syms_of_fringe ();
       syms_of_image ();
@@ -1581,6 +1597,8 @@ main (argc, argv
 #endif
 #endif /* HAVE_X_WINDOWS */
 
+      syms_of_menu ();
+
 #ifndef HAVE_NTGUI
 #ifndef MAC_OS
       /* Called before init_window_once for Mac OS Classic.  */
@@ -1621,7 +1639,6 @@ main (argc, argv
       keys_of_buffer ();
       keys_of_keyboard ();
       keys_of_keymap ();
-      keys_of_minibuf ();
       keys_of_window ();
     }
   else
@@ -1635,6 +1652,8 @@ main (argc, argv
 #endif  /* HAVE_NTGUI */
     }
 
+  init_charset ();
+
   init_editfns (); /* init_process uses Voperating_system_release. */
   init_process (); /* init_display uses add_keyboard_wait_descriptor. */
   init_keyboard ();    /* This too must precede init_sys_modes.  */
@@ -1815,6 +1834,7 @@ struct standard_args standard_args[] =
   { "-title", 0, 10, 1 },
   { "-name", "--name", 10, 1 },
   { "-xrm", "--xrm", 10, 1 },
+  { "-parent-id", "--parent-id", 10, 1 },
   { "-r", "--reverse-video", 5, 0 },
   { "-rv", 0, 5, 0 },
   { "-reverse", 0, 5, 0 },
@@ -1829,7 +1849,11 @@ struct standard_args standard_args[] =
   { "-directory", 0, 0, 1 },
   { "-l", "--load", 0, 1 },
   { "-load", 0, 0, 1 },
-  { "-scriptload", "--scriptload", 0, 1 },
+  /* This has no longname, because using --scriptload confuses sort_args,
+     because then the --script long option seems to match twice; ie
+     you can't have a long option which is a prefix of another long
+     option.  In any case, this is entirely an internal option.  */
+  { "-scriptload", NULL, 0, 1 },
   { "-f", "--funcall", 0, 1 },
   { "-funcall", 0, 0, 1 },
   { "-eval", "--eval", 0, 1 },
@@ -1940,6 +1964,9 @@ sort_args (argc, argv)
                    fatal ("Option `%s' requires an argument\n", argv[from]);
                  from += options[from];
                }
+             /* FIXME When match < 0, shouldn't there be some error,
+                or at least indication to the user that there was a
+                problem?  */
            }
        done: ;
        }