(Qfont_spec, Qfont_entity, Qfont_object): Extern them.
[bpt/emacs.git] / src / emacs.c
index 46d07b1..7074076 100644 (file)
@@ -1,6 +1,7 @@
 /* Fully extensible Emacs, running on Unix, intended for GNU.
    Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 1998, 1999,
-                 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+                 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+                 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -262,6 +263,7 @@ Initialization options:\n\
 \n\
 --batch                     do not do interactive display; implies -q\n\
 --debug-init                enable Emacs Lisp debugger for init file\n\
+--disable-font-backend      do not use font backend (only if compiled)\n\
 --display, -d DISPLAY       use X server DISPLAY\n\
 --multibyte, --no-unibyte   inhibit the effect of EMACS_UNIBYTE\n\
 --no-desktop                do not load a saved desktop\n\
@@ -325,6 +327,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,7 +356,7 @@ 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 meay be
+/* 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).  */
 
@@ -421,11 +424,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);
@@ -1082,10 +1081,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.  */
@@ -1135,8 +1130,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);
@@ -1282,6 +1278,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.  */
@@ -1320,7 +1317,6 @@ main (argc, argv
       syms_of_macterm ();
       syms_of_macmenu ();
       syms_of_macselect ();
-      syms_of_data ();
       syms_of_search ();
       syms_of_frame ();
 
@@ -1328,6 +1324,16 @@ main (argc, argv
       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.  */
@@ -1350,9 +1356,7 @@ main (argc, argv
 #ifdef CLASH_DETECTION
   init_filelock ();
 #endif
-#ifndef MAC_OS8
   init_atimer ();
-#endif
   running_asynch_code = 0;
 
   /* Handle --unibyte and the EMACS_UNIBYTE envvar,
@@ -1403,12 +1407,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);
+               }
            }
        }
     }
@@ -1416,7 +1423,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
@@ -1532,18 +1538,15 @@ main (argc, argv
       /* The basic levels of Lisp must come first.  */
       /* And data must come first of all
         for the sake of symbols like error-message.  */
-#ifndef MAC_OS8
       /* Called before init_window_once for Mac OS Classic.  */
       syms_of_data ();
-#endif
-      syms_of_alloc ();
+      syms_of_chartab ();
       syms_of_lread ();
       syms_of_print ();
       syms_of_eval ();
       syms_of_fns ();
       syms_of_floatfns ();
 
-      syms_of_abbrev ();
       syms_of_buffer ();
       syms_of_bytecode ();
       syms_of_callint ();
@@ -1551,11 +1554,8 @@ main (argc, argv
       syms_of_casetab ();
       syms_of_callproc ();
       syms_of_category ();
-#ifndef MAC_OS8
-      /* Called before init_window_once for Mac OS Classic.  */
       syms_of_ccl ();
-#endif
-      syms_of_charset ();
+      syms_of_character ();
       syms_of_cmds ();
 #ifndef NO_DIR_LIBRARY
       syms_of_dired ();
@@ -1564,8 +1564,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 */
@@ -1576,11 +1574,8 @@ main (argc, argv
       syms_of_marker ();
       syms_of_minibuf ();
       syms_of_process ();
-#ifndef MAC_OS8
-      /* Called before init_window_once for Mac OS Classic.  */
       syms_of_search ();
       syms_of_frame ();
-#endif
       syms_of_syntax ();
       syms_of_terminal ();
       syms_of_term ();
@@ -1588,10 +1583,7 @@ main (argc, argv
 #ifdef HAVE_SOUND
       syms_of_sound ();
 #endif
-#ifndef MAC_OS8
-      /* Called before init_window_once for Mac OS Classic.  */
       syms_of_textprop ();
-#endif
       syms_of_composite ();
 #ifdef VMS
       syms_of_vmsproc ();
@@ -1602,6 +1594,7 @@ main (argc, argv
       syms_of_window ();
       syms_of_xdisp ();
 #ifdef HAVE_WINDOW_SYSTEM
+      syms_of_font ();
       syms_of_fringe ();
       syms_of_image ();
 #endif /* HAVE_WINDOW_SYSTEM */
@@ -1640,6 +1633,10 @@ main (argc, argv
       syms_of_fontset ();
 #endif /* MAC_OSX && HAVE_CARBON */
 
+#ifdef HAVE_DBUS
+      syms_of_dbusbind ();
+#endif /* HAVE_DBUS */
+
 #ifdef SYMS_SYSTEM
       SYMS_SYSTEM;
 #endif
@@ -1667,11 +1664,11 @@ 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. */
-#ifndef MAC_OS8
-  /* Called before init_window_once for Mac OS Classic.  */
   init_keyboard ();    /* This too must precede init_sys_modes.  */
-#endif
 #ifdef VMS
   init_vmsproc ();     /* And this too.  */
 #endif /* VMS */
@@ -1689,7 +1686,6 @@ main (argc, argv
   init_image ();
 #endif /* HAVE_WINDOW_SYSTEM */
   init_macros ();
-  init_editfns ();
   init_floatfns ();
 #ifdef VMS
   init_vmsfns ();
@@ -1813,6 +1809,7 @@ struct standard_args standard_args[] =
   { "-unibyte", "--unibyte", 81, 0 },
   { "-no-multibyte", "--no-multibyte", 80, 0 },
   { "-nl", "--no-loadup", 70, 0 },
+  { "-disable-font-backend", "--disable-font-backend", 65, 0 },
   /* -d must come last before the options handled in startup.el.  */
   { "-d", "--display", 60, 1 },
   { "-display", 0, 60, 1 },
@@ -1850,6 +1847,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 },
@@ -1864,7 +1862,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 },
@@ -1975,6 +1977,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: ;
        }
@@ -2229,10 +2234,10 @@ You must run Emacs in batch mode in order to dump it.  */)
     {
       fprintf (stderr, "**************************************************\n");
       fprintf (stderr, "Warning: Your system has a gap between BSS and the\n");
-      fprintf (stderr, "heap (%lu byte).  This usually means that exec-shield\n",
+      fprintf (stderr, "heap (%lu bytes).  This usually means that exec-shield\n",
                heap_bss_diff);
       fprintf (stderr, "or something similar is in effect.  The dump may\n");
-      fprintf (stderr, "fail because of this.  See the section about \n");
+      fprintf (stderr, "fail because of this.  See the section about\n");
       fprintf (stderr, "exec-shield in etc/PROBLEMS for more information.\n");
       fprintf (stderr, "**************************************************\n");
     }
@@ -2475,7 +2480,7 @@ Emacs is running.  */);
               doc: /* Non-nil means Emacs is running without interactive terminal.  */);
 
   DEFVAR_LISP ("kill-emacs-hook", &Vkill_emacs_hook,
-              doc: /* Hook to be run when kill-emacs is called.
+              doc: /* Hook to be run when `kill-emacs' is called.
 Since `kill-emacs' may be invoked when the terminal is disconnected (or
 in other similar situations), functions placed on this hook should not
 expect to be able to interact with the user.  To ask for confirmation,
@@ -2512,8 +2517,8 @@ The value is nil if that directory's name is not known.  */);
   DEFVAR_LISP ("installation-directory", &Vinstallation_directory,
               doc: /* A directory within which to look for the `lib-src' and `etc' directories.
 This is non-nil when we can't find those directories in their standard
-installed locations, but we can find them
-near where the Emacs executable was found.  */);
+installed locations, but we can find them near where the Emacs executable
+was found.  */);
   Vinstallation_directory = Qnil;
 
   DEFVAR_LISP ("system-messages-locale", &Vsystem_messages_locale,