]> code.delx.au - gnu-emacs/blobdiff - src/emacs.c
(main): Test `initialized' before clearing *Messages*.
[gnu-emacs] / src / emacs.c
index f501ec847b88708c52b721cf2f21d133a4daae77..3de28f12db4288725fad1477ebcff08d4857d796 100644 (file)
@@ -39,6 +39,7 @@ Boston, MA 02111-1307, USA.  */
 #include "lisp.h"
 #include "commands.h"
 #include "intervals.h"
+#include "buffer.h"
 
 #include "systty.h"
 #include "blockinput.h"
@@ -266,11 +267,13 @@ memory_warning_signal (sig)
    so that GDB can return from a breakpoint here.
    MSDOS has its own definition on msdos.c  */
 
-#ifndef DOS_NT
+#if ! defined (DOS_NT) && ! defined (NO_ABORT)
 void
 abort ()
 {
   kill (getpid (), SIGABRT);
+  /* This shouldn't be executed, but it prevents a warning.  */
+  exit (1);
 }
 #endif
 
@@ -741,29 +744,6 @@ main (argc, argv, envp)
 
   inhibit_window_system = 0;
 
-  {
-    int inhibit_unibyte = 0;
-
-    /* --multibyte overrides EMACS_UNIBYTE.  */
-    if (argmatch (argv, argc, "-no-unibyte", "--no-unibyte", 4, NULL, &skip_args)
-       || argmatch (argv, argc, "-multibyte", "--multibyte", 4, NULL, &skip_args))
-      inhibit_unibyte = 1;
-  
-    /* --unibyte requests that we set up to do everything with single-byte
-       buffers and strings.  We need to handle this before calling
-       init_lread, init_editfns and other places that generate Lisp strings
-       from text in the environment.  */
-    if (argmatch (argv, argc, "-unibyte", "--unibyte", 4, NULL, &skip_args)
-       || argmatch (argv, argc, "-no-multibyte", "--no-multibyte", 4, NULL, &skip_args)
-       || (getenv ("EMACS_UNIBYTE") && !inhibit_unibyte))
-      {
-       Lisp_Object symbol;
-       symbol = intern ("default-enable-multibyte-characters");
-       Fset (symbol, Qnil);
-       Fset_default (symbol, Qnil);
-      }
-  }
-
   /* Handle the -t switch, which specifies filename to use as terminal */
   {
     char *term;
@@ -805,10 +785,10 @@ main (argc, argv, envp)
       printf ("\
 Usage: %s [-t term] [--terminal term]  [-nw] [--no-windows]  [--batch]\n\
       [-q] [--no-init-file]  [-u user] [--user user]  [--debug-init]\n\
-      [--version] [--no-site-file]\n\
+      [--unibyte] [--multibyte] [--version] [--no-site-file]\n\
       [-f func] [--funcall func]  [-l file] [--load file]  [--insert file]\n\
       [+linenum] file-to-visit  [--kill]\n\
-Report bugs to bug-gnu-emacs@prep.ai.mit.edu.  First, please see\n\
+Report bugs to bug-gnu-emacs@gnu.org.  First, please see\n\
 the Bugs section of the Emacs manual or the file BUGS.\n", argv[0]);
       exit (0);
     }
@@ -998,6 +978,62 @@ the Bugs section of the Emacs manual or the file BUGS.\n", argv[0]);
   init_data ();
   running_asynch_code = 0;
 
+  /* Handle --unibyte and the EMACS_UNIBYTE envvar,
+     but not while dumping.  */
+  if (
+#ifndef CANNOT_DUMP
+      ! noninteractive || initialized
+#else
+      1
+#endif
+      )
+    {
+      int inhibit_unibyte = 0;
+
+      /* --multibyte overrides EMACS_UNIBYTE.  */
+      if (argmatch (argv, argc, "-no-unibyte", "--no-unibyte", 4, NULL, &skip_args)
+         || argmatch (argv, argc, "-multibyte", "--multibyte", 4, NULL, &skip_args))
+       inhibit_unibyte = 1;
+
+      /* --unibyte requests that we set up to do everything with single-byte
+        buffers and strings.  We need to handle this before calling
+        init_lread, init_editfns and other places that generate Lisp strings
+        from text in the environment.  */
+      if (argmatch (argv, argc, "-unibyte", "--unibyte", 4, NULL, &skip_args)
+         || argmatch (argv, argc, "-no-multibyte", "--no-multibyte", 4, NULL, &skip_args)
+         || (getenv ("EMACS_UNIBYTE") && !inhibit_unibyte))
+       {
+         Lisp_Object old_log_max;
+         Lisp_Object symbol, tail;
+
+         symbol = intern ("default-enable-multibyte-characters");
+         Fset (symbol, Qnil);
+
+         if (initialized)
+           {
+             /* Erase pre-dump messages in *Messages* now so no abort.  */
+             old_log_max = Vmessage_log_max;
+             XSETFASTINT (Vmessage_log_max, 0);
+             message_dolog ("", 0, 1, 0);
+             Vmessage_log_max = old_log_max;
+           }
+
+         for (tail = Vbuffer_alist; CONSP (tail);
+              tail = XCONS (tail)->cdr)
+           {
+             Lisp_Object buffer;
+
+             buffer = Fcdr (XCONS (tail)->car);
+             /* 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;
+           }
+       }
+    }
+
 #ifdef MSDOS
   /* Call early 'cause init_environment needs it.  */
   init_dosfns ();
@@ -1043,30 +1079,8 @@ the Bugs section of the Emacs manual or the file BUGS.\n", argv[0]);
   init_callproc ();    /* Must follow init_cmdargs but not init_sys_modes.  */
   init_lread ();
 
-  if (!noninteractive)
-    {
-#ifdef VMS
-      init_vms_input ();/* init_display calls get_frame_size, that needs this */
-#endif /* VMS */
-      init_display (); /* Determine terminal type.  init_sys_modes uses results */
-    }
-  init_keyboard ();    /* This too must precede init_sys_modes */
-#ifdef VMS
-  init_vmsproc ();     /* And this too. */
-#endif /* VMS */
-  init_sys_modes ();   /* Init system terminal modes (RAW or CBREAK, etc.) */
-  init_xdisp ();
-  init_macros ();
-  init_editfns ();
-#ifdef LISP_FLOAT_TYPE
-  init_floatfns ();
-#endif
-#ifdef VMS
-  init_vmsfns ();
-#endif /* VMS */
-  init_process ();
-
-/* Intern the names of all standard functions and variables; define standard keys */
+  /* Intern the names of all standard functions and variables;
+     define standard keys.  */
 
   if (!initialized)
     {
@@ -1170,6 +1184,29 @@ the Bugs section of the Emacs manual or the file BUGS.\n", argv[0]);
       keys_of_frame ();
     }
 
+  if (!noninteractive)
+    {
+#ifdef VMS
+      init_vms_input ();/* init_display calls get_frame_size, that needs this */
+#endif /* VMS */
+      init_display (); /* Determine terminal type.  init_sys_modes uses results */
+    }
+  init_keyboard ();    /* This too must precede init_sys_modes */
+#ifdef VMS
+  init_vmsproc ();     /* And this too. */
+#endif /* VMS */
+  init_sys_modes ();   /* Init system terminal modes (RAW or CBREAK, etc.) */
+  init_xdisp ();
+  init_macros ();
+  init_editfns ();
+#ifdef LISP_FLOAT_TYPE
+  init_floatfns ();
+#endif
+#ifdef VMS
+  init_vmsfns ();
+#endif /* VMS */
+  init_process ();
+
   if (!initialized)
     {
       char *file;
@@ -1265,14 +1302,14 @@ struct standard_args standard_args[] =
 #ifdef VMS
   { "-map", "--map-data", 100, 0 },
 #endif
-  { "-no-unibyte", "--no-unibyte", 96, 0 },
-  { "-multibyte", "--multibyte", 96, 0 },
-  { "-unibyte", "--unibyte", 95, 0 },
-  { "-no-multibyte", "--no-multibyte", 95, 0 },
   { "-t", "--terminal", 90, 1 },
   { "-d", "--display", 80, 1 },
   { "-display", 0, 80, 1 },
   { "-nw", "--no-windows", 70, 0 },
+  { "-no-unibyte", "--no-unibyte", 66, 0 },
+  { "-multibyte", "--multibyte", 66, 0 },
+  { "-unibyte", "--unibyte", 65, 0 },
+  { "-no-multibyte", "--no-multibyte", 65, 0 },
   { "-batch", "--batch", 60, 0 },
   { "-q", "--no-init-file", 50, 0 },
   { "-no-init-file", 0, 50, 0 },
@@ -1806,11 +1843,11 @@ see `kill-emacs-query-functions' instead.");
 
 #ifdef SIGUSR1
   DEFVAR_LISP ("signal-USR1-hook", &Vsignal_USR1_hook,
-    "Hook to be run whenever emacs recieves a USR1 signal");
+    "Hook to be run whenever emacs receives a USR1 signal");
   Vsignal_USR1_hook = Qnil;
 #ifdef SIGUSR2
   DEFVAR_LISP ("signal-USR2-hook", &Vsignal_USR2_hook,
-    "Hook to be run whenever emacs recieves a USR2 signal");
+    "Hook to be run whenever emacs receives a USR2 signal");
   Vsignal_USR2_hook = Qnil;
 #endif
 #endif
@@ -1822,6 +1859,8 @@ This value is effective only if set before Emacs is dumped,\n\
 and only if the Emacs executable is installed with setuid to permit\n\
 it to change priority.  (Emacs sets its uid back to the real uid.)\n\
 Currently, you need to define SET_EMACS_PRIORITY in `config.h'\n\
+before you compile Emacs, to enable the code for this feature.");
+  emacs_priority = 0;
 
   DEFVAR_LISP ("path-separator", &Vpath_separator,
     "The directory separator in search paths, as a string.");
@@ -1829,8 +1868,6 @@ Currently, you need to define SET_EMACS_PRIORITY in `config.h'\n\
     char c = SEPCHAR;
     Vpath_separator = make_string (&c, 1);
   }
-before you compile Emacs, to enable the code for this feature.");
-  emacs_priority = 0;
 
   DEFVAR_LISP ("invocation-name", &Vinvocation_name,
     "The program name that was used to run Emacs.\n\