(unchain_marker): Allow differing buffers
[bpt/emacs.git] / src / emacs.c
index 34554d1..ceb56aa 100644 (file)
@@ -420,6 +420,22 @@ main (argc, argv, envp)
 
   sort_args (argc, argv);
 
+  if (argmatch (argv, argc, "-version", "--version", 3, NULL, &skip_args))
+    {
+      Lisp_Object tem;
+      tem = Fsymbol_value (intern ("emacs-version"));
+      if (!STRINGP (tem))
+       {
+         fprintf (stderr, "Invalid value of `emacs-version'\n");
+         exit (1);
+       }
+      else
+       {
+         printf ("%s\n", XSTRING (tem)->data);
+         exit (0);
+       }
+    }
+
 /* Map in shared memory, if we are using that.  */
 #ifdef HAVE_SHM
   if (argmatch (argv, argc, "-nl", "--no-shared-memory", 6, NULL, &skip_args))
@@ -604,7 +620,9 @@ Usage: %s [-t term] [--terminal term]  [-nw] [--no-windows]  [--batch]\n\
        argv = new;
        argc++;
       }
-    else if (displayname != 0 && argv[count_before + 1][1] == '-')
+    /* Change --display to -d, when its arg is separate.  */
+    else if (displayname != 0 && skip_args > count_before
+            && argv[count_before + 1][1] == '-')
       argv[count_before] = "-d";
 
     /* Don't actually discard this arg.  */
@@ -646,6 +664,27 @@ Usage: %s [-t term] [--terminal term]  [-nw] [--no-windows]  [--batch]\n\
       signal (SIGQUIT, fatal_error_signal);
       signal (SIGILL, fatal_error_signal);
       signal (SIGTRAP, fatal_error_signal);
+#ifdef SIGABRT
+      signal (SIGABRT, fatal_error_signal);
+#endif
+#ifdef SIGHWE
+      signal (SIGHWE, fatal_error_signal);
+#endif
+#ifdef SIGPRE
+      signal (SIGPRE, fatal_error_signal);
+#endif
+#ifdef SIGORE
+      signal (SIGORE, fatal_error_signal);
+#endif
+#ifdef SIGUME
+      signal (SIGUME, fatal_error_signal);
+#endif
+#ifdef SIGDLK
+      signal (SIGDLK, fatal_error_signal);
+#endif
+#ifdef SIGCPULIM
+      signal (SIGCPULIM, fatal_error_signal);
+#endif
 #ifdef SIGIOT
       /* This is missing on some systems - OS/2, for example.  */
       signal (SIGIOT, fatal_error_signal);
@@ -921,11 +960,6 @@ struct standard_args standard_args[] =
   { "-u", "--user", 30, 1 },
   { "-user", 0, 30, 1 },
   { "-debug-init", "--debug-init", 20, 0 },
-  { "-l", "--load", 10, 1 },
-  { "-load", 0, 10, 1 },
-  { "-f", "--funcall", 10, 1 },
-  { "-funcall", 0, 10, 1 },
-  { "-insert", "--insert", 10, 1 },
   { "-bg", "--background-color", 10, 1 },
   { "-background", 0, 10, 1 },
   { "-fg", "--foreground-color", 10, 1 },
@@ -944,12 +978,19 @@ struct standard_args standard_args[] =
   { "-itype", 0, 10, 1 },
   { "-name", "--name", 10, 1 },
   { "-xrm", "--xrm", 10, 1 },
-  { "-r", "--reverse-video", 0, 0 },
-  { "-rv", 0, 0, 0 },
-  { "-reverse", 0, 0, 0 },
-  { "-vb", "--vertical-scroll-bars", 0, 0 },
-  { "-iconic", "--iconic", 0, 0 },
-  { "-kill", "--kill", 0, 0 },
+  { "-r", "--reverse-video", 5, 0 },
+  { "-rv", 0, 5, 0 },
+  { "-reverse", 0, 5, 0 },
+  { "-vb", "--vertical-scroll-bars", 5, 0 },
+  { "-iconic", "--iconic", 5, 0 },
+  /* These have the same priority as ordinary file name args,
+     so they are not reordered with respect to those.  */
+  { "-l", "--load", 0, 1 },
+  { "-load", 0, 0, 1 },
+  { "-f", "--funcall", 0, 1 },
+  { "-funcall", 0, 0, 1 },
+  { "-insert", "--insert", 0, 1 },
+  { "-kill", "--kill", -10, 0 },
 };
 
 /* Reorder the elements of ARGV (assumed to have ARGC elements)
@@ -968,7 +1009,7 @@ sort_args (argc, argv)
      0 for an option that takes no arguments,
      1 for an option that takes one argument, etc.
      -1 for an ordinary non-option argument.  */
-  char *options = (char *) xmalloc (argc);
+  int *options = (int *) xmalloc (sizeof (int) * argc);
   int *priority = (int *) xmalloc (sizeof (int) * argc);
   int to = 1;
   int from;
@@ -979,7 +1020,7 @@ sort_args (argc, argv)
   for (from = 1; from < argc; from++)
     {
       options[from] = -1;
-      priority[from] = -1;
+      priority[from] = 0;
       if (argv[from][0] == '-')
        {
          int match, thislen;
@@ -1066,7 +1107,7 @@ sort_args (argc, argv)
        argv[best + i + 1] = 0;
     }
 
-  bcopy (new, argv, sizeof (char *) * (argc + 1));
+  bcopy (new, argv, sizeof (char *) * argc);
 }
 \f
 DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P",
@@ -1346,7 +1387,8 @@ syms_of_emacs ()
     "Hook to be run whenever kill-emacs is called.\n\
 Since kill-emacs may be invoked when the terminal is disconnected (or\n\
 in other similar situations), functions placed on this hook should not\n\
-expect to be able to interact with the user.");
+expect to be able to interact with the user.  To ask for confirmation,\n\
+see `kill-emacs-query-functions' instead.");
   Vkill_emacs_hook = Qnil;
 
   DEFVAR_INT ("emacs-priority", &emacs_priority,