* bitmaps/README:
[bpt/emacs.git] / src / emacs.c
index 46d07b1..ece0e41 100644 (file)
@@ -1,13 +1,14 @@
 /* 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.
 
-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
@@ -15,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>
@@ -28,10 +27,6 @@ Boston, MA 02110-1301, USA.  */
 #include <sys/types.h>
 #include <sys/file.h>
 
-#ifdef VMS
-#include <ssdef.h>
-#endif
-
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
@@ -47,6 +42,11 @@ Boston, MA 02110-1301, USA.  */
 #include "w32heap.h" /* for prototype of sbrk */
 #endif
 
+#ifdef NS_IMPL_GNUSTEP
+/* At least under Debian, GSConfig is in a subdirectory.  --Stef  */
+#include <GNUstepBase/GSConfig.h>
+#endif
+
 #include "lisp.h"
 #include "commands.h"
 #include "intervals.h"
@@ -99,7 +99,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;
@@ -194,7 +194,7 @@ int running_asynch_code;
 extern int inherited_pgroup;
 #endif
 
-#ifdef HAVE_X_WINDOWS
+#if defined(HAVE_X_WINDOWS) || defined(HAVE_NS)
 /* If non-zero, -d was specified, meaning we're using some window system.  */
 int display_arg;
 #endif
@@ -222,13 +222,6 @@ extern Lisp_Object Vauto_save_list_file_name;
 
 extern Lisp_Object Vinhibit_redisplay;
 
-#ifdef USG_SHARED_LIBRARIES
-/* If nonzero, this is the place to put the end of the writable segment
-   at startup.  */
-
-unsigned int bss_end = 0;
-#endif
-
 /* Nonzero means running Emacs without interactive terminal.  */
 
 int noninteractive;
@@ -325,6 +318,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"
@@ -352,10 +346,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 meay 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,
+   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
@@ -380,9 +374,6 @@ fatal_error_signal (sig)
       shut_down_emacs (sig, 0, Qnil);
     }
 
-#ifdef VMS
-  LIB$STOP (SS$_ABORT);
-#else
   /* Signal the same code; this time it will really be fatal.
      Remember that since we're in a signal handler, the signal we're
      going to send is probably blocked, so we have to unblock it if we
@@ -395,7 +386,6 @@ fatal_error_signal (sig)
     fatal_error_signal_hook ();
 
   kill (getpid (), fatal_error_code);
-#endif /* not VMS */
 }
 
 #ifdef SIGDANGER
@@ -421,11 +411,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);
@@ -597,14 +583,6 @@ DEFUN ("invocation-directory", Finvocation_directory, Sinvocation_directory,
 }
 
 \f
-#ifdef VMS
-#ifdef LINK_CRTL_SHARE
-#ifdef SHARABLE_LIB_BUG
-extern noshare char **environ;
-#endif /* SHARABLE_LIB_BUG */
-#endif /* LINK_CRTL_SHARE */
-#endif /* VMS */
-
 #ifdef HAVE_TZSET
 /* A valid but unlikely value for the TZ environment value.
    It is OK (though a bit slower) if the user actually chooses this value.  */
@@ -791,16 +769,7 @@ bug_reporting_address ()
 
 /* ARGSUSED */
 int
-main (argc, argv
-#ifdef VMS
-, envp
-#endif
-)
-     int argc;
-     char **argv;
-#ifdef VMS
-     char **envp;
-#endif
+main (int argc, char **argv)
 {
 #if GC_MARK_STACK
   Lisp_Object dummy;
@@ -834,6 +803,7 @@ main (argc, argv
     }
 
 #ifdef LINUX_SBRK_BUG
+  /* This is only used GNU/LINUX running on alpha when using libc5 */
   __sbrk (1);
 #endif
 
@@ -842,7 +812,7 @@ main (argc, argv
     run_time_remap (argv[0]);
 #endif
 
-#ifdef MAC_OSX
+#if defined (NS_IMPL_COCOA)
   if (!initialized)
     unexec_init_emacs_zone ();
 #endif
@@ -926,52 +896,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
-     Emacs is invoked from the Finder or by the `open' command.  In
-     these cases, the working directory becomes `/', so we change it
-     to the user's home directory.  */
-  if (argc > skip_args + 1 && strncmp (argv[skip_args+1], "-psn_", 5) == 0)
-    {
-      chdir (getenv ("HOME"));
-      skip_args++;
-    }
-#endif /* MAC_OSX */
-
-#ifdef VMS
-  /* If -map specified, map the data file in.  */
-  {
-    char *file;
-    if (argmatch (argv, argc, "-map", "--map-data", 3, &file, &skip_args))
-      mapin_data (file);
-  }
-
-#ifdef LINK_CRTL_SHARE
-#ifdef SHARABLE_LIB_BUG
-  /* Bletcherous shared libraries!  */
-  if (!stdin)
-    stdin = fdopen (0, "r");
-  if (!stdout)
-    stdout = fdopen (1, "w");
-  if (!stderr)
-    stderr = fdopen (2, "w");
-  if (!environ)
-    environ = envp;
-#endif /* SHARABLE_LIB_BUG */
-#endif /* LINK_CRTL_SHARE */
-#endif /* VMS */
-
 #if defined (HAVE_SETRLIMIT) && defined (RLIMIT_STACK)
   /* Extend the stack space available.
      Don't do that if dumping, since some systems (e.g. DJGPP)
@@ -1015,11 +939,6 @@ main (argc, argv
   /* Record (approximately) where the stack begins.  */
   stack_bottom = &stack_bottom_variable;
 
-#ifdef USG_SHARED_LIBRARIES
-  if (bss_end)
-    brk ((void *)bss_end);
-#endif
-
   clearerr (stdin);
 
 #ifndef SYSTEM_MALLOC
@@ -1036,9 +955,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
@@ -1082,10 +1001,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 +1050,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 +1198,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.  */
@@ -1306,28 +1223,16 @@ 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 ();
+      /* Called before syms_of_fileio, because it sets up Qerror_condition.  */
       syms_of_data ();
-      syms_of_search ();
-      syms_of_frame ();
-
-      init_atimer ();
-      mac_term_init (build_string ("Mac"), NULL, NULL);
-      init_keyboard ();
-#endif
+      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 +1255,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 +1306,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,6 +1322,37 @@ main (argc, argv
   no_loadup
     = argmatch (argv, argc, "-nl", "--no-loadup", 6, NULL, &skip_args);
 
+#ifdef HAVE_NS
+  ns_alloc_autorelease_pool();
+  if (!noninteractive)
+    {
+      char *tmp;
+      display_arg = 4;
+#ifdef NS_IMPL_COCOA
+      if (skip_args < argc)
+        {
+          if (!strncmp(argv[skip_args], "-psn", 4))
+            {
+              skip_args += 1;
+            }
+          else
+            {
+              if (skip_args+1 < argc && !strncmp(argv[skip_args+1], "-psn", 4))
+                  skip_args += 2;
+            }
+        }
+#endif
+      /* This used for remote operation.. not fully implemented yet. */
+      if (argmatch (argv, argc, "-_NSMachLaunch", 0, 3, &tmp, &skip_args))
+          display_arg = 4;
+      else if (argmatch (argv, argc, "-MachLaunch", 0, 3, &tmp, &skip_args))
+          display_arg = 4;
+      else if (argmatch (argv, argc, "-macosx", 0, 2, NULL, &skip_args))
+          display_arg = 4;
+      else if (argmatch (argv, argc, "-NSHost", 0, 3, &tmp, &skip_args))
+          display_arg = 4;
+    }
+#endif /* HAVE_NS */
 
 #ifdef HAVE_X_WINDOWS
   /* Stupid kludge to catch command-line display spec.  We can't
@@ -1489,9 +1426,11 @@ main (argc, argv
   init_ntproc ();      /* must precede init_editfns.  */
 #endif
 
-#if defined (MAC_OSX) && defined (HAVE_CARBON)
+#ifdef HAVE_NS
+#ifndef CANNOT_DUMP
   if (initialized)
-    init_mac_osx_environment ();
+#endif
+    ns_init_paths ();
 #endif
 
   /* egetenv is a pretty low-level facility, which may get called in
@@ -1502,7 +1441,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
 
@@ -1532,18 +1471,14 @@ 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 +1486,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 +1496,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 +1506,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,19 +1515,14 @@ 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 ();
-#endif /* VMS */
 #ifdef WINDOWSNT
       syms_of_ntproc ();
 #endif /* WINDOWSNT */
       syms_of_window ();
       syms_of_xdisp ();
+      syms_of_font ();
 #ifdef HAVE_WINDOW_SYSTEM
       syms_of_fringe ();
       syms_of_image ();
@@ -1608,6 +1530,7 @@ main (argc, argv
 #ifdef HAVE_X_WINDOWS
       syms_of_xterm ();
       syms_of_xfns ();
+      syms_of_xmenu ();
       syms_of_fontset ();
 #ifdef HAVE_X_SM
       syms_of_xsmfns ();
@@ -1617,12 +1540,7 @@ main (argc, argv
 #endif
 #endif /* HAVE_X_WINDOWS */
 
-#ifndef HAVE_NTGUI
-#ifndef MAC_OS
-      /* Called before init_window_once for Mac OS Classic.  */
-      syms_of_xmenu ();
-#endif
-#endif
+      syms_of_menu ();
 
 #ifdef HAVE_NTGUI
       syms_of_w32term ();
@@ -1632,13 +1550,17 @@ main (argc, argv
       syms_of_fontset ();
 #endif /* HAVE_NTGUI */
 
-#if defined (MAC_OSX) && defined (HAVE_CARBON)
-      syms_of_macterm ();
-      syms_of_macfns ();
-      syms_of_macmenu ();
-      syms_of_macselect ();
+#ifdef HAVE_NS
+      syms_of_nsterm ();
+      syms_of_nsfns ();
+      syms_of_nsmenu ();
+      syms_of_nsselect ();
       syms_of_fontset ();
-#endif /* MAC_OSX && HAVE_CARBON */
+#endif /* HAVE_NS */
+
+#ifdef HAVE_DBUS
+      syms_of_dbusbind ();
+#endif /* HAVE_DBUS */
 
 #ifdef SYMS_SYSTEM
       SYMS_SYSTEM;
@@ -1653,7 +1575,6 @@ main (argc, argv
       keys_of_buffer ();
       keys_of_keyboard ();
       keys_of_keymap ();
-      keys_of_minibuf ();
       keys_of_window ();
     }
   else
@@ -1667,21 +1588,13 @@ 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 */
   if (!noninteractive)
-    {
-#ifdef VMS
-      init_vms_input ();/* init_display calls get_tty_size, that needs this.  */
-#endif /* VMS */
-      init_display (); /* Determine terminal type.  Calls init_sys_modes.  */
-    }
+    init_display ();   /* Determine terminal type.  Calls init_sys_modes.  */
   init_fns ();
   init_xdisp ();
 #ifdef HAVE_WINDOW_SYSTEM
@@ -1689,11 +1602,7 @@ main (argc, argv
   init_image ();
 #endif /* HAVE_WINDOW_SYSTEM */
   init_macros ();
-  init_editfns ();
   init_floatfns ();
-#ifdef VMS
-  init_vmsfns ();
-#endif /* VMS */
 #ifdef HAVE_SOUND
   init_sound ();
 #endif
@@ -1798,9 +1707,6 @@ struct standard_args standard_args[] =
   { "-version", "--version", 150, 0 },
 #ifdef HAVE_SHM
   { "-nl", "--no-shared-memory", 140, 0 },
-#endif
-#ifdef VMS
-  { "-map", "--map-data", 130, 0 },
 #endif
   { "-t", "--terminal", 120, 1 },
   { "-nw", "--no-window-system", 110, 0 },
@@ -1850,6 +1756,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 },
@@ -1858,13 +1765,26 @@ struct standard_args standard_args[] =
   { "-color", "--color", 5, 0},
   { "-no-splash", "--no-splash", 3, 0 },
   { "-no-desktop", "--no-desktop", 3, 0 },
+#ifdef HAVE_NS
+  { "-NSAutoLaunch", 0, 5, 1 },
+  { "-NXAutoLaunch", 0, 5, 1 },
+  { "-disable-font-backend", "--disable-font-backend", 65, 0 },
+  { "-_NSMachLaunch", 0, 85, 1 },
+  { "-MachLaunch", 0, 85, 1 },
+  { "-macosx", 0, 85, 0 },
+  { "-NSHost", 0, 85, 1 },
+#endif
   /* These have the same priority as ordinary file name args,
      so they are not reordered with respect to those.  */
   { "-L", "--directory", 0, 1 },
   { "-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 },
@@ -1873,6 +1793,13 @@ struct standard_args standard_args[] =
   { "-visit", "--visit", 0, 1 },
   { "-file", "--file", 0, 1 },
   { "-insert", "--insert", 0, 1 },
+#ifdef HAVE_NS
+  { "-NXOpen", 0, 0, 1 },
+  { "-NXOpenTemp", 0, 0, 1 },
+  { "-NSOpen", 0, 0, 1 },
+  { "-NSOpenTemp", 0, 0, 1 },
+  { "-GSFilePath", 0, 0, 1 },
+#endif
   /* This should be processed after ordinary file name args and the like.  */
   { "-kill", "--kill", -10, 0 },
 };
@@ -1975,6 +1902,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: ;
        }
@@ -2056,12 +1986,6 @@ all of which are called before Emacs is actually killed.  */)
 
   UNGCPRO;
 
-/* Is it really necessary to do this deassign
-   when we are going to exit anyway?  */
-/* #ifdef VMS
-  stop_vms_input ();
- #endif  */
-
   shut_down_emacs (0, 0, STRINGP (arg) ? arg : Qnil);
 
   /* If we have an auto-save list file,
@@ -2129,10 +2053,6 @@ shut_down_emacs (sig, no_x, stuff)
   unlock_all_files ();
 #endif
 
-#ifdef VMS
-  kill_vms_processes ();
-#endif
-
 #if 0 /* This triggers a bug in XCloseDisplay and is not needed.  */
 #ifdef HAVE_X_WINDOWS
   /* It's not safe to call intern here.  Maybe we are crashing.  */
@@ -2166,6 +2086,10 @@ shut_down_emacs (sig, no_x, stuff)
 #ifdef MSDOS
   dos_cleanup ();
 #endif
+
+#ifdef HAVE_NS
+  ns_term_shutdown (sig);
+#endif
 }
 
 
@@ -2229,10 +2153,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");
     }
@@ -2265,9 +2189,6 @@ You must run Emacs in batch mode in order to dump it.  */)
 #endif
 
   fflush (stdout);
-#ifdef VMS
-  mapout_data (SDATA (filename));
-#else
   /* Tell malloc where start of impure now is.  */
   /* Also arrange for warnings when nearly out of space.  */
 #ifndef SYSTEM_MALLOC
@@ -2298,7 +2219,6 @@ You must run Emacs in batch mode in order to dump it.  */)
 #ifdef DOUG_LEA_MALLOC
   free (malloc_state_ptr);
 #endif
-#endif /* not VMS */
 
   Vpurify_flag = tem;
 
@@ -2450,14 +2370,12 @@ Many arguments are deleted from the list as they are processed.  */);
   DEFVAR_LISP ("system-type", &Vsystem_type,
               doc: /* Value is symbol indicating type of operating system you are using.
 Special values:
+  `gnu'         compiled for a GNU Hurd system.
   `gnu/linux'   compiled for a GNU/Linux system.
   `darwin'      compiled for Darwin (GNU-Darwin, Mac OS X, ...).
-  `macos'       compiled for Mac OS 9.
   `ms-dos'      compiled as an MS-DOS application.
   `windows-nt'  compiled as a native W32 application.
   `cygwin'      compiled using the Cygwin library.
-  `vax-vms' or
-  `axp-vms'     compiled for a (Open)VMS system.
 Anything else indicates some sort of Unix system.  */);
   Vsystem_type = intern (SYSTEM_TYPE);
 
@@ -2475,7 +2393,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 +2430,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,