]> code.delx.au - gnu-emacs/blobdiff - src/keyboard.c
*** empty log message ***
[gnu-emacs] / src / keyboard.c
index 259a2aabd6d78a891aef5be45306be8e22ea49be..442a4f318eaa7c5b5352ccb1481df663d897dcc5 100644 (file)
@@ -1,5 +1,5 @@
 /* Keyboard and mouse input; editor command loop.
-   Copyright (C) 1985, 1986, 1987, 1988, 1989 Free Software Foundation, Inc.
+   Copyright (C) 1985, 1986, 1987, 1988, 1989, 1992 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -28,7 +28,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "lisp.h"
 #include "termhooks.h"
 #include "macros.h"
-#include "screen.h"
+#include "frame.h"
 #include "window.h"
 #include "commands.h"
 #include "buffer.h"
@@ -43,6 +43,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #include "syssignal.h"
 #include "systerm.h"
+#include "systime.h"
 
 extern int errno;
 
@@ -154,7 +155,7 @@ Lisp_Object meta_prefix_char;
 /* Last size recorded for a current buffer which is not a minibuffer.  */
 static int last_non_minibuf_size;
 
-/* Number of idle seconds before an auto-save.  */
+/* Number of idle seconds before an auto-save and garbage collection.  */
 static Lisp_Object Vauto_save_timeout;
 
 /* Total number of times read_char has returned.  */
@@ -190,26 +191,27 @@ extern Lisp_Object Vmouse_event;
 /* Hook to call on each mouse event after running its definition.  */
 Lisp_Object Vmouse_event_function;
 
-/* Hook to call when mouse leaves screen.  */
+/* Hook to call when mouse leaves frame.  */
 Lisp_Object Vmouse_left_hook;
 
-/* Hook to call when a screen is mapped.  */
-Lisp_Object Vmap_screen_hook;
+/* Hook to call when a frame is mapped.  */
+Lisp_Object Vmap_frame_hook;
 
-/* Hook to call when a screen is unmapped.  */
-Lisp_Object Vunmap_screen_hook;
+/* Hook to call when a frame is unmapped.  */
+Lisp_Object Vunmap_frame_hook;
 
 /* Handler for non-grabbed (no keys depressed) mouse motion.  */
 Lisp_Object Vmouse_motion_handler;
 
-/* The screen in which the last input event occurred.
-   command_loop_1 will select this screen before running the
+/* The frame in which the last input event occurred.
+   command_loop_1 will select this frame before running the
    command bound to an event sequence, and read_key_sequence will
    toss the existing prefix if the user starts typing at a
-   new screen.  */
-Lisp_Object Vlast_event_screen;
+   new frame.  */
+Lisp_Object Vlast_event_frame;
 
-/* X Windows wants this for selection ownership.  */
+/* The timestamp of the last input event we received from the X server.
+   X Windows wants this for selection ownership.  */
 unsigned long last_event_timestamp;
 
 Lisp_Object Qself_insert_command;
@@ -308,11 +310,12 @@ Lisp_Object Qevent_unmodified;
 
 /* Symbols to use for non-text mouse positions.  */
 Lisp_Object Qmode_line;
-Lisp_Object Qvertical_split;
+Lisp_Object Qvertical_line;
 
 
-/* Address (if not 0) of word to zero out if a SIGIO interrupt happens.  */
-long *input_available_clear_word;
+/* Address (if not 0) of EMACS_TIME to zero out if a SIGIO interrupt
+   happens.  */
+EMACS_TIME *input_available_clear_time;
 
 /* Nonzero means use SIGIO interrupts; zero means use CBREAK mode.
    Default is 1 if INTERRUPT_INPUT is defined.  */
@@ -491,7 +494,7 @@ echo_length ()
 
 /* Truncate the current echo message to its first LEN chars.
    This and echo_char get used by read_key_sequence when the user
-   switches screens while entering a key sequence.  */
+   switches frames while entering a key sequence.  */
 
 static void
 echo_truncate (len)
@@ -597,10 +600,10 @@ cmd_error (data)
   Vexecuting_macro = Qnil;
   echo_area_glyphs = 0;
 
-  /* If the window system or terminal screen hasn't been initialized
+  /* If the window system or terminal frame hasn't been initialized
      yet, or we're not interactive, it's best to dump this message out
      to stderr and exit.  */
-  if (! SCREEN_MESSAGE_BUF (selected_screen)
+  if (! FRAME_MESSAGE_BUF (selected_frame)
       || noninteractive)
     stream = Qexternal_debugging_output;
   else
@@ -654,9 +657,9 @@ cmd_error (data)
     }
   UNGCPRO;
 
-  /* If the window system or terminal screen hasn't been initialized
+  /* If the window system or terminal frame hasn't been initialized
      yet, or we're in -batch mode, this error should cause Emacs to exit.  */
-  if (! SCREEN_MESSAGE_BUF (selected_screen)
+  if (! FRAME_MESSAGE_BUF (selected_frame)
       || noninteractive)
     {
       Fterpri (stream);
@@ -833,11 +836,11 @@ command_loop_1 ()
 
       ++num_input_keys;
 
-#ifdef MULTI_SCREEN
-      /* Select the screen that the key sequence came from.  */
-      if (XTYPE (Vlast_event_screen) == Lisp_Screen
-         && XSCREEN (Vlast_event_screen) != selected_screen)
-       Fselect_screen (Vlast_event_screen, Qnil);
+#ifdef MULTI_FRAME
+      /* Select the frame that the key sequence came from.  */
+      if (XTYPE (Vlast_event_frame) == Lisp_Frame
+         && XFRAME (Vlast_event_frame) != selected_frame)
+       Fselect_frame (Vlast_event_frame, Qnil);
 #endif
 
       /* Now we have read a key sequence of length I,
@@ -848,7 +851,7 @@ command_loop_1 ()
 
 #if 0
 #ifdef HAVE_X_WINDOWS
-      if (SCREEN_IS_X (selected_screen))
+      if (FRAME_IS_X (selected_frame))
        {
          if (i == -1)          /* Mouse event */
            {
@@ -1146,7 +1149,7 @@ read_char (commandflag)
     }
 
   /* Save outer setjmp data, in case called recursively.  */
-  bcopy (getcjmp, save_jump, sizeof getcjmp);
+  save_getcjmp (save_jump);
 
   stop_polling ();
 
@@ -1156,9 +1159,9 @@ read_char (commandflag)
   if (_setjmp (getcjmp))
     {
       XSET (c, Lisp_Int, quit_char);
-
-      waiting_for_input = 0;
-      input_available_clear_word = 0;
+#ifdef MULTI_FRAME
+      XSET (Vlast_event_frame, Lisp_Frame, selected_frame);
+#endif
 
       goto non_reread;
     }
@@ -1178,7 +1181,7 @@ read_char (commandflag)
     {
       Lisp_Object tem0;
 
-      tem0 = Fsit_for (make_number (echo_keystrokes), Qnil, Qt);
+      tem0 = sit_for (echo_keystrokes, 0, 1, 1);
       if (EQ (tem0, Qt))
        echo ();
     }
@@ -1219,7 +1222,7 @@ read_char (commandflag)
       {
        Lisp_Object tem0;
        int delay = delay_level * XFASTINT (Vauto_save_timeout) / 4;
-       tem0 = Fsit_for (make_number (delay), Qnil, Qt);
+       tem0 = sit_for (delay, 0, 1, 1);
        if (EQ (tem0, Qt))
          {
            jmp_buf temp;
@@ -1259,7 +1262,7 @@ read_char (commandflag)
 
  non_reread:
 
-  bcopy (save_jump, getcjmp, sizeof getcjmp);
+  restore_getcjmp (save_jump);
 
   start_polling ();
 
@@ -1342,7 +1345,7 @@ read_char (commandflag)
 
       cancel_echoing ();
       c = read_char (0);
-      /* Remove the help from the screen */
+      /* Remove the help from the frame */
       unbind_to (count, Qnil);
       redisplay ();
       if (EQ (c, make_number (040)))
@@ -1390,7 +1393,7 @@ restore_getcjmp (temp)
 /* Set this for debugging, to have a way to get out */
 int stop_character;
 
-extern int screen_garbaged;
+extern int frame_garbaged;
 
 /* Return true iff there are any events in the queue that read-char
    would return.  If this returns false, a read-char would block.  */
@@ -1449,8 +1452,9 @@ tracking_off (old_value)
 
 DEFUN ("track-mouse", Ftrack_mouse, Strack_mouse, 0, UNEVALLED, 0,
   "Evaluate BODY with mouse movement and button release events enabled.\n\
-Within a track-mouse, read-event reports mouse movement and button releases;\n\
-otherwise, they are ignored.")
+Within a `track-mouse', mouse motion and button releases generate input\n\
+events that you can read with `read-event'.\n\
+Normally, these occurrences don't generate events.")
   (args)
      Lisp_Object args;
 {
@@ -1483,12 +1487,12 @@ kbd_buffer_store_event (event)
          || ((c == (0200 | quit_char)) && !meta_key))
        {
          /* If this results in a quit_char being returned to Emacs as
-            input, set last-event-screen properly.  If this doesn't
+            input, set last-event-frame properly.  If this doesn't
             get returned to Emacs as an event, the next event read
-            will set Vlast_event_screen again, so this is safe to do.  */
+            will set Vlast_event_frame again, so this is safe to do.  */
          extern SIGTYPE interrupt_signal ();
-         XSET (Vlast_event_screen, Lisp_Screen, event->screen);
-         last_event_timestamp = XINT (event->timestamp);
+         Vlast_event_frame = FRAME_FOCUS_FRAME (event->frame);
+         last_event_timestamp = event->timestamp;
          interrupt_signal ();
          return;
        }
@@ -1514,7 +1518,7 @@ kbd_buffer_store_event (event)
       kbd_store_ptr->kind = event->kind;
       kbd_store_ptr->code = event->code;
       kbd_store_ptr->part = event->part;
-      kbd_store_ptr->screen = event->screen;
+      kbd_store_ptr->frame = event->frame;
       kbd_store_ptr->modifiers = event->modifiers;
       kbd_store_ptr->x = event->x;
       kbd_store_ptr->y = event->y;
@@ -1586,24 +1590,10 @@ kbd_buffer_get_event ()
 #endif /* SIGIO */
       if (EVENT_QUEUES_EMPTY)
        {
-#ifdef subprocesses
-         wait_reading_process_input (0, 0, -1, 1);
-#else
-/* Note SIGIO has been undef'd if FIONREAD is missing.  */
-#ifdef SIGIO
-         if (interrupt_input)
-           {
-             sigblockx (SIGIO);
-             set_waiting_for_input (0);
-             while (EVENT_QUEUES_EMPTY)
-               sigpausex (SIGIO);
-             clear_waiting_for_input ();
-             sigunblockx (SIGIO);
-           }
-#else
-         interrupt_input = 0;
-#endif /* not SIGIO */
-#endif /* subprocesses */
+         Lisp_Object minus_one;
+
+         XSET (minus_one, Lisp_Int, -1);
+         wait_reading_process_input (0, 0, minus_one, 1);
 
          if (!interrupt_input && EVENT_QUEUES_EMPTY)
            {
@@ -1620,8 +1610,12 @@ kbd_buffer_get_event ()
     {
       if (kbd_fetch_ptr == kbd_buffer + KBD_BUFFER_SIZE)
        kbd_fetch_ptr = kbd_buffer;
-      XSET (Vlast_event_screen, Lisp_Screen, kbd_fetch_ptr->screen);
-      last_event_timestamp = XINT (kbd_fetch_ptr->timestamp);
+      /* Do the redirection specified by the focus_frame
+        member now, before we return this event.  */
+      kbd_fetch_ptr->frame =
+       XFRAME (FRAME_FOCUS_FRAME (kbd_fetch_ptr->frame));
+      XSET (Vlast_event_frame, Lisp_Frame, kbd_fetch_ptr->frame);
+      last_event_timestamp = kbd_fetch_ptr->timestamp;
       obj = make_lispy_event (kbd_fetch_ptr);
       kbd_fetch_ptr->kind = no_event;
       kbd_fetch_ptr++;
@@ -1630,13 +1624,14 @@ kbd_buffer_get_event ()
     }
   else if (do_mouse_tracking && mouse_moved)
     {
-      SCREEN_PTR screen;
-      Lisp_Object x, y, time;
+      FRAME_PTR frame;
+      Lisp_Object x, y;
+      unsigned long time;
 
-      (*mouse_position_hook) (&screen, &x, &y, &time);
-      XSET (Vlast_event_screen, Lisp_Screen, screen);
+      (*mouse_position_hook) (&frame, &x, &y, &time);
+      XSET (Vlast_event_frame, Lisp_Frame, frame);
 
-      obj = make_lispy_movement (screen, x, y, time);
+      obj = make_lispy_movement (frame, x, y, time);
     }
   else
     /* We were promised by the above while loop that there was
@@ -1768,7 +1763,7 @@ make_lispy_event (event)
       {
        int part;
        Lisp_Object window =
-         window_from_coordinates (event->screen,
+         window_from_coordinates (event->frame,
                                   XINT (event->x), XINT (event->y),
                                   &part);
        Lisp_Object posn;
@@ -1785,7 +1780,7 @@ make_lispy_event (event)
            if (part == 1)
              posn = Qmode_line;
            else if (part == 2)
-             posn = Qvertical_split;
+             posn = Qvertical_line;
            else
              XSET (posn, Lisp_Int,
                    buffer_posn_from_coords (XWINDOW (window),
@@ -1802,7 +1797,8 @@ make_lispy_event (event)
                      Fcons (window,
                             Fcons (posn,
                                    Fcons (Fcons (event->x, event->y),
-                                          Fcons (event->timestamp,
+                                          Fcons (make_number
+                                                 (event->timestamp),
                                                  Qnil)))));
       }
 
@@ -1818,10 +1814,11 @@ make_lispy_event (event)
                                 (sizeof (lispy_mouse_names)
                                  / sizeof (lispy_mouse_names[0])));
        return Fcons (event->part,
-                     Fcons (SCREEN_SELECTED_WINDOW (event->screen),
+                     Fcons (FRAME_SELECTED_WINDOW (event->frame),
                             Fcons (button,
                                    Fcons (Fcons (event->x, event->y),
-                                          Fcons (event->timestamp,
+                                          Fcons (make_number
+                                                 (event->timestamp),
                                                  Qnil)))));
       }
 
@@ -1832,10 +1829,10 @@ make_lispy_event (event)
 }
 
 static Lisp_Object
-make_lispy_movement (screen, x, y, time)
-     SCREEN_PTR screen;
+make_lispy_movement (frame, x, y, time)
+     FRAME_PTR frame;
      Lisp_Object x, y;
-     Lisp_Object time;
+     unsigned long time;
 {
   Lisp_Object window;
   int ix, iy;
@@ -1844,8 +1841,8 @@ make_lispy_movement (screen, x, y, time)
 
   ix = XINT (x);
   iy = XINT (y);
-  window = (screen
-           ? window_from_coordinates (screen, ix, iy, &part)
+  window = (frame
+           ? window_from_coordinates (frame, ix, iy, &part)
            : Qnil);
   if (XTYPE (window) != Lisp_Window)
     posn = Qnil;
@@ -1856,7 +1853,7 @@ make_lispy_movement (screen, x, y, time)
       if (part == 1)
        posn = Qmode_line;
       else if (part == 2)
-       posn = Qvertical_split;
+       posn = Qvertical_line;
       else
        XSET (posn, Lisp_Int, buffer_posn_from_coords (XWINDOW (window),
                                                       ix, iy));
@@ -1868,7 +1865,7 @@ make_lispy_movement (screen, x, y, time)
                Fcons (window,
                       Fcons (posn,
                              Fcons (Fcons (x, y),
-                                    Fcons (time, Qnil)))));
+                                    Fcons (make_number (time), Qnil)))));
 }
 
 
@@ -1883,8 +1880,8 @@ format_modifiers (modifiers, buf)
 {
   char *p = buf;
 
-  if (modifiers & meta_modifier) { *p++ = 'M'; *p++ = '-'; }
   if (modifiers & ctrl_modifier) { *p++ = 'C'; *p++ = '-'; }
+  if (modifiers & meta_modifier) { *p++ = 'M'; *p++ = '-'; }
   if (modifiers & shift_modifier) { *p++ = 'S'; *p++ = '-'; }
   if (modifiers & up_modifier) { *p++ = 'U'; *p++ = '-'; }
   *p = '\0';
@@ -2118,7 +2115,8 @@ gobble_input (expected)
 #ifdef SIGIO
   if (interrupt_input)
     {
-      SIGMASKTYPE mask = sigblockx (SIGIO);
+      SIGMASKTYPE mask;
+      mask = sigblockx (SIGIO);
       read_avail_input (expected);
       sigsetmask (mask);
     }
@@ -2209,7 +2207,7 @@ read_avail_input (expected)
        {
          buf[i].kind = ascii_keystroke;
          XSET (buf[i].code, Lisp_Int, cbuf[i]);
-         buf[i].screen = selected_screen;
+         buf[i].frame = selected_frame;
        }
     }
 
@@ -2250,8 +2248,8 @@ input_available_signal (signo)
   sigisheld (SIGIO);
 #endif
 
-  if (input_available_clear_word)
-    *input_available_clear_word = 0;
+  if (input_available_clear_time)
+    EMACS_SET_SECS_USECS (*input_available_clear_time, 0, 0);
 
   while (1)
     {
@@ -2311,7 +2309,7 @@ read_char_menu_prompt (prompt, local, global)
   register Lisp_Object rest, name;
   Lisp_Object hmap;
   int nlength;
-  int width = SCREEN_WIDTH (selected_screen) - 4;
+  int width = FRAME_WIDTH (selected_frame) - 4;
   char *menu = (char *) alloca (width);
 
   /* Use local over global Menu maps */
@@ -2517,7 +2515,7 @@ follow_key (key, nmaps, current, defs, next)
    with PROMPT.  Echo starting immediately unless `prompt' is 0.
    Return the length of the key sequence stored.
 
-   If the user switches screens in the midst of a key sequence, we
+   If the user switches frames in the midst of a key sequence, we
    throw away any prefix we have read so far, and start afresh.  For
    mouse clicks, we look up the click in the keymap of the buffer
    clicked on, throwing away any prefix if it is not the same buffer
@@ -2534,7 +2532,7 @@ read_key_sequence (keybuf, bufsize, prompt)
 
   /* The buffer that the most recently read event was typed at.  This
      helps us read mouse clicks according to the buffer clicked in,
-     and notice when the mouse has moved from one screen to another.  */
+     and notice when the mouse has moved from one frame to another.  */
   struct buffer *last_event_buffer = current_buffer;
 
   /* The length of the echo buffer when we started reading, and
@@ -2641,12 +2639,13 @@ read_key_sequence (keybuf, bufsize, prompt)
          
          Vquit_flag = Qnil;
 
+#ifdef MULTI_FRAME
          /* What buffer was this event typed/moused at?  */
          if (XTYPE (key) == Lisp_Int || XTYPE (key) == Lisp_Symbol)
            buf = (XBUFFER
                   (XWINDOW
-                   (SCREEN_SELECTED_WINDOW
-                    (XSCREEN (Vlast_event_screen)))->buffer));
+                   (FRAME_SELECTED_WINDOW
+                    (XFRAME (Vlast_event_frame)))->buffer));
          else if (EVENT_HAS_PARAMETERS (key))
            {
              Lisp_Object window = EVENT_WINDOW (key);
@@ -2665,7 +2664,7 @@ read_key_sequence (keybuf, bufsize, prompt)
          if (buf != last_event_buffer)
            {
              last_event_buffer = buf;
-             Fselect_screen (Vlast_event_screen, Qnil);
+             Fselect_frame (Vlast_event_frame, Qnil);
 
              /* Arrange to read key as the next event.  */
              keybuf[0] = key;
@@ -2677,6 +2676,7 @@ read_key_sequence (keybuf, bufsize, prompt)
 
              goto restart;
            }
+#endif
        }
 
       first_binding = (follow_key (key,
@@ -2744,19 +2744,21 @@ read_key_sequence (keybuf, bufsize, prompt)
   return t;
 }
 
-DEFUN ("read-key-sequence", Fread_key_sequence, Sread_key_sequence, 1, 1, 0,
+DEFUN ("read-key-sequence", Fread_key_sequence, Sread_key_sequence, 1, 2, 0,
   "Read a sequence of keystrokes and return as a string or vector.\n\
 The sequence is sufficient to specify a non-prefix command in the\n\
 current local and global maps.\n\
 \n\
-Arg PROMPT is a prompt string.  If nil, do not prompt specially.\n\
+First arg PROMPT is a prompt string.  If nil, do not prompt specially.\n\
+Second (optional) arg CONTINUE-ECHO, if non-nil, means this key echos\n\
+as a continuation of the previous key.\n\
 \n\
-If Emacs is running on multiple screens, switching between screens in\n\
+If Emacs is running on multiple frames, switching between frames in\n\
 the midst of a keystroke will toss any prefix typed so far.  A C-g\n\
 typed while in this function is treated like any other character, and\n\
 `quit-flag' is not set.")
-  (prompt)
-     Lisp_Object prompt;
+  (prompt, continue_echo)
+     Lisp_Object prompt, continue_echo;
 {
   Lisp_Object keybuf[30];
   register int i;
@@ -2770,7 +2772,9 @@ typed while in this function is treated like any other character, and\n\
   GCPRO1 (keybuf[0]);
   gcpro1.nvars = (sizeof keybuf/sizeof (keybuf[0]));
 
-  this_command_key_count = 0;
+  if (NILP (continue_echo))
+    this_command_key_count = 0;
+
   i = read_key_sequence (keybuf, (sizeof keybuf/sizeof (keybuf[0])),
                         NILP (prompt)  ? 0 : XSTRING (prompt)->data);
 
@@ -2806,13 +2810,7 @@ Otherwise, that is done only if an arg is read using the minibuffer.")
 
   while (1)
     {
-      final = cmd;
-      while (XTYPE (final) == Lisp_Symbol)
-       {
-         if (EQ (Qunbound, XSYMBOL (final)->function))
-           Fsymbol_function (final);    /* Get an error! */
-         final = XSYMBOL (final)->function;
-       }
+      final = Findirect_function (cmd);
 
       if (CONSP (final) && (tem = Fcar (final), EQ (tem, Qautoload)))
        do_autoload (final, cmd);
@@ -2866,7 +2864,7 @@ with EVENT as arg.")
 {
   Lisp_Object tem;
   Lisp_Object mouse_cmd;
-  Lisp_Object keyseq, window, screen_part, pos, time;
+  Lisp_Object keyseq, window, frame_part, pos, time;
 
 #ifndef HAVE_X11
   Vmouse_event = event;
@@ -2881,7 +2879,7 @@ with EVENT as arg.")
   CHECK_CONS (event, 0);
   pos = Fcar (event);
   window = Fcar (Fcdr (event));
-  screen_part = Fcar (Fcdr (Fcdr (event)));
+  frame_part = Fcar (Fcdr (Fcdr (event)));
   keyseq = Fcar (Fcdr (Fcdr (Fcdr (event))));
   time = Fcar (Fcdr (Fcdr (Fcdr (Fcdr (event)))));
   CHECK_STRING (keyseq, 0);
@@ -2923,14 +2921,14 @@ with EVENT as arg.")
     }
   else
     {
-      SCREEN_PTR s = XSCREEN (WINDOW_SCREEN (XWINDOW (window)));
+      FRAME_PTR f = XFRAME (WINDOW_FRAME (XWINDOW (window)));
 
 #ifndef HAVE_X11
-      Vmouse_window = s->selected_window;
+      Vmouse_window = f->selected_window;
 #endif /* HAVE_X11 */
       /* It's defined; call the definition.  */
       Vprefix_arg = Qnil;
-      if (!NILP (screen_part))
+      if (!NILP (frame_part))
        {
          /* For a scroll-bar click, set the prefix arg
             to the number of lines down from the top the click was.
@@ -2945,7 +2943,7 @@ with EVENT as arg.")
 
          if (XINT (length) != 0)
            XSET (Vprefix_arg, Lisp_Int,
-                 (SCREEN_HEIGHT (s) * (XINT (position) + XINT (offset))
+                 (FRAME_HEIGHT (f) * (XINT (position) + XINT (offset))
                   / (XINT (length) + 2 * XINT (offset))));
        }
       Fcommand_execute (mouse_cmd, Qnil);
@@ -2994,17 +2992,31 @@ DEFUN ("execute-extended-command", Fexecute_extended_command, Sexecute_extended_
                               Vobarray, Qcommandp,
                               Qt, Qnil, Qnil);
 
-  /* Add the text read to this_command_keys.  */
+  /* Set this_command_keys to the concatenation of saved_keys and
+     function, followed by a RET.  */
   {
-    struct Lisp_String *func_str = XSTRING (function);
+    struct Lisp_String *str;
     int i;
     Lisp_Object tem;
 
-    for (i = 0; i < func_str->size; i++)
+    this_command_key_count = 0;
+
+    str = XSTRING (saved_keys);
+    for (i = 0; i < str->size; i++)
+      {
+       XFASTINT (tem) = str->data[i];
+       add_command_key (tem);
+      }
+
+    str = XSTRING (function);
+    for (i = 0; i < str->size; i++)
       {
-       XSET (tem, Lisp_Int, func_str->data[i]);
+       XFASTINT (tem) = str->data[i];
        add_command_key (tem);
       }
+
+    XFASTINT (tem) = '\015';
+    add_command_key (tem);
   }
 
   UNGCPRO;
@@ -3025,6 +3037,14 @@ detect_input_pending ()
   return input_pending;
 }
 
+/* This is called in some cases before a possible quit.
+   It cases the next call to detect_input_pending to recompute input_pending.
+   So calling this function unnecessarily can't do any harm.  */
+clear_input_pending ()
+{
+  input_pending = 0;
+}
+
 DEFUN ("input-pending-p", Finput_pending_p, Sinput_pending_p, 0, 0, 0,
   "T if command input is currently available with no waiting.\n\
 Actually, the value is nil only if we can be sure that no input is available.")
@@ -3147,7 +3167,7 @@ On such systems, Emacs will start a subshell and wait for it to exit.")
       if (!EQ (tem, Qnil)) return Qnil;
     }
 
-  get_screen_size (&old_width, &old_height);
+  get_frame_size (&old_width, &old_height);
   reset_sys_modes ();
   /* sys_suspend can get an error if it tries to fork a subshell
      and the system resources aren't available for that.  */
@@ -3159,9 +3179,9 @@ On such systems, Emacs will start a subshell and wait for it to exit.")
   /* Check if terminal/window size has changed.
      Note that this is not useful when we are running directly
      with a window system; but suspend should be disabled in that case.  */
-  get_screen_size (&width, &height);
+  get_frame_size (&width, &height);
   if (width != old_width || height != old_height)
-    change_screen_size (height, width, 0);
+    change_frame_size (height, width, 0);
 
   /* Call value of suspend-resume-hook
      if it is bound and value is non-nil.  */
@@ -3207,10 +3227,10 @@ stuff_buffered_input (stuffstring)
 #endif /* BSD and not BSD4_1 */
 }
 \f
-set_waiting_for_input (word_to_clear)
-     long *word_to_clear;
+set_waiting_for_input (time_to_clear)
+     EMACS_TIME *time_to_clear;
 {
-  input_available_clear_word = word_to_clear;
+  input_available_clear_time = time_to_clear;
 
   /* Tell interrupt_signal to throw back to read_char,  */
   waiting_for_input = 1;
@@ -3232,7 +3252,7 @@ clear_waiting_for_input ()
 {
   /* Tell interrupt_signal not to throw back to read_char,  */
   waiting_for_input = 0;
-  input_available_clear_word = 0;
+  input_available_clear_time = 0;
 }
 
 /* This routine is called at interrupt level in response to C-G.
@@ -3264,7 +3284,7 @@ interrupt_signal ()
 
   cancel_echoing ();
 
-  if (!NILP (Vquit_flag) && SCREEN_IS_TERMCAP (selected_screen))
+  if (!NILP (Vquit_flag) && FRAME_IS_TERMCAP (selected_frame))
     {
       fflush (stdout);
       reset_sys_modes ();
@@ -3340,7 +3360,7 @@ quit_throw_to_read_char ()
   quit_error_check ();
   sigfree ();
   /* Prevent another signal from doing this before we finish.  */
-  waiting_for_input = 0;
+  clear_waiting_for_input ();
   input_pending = 0;
 
 #if 0
@@ -3353,12 +3373,13 @@ quit_throw_to_read_char ()
 \f
 DEFUN ("set-input-mode", Fset_input_mode, Sset_input_mode, 3, 4, 0,
   "Set mode of reading keyboard input.\n\
-First arg non-nil means use input interrupts; nil means use CBREAK mode.\n\
-Second arg non-nil means use ^S/^Q flow control for output to terminal\n\
+First arg INTERRUPT non-nil means use input interrupts;\n\
+ nil means use CBREAK mode.\n\
+Second arg FLOW non-nil means use ^S/^Q flow control for output to terminal\n\
  (no effect except in CBREAK mode).\n\
-Third arg non-nil means accept 8-bit input (for a Meta key).\n\
+Third arg META non-nil means accept 8-bit input (for a Meta key).\n\
  Otherwise, the top bit is ignored, on the assumption it is parity.\n\
-Optional fourth arg non-nil specifies character to use for quitting.")
+Optional fourth arg QUIT if non-nil specifies character to use for quitting.")
   (interrupt, flow, meta, quit)
      Lisp_Object interrupt, flow, meta, quit;
 {
@@ -3494,8 +3515,8 @@ syms_of_keyboard ()
 
   Qmode_line = intern ("mode-line");
   staticpro (&Qmode_line);
-  Qvertical_split = intern ("vertical-split");
-  staticpro (&Qvertical_split);
+  Qvertical_line = intern ("vertical-line");
+  staticpro (&Qvertical_line);
 
   Qevent_kind = intern ("event-type");
   staticpro (&Qevent_kind);
@@ -3577,7 +3598,9 @@ Zero means disable autosaving due to number of characters typed.");
 
   DEFVAR_LISP ("auto-save-timeout", &Vauto_save_timeout,
     "*Number of seconds idle time before auto-save.\n\
-Zero or nil means disable auto-saving due to idleness.");
+Zero or nil means disable auto-saving due to idleness.\n\
+After auto-saving due to this many seconds of idle time,\n\
+Emacs also does a garbage collection if that seems to be warranted.");
   XFASTINT (Vauto_save_timeout) = 30;
 
   DEFVAR_INT ("echo-keystrokes", &echo_keystrokes,
@@ -3595,9 +3618,9 @@ Polling is automatically disabled in all other cases.");
     "*Number of complete keys read from the keyboard so far.");
   num_input_keys = 0;
 
-  DEFVAR_LISP ("last-event-screen", &Vlast_event_screen,
-    "*The screen in which the most recently read event occurred.");
-  Vlast_event_screen = Qnil;
+  DEFVAR_LISP ("last-event-frame", &Vlast_event_frame,
+    "*The frame in which the most recently read event occurred.");
+  Vlast_event_frame = Qnil;
 
   DEFVAR_LISP ("help-char", &help_char,
     "Character to recognize as meaning Help.\n\
@@ -3633,13 +3656,13 @@ See the variable `mouse-event' for the format of this list.");
               "Function to call when mouse leaves window.  No arguments.");
   Vmouse_left_hook = Qnil;
 
-  DEFVAR_LISP ("map-screen-hook", &Vmap_screen_hook,
-              "Function to call when screen is mapped.  No arguments.");
-  Vmap_screen_hook = Qnil;
+  DEFVAR_LISP ("map-frame-hook", &Vmap_frame_hook,
+              "Function to call when frame is mapped.  No arguments.");
+  Vmap_frame_hook = Qnil;
 
-  DEFVAR_LISP ("unmap-screen-hook", &Vunmap_screen_hook,
-              "Function to call when screen is unmapped.  No arguments.");
-  Vunmap_screen_hook = Qnil;
+  DEFVAR_LISP ("unmap-frame-hook", &Vunmap_frame_hook,
+              "Function to call when frame is unmapped.  No arguments.");
+  Vunmap_frame_hook = Qnil;
 
   DEFVAR_LISP ("mouse-motion-handler", &Vmouse_motion_handler,
               "Handler for motion events.  No arguments.");