changeset 3294:4a10e4c34b11

(read_key_sequence): Read the first char specially before the main loop.
author Richard M. Stallman <rms@gnu.org>
date Sun, 30 May 1993 04:49:24 +0000
parents 03e4cad68481
children 4d405f172c79
files src/keyboard.c
diffstat 1 files changed, 24 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/keyboard.c	Sun May 30 04:48:18 1993 +0000
+++ b/src/keyboard.c	Sun May 30 04:49:24 1993 +0000
@@ -3597,19 +3597,25 @@
      recognized a function key, to avoid searching for the function
      key's again in Vfunction_key_map.  */
   int fkey_start = 0, fkey_end = 0;
-  Lisp_Object fkey_map = Vfunction_key_map;
+  Lisp_Object fkey_map;
 
   /* If we receive a ``switch-frame'' event in the middle of a key sequence,
      we put it off for later.  While we're reading, we keep the event here.  */
-  Lisp_Object delayed_switch_frame = Qnil;
-
+  Lisp_Object delayed_switch_frame;
+
+  Lisp_Object first_event;
+
+  int junk;
+
+  last_nonmenu_event = Qnil;
+
+  delayed_switch_frame = Qnil;
+  fkey_map = Vfunction_key_map;
 
   /* If there is no function key map, turn off function key scanning.  */
   if (NILP (Fkeymapp (Vfunction_key_map)))
     fkey_start = fkey_end = bufsize + 1;
 
-  last_nonmenu_event = Qnil;
-
   if (INTERACTIVE)
     {
       if (prompt)
@@ -3626,6 +3632,11 @@
     echo_start = echo_length ();
   keys_start = this_command_key_count;
 
+  /* Read the first char of the sequence specially, before setting
+     up any keymaps, in case a filter runs and switches buffers on us.  */
+  first_event = read_char (!prompt, 0, submaps, last_nonmenu_event,
+			   &junk);
+
   /* We jump here when the key sequence has been thoroughly changed, and
      we need to rescan it starting from the beginning.  When we jump here,
      keybuf[0..mock_input] holds the sequence we should reread.  */
@@ -3724,8 +3735,14 @@
 	{
 	  last_real_key_start = t;
 
-	  key = read_char (!prompt, nmaps, submaps, last_nonmenu_event,
-			   &used_mouse_menu);
+	  if (! NILP (first_event))
+	    {
+	      key = first_event;
+	      first_event = Qnil;
+	    }
+	  else
+	    key = read_char (!prompt, nmaps, submaps, last_nonmenu_event,
+			     &used_mouse_menu);
 
 	  /* read_char returns -1 at the end of a macro.
 	     Emacs 18 handles this by returning immediately with a