changeset 87219:5da2063a52e4

(Fcommand_execute): Call Qcall_interactively instead of manipulating the backtrace manually. (make_lispy_event): Merge the ASCII and MULTIBYTE cases. (struct backtrace, backtrace_list): Remove. (command_loop_1): Remove dead var `no_direct'.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Mon, 10 Dec 2007 03:48:05 +0000
parents 409f76c92cb2
children 655d101f4e6b
files src/keyboard.c
diffstat 1 files changed, 27 insertions(+), 66 deletions(-) [+]
line wrap: on
line diff
--- a/src/keyboard.c	Mon Dec 10 03:47:46 2007 +0000
+++ b/src/keyboard.c	Mon Dec 10 03:48:05 2007 +0000
@@ -108,21 +108,6 @@
 #define KBD_BUFFER_SIZE 4096
 #endif	/* No X-windows */
 
-/* Following definition copied from eval.c */
-
-struct backtrace
-  {
-    struct backtrace *next;
-    Lisp_Object *function;
-    Lisp_Object *args;	/* Points to vector of args. */
-    int nargs;		/* length of vector.  If nargs is UNEVALLED,
-			   args points to slot holding list of
-			   unevalled args */
-    char evalargs;
-    /* Nonzero means call value of debugger when done with this operation. */
-    char debug_on_exit;
-  };
-
 #ifdef MULTI_KBOARD
 KBOARD *initial_kboard;
 KBOARD *current_kboard;
@@ -175,8 +160,6 @@
 
 extern int message_enable_multibyte;
 
-extern struct backtrace *backtrace_list;
-
 /* If non-nil, the function that implements the display of help.
    It's called with one argument, the help string to display.  */
 
@@ -1565,7 +1548,6 @@
   int nonundocount;
   Lisp_Object keybuf[30];
   int i;
-  int no_direct;
   int prev_modiff = 0;
   struct buffer *prev_buffer = NULL;
 #if 0 /* This shouldn't be necessary anymore.  --lorentey  */
@@ -1625,8 +1607,6 @@
       while (pending_malloc_warning)
 	display_malloc_warning ();
 
-      no_direct = 0;
-
       Vdeactivate_mark = Qnil;
 
       /* If minibuffer on and echo area in use,
@@ -1787,7 +1767,7 @@
 	}
       else
 	{
-	  if (NILP (current_kboard->Vprefix_arg) && ! no_direct)
+	  if (NILP (current_kboard->Vprefix_arg))
 	    {
 	      /* In case we jump to directly_done.  */
 	      Vcurrent_prefix_arg = current_kboard->Vprefix_arg;
@@ -5558,41 +5538,32 @@
     {
       /* A simple keystroke.  */
     case ASCII_KEYSTROKE_EVENT:
-      {
-	Lisp_Object lispy_c;
-	int c = event->code & 0377;
-	/* Turn ASCII characters into control characters
-	   when proper.  */
-	if (event->modifiers & ctrl_modifier)
-	  c = make_ctrl_char (c);
-
-	/* Add in the other modifier bits.  We took care of ctrl_modifier
-	   just above, and the shift key was taken care of by the X code,
-	   and applied to control characters by make_ctrl_char.  */
-	c |= (event->modifiers
-	      & (meta_modifier | alt_modifier
-		 | hyper_modifier | super_modifier));
-	/* Distinguish Shift-SPC from SPC.  */
-	if ((event->code & 0377) == 040
-	    && event->modifiers & shift_modifier)
-	  c |= shift_modifier;
-	button_down_time = 0;
-	XSETFASTINT (lispy_c, c);
-	return lispy_c;
-      }
-
     case MULTIBYTE_CHAR_KEYSTROKE_EVENT:
       {
 	Lisp_Object lispy_c;
 	int c = event->code;
-
-	/* Add in the other modifier bits.  We took care of ctrl_modifier
-	   just above, and the shift key was taken care of by the X code,
-	   and applied to control characters by make_ctrl_char.  */
+	if (event->kind == ASCII_KEYSTROKE_EVENT)
+	  {
+	    c &= 0377;
+	    eassert (c == event->code);
+	    /* Turn ASCII characters into control characters
+	       when proper.  */
+	    if (event->modifiers & ctrl_modifier)
+	      {
+		c = make_ctrl_char (c);
+		event->modifiers &= ~ctrl_modifier;
+	      }
+	  }
+
+	/* Add in the other modifier bits.  The shift key was taken care
+	   of by the X code.  */
 	c |= (event->modifiers
 	      & (meta_modifier | alt_modifier
 		 | hyper_modifier | super_modifier | ctrl_modifier));
-	/* What about the `shift' modifier ?  */
+	/* Distinguish Shift-SPC from SPC.  */
+	if ((event->code) == 040
+	    && event->modifiers & shift_modifier)
+	  c |= shift_modifier;
 	button_down_time = 0;
 	XSETFASTINT (lispy_c, c);
 	return lispy_c;
@@ -9619,7 +9590,7 @@
 	    }
 
 	  GROW_RAW_KEYBUF;
-	  XVECTOR (raw_keybuf)->contents[raw_keybuf_count++] = key;
+	  ASET (raw_keybuf, raw_keybuf_count++, key);
 	}
 
       /* Clicks in non-text areas get prefixed by the symbol
@@ -10371,7 +10342,6 @@
   register Lisp_Object final;
   register Lisp_Object tem;
   Lisp_Object prefixarg;
-  struct backtrace backtrace;
   extern int debug_on_next_call;
 
   debug_on_next_call = 0;
@@ -10437,20 +10407,11 @@
     }
 
   if (CONSP (final) || SUBRP (final) || COMPILEDP (final))
-    {
-      backtrace.next = backtrace_list;
-      backtrace_list = &backtrace;
-      backtrace.function = &Qcall_interactively;
-      backtrace.args = &cmd;
-      backtrace.nargs = 1;
-      backtrace.evalargs = 0;
-      backtrace.debug_on_exit = 0;
-
-      tem = Fcall_interactively (cmd, record_flag, keys);
-
-      backtrace_list = backtrace.next;
-      return tem;
-    }
+    /* Don't call Fcall_interactively directly because we want to make
+       sure the backtrace has an entry for `call-interactively'.
+       For the same reason, pass `cmd' rather than `final'.  */
+      return call3 (Qcall_interactively, cmd, record_flag, keys);
+
   return Qnil;
 }
 
@@ -10561,7 +10522,7 @@
     bindings = Qnil;
 
   value = Qnil;
-  GCPRO2 (bindings, value);
+  GCPRO3 (bindings, value, function);
   value = Fcommand_execute (function, Qt, Qnil, Qnil);
 
   /* If the command has a key binding, print it now.  */