diff src/event-stream.c @ 5473:ac37a5f7e5be

Merge with trunk.
author Mats Lidell <matsl@xemacs.org>
date Thu, 17 Mar 2011 23:42:59 +0100
parents 8d29f1c4bb98 6f10ac29bf40
children 4dee0387b9de
line wrap: on
line diff
--- a/src/event-stream.c	Tue Feb 22 22:56:02 2011 +0100
+++ b/src/event-stream.c	Thu Mar 17 23:42:59 2011 +0100
@@ -4443,6 +4443,7 @@
       {
 	Lisp_Object leaf = lookup_command_event (command_builder, event, 1);
 
+      lookedup:
 	if (KEYMAPP (leaf))
 	  /* Incomplete key sequence */
 	  break;
@@ -4522,6 +4523,22 @@
 		GCPRO1 (keys);
 		pre_command_hook ();
 		UNGCPRO;
+
+                if (!NILP (Vthis_command))
+                  {
+                    /* Allow pre-command-hook to change the command to
+                       something more useful, and avoid barfing. */
+                    leaf = Vthis_command;
+                    if (!EQ (command_builder->most_current_event,
+                             Vlast_command_event))
+                      {
+                        reset_current_events (command_builder);
+                        command_builder_append_event (command_builder,
+                                                      Vlast_command_event);
+                      }
+                    goto lookedup;
+                  }
+
 		/* The post-command-hook doesn't run. */
 		Fsignal (Qundefined_keystroke_sequence, list1 (keys));
 	      }