changeset 23047:fc5f85abc044

(Freset_this_command_lengths): Return nil. (read_char): [All these changes are in the input method code.] Process and clear before_command_restore_flag before the input method. Save and restore ok_to_echo_at_next_pause and current_kboard->echo_after_prompt. Save, copy and empty this_command_keys, if it is not empty. Clear the echo area before the input method. Then in all cases restore this_command_keys, and reenable echoing if it was enabled before.
author Richard M. Stallman <rms@gnu.org>
date Mon, 17 Aug 1998 07:04:41 +0000
parents 87169117f80c
children fd2d1a752d93
files src/keyboard.c
diffstat 1 files changed, 49 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/keyboard.c	Mon Aug 17 04:45:21 1998 +0000
+++ b/src/keyboard.c	Mon Aug 17 07:04:41 1998 +0000
@@ -2363,24 +2363,64 @@
       && (unsigned) XINT (c) < 127)
     {
       Lisp_Object keys; 
-      int key_count = this_command_key_count;
-      int saved = current_kboard->immediate_echo;
+      int key_count;
       struct gcpro gcpro1;
 
-      keys = Fcopy_sequence (this_command_keys);
+      /* Save the echo status.  */
+      int saved_immediate_echo = current_kboard->immediate_echo;
+      char *saved_ok_to_echo = ok_to_echo_at_next_pause;
+      int saved_echo_after_prompt = current_kboard->echo_after_prompt;
+
+      if (before_command_restore_flag)
+	{
+	  this_command_key_count = before_command_key_count_1;
+	  if (this_command_key_count < this_single_command_key_start)
+	    this_single_command_key_start = this_command_key_count;
+	  echo_truncate (before_command_echo_length_1);
+	  before_command_restore_flag = 0;
+	}
+
+      /* Save the this_command_keys status.  */
+      key_count = this_command_key_count;
+
+      if (key_count > 0)
+	keys = Fcopy_sequence (this_command_keys);
+      else
+	keys = Qnil;
       GCPRO1 (keys);
+
+      /* Clear out this_command_keys.  */
+      this_command_key_count = 0;
+
+      /* Now wipe the echo area.  */
+      if (echo_area_glyphs)
+	safe_run_hooks (Qecho_area_clear_hook);
+      echo_area_glyphs = 0;
+      echo_truncate (0);
+
+      /* Call the input method.  */
       tem = call1 (Vinput_method_function, c);
+      
+      /* Restore the saved echoing state
+	 and this_command_keys state.  */
+      this_command_key_count = key_count;
+      if (key_count > 0)
+	this_command_keys = keys;
+
+      cancel_echoing ();
+      ok_to_echo_at_next_pause = saved_ok_to_echo;
+      current_kboard->echo_after_prompt = saved_echo_after_prompt;
+      if (saved_immediate_echo)
+	echo_now ();
+
       UNGCPRO;
-      current_kboard->immediate_echo = saved;
+
       /* The input method can return no events.  */
       if (! CONSP (tem))
 	{
 	  /* Bring back the previous message, if any.  */
-	  if (! NILP (Vinput_method_previous_message))
+	  if (! NILP (echo_area_message))
 	    message_with_string ("%s", echo_area_message, 0);
-	  this_command_keys = keys;
-	  this_command_key_count = key_count;
-	  cancel_echoing ();
 	  goto retry;
 	}
       /* It returned one event or more.  */
@@ -8175,6 +8215,7 @@
   before_command_restore_flag = 1;
   before_command_key_count_1 = before_command_key_count;
   before_command_echo_length_1 = before_command_echo_length;
+  return Qnil;
 }
 
 DEFUN ("recursion-depth", Frecursion_depth, Srecursion_depth, 0, 0, 0,