emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Severe lossage from unread-command-events


From: Eli Zaretskii
Subject: Re: Severe lossage from unread-command-events
Date: Thu, 06 Aug 2015 17:29:58 +0300

> From: David Kastrup <address@hidden>
> Date: Wed, 05 Aug 2015 17:46:50 +0200
> 
> run the included test file using
> 
> emacs -Q -l timer-test.el
> 
> and then open the generated dribble file /tmp/mydrib.  On my computer,
> it looks something like
> 
> 0000000000000000001111111111111111111222222222222222222223333333333333333444444444444444444555555555555555556666666666666666667777777777777777778888888888888888899999999999999999
> 
> which means that of 4000 events having an effect in the scratch buffer,
> about 5% (a non-deterministic amount) are actually recorded in the
> dribble file.  In particular, it looks like only the first of several
> events placed into unread-command-events at one point of time will ever
> see the dribble file.  While I am only moderately interested in actually
> generating a useful dribble file, the same holds for macro recording.
> And I have an actual application which is severely impacted here.
> 
> Note that _all_ of the events (usually) are actually processed as input
> in the *scratch* buffer.  It is only the recording of them which falls
> really, really flat on its face.

My reading of the code in read_char is that when we consume events
from unread-command-events, we don't always record the events we find
there.

Does the following naïve attempt at fixing this give good results?  If
not, can you tell why not, or show a test case where it misbehaves?

--- src/keyboard.c~0    2015-07-19 09:38:14.000000000 +0300
+++ src/keyboard.c      2015-08-06 17:46:30.596420600 +0300
@@ -2383,7 +2383,7 @@
   Lisp_Object tem, save;
   volatile Lisp_Object previous_echo_area_message;
   volatile Lisp_Object also_record;
-  volatile bool reread;
+  volatile bool reread, recorded;
   struct gcpro gcpro1, gcpro2;
   bool volatile polling_stopped_here = 0;
   struct kboard *orig_kboard = current_kboard;
@@ -2401,6 +2401,8 @@
 
  retry:
 
+  recorded = false;
+
   if (CONSP (Vunread_post_input_method_events))
     {
       c = XCAR (Vunread_post_input_method_events);
@@ -2990,6 +2992,7 @@
   /* Store these characters into recent_keys, the dribble file if any,
      and the keyboard macro being defined, if any.  */
   record_char (c);
+  recorded = true;
   if (! NILP (also_record))
     record_char (also_record);
 
@@ -3125,6 +3128,14 @@
       Vunread_post_input_method_events
        = nconc2 (XCDR (tem), Vunread_post_input_method_events);
     }
+  /* When we consume events from the various unread-*-events lists, we
+     bypass the code that records input, so record these events now if
+     they were not recorded already.  */
+  if (!recorded)
+    {
+      record_char (c);
+      recorded = true;
+    }
 
  reread_first:
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]