From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Severe lossage from unread-command-events Date: Thu, 06 Aug 2015 17:29:58 +0300 Message-ID: <83pp30sd5l.fsf@gnu.org> References: <87egjh4u1h.fsf@fencepost.gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE X-Trace: ger.gmane.org 1438871431 11519 80.91.229.3 (6 Aug 2015 14:30:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 6 Aug 2015 14:30:31 +0000 (UTC) Cc: emacs-devel@gnu.org To: David Kastrup Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Aug 06 16:30:17 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZNMBT-0006wW-Sc for ged-emacs-devel@m.gmane.org; Thu, 06 Aug 2015 16:30:16 +0200 Original-Received: from localhost ([::1]:45392 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNMBT-0005Xe-8Y for ged-emacs-devel@m.gmane.org; Thu, 06 Aug 2015 10:30:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48615) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNMBP-0005X3-OC for emacs-devel@gnu.org; Thu, 06 Aug 2015 10:30:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZNMBO-0004pM-Qi for emacs-devel@gnu.org; Thu, 06 Aug 2015 10:30:11 -0400 Original-Received: from mtaout24.012.net.il ([80.179.55.180]:54194) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZNMBJ-0004co-IQ; Thu, 06 Aug 2015 10:30:06 -0400 Original-Received: from conversion-daemon.mtaout24.012.net.il by mtaout24.012.net.il (HyperSendmail v2007.08) id <0NSN00300ZTI3V00@mtaout24.012.net.il>; Thu, 06 Aug 2015 17:21:42 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout24.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NSN00HQIZW6G690@mtaout24.012.net.il>; Thu, 06 Aug 2015 17:21:42 +0300 (IDT) In-reply-to: <87egjh4u1h.fsf@fencepost.gnu.org> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 80.179.55.180 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:188499 Archived-At: > From: David Kastrup > Date: Wed, 05 Aug 2015 17:46:50 +0200 >=20 > run the included test file using >=20 > emacs -Q -l timer-test.el >=20 > and then open the generated dribble file /tmp/mydrib. On my comput= er, > it looks something like >=20 > 0000000000000000001111111111111111111222222222222222222223333333333= 333333444444444444444444555555555555555556666666666666666667777777777= 777777778888888888888888899999999999999999 >=20 > which means that of 4000 events having an effect in the scratch buf= fer, > about 5% (a non-deterministic amount) are actually recorded in the > dribble file. In particular, it looks like only the first of sever= al > events placed into unread-command-events at one point of time will = ever > see the dribble file. While I am only moderately interested in act= ually > generating a useful dribble file, the same holds for macro recordin= g. > And I have an actual application which is severely impacted here. >=20 > Note that _all_ of the events (usually) are actually processed as i= nput > in the *scratch* buffer. It is only the recording of them which fa= lls > really, really flat on its face. My reading of the code in read_char is that when we consume events =66rom unread-command-events, we don't always record the events we fi= nd there. Does the following na=C3=AFve attempt at fixing this give good result= s? If not, can you tell why not, or show a test case where it misbehaves? --- src/keyboard.c~0=092015-07-19 09:38:14.000000000 +0300 +++ src/keyboard.c=092015-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 =3D 0; struct kboard *orig_kboard =3D current_kboard; @@ -2401,6 +2401,8 @@ =20 retry: =20 + recorded =3D false; + if (CONSP (Vunread_post_input_method_events)) { c =3D XCAR (Vunread_post_input_method_events); @@ -2990,6 +2992,7 @@ /* Store these characters into recent_keys, the dribble file if an= y, and the keyboard macro being defined, if any. */ record_char (c); + recorded =3D true; if (! NILP (also_record)) record_char (also_record); =20 @@ -3125,6 +3128,14 @@ Vunread_post_input_method_events =09=3D 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 =3D true; + } =20 reread_first: =20