From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry OReilly Newsgroups: gmane.emacs.bugs Subject: bug#15045: Point jumps inappropriately around time of Semantic lexing Date: Thu, 17 Oct 2013 16:01:50 -0400 Message-ID: References: <8738qksz6l.fsf@engster.org> <837gfvua2r.fsf@gnu.org> <87y58bs9x4.fsf@engster.org> <83zjsrs3k2.fsf@gnu.org> <87pptmsv4z.fsf@engster.org> <83siyira0w.fsf@gnu.org> <87vc3drhuv.fsf@engster.org> <83haexrgjn.fsf@gnu.org> <83ppr7pr6c.fsf@gnu.org> <83li1upkfx.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a11c2de60da307d04e8f549e8 X-Trace: ger.gmane.org 1382040135 12835 80.91.229.3 (17 Oct 2013 20:02:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 17 Oct 2013 20:02:15 +0000 (UTC) Cc: 15045@debbugs.gnu.org, David Engster , Eric Ludlam To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Oct 17 22:02:19 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1VWtly-0007S3-AC for geb-bug-gnu-emacs@m.gmane.org; Thu, 17 Oct 2013 22:02:18 +0200 Original-Received: from localhost ([::1]:54051 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWtlx-00060L-Tc for geb-bug-gnu-emacs@m.gmane.org; Thu, 17 Oct 2013 16:02:17 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45387) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWtlo-0005q5-AE for bug-gnu-emacs@gnu.org; Thu, 17 Oct 2013 16:02:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VWtlj-0004c2-Pm for bug-gnu-emacs@gnu.org; Thu, 17 Oct 2013 16:02:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:41847) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VWtlj-0004bx-GU for bug-gnu-emacs@gnu.org; Thu, 17 Oct 2013 16:02:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VWtli-0007zK-BI for bug-gnu-emacs@gnu.org; Thu, 17 Oct 2013 16:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Barry OReilly Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 17 Oct 2013 20:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15045 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 15045-submit@debbugs.gnu.org id=B15045.138204012030697 (code B ref 15045); Thu, 17 Oct 2013 20:02:02 +0000 Original-Received: (at 15045) by debbugs.gnu.org; 17 Oct 2013 20:02:00 +0000 Original-Received: from localhost ([127.0.0.1]:55866 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VWtlf-0007z2-2I for submit@debbugs.gnu.org; Thu, 17 Oct 2013 16:01:59 -0400 Original-Received: from mail-oa0-f51.google.com ([209.85.219.51]:47336) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VWtlc-0007yj-Le for 15045@debbugs.gnu.org; Thu, 17 Oct 2013 16:01:57 -0400 Original-Received: by mail-oa0-f51.google.com with SMTP id h1so1030733oag.10 for <15045@debbugs.gnu.org>; Thu, 17 Oct 2013 13:01:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=UpCRf9yYdWHmr3OXQxjUOl5SoV3ZFByHbM4sEfPrUjs=; b=z5YoTDNyjzsc2Xk86N5jEaG5P4nVct/pnSG1F83Z1V+Lsg69HRxdf0YrQ+0aO3Ozk+ e3QbG5z02dO0+gFg2Y2UVlWfuj7pwGIo1Hed8AwIKp6JBs0wkFJS5Ol6U89I4Fm9razw qe15C134hzswqBg+Fie1ezVghdXeNDCxDuUIYbffTdbYY0IxjByWLDLseYWdlR7EKKNw 0fiP7Sphn6vQRroJ0WcI9VD7N3CRKTfaeUpsYF7db0oqe9ZYU8nglHOazXaH2C4E5TLE RgYzcYNjD4ahUq+ZpiOUX9D0rlPkWW+2Zez5hU8t/5cbd+TRbREs8NOu3kykxAN0zi8c c3/Q== X-Received: by 10.182.39.161 with SMTP id q1mr5117696obk.54.1382040110508; Thu, 17 Oct 2013 13:01:50 -0700 (PDT) Original-Received: by 10.76.156.103 with HTTP; Thu, 17 Oct 2013 13:01:50 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:79347 Archived-At: --001a11c2de60da307d04e8f549e8 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable > I think there's a race-condition, here: > - let's say we're at time < timeout. > - we run sit-for, which does not run the timer since we're still - time advances to > timeout. > - we check (should (time-less-p (current-time) timeout)) > - we complain unjustly. This statement isn't right: > - we run sit-for, which does not run the timer since we're still + + Don't run timers in input-pending-p. Its new check-timers param + provides the prior behavior. (Bug#15045). + * src/keyboard.c (Finput_pending_p): Accept optional check-timers + param. + * lisp/subr.el (sit-for): Call (input-pending-p t) so as to behave + as before. + * test/automated/timer-tests.el: New file. Tests that (sit-for 0) + allows another timer to run. + 2013-10-13 Glenn Morris * configure.ac [alpha]: Explicit error in non-ELF case. (Bug#15601) diff --git a/etc/NEWS b/etc/NEWS index ddb9a9f..963c372 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -611,6 +611,9 @@ low-level libraries gfilenotify.c, inotify.c or w32notify.c. * Incompatible Lisp Changes in Emacs 24.4 +** `(input-pending-p)' no longer runs other timers which are ready to +run. The new optional CHECK-TIMERS param allows for the prior behavior. + ** `defvar' and `defcustom' in a let-binding affect the "external" default= . ** The syntax of ?=BB and ?=AB is now punctuation instead of matched paren= s. diff --git a/lisp/subr.el b/lisp/subr.el index 0d03e9a..952b9b6 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -2222,7 +2222,7 @@ floating point support." (noninteractive (sleep-for seconds) t) - ((input-pending-p) + ((input-pending-p t) nil) ((<=3D seconds 0) (or nodisp (redisplay))) diff --git a/src/keyboard.c b/src/keyboard.c index bb8fefa..85a1ce7 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -9947,12 +9947,13 @@ requeued_events_pending_p (void) return (!NILP (Vunread_command_events)); } - -DEFUN ("input-pending-p", Finput_pending_p, Sinput_pending_p, 0, 0, 0, +DEFUN ("input-pending-p", Finput_pending_p, Sinput_pending_p, 0, 1, 0, doc: /* Return t if command input is currently available with no wait. Actually, the value is nil only if we can be sure that no input is available; -if there is a doubt, the value is t. */) - (void) +if there is a doubt, the value is t. + +If CHECK-TIMERS is non-nil, timers that are ready to run will do so. */) + (Lisp_Object check_timers) { if (!NILP (Vunread_command_events) || !NILP (Vunread_post_input_method_events) @@ -9962,8 +9963,9 @@ if there is a doubt, the value is t. */) /* Process non-user-visible events (Bug#10195). */ process_special_events (); - return (get_input_pending (READABLE_EVENTS_DO_TIMERS_NOW - | READABLE_EVENTS_FILTER_EVENTS) + return (get_input_pending ((NILP (check_timers) + ? 0 : READABLE_EVENTS_DO_TIMERS_NOW) + | READABLE_EVENTS_FILTER_EVENTS) ? Qt : Qnil); } diff --git a/test/automated/timer-tests.el b/test/automated/timer-tests.el new file mode 100644 index 0000000..71a9b96 --- /dev/null +++ b/test/automated/timer-tests.el @@ -0,0 +1,38 @@ +;;; timer-tests.el --- tests for timers -*- lexical-binding:t -*- + +;; Copyright (C) 2013 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; This program is free software: you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation, either version 3 of the +;; License, or (at your option) any later version. +;; +;; This program is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. +;; +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see `http://www.gnu.org/licenses/'. + +;;; Commentary: + +;;; Code: + +(ert-deftest timer-tests-sit-for () + (let ((timer-ran nil) + ;; Want sit-for behavior when interactive + (noninteractive nil)) + (run-at-time '(0 0 0 0) + nil + (lambda () (setq timer-ran t))) + ;; The test assumes run-at-time didn't take the liberty of firing + ;; the timer, so assert the test's assumption + (should (not timer-ran)) + (sit-for 0 t) + (should timer-ran))) + +;;; timer-tests.el ends here + --001a11c2de60da307d04e8f549e8 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
> I think there's a race-condition, here:
> -= let's say we're at time < timeout.
> - we run sit-for, wh= ich does not run the timer since we're still <timeout.
> - tim= e advances to > timeout.
> - we check (should (time-less-p (current-time) timeout))
> - we = complain unjustly.

This statement isn't right:

> - we = run sit-for, which does not run the timer since we're still <timeout= .

If sit-for doesn't run the timer at any time in T+1s to T+10s, then=
it's supposed to fail.

However, reconsidering the test, I do= n't think the timing is
necessary, so I've simplified it.

diff --git a/ChangeLog b/ChangeLog
index a755b5c..553abe2 100644
= --- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2013-10-17=A0 Ba= rry O'Reilly=A0 <gundaetiap= o@gmail.com>
+
+=A0=A0=A0 Don't run timers in input-pending-p.=A0 Its new check-t= imers param
+=A0=A0=A0 provides the prior behavior. (Bug#15045).
+=A0= =A0=A0 * src/keyboard.c (Finput_pending_p): Accept optional check-timers+=A0=A0=A0 param.
+=A0=A0=A0 * lisp/subr.el (sit-for): Call (input-pending-p t) so as to beha= ve
+=A0=A0=A0 as before.
+=A0=A0=A0 * test/automated/timer-tests.el: = New file.=A0 Tests that (sit-for 0)
+=A0=A0=A0 allows another timer to r= un.
+
=A02013-10-13=A0 Glenn Morris=A0 <rgm@gnu.org>
=A0
=A0=A0=A0=A0 * configure.ac [alp= ha]: Explicit error in non-ELF case.=A0 (Bug#15601)
diff --git a/etc/NEW= S b/etc/NEWS
index ddb9a9f..963c372 100644
--- a/etc/NEWS
+++ b/et= c/NEWS
@@ -611,6 +611,9 @@ low-level libraries gfilenotify.c, inotify.c or w32noti= fy.c.
=A0=0C
=A0* Incompatible Lisp Changes in Emacs 24.4
=A0
+= ** `(input-pending-p)' no longer runs other timers which are ready to+run.=A0 The new optional CHECK-TIMERS param allows for the prior behavio= r.
+
=A0** `defvar' and `defcustom' in a let-binding affect the &qu= ot;external" default.
=A0
=A0** The syntax of ?=BB and ?=AB is n= ow punctuation instead of matched parens.
diff --git a/lisp/subr.el b/li= sp/subr.el
index 0d03e9a..952b9b6 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el@@ -2222,7 +2222,7 @@ floating point support."
=A0=A0=A0 (noninte= ractive
=A0=A0=A0=A0 (sleep-for seconds)
=A0=A0=A0=A0 t)
-=A0=A0 (= (input-pending-p)
+=A0=A0 ((input-pending-p t)
=A0=A0=A0=A0 nil)
=A0=A0=A0 ((<=3D seconds 0)
=A0=A0=A0=A0 (or nod= isp (redisplay)))
diff --git a/src/keyboard.c b/src/keyboard.c
index = bb8fefa..85a1ce7 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
= @@ -9947,12 +9947,13 @@ requeued_events_pending_p (void)
=A0=A0 return (!NILP (Vunread_command_events));
=A0}
=A0
-
-DEF= UN ("input-pending-p", Finput_pending_p, Sinput_pending_p, 0, 0, = 0,
+DEFUN ("input-pending-p", Finput_pending_p, Sinput_pending= _p, 0, 1, 0,
=A0=A0=A0=A0=A0=A0=A0 doc: /* Return t if command input is currently availa= ble with no wait.
=A0Actually, the value is nil only if we can be sure t= hat no input is available;
-if there is a doubt, the value is t.=A0 */)<= br>-=A0 (void)
+if there is a doubt, the value is t.
+
+If CHECK-TIMERS is non-nil, = timers that are ready to run will do so.=A0 */)
+=A0 (Lisp_Object check_= timers)
=A0{
=A0=A0 if (!NILP (Vunread_command_events)
=A0=A0=A0= =A0=A0=A0 || !NILP (Vunread_post_input_method_events)
@@ -9962,8 +9963,9 @@ if there is a doubt, the value is t.=A0 */)
=A0=A0= /* Process non-user-visible events (Bug#10195).=A0 */
=A0=A0 process_sp= ecial_events ();
=A0
-=A0 return (get_input_pending (READABLE_EVENTS_= DO_TIMERS_NOW
-=A0=A0=A0 =A0=A0=A0 =A0=A0=A0 =A0=A0=A0=A0 | READABLE_EVENTS_FILTER_EVENTS= )
+=A0 return (get_input_pending ((NILP (check_timers)
+=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= ? 0 : READABLE_EVENTS_DO_TIMERS_NOW)
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 | READABLE_EVENTS_FILTE= R_EVENTS)
=A0=A0=A0=A0 =A0 ? Qt : Qnil);
=A0}
=A0
diff --git a/test/automate= d/timer-tests.el b/test/automated/timer-tests.el
new file mode 100644index 0000000..71a9b96
--- /dev/null
+++ b/test/automated/timer-test= s.el
@@ -0,0 +1,38 @@
+;;; timer-tests.el --- tests for timers -*- lexical-binding:t -*-
+
= +;; Copyright (C) 2013 Free Software Foundation, Inc.
+
+;; This file= is part of GNU Emacs.
+
+;; This program is free software: you can r= edistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; p= ublished by the Free Software Foundation, either version 3 of the
+;; Li= cense, or (at your option) any later version.
+;;
+;; This program is= distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCH= ANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.=A0 See the GNU
+;; Gener= al Public License for more details.
+;;
+;; You should have received = a copy of the GNU General Public License
+;; along with this program.=A0 If not, see `http://www.gnu.org/licenses/'.
+
+;;; Commentary:<= br>+
+;;; Code:
+
+(ert-deftest timer-tests-sit-for ()
+=A0 (le= t ((timer-ran nil)
+=A0=A0=A0=A0=A0=A0=A0 ;; Want sit-for behavior when interactive
+=A0=A0= =A0=A0=A0=A0=A0 (noninteractive nil))
+=A0=A0=A0 (run-at-time '(0 0 = 0 0)
+=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 nil
+=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 (lambda () (setq timer-ran t)))
= +=A0=A0=A0 ;; The test assumes run-at-time didn't take the liberty of f= iring
+=A0=A0=A0 ;; the timer, so assert the test's assumption
+=A0=A0=A0 = (should (not timer-ran))
+=A0=A0=A0 (sit-for 0 t)
+=A0=A0=A0 (should = timer-ran)))
+
+;;; timer-tests.el ends here
+

--001a11c2de60da307d04e8f549e8--