]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't run timers in input-pending-p. Its new check-timers param
authorBarry O'Reilly <gundaetiapo@gmail.com>
Fri, 18 Oct 2013 04:27:34 +0000 (00:27 -0400)
committerBarry O'Reilly <gundaetiapo@gmail.com>
Fri, 18 Oct 2013 04:27:34 +0000 (00:27 -0400)
provides the prior behavior..
* 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.

Fixes: debbugs:15045
etc/NEWS
lisp/ChangeLog
lisp/subr.el
src/ChangeLog
src/keyboard.c
test/ChangeLog
test/automated/timer-tests.el [new file with mode: 0644]

index 7c19ad9f87a303523cd407b096f25b98ea3d6b04..de13733f7751ebe9e6ba2fe1e38f9fd76d5a93e8 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -620,6 +620,9 @@ low-level libraries gfilenotify.c, inotify.c or w32notify.c.
 \f
 * 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 ?» and ?« is now punctuation instead of matched parens.
index 2902d9281fbac4eac9c060e374217dd8d92702a4..b91d17ba8a3a09e3122fbc2c3ad432592af24c60 100644 (file)
@@ -1,3 +1,8 @@
+2013-10-17  Barry O'Reilly  <gundaetiapo@gmail.com>
+
+       * lisp/subr.el (sit-for): Call (input-pending-p t) so as to behave
+       as before.
+
 2013-10-18  Reuben Thomas  <rrt@sc3d.org>
 
        * textmodes/remember.el (remember): set buffer-offer-save in
index 0d03e9a88c1166d417866555636611515bac6025..952b9b601dc27b58193eb24ec3f5a3b691df762e 100644 (file)
@@ -2222,7 +2222,7 @@ floating point support."
    (noninteractive
     (sleep-for seconds)
     t)
-   ((input-pending-p)
+   ((input-pending-p t)
     nil)
    ((<= seconds 0)
     (or nodisp (redisplay)))
index a0df4425844032d97c6a9dc54077ee07c185cf32..0dae87bd69a4b6b2b3305b9b046fc576749e48db 100644 (file)
@@ -1,3 +1,10 @@
+2013-10-17  Barry O'Reilly  <gundaetiapo@gmail.com>
+
+       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.
+
 2013-10-17  Paul Eggert  <eggert@cs.ucla.edu>
 
        Make some functions static in non-Microsoft builds.
index a776720b807b8e7583312fc40668a48bea4ca683..6b39dfe1019394942630ebaf1b468556b7b0d143 100644 (file)
@@ -9950,12 +9950,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)
@@ -9965,7 +9966,8 @@ 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
+  return (get_input_pending ((NILP (check_timers)
+                              ? 0 : READABLE_EVENTS_DO_TIMERS_NOW)
                             | READABLE_EVENTS_FILTER_EVENTS)
          ? Qt : Qnil);
 }
index bf5a427548303f368e9ffcd6bb54bb0cf2e7aa08..9a8a61eb062623ce6b87ce536efcfb3a947fd022 100644 (file)
@@ -1,3 +1,8 @@
+2013-10-17  Barry O'Reilly  <gundaetiapo@gmail.com>
+
+       * test/automated/timer-tests.el: New file.  Tests that (sit-for 0)
+       allows another timer to run.
+
 2013-10-14  Dmitry Gutov  <dgutov@yandex.ru>
 
        * indent/ruby.rb: More examples for bug#15594, both failing and
diff --git a/test/automated/timer-tests.el b/test/automated/timer-tests.el
new file mode 100644 (file)
index 0000000..71a9b96
--- /dev/null
@@ -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
+