# HG changeset patch # User Richard M. Stallman # Date 1157382452 0 # Node ID ade5681a8e7eb048654872aa159c33982eab3b2d # Parent abebf4e18f108ad3ccf0d62c2997917eed0656f6 (Idle Timers): Explain why timer functions should not loop until (input-pending-p). diff -r abebf4e18f10 -r ade5681a8e7e lispref/os.texi --- a/lispref/os.texi Mon Sep 04 15:03:26 2006 +0000 +++ b/lispref/os.texi Mon Sep 04 15:07:32 2006 +0000 @@ -1578,6 +1578,25 @@ @end smallexample @end defun + Some idle timer functions in user Lisp packages have a loop that +does a certain amount of processing each time around, and exits when +@code{(input-pending-p)} is non-@code{nil}. That approach seems very +natural but has two problems: + +@itemize +@item +It blocks out all process output (since Emacs accepts process output +only while waiting). + +@item +It blocks out any idle timers that ought to run during that time. +@end itemize + +@noindent +To avoid these problems, don't use that technique. Instead, write +such idle timers to reschedule themselves after a brief pause, using +the method in the @code{timer-function} example above. + @node Terminal Input @section Terminal Input @cindex terminal input