emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] Changes to emacs/lisp/subr.el,v


From: Chong Yidong
Subject: [Emacs-diffs] Changes to emacs/lisp/subr.el,v
Date: Mon, 10 Jul 2006 18:52:14 +0000

CVSROOT:        /cvsroot/emacs
Module name:    emacs
Changes by:     Chong Yidong <cyd>      06/07/10 18:52:13

Index: subr.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/subr.el,v
retrieving revision 1.518
retrieving revision 1.519
diff -u -b -r1.518 -r1.519
--- subr.el     9 Jul 2006 02:00:10 -0000       1.518
+++ subr.el     10 Jul 2006 18:52:12 -0000      1.519
@@ -1700,6 +1700,45 @@
            t)))
     n))
 
+(defun sit-for (seconds &optional nodisp obsolete)
+  "Perform redisplay, then wait for SECONDS seconds or until input is 
available.
+SECONDS may be a floating-point value.
+\(On operating systems that do not support waiting for fractions of a
+second, floating-point values are rounded down to the nearest integer.)
+
+If optional arg NODISP is t, don't redisplay, just wait for input.
+Redisplay does not happen if input is available before it starts.
+However, as a special exception, redisplay will occur even when
+input is available if SECONDS is negative.
+
+Value is t if waited the full time with no input arriving, and nil otherwise.
+
+An obsolete but still supported form is
+\(sit-for SECONDS &optional MILLISECONDS NODISP)
+Where the optional arg MILLISECONDS specifies an additional wait period,
+in milliseconds; this was useful when Emacs was built without
+floating point support."
+  (when (or obsolete (numberp nodisp))
+    (setq seconds (+ seconds (* 1e-3 nodisp)))
+    (setq nodisp obsolete))
+  (unless nodisp
+    (let ((redisplay-dont-pause (or (< seconds 0) redisplay-dont-pause)))
+      (redisplay)))
+  (or (<= seconds 0)
+      (let ((timer (timer-create))
+           (echo-keystrokes 0))
+       (if (catch 'sit-for-timeout
+             (timer-set-time timer (timer-relative-time
+                                    (current-time) seconds))
+             (timer-set-function timer 'with-timeout-handler
+                                 '(sit-for-timeout))
+             (timer-activate timer)
+             (push (read-event) unread-command-events)
+             nil)
+           t
+         (cancel-timer timer)
+         nil))))
+
 ;;; Atomic change groups.
 
 (defmacro atomic-change-group (&rest body)




reply via email to

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