aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2006-07-10 18:52:13 +0000
committerChong Yidong2006-07-10 18:52:13 +0000
commit0369eb8545cb960836e64e81d14bf1db357a925f (patch)
treed1082d6466bcabe84351742fd035a5421ca5be6b
parent7157b8fe893c3d6a213d133588f85117a7d80250 (diff)
downloademacs-0369eb8545cb960836e64e81d14bf1db357a925f.tar.gz
emacs-0369eb8545cb960836e64e81d14bf1db357a925f.zip
* subr.el (sit-for): New function.
* play/hanoi.el (hanoi-sit-for): Check sit-for return value.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/play/hanoi.el5
-rw-r--r--lisp/subr.el39
3 files changed, 47 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 8416aa837cc..ec13ee51487 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12006-07-10 Chong Yidong <cyd@stupidchicken.com>
2
3 * subr.el (sit-for): New function.
4
5 * play/hanoi.el (hanoi-sit-for): Check sit-for return value.
6
12006-07-10 Richard Stallman <rms@gnu.org> 72006-07-10 Richard Stallman <rms@gnu.org>
2 8
3 * ldefs-boot.el (edebug): Update page. 9 * ldefs-boot.el (edebug): Update page.
diff --git a/lisp/play/hanoi.el b/lisp/play/hanoi.el
index 296ca82b64a..40a96f4e6c2 100644
--- a/lisp/play/hanoi.el
+++ b/lisp/play/hanoi.el
@@ -399,9 +399,8 @@ BITS must be of length nrings. Start at START-TIME."
399;; update display and pause, quitting with a pithy comment if the user 399;; update display and pause, quitting with a pithy comment if the user
400;; hits a key. 400;; hits a key.
401(defun hanoi-sit-for (seconds) 401(defun hanoi-sit-for (seconds)
402 (sit-for seconds) 402 (unless (sit-for seconds)
403 (if (input-pending-p) 403 (signal 'quit '("I can tell you've had enough"))))
404 (signal 'quit '("I can tell you've had enough"))))
405 404
406;; move ring to a given buffer position and update ring's car. 405;; move ring to a given buffer position and update ring's car.
407(defun hanoi-ring-to-pos (ring pos) 406(defun hanoi-ring-to-pos (ring pos)
diff --git a/lisp/subr.el b/lisp/subr.el
index 9672a7afb76..5c7e1c30cf4 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1699,6 +1699,45 @@ by doing (clear-string STRING)."
1699 (sit-for 1) 1699 (sit-for 1)
1700 t))) 1700 t)))
1701 n)) 1701 n))
1702
1703(defun sit-for (seconds &optional nodisp obsolete)
1704 "Perform redisplay, then wait for SECONDS seconds or until input is available.
1705SECONDS may be a floating-point value.
1706\(On operating systems that do not support waiting for fractions of a
1707second, floating-point values are rounded down to the nearest integer.)
1708
1709If optional arg NODISP is t, don't redisplay, just wait for input.
1710Redisplay does not happen if input is available before it starts.
1711However, as a special exception, redisplay will occur even when
1712input is available if SECONDS is negative.
1713
1714Value is t if waited the full time with no input arriving, and nil otherwise.
1715
1716An obsolete but still supported form is
1717\(sit-for SECONDS &optional MILLISECONDS NODISP)
1718Where the optional arg MILLISECONDS specifies an additional wait period,
1719in milliseconds; this was useful when Emacs was built without
1720floating point support."
1721 (when (or obsolete (numberp nodisp))
1722 (setq seconds (+ seconds (* 1e-3 nodisp)))
1723 (setq nodisp obsolete))
1724 (unless nodisp
1725 (let ((redisplay-dont-pause (or (< seconds 0) redisplay-dont-pause)))
1726 (redisplay)))
1727 (or (<= seconds 0)
1728 (let ((timer (timer-create))
1729 (echo-keystrokes 0))
1730 (if (catch 'sit-for-timeout
1731 (timer-set-time timer (timer-relative-time
1732 (current-time) seconds))
1733 (timer-set-function timer 'with-timeout-handler
1734 '(sit-for-timeout))
1735 (timer-activate timer)
1736 (push (read-event) unread-command-events)
1737 nil)
1738 t
1739 (cancel-timer timer)
1740 nil))))
1702 1741
1703;;; Atomic change groups. 1742;;; Atomic change groups.
1704 1743