aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim F. Storm2006-09-11 22:21:55 +0000
committerKim F. Storm2006-09-11 22:21:55 +0000
commit790e0ef78e306edc0664b8fa5a584c62ec01b444 (patch)
treef85678b0cfc608a7fd3c7ec4eaf781111c794f60
parent73313accc4ef30d09aa5250a2b4bf30d6c0a4ffa (diff)
downloademacs-790e0ef78e306edc0664b8fa5a584c62ec01b444.tar.gz
emacs-790e0ef78e306edc0664b8fa5a584c62ec01b444.zip
(sit-for): Rework to use input-pending-p and cond.
Return nil input is pending on entry also for SECONDS <= 0. (while-no-input): Use input-pending-p instead of sit-for.
-rw-r--r--lisp/subr.el35
1 files changed, 19 insertions, 16 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index 33aac6081f9..88af6f08869 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -1737,20 +1737,23 @@ in milliseconds; this was useful when Emacs was built without
1737floating point support. 1737floating point support.
1738 1738
1739\(fn SECONDS &optional NODISP)" 1739\(fn SECONDS &optional NODISP)"
1740 (unless (or unread-command-events 1740 (when (or obsolete (numberp nodisp))
1741 unread-post-input-method-events 1741 (setq seconds (+ seconds (* 1e-3 nodisp)))
1742 unread-input-method-events 1742 (setq nodisp obsolete))
1743 (>= unread-command-char 0)) 1743 (cond
1744 (when (or obsolete (numberp nodisp)) 1744 (noninteractive
1745 (setq seconds (+ seconds (* 1e-3 nodisp))) 1745 (sleep-for seconds)
1746 (setq nodisp obsolete)) 1746 t)
1747 (if noninteractive 1747 ((input-pending-p)
1748 (progn (sleep-for seconds) t) 1748 nil)
1749 (unless nodisp (redisplay)) 1749 ((<= seconds 0)
1750 (or (<= seconds 0) 1750 (or nodisp (redisplay)))
1751 (let ((read (read-event nil nil seconds))) 1751 (t
1752 (or (null read) 1752 (or nodisp (redisplay))
1753 (progn (push read unread-command-events) nil))))))) 1753 (let ((read (read-event nil nil seconds)))
1754 (or (null read)
1755 (progn (push read unread-command-events)
1756 nil))))))
1754 1757
1755;;; Atomic change groups. 1758;;; Atomic change groups.
1756 1759
@@ -2398,8 +2401,8 @@ If BODY finishes, `while-no-input' returns whatever value BODY produced."
2398 `(with-local-quit 2401 `(with-local-quit
2399 (catch ',catch-sym 2402 (catch ',catch-sym
2400 (let ((throw-on-input ',catch-sym)) 2403 (let ((throw-on-input ',catch-sym))
2401 (or (not (sit-for 0 0 t)) 2404 (or (input-pending-p)
2402 ,@body)))))) 2405 ,@body))))))
2403 2406
2404(defmacro combine-after-change-calls (&rest body) 2407(defmacro combine-after-change-calls (&rest body)
2405 "Execute BODY, but don't call the after-change functions till the end. 2408 "Execute BODY, but don't call the after-change functions till the end.