diff lisp/subr.el @ 72817:b70548506872

(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.
author Kim F. Storm <storm@cua.dk>
date Mon, 11 Sep 2006 22:21:55 +0000
parents 3f19250c6e68
children 66a5ba8082a9 a1a25ac6c88a
line wrap: on
line diff
--- a/lisp/subr.el	Mon Sep 11 22:21:42 2006 +0000
+++ b/lisp/subr.el	Mon Sep 11 22:21:55 2006 +0000
@@ -1737,20 +1737,23 @@
 floating point support.
 
 \(fn SECONDS &optional NODISP)"
-  (unless (or unread-command-events
-	      unread-post-input-method-events
-	      unread-input-method-events
-	      (>= unread-command-char 0))
-    (when (or obsolete (numberp nodisp))
-      (setq seconds (+ seconds (* 1e-3 nodisp)))
-      (setq nodisp obsolete))
-    (if noninteractive
-	(progn (sleep-for seconds) t)
-      (unless nodisp (redisplay))
-      (or (<= seconds 0)
-	  (let ((read (read-event nil nil seconds)))
-	    (or (null read)
-		(progn (push read unread-command-events) nil)))))))
+  (when (or obsolete (numberp nodisp))
+    (setq seconds (+ seconds (* 1e-3 nodisp)))
+    (setq nodisp obsolete))
+  (cond
+   (noninteractive
+    (sleep-for seconds)
+    t)
+   ((input-pending-p)
+    nil)
+   ((<= seconds 0)
+    (or nodisp (redisplay)))
+   (t
+    (or nodisp (redisplay))
+    (let ((read (read-event nil nil seconds)))
+      (or (null read)
+	  (progn (push read unread-command-events)
+		 nil))))))
 
 ;;; Atomic change groups.
 
@@ -2398,8 +2401,8 @@
     `(with-local-quit
        (catch ',catch-sym
 	 (let ((throw-on-input ',catch-sym))
-	   (or (not (sit-for 0 0 t))
-	     ,@body))))))
+	   (or (input-pending-p)
+	       ,@body))))))
 
 (defmacro combine-after-change-calls (&rest body)
   "Execute BODY, but don't call the after-change functions till the end.