comparison 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
comparison
equal deleted inserted replaced
72816:6399941618f6 72817:b70548506872
1735 where the optional arg MILLISECONDS specifies an additional wait period, 1735 where the optional arg MILLISECONDS specifies an additional wait period,
1736 in milliseconds; this was useful when Emacs was built without 1736 in milliseconds; this was useful when Emacs was built without
1737 floating point support. 1737 floating 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
1757 (defmacro atomic-change-group (&rest body) 1760 (defmacro atomic-change-group (&rest body)
1758 "Perform BODY as an atomic change group. 1761 "Perform BODY as an atomic change group.
2396 (declare (debug t) (indent 0)) 2399 (declare (debug t) (indent 0))
2397 (let ((catch-sym (make-symbol "input"))) 2400 (let ((catch-sym (make-symbol "input")))
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.
2406 If BODY makes changes in the buffer, they are recorded 2409 If BODY makes changes in the buffer, they are recorded
2407 and the functions on `after-change-functions' are called several times 2410 and the functions on `after-change-functions' are called several times