comparison lisp/subr.el @ 64792:f309b64476da

(while-no-input): Return t if there is input.
author Richard M. Stallman <rms@gnu.org>
date Tue, 09 Aug 2005 02:51:22 +0000
parents 41bb365f41c4
children 3aa61588445b
comparison
equal deleted inserted replaced
64791:ef236edf96ec 64792:f309b64476da
1831 (quit (setq quit-flag t) nil))) 1831 (quit (setq quit-flag t) nil)))
1832 1832
1833 (defmacro while-no-input (&rest body) 1833 (defmacro while-no-input (&rest body)
1834 "Execute BODY only as long as there's no pending input. 1834 "Execute BODY only as long as there's no pending input.
1835 If input arrives, that ends the execution of BODY, 1835 If input arrives, that ends the execution of BODY,
1836 and `while-no-input' returns nil. If BODY finishes, 1836 and `while-no-input' returns t. Quitting makes it return nil.
1837 `while-no-input' returns whatever value BODY produced." 1837 If BODY finishes, `while-no-input' returns whatever value BODY produced."
1838 (declare (debug t) (indent 0)) 1838 (declare (debug t) (indent 0))
1839 (let ((catch-sym (make-symbol "input"))) 1839 (let ((catch-sym (make-symbol "input")))
1840 `(with-local-quit 1840 `(with-local-quit
1841 (catch ',catch-sym 1841 (catch ',catch-sym
1842 (let ((throw-on-input ',catch-sym)) 1842 (let ((throw-on-input ',catch-sym))
1843 (when (sit-for 0 0 t) 1843 (or (not (sit-for 0 0 t))
1844 ,@body)))))) 1844 ,@body))))))
1845 1845
1846 (defmacro combine-after-change-calls (&rest body) 1846 (defmacro combine-after-change-calls (&rest body)
1847 "Execute BODY, but don't call the after-change functions till the end. 1847 "Execute BODY, but don't call the after-change functions till the end.
1848 If BODY makes changes in the buffer, they are recorded 1848 If BODY makes changes in the buffer, they are recorded