Mercurial > emacs
changeset 58934:ee02b41be7da
(while-no-input): New macro.
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Mon, 13 Dec 2004 19:26:42 +0000 |
parents | dae0885d0340 |
children | 95bb6b9a27a3 |
files | lisp/subr.el |
diffstat | 1 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/subr.el Mon Dec 13 19:05:42 2004 +0000 +++ b/lisp/subr.el Mon Dec 13 19:26:42 2004 +0000 @@ -1862,6 +1862,19 @@ ,@body) (quit (setq quit-flag t) nil))) +(defmacro while-no-input (&rest body) + "Execute BODY only as long as there's no pending input. +If input arrives, that ends the execution of BODY, +and `while-no-input' returns nil. If BODY finishes, +`while-no-input' returns whatever value BODY produced." + (declare (debug t) (indent 0)) + (let ((catch-sym (make-symbol "input"))) + `(with-local-quit + (catch ',catch-sym + (let ((throw-on-input ',catch-sym)) + (when (sit-for 0 0 t) + ,@body)))))) + (defmacro combine-after-change-calls (&rest body) "Execute BODY, but don't call the after-change functions till the end. If BODY makes changes in the buffer, they are recorded