diff options
author | Richard M. Stallman <rms@gnu.org> | 2004-12-13 19:26:42 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 2004-12-13 19:26:42 +0000 |
commit | c2b53d7bd469c048527051fc04c1924bb0cb7c89 (patch) | |
tree | 2b7811eae19711b39c99322cfaff4beb987664d9 /lisp | |
parent | 42ed718e49546a46536ba8f7de3110a67677b722 (diff) | |
download | emacs-c2b53d7bd469c048527051fc04c1924bb0cb7c89.tar.gz |
(while-no-input): New macro.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/subr.el | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 3bdef5988ce..84129908fc7 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1862,6 +1862,19 @@ is allowed once again." ,@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 |