aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2004-12-13 19:26:42 +0000
committerRichard M. Stallman2004-12-13 19:26:42 +0000
commitc2b53d7bd469c048527051fc04c1924bb0cb7c89 (patch)
tree2b7811eae19711b39c99322cfaff4beb987664d9
parent42ed718e49546a46536ba8f7de3110a67677b722 (diff)
downloademacs-c2b53d7bd469c048527051fc04c1924bb0cb7c89.tar.gz
emacs-c2b53d7bd469c048527051fc04c1924bb0cb7c89.zip
(while-no-input): New macro.
-rw-r--r--lisp/subr.el13
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."
1862 ,@body) 1862 ,@body)
1863 (quit (setq quit-flag t) nil))) 1863 (quit (setq quit-flag t) nil)))
1864 1864
1865(defmacro while-no-input (&rest body)
1866 "Execute BODY only as long as there's no pending input.
1867If input arrives, that ends the execution of BODY,
1868and `while-no-input' returns nil. If BODY finishes,
1869`while-no-input' returns whatever value BODY produced."
1870 (declare (debug t) (indent 0))
1871 (let ((catch-sym (make-symbol "input")))
1872 `(with-local-quit
1873 (catch ',catch-sym
1874 (let ((throw-on-input ',catch-sym))
1875 (when (sit-for 0 0 t)
1876 ,@body))))))
1877
1865(defmacro combine-after-change-calls (&rest body) 1878(defmacro combine-after-change-calls (&rest body)
1866 "Execute BODY, but don't call the after-change functions till the end. 1879 "Execute BODY, but don't call the after-change functions till the end.
1867If BODY makes changes in the buffer, they are recorded 1880If BODY makes changes in the buffer, they are recorded